Mercurial > libavcodec.hg
comparison vp3.c @ 10648:b5644bcfff48 libavcodec
Revert r20747: It mixed functional and cosmetical changes.
author | cehoyos |
---|---|
date | Sun, 06 Dec 2009 15:30:53 +0000 |
parents | 0139a62827ce |
children | a34d38ec5a0b |
comparison
equal
deleted
inserted
replaced
10647:0139a62827ce | 10648:b5644bcfff48 |
---|---|
1231 * the frame. Much of this function is adapted directly from the original | 1231 * the frame. Much of this function is adapted directly from the original |
1232 * VP3 source code. | 1232 * VP3 source code. |
1233 */ | 1233 */ |
1234 #define COMPATIBLE_FRAME(x) \ | 1234 #define COMPATIBLE_FRAME(x) \ |
1235 (compatible_frame[s->all_fragments[x].coding_method] == current_frame_type) | 1235 (compatible_frame[s->all_fragments[x].coding_method] == current_frame_type) |
1236 #define FRAME_CODED(x) (s->all_fragments[x].coding_method != MODE_COPY) | |
1236 #define DC_COEFF(u) (s->coeffs[u].index ? 0 : s->coeffs[u].coeff) //FIXME do somethin to simplify this | 1237 #define DC_COEFF(u) (s->coeffs[u].index ? 0 : s->coeffs[u].coeff) //FIXME do somethin to simplify this |
1237 | 1238 |
1238 static void reverse_dc_prediction(Vp3DecodeContext *s, | 1239 static void reverse_dc_prediction(Vp3DecodeContext *s, |
1239 int first_fragment, | 1240 int first_fragment, |
1240 int fragment_width, | 1241 int fragment_width, |
1287 * prediction. For example, INTRA is the only mode in this table to | 1288 * prediction. For example, INTRA is the only mode in this table to |
1288 * have a frame number of 0. That means INTRA blocks can only predict | 1289 * have a frame number of 0. That means INTRA blocks can only predict |
1289 * from other INTRA blocks. There are 2 golden frame coding types; | 1290 * from other INTRA blocks. There are 2 golden frame coding types; |
1290 * blocks encoding in these modes can only predict from other blocks | 1291 * blocks encoding in these modes can only predict from other blocks |
1291 * that were encoded with these 1 of these 2 modes. */ | 1292 * that were encoded with these 1 of these 2 modes. */ |
1292 static const unsigned char compatible_frame[9] = { | 1293 static const unsigned char compatible_frame[8] = { |
1293 1, /* MODE_INTER_NO_MV */ | 1294 1, /* MODE_INTER_NO_MV */ |
1294 0, /* MODE_INTRA */ | 1295 0, /* MODE_INTRA */ |
1295 1, /* MODE_INTER_PLUS_MV */ | 1296 1, /* MODE_INTER_PLUS_MV */ |
1296 1, /* MODE_INTER_LAST_MV */ | 1297 1, /* MODE_INTER_LAST_MV */ |
1297 1, /* MODE_INTER_PRIOR_MV */ | 1298 1, /* MODE_INTER_PRIOR_MV */ |
1298 2, /* MODE_USING_GOLDEN */ | 1299 2, /* MODE_USING_GOLDEN */ |
1299 2, /* MODE_GOLDEN_MV */ | 1300 2, /* MODE_GOLDEN_MV */ |
1300 1, /* MODE_INTER_FOUR_MV */ | 1301 1 /* MODE_INTER_FOUR_MV */ |
1301 3 /* MODE_COPY */ | |
1302 }; | 1302 }; |
1303 int current_frame_type; | 1303 int current_frame_type; |
1304 | 1304 |
1305 /* there is a last DC predictor for each of the 3 frame types */ | 1305 /* there is a last DC predictor for each of the 3 frame types */ |
1306 short last_dc[3]; | 1306 short last_dc[3]; |
1324 | 1324 |
1325 transform= 0; | 1325 transform= 0; |
1326 if(x){ | 1326 if(x){ |
1327 l= i-1; | 1327 l= i-1; |
1328 vl = DC_COEFF(l); | 1328 vl = DC_COEFF(l); |
1329 if(COMPATIBLE_FRAME(l)) | 1329 if(FRAME_CODED(l) && COMPATIBLE_FRAME(l)) |
1330 transform |= PL; | 1330 transform |= PL; |
1331 } | 1331 } |
1332 if(y){ | 1332 if(y){ |
1333 u= i-fragment_width; | 1333 u= i-fragment_width; |
1334 vu = DC_COEFF(u); | 1334 vu = DC_COEFF(u); |
1335 if(COMPATIBLE_FRAME(u)) | 1335 if(FRAME_CODED(u) && COMPATIBLE_FRAME(u)) |
1336 transform |= PU; | 1336 transform |= PU; |
1337 if(x){ | 1337 if(x){ |
1338 ul= i-fragment_width-1; | 1338 ul= i-fragment_width-1; |
1339 vul = DC_COEFF(ul); | 1339 vul = DC_COEFF(ul); |
1340 if(COMPATIBLE_FRAME(ul)) | 1340 if(FRAME_CODED(ul) && COMPATIBLE_FRAME(ul)) |
1341 transform |= PUL; | 1341 transform |= PUL; |
1342 } | 1342 } |
1343 if(x + 1 < fragment_width){ | 1343 if(x + 1 < fragment_width){ |
1344 ur= i-fragment_width+1; | 1344 ur= i-fragment_width+1; |
1345 vur = DC_COEFF(ur); | 1345 vur = DC_COEFF(ur); |
1346 if(COMPATIBLE_FRAME(ur)) | 1346 if(FRAME_CODED(ur) && COMPATIBLE_FRAME(ur)) |
1347 transform |= PUR; | 1347 transform |= PUR; |
1348 } | 1348 } |
1349 } | 1349 } |
1350 | 1350 |
1351 if (transform == 0) { | 1351 if (transform == 0) { |
1364 | 1364 |
1365 predicted_dc /= 128; | 1365 predicted_dc /= 128; |
1366 | 1366 |
1367 /* check for outranging on the [ul u l] and | 1367 /* check for outranging on the [ul u l] and |
1368 * [ul u ur l] predictors */ | 1368 * [ul u ur l] predictors */ |
1369 if ((transform == 15) || (transform == 13)) { | 1369 if ((transform == 13) || (transform == 15)) { |
1370 if (FFABS(predicted_dc - vu) > 128) | 1370 if (FFABS(predicted_dc - vu) > 128) |
1371 predicted_dc = vu; | 1371 predicted_dc = vu; |
1372 else if (FFABS(predicted_dc - vl) > 128) | 1372 else if (FFABS(predicted_dc - vl) > 128) |
1373 predicted_dc = vl; | 1373 predicted_dc = vl; |
1374 else if (FFABS(predicted_dc - vul) > 128) | 1374 else if (FFABS(predicted_dc - vul) > 128) |
1639 if (!s->flipped_image) stride = -stride; | 1639 if (!s->flipped_image) stride = -stride; |
1640 | 1640 |
1641 for (y = 0; y < height; y++) { | 1641 for (y = 0; y < height; y++) { |
1642 | 1642 |
1643 for (x = 0; x < width; x++) { | 1643 for (x = 0; x < width; x++) { |
1644 /* This code basically just deblocks on the edges of coded blocks. | 1644 /* do not perform left edge filter for left columns frags */ |
1645 * However, it has to be much more complicated because of the | 1645 if ((x > 0) && |
1646 * braindamaged deblock ordering used in VP3/Theora. Order matters | 1646 (s->all_fragments[fragment].coding_method != MODE_COPY)) { |
1647 * because some pixels get filtered twice. */ | 1647 s->dsp.vp3_h_loop_filter( |
1648 if( s->all_fragments[fragment].coding_method != MODE_COPY ) | 1648 plane_data + s->all_fragments[fragment].first_pixel, |
1649 { | 1649 stride, bounding_values); |
1650 /* do not perform left edge filter for left columns frags */ | 1650 } |
1651 if (x > 0) { | 1651 |
1652 s->dsp.vp3_h_loop_filter( | 1652 /* do not perform top edge filter for top row fragments */ |
1653 plane_data + s->all_fragments[fragment].first_pixel, | 1653 if ((y > 0) && |
1654 stride, bounding_values); | 1654 (s->all_fragments[fragment].coding_method != MODE_COPY)) { |
1655 } | 1655 s->dsp.vp3_v_loop_filter( |
1656 | 1656 plane_data + s->all_fragments[fragment].first_pixel, |
1657 /* do not perform top edge filter for top row fragments */ | 1657 stride, bounding_values); |
1658 if (y > 0) { | 1658 } |
1659 s->dsp.vp3_v_loop_filter( | 1659 |
1660 plane_data + s->all_fragments[fragment].first_pixel, | 1660 /* do not perform right edge filter for right column |
1661 stride, bounding_values); | 1661 * fragments or if right fragment neighbor is also coded |
1662 } | 1662 * in this frame (it will be filtered in next iteration) */ |
1663 | 1663 if ((x < width - 1) && |
1664 /* do not perform right edge filter for right column | 1664 (s->all_fragments[fragment].coding_method != MODE_COPY) && |
1665 * fragments or if right fragment neighbor is also coded | 1665 (s->all_fragments[fragment + 1].coding_method == MODE_COPY)) { |
1666 * in this frame (it will be filtered in next iteration) */ | 1666 s->dsp.vp3_h_loop_filter( |
1667 if ((x < width - 1) && | 1667 plane_data + s->all_fragments[fragment + 1].first_pixel, |
1668 (s->all_fragments[fragment + 1].coding_method == MODE_COPY)) { | 1668 stride, bounding_values); |
1669 s->dsp.vp3_h_loop_filter( | 1669 } |
1670 plane_data + s->all_fragments[fragment + 1].first_pixel, | 1670 |
1671 stride, bounding_values); | 1671 /* do not perform bottom edge filter for bottom row |
1672 } | 1672 * fragments or if bottom fragment neighbor is also coded |
1673 | 1673 * in this frame (it will be filtered in the next row) */ |
1674 /* do not perform bottom edge filter for bottom row | 1674 if ((y < height - 1) && |
1675 * fragments or if bottom fragment neighbor is also coded | 1675 (s->all_fragments[fragment].coding_method != MODE_COPY) && |
1676 * in this frame (it will be filtered in the next row) */ | 1676 (s->all_fragments[fragment + width].coding_method == MODE_COPY)) { |
1677 if ((y < height - 1) && | 1677 s->dsp.vp3_v_loop_filter( |
1678 (s->all_fragments[fragment + width].coding_method == MODE_COPY)) { | 1678 plane_data + s->all_fragments[fragment + width].first_pixel, |
1679 s->dsp.vp3_v_loop_filter( | 1679 stride, bounding_values); |
1680 plane_data + s->all_fragments[fragment + width].first_pixel, | |
1681 stride, bounding_values); | |
1682 } | |
1683 } | 1680 } |
1684 | 1681 |
1685 fragment++; | 1682 fragment++; |
1686 } | 1683 } |
1687 } | 1684 } |