diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 17a5b1f79c..a533b1bf95 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -28,6 +28,7 @@ #include #include +#include #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" @@ -1494,20 +1495,27 @@ void ff_estimate_b_frame_motion(MpegEncContext * s, int fmin, bmin, dmin, fbmin; int type=0; - dmin= direct_search(s, mb_x, mb_y); + s->me.skip=0; + if (s->codec_id == CODEC_ID_MPEG4) + dmin= direct_search(s, mb_x, mb_y); + else + dmin= INT_MAX; + s->me.skip=0; fmin= ff_estimate_motion_b(s, mb_x, mb_y, s->b_forw_mv_table, &s->last_picture, s->f_code) + 3*penalty_factor; + + s->me.skip=0; bmin= ff_estimate_motion_b(s, mb_x, mb_y, s->b_back_mv_table, &s->next_picture, s->b_code) + 2*penalty_factor; //printf(" %d %d ", s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1]); + s->me.skip=0; fbmin= bidir_refine(s, mb_x, mb_y) + penalty_factor; //printf("%d %d %d %d\n", dmin, fmin, bmin, fbmin); { int score= fmin; type = MB_TYPE_FORWARD; - // RAL: No MB_TYPE_DIRECT in MPEG-1 video (only MPEG-4) - if (s->codec_id == CODEC_ID_MPEG4 && dmin <= score){ + if (dmin <= score){ score = dmin; type = MB_TYPE_DIRECT; } diff --git a/tests/rotozoom.regression.ref b/tests/rotozoom.regression.ref index 4d38d0e932..076009cb0a 100644 --- a/tests/rotozoom.regression.ref +++ b/tests/rotozoom.regression.ref @@ -29,15 +29,15 @@ stddev: 5.28 bytes:7602176 242a7a18c2793e115007bc163861ef4e *./data/a-huffyuv.avi dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv stddev: 0.00 bytes:7602176 -2a9ee5a50073e3c5c25653f83d2b78ae *./data/a-mpeg4-rc.avi -6851f0023a361b2b088d115f6d42d03e *./data/out.yuv -stddev: 5.12 bytes:7145472 +794463e80f8de682591e13b82510f967 *./data/a-mpeg4-rc.avi +25f3d554edf174034b5e484a7cfb04d3 *./data/out.yuv +stddev: 4.32 bytes:7145472 aeb300900461bdf9e0321934aa6dcc93 *./data/a-mpeg4-adv.avi e465df12f2c8a6492a6ec0b1bddc1d0d *./data/out.yuv stddev: 4.97 bytes:7602176 -2ec827a941ee8e82911280405987f8ef *./data/a-mpeg1b.mpg -2935a090a88c74ccb220c18c1399cea7 *./data/out.yuv -stddev: 4.69 bytes:6993920 +a7ab3fba8d7cd004b4809b5fe04e37d0 *./data/a-mpeg1b.mpg +c9b8f923d91d6a574b0673e05fd2d6bd *./data/out.yuv +stddev: 4.61 bytes:6993920 e9218a1db885fe0262e88f9df630307d *./data/a-mjpeg.avi a365b4da246ad68caf96b702b7f961a1 *./data/out.yuv stddev: 4.76 bytes:7602176