diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 713b42d18f..ba352d5c4c 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -392,13 +392,19 @@ void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number) // RAL: Forward f_code also needed for B frames if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) { put_bits(&s->pb, 1, 0); /* half pel coordinates */ - put_bits(&s->pb, 3, s->f_code); /* forward_f_code */ + if(s->codec_id == CODEC_ID_MPEG1VIDEO) + put_bits(&s->pb, 3, s->f_code); /* forward_f_code */ + else + put_bits(&s->pb, 3, 7); /* forward_f_code */ } // RAL: Backward f_code necessary for B frames if (s->pict_type == B_TYPE) { put_bits(&s->pb, 1, 0); /* half pel coordinates */ - put_bits(&s->pb, 3, s->b_code); /* backward_f_code */ + if(s->codec_id == CODEC_ID_MPEG1VIDEO) + put_bits(&s->pb, 3, s->b_code); /* backward_f_code */ + else + put_bits(&s->pb, 3, 7); /* backward_f_code */ } put_bits(&s->pb, 1, 0); /* extra bit picture */ @@ -406,10 +412,18 @@ void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number) if(s->codec_id == CODEC_ID_MPEG2VIDEO){ put_header(s, EXT_START_CODE); put_bits(&s->pb, 4, 8); //pic ext - put_bits(&s->pb, 4, s->f_code); - put_bits(&s->pb, 4, s->f_code); - put_bits(&s->pb, 4, s->b_code); - put_bits(&s->pb, 4, s->b_code); + if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) { + put_bits(&s->pb, 4, s->f_code); + put_bits(&s->pb, 4, s->f_code); + }else{ + put_bits(&s->pb, 8, 255); + } + if (s->pict_type == B_TYPE) { + put_bits(&s->pb, 4, s->b_code); + put_bits(&s->pb, 4, s->b_code); + }else{ + put_bits(&s->pb, 8, 255); + } put_bits(&s->pb, 2, s->intra_dc_precision); put_bits(&s->pb, 2, s->picture_structure= PICT_FRAME); put_bits(&s->pb, 1, s->top_field_first); diff --git a/tests/ffmpeg.regression.ref b/tests/ffmpeg.regression.ref index 43f991650c..b4d5290a7a 100644 --- a/tests/ffmpeg.regression.ref +++ b/tests/ffmpeg.regression.ref @@ -1,8 +1,8 @@ ffmpeg regression test -6787ecce1da78d5e0cdeb35931f3212c *./data/a-mpeg1.mpg +b85daef6da4204e2f85376a34d9ada8d *./data/a-mpeg1.mpg 6713259d72260740bbddaea30631ea18 *./data/out.yuv stddev: 7.58 bytes:7299072 -40b1ce56144067f5c8d4df422705ae6a *./data/a-mpeg2.vob +6640be3963445c470f148382aab77af0 *./data/a-mpeg2.vob 9f5d85c6473b802a9d86cfc01a3ed046 *./data/out.yuv stddev: 7.66 bytes:7450624 d0dc46dd831398237a690ebbeff18b64 *./data/a-msmpeg4v2.avi @@ -35,7 +35,7 @@ stddev: 10.53 bytes:7145472 2cbab98ebef5fbd229c66fb6435bf9a2 *./data/a-mpeg4-adv.avi b54262af56f6681186fa2c44e4ef6ec7 *./data/out.yuv stddev: 7.32 bytes:7602176 -5515306aa3c69112ee627023856bd696 *./data/a-mpeg1b.mpg +3fd47ba846e8d7631304d945af410da2 *./data/a-mpeg1b.mpg bd047a4567c366566da96874d176199d *./data/out.yuv stddev: 6.35 bytes:6993920 07042f42b3119c39eb26537a84a451df *./data/a-mjpeg.avi diff --git a/tests/rotozoom.regression.ref b/tests/rotozoom.regression.ref index a86e24de51..b01472477a 100644 --- a/tests/rotozoom.regression.ref +++ b/tests/rotozoom.regression.ref @@ -1,8 +1,8 @@ ffmpeg regression test -6dce999b1f02a94dfd6d6222caf06ff1 *./data/a-mpeg1.mpg +31334d408162b55725075347e382d313 *./data/a-mpeg1.mpg 0cf790edd0f4c5cf993c2d59211b9de2 *./data/out.yuv stddev: 4.91 bytes:7299072 -bbb41fb21c836cff975442e583702216 *./data/a-mpeg2.vob +8d7dcc133e04f24f3fb40cdada990b24 *./data/a-mpeg2.vob f5436b327c38b66eb95f3428aff790f1 *./data/out.yuv stddev: 4.94 bytes:7450624 14db391f167b52b21a983157b410affc *./data/a-msmpeg4v2.avi @@ -35,7 +35,7 @@ stddev: 4.32 bytes:7145472 aeb300900461bdf9e0321934aa6dcc93 *./data/a-mpeg4-adv.avi e465df12f2c8a6492a6ec0b1bddc1d0d *./data/out.yuv stddev: 4.97 bytes:7602176 -fc873784878d9588e748c1494df606be *./data/a-mpeg1b.mpg +33c05290014210e4fb890a11954e1a00 *./data/a-mpeg1b.mpg c9b8f923d91d6a574b0673e05fd2d6bd *./data/out.yuv stddev: 4.61 bytes:6993920 e9218a1db885fe0262e88f9df630307d *./data/a-mjpeg.avi