Commit 620e7f0f authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/mpeg12dec: fix time_base and framerate

They are not just inverses of each other.
This should restore behavior to before the introduction of framerate
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 801876fb
...@@ -1316,7 +1316,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) ...@@ -1316,7 +1316,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
// MPEG-2 fps // MPEG-2 fps
av_reduce(&s->avctx->framerate.num, av_reduce(&s->avctx->framerate.num,
&s->avctx->framerate.den, &s->avctx->framerate.den,
ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num * 2, ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num,
ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den, ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
1 << 30); 1 << 30);
avctx->ticks_per_frame = 2; avctx->ticks_per_frame = 2;
......
...@@ -73,6 +73,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, ...@@ -73,6 +73,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
pc->frame_rate = avctx->framerate = ff_mpeg12_frame_rate_tab[frame_rate_index]; pc->frame_rate = avctx->framerate = ff_mpeg12_frame_rate_tab[frame_rate_index];
bit_rate = (buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6); bit_rate = (buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6);
avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO; avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO;
avctx->ticks_per_frame = 1;
} }
break; break;
case EXT_START_CODE: case EXT_START_CODE:
...@@ -94,9 +95,10 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, ...@@ -94,9 +95,10 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
bit_rate = (bit_rate&0x3FFFF) | (bit_rate_ext << 18); bit_rate = (bit_rate&0x3FFFF) | (bit_rate_ext << 18);
if(did_set_size) if(did_set_size)
ff_set_dimensions(avctx, pc->width, pc->height); ff_set_dimensions(avctx, pc->width, pc->height);
avctx->framerate.num = pc->frame_rate.num * (frame_rate_ext_n + 1) * 2; avctx->framerate.num = pc->frame_rate.num * (frame_rate_ext_n + 1);
avctx->framerate.den = pc->frame_rate.den * (frame_rate_ext_d + 1); avctx->framerate.den = pc->frame_rate.den * (frame_rate_ext_d + 1);
avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO; avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;
avctx->ticks_per_frame = 2;
} }
break; break;
case 0x8: /* picture coding extension */ case 0x8: /* picture coding extension */
...@@ -151,7 +153,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, ...@@ -151,7 +153,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
} }
#if FF_API_AVCTX_TIMEBASE #if FF_API_AVCTX_TIMEBASE
if (avctx->framerate.num) if (avctx->framerate.num)
avctx->time_base = av_inv_q(avctx->framerate); avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
#endif #endif
} }
...@@ -181,7 +183,7 @@ static int mpegvideo_parse(AVCodecParserContext *s, ...@@ -181,7 +183,7 @@ static int mpegvideo_parse(AVCodecParserContext *s,
function should be negligible for uncorrupted streams */ function should be negligible for uncorrupted streams */
mpegvideo_extract_headers(s, avctx, buf, buf_size); mpegvideo_extract_headers(s, avctx, buf, buf_size);
av_dlog(NULL, "pict_type=%d frame_rate=%0.3f repeat_pict=%d\n", av_dlog(NULL, "pict_type=%d frame_rate=%0.3f repeat_pict=%d\n",
s->pict_type, (double)avctx->time_base.den / avctx->time_base.num, s->repeat_pict); s->pict_type, av_q2d(avctx->framerate), s->repeat_pict);
*poutbuf = buf; *poutbuf = buf;
*poutbuf_size = buf_size; *poutbuf_size = buf_size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment