mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-17 20:37:04 +00:00
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: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
801876fb07
commit
620e7f0f3b
@ -1316,7 +1316,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
|
||||
// MPEG-2 fps
|
||||
av_reduce(&s->avctx->framerate.num,
|
||||
&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,
|
||||
1 << 30);
|
||||
avctx->ticks_per_frame = 2;
|
||||
|
@ -73,6 +73,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
|
||||
pc->frame_rate = avctx->framerate = ff_mpeg12_frame_rate_tab[frame_rate_index];
|
||||
bit_rate = (buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6);
|
||||
avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO;
|
||||
avctx->ticks_per_frame = 1;
|
||||
}
|
||||
break;
|
||||
case EXT_START_CODE:
|
||||
@ -94,9 +95,10 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
|
||||
bit_rate = (bit_rate&0x3FFFF) | (bit_rate_ext << 18);
|
||||
if(did_set_size)
|
||||
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->codec_id = AV_CODEC_ID_MPEG2VIDEO;
|
||||
avctx->ticks_per_frame = 2;
|
||||
}
|
||||
break;
|
||||
case 0x8: /* picture coding extension */
|
||||
@ -151,7 +153,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
|
||||
}
|
||||
#if FF_API_AVCTX_TIMEBASE
|
||||
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
|
||||
}
|
||||
|
||||
@ -181,7 +183,7 @@ static int mpegvideo_parse(AVCodecParserContext *s,
|
||||
function should be negligible for uncorrupted streams */
|
||||
mpegvideo_extract_headers(s, avctx, buf, buf_size);
|
||||
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_size = buf_size;
|
||||
|
Loading…
Reference in New Issue
Block a user