summaryrefslogtreecommitdiff
path: root/libavcodec/mpegvideo_parser.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-15 15:54:02 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-10-15 15:54:02 +0200
commit620e7f0f3b3dff85d9c49a5c4b8a5df7143af7fe (patch)
tree080d5fdfe1041faa2eb33e865b8e4f902187c05c /libavcodec/mpegvideo_parser.c
parent801876fb079ecac157dbbffe2b6d10f2e2408fbf (diff)
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>
Diffstat (limited to 'libavcodec/mpegvideo_parser.c')
-rw-r--r--libavcodec/mpegvideo_parser.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c
index 668a94660b..0159421b56 100644
--- a/libavcodec/mpegvideo_parser.c
+++ b/libavcodec/mpegvideo_parser.c
@@ -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;