aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-30 02:05:56 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-10-30 02:19:21 +0100
commit740959fdbfbf804ccd8a6e426b1b1ba321fe5cfb (patch)
tree73aa0f627c4549d07739c87011bb43c72f8c0ac3
parent11d695d120d0249954b06646561cb43be04d8240 (diff)
downloadffmpeg-740959fdbfbf804ccd8a6e426b1b1ba321fe5cfb.tar.gz
mpeg12parser: cleanup bitrate parsing.
This fixes several bugs in the code. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/mpegvideo_parser.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c
index c60d3cd1cf..bea83a262c 100644
--- a/libavcodec/mpegvideo_parser.c
+++ b/libavcodec/mpegvideo_parser.c
@@ -43,6 +43,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
int top_field_first, repeat_first_field, progressive_frame;
int horiz_size_ext, vert_size_ext, bit_rate_ext;
int did_set_size=0;
+ int bit_rate = 0;
//FIXME replace the crap with get_bits()
s->repeat_pict = 0;
@@ -67,7 +68,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
frame_rate_index = buf[3] & 0xf;
pc->frame_rate.den = avctx->time_base.den = ff_mpeg12_frame_rate_tab[frame_rate_index].num;
pc->frame_rate.num = avctx->time_base.num = ff_mpeg12_frame_rate_tab[frame_rate_index].den;
- avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400;
+ bit_rate = (buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6);
avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO;
}
break;
@@ -87,7 +88,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
pc->width |=(horiz_size_ext << 12);
pc->height |=( vert_size_ext << 12);
- avctx->bit_rate += (bit_rate_ext << 18) * 400;
+ bit_rate = (bit_rate&0x3FFFF) | (bit_rate_ext << 18);
if(did_set_size)
avcodec_set_dimensions(avctx, pc->width, pc->height);
avctx->time_base.den = pc->frame_rate.den * (frame_rate_ext_n + 1) * 2;
@@ -130,6 +131,9 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
}
}
the_end: ;
+ if (bit_rate) {
+ avctx->bit_rate = 400 * bit_rate;
+ }
}
static int mpegvideo_parse(AVCodecParserContext *s,