summaryrefslogtreecommitdiffstats
path: root/libavcodec/mpeg12.c
diff options
context:
space:
mode:
authorHeesuk Jung <heesuk.jung@lge.com>2012-11-02 08:25:03 -0700
committerMichael Niedermayer <michaelni@gmx.at>2012-11-02 22:27:17 +0100
commit25b7aa980bb8ecc6de085adf7d6b8e68a44bcbd4 (patch)
tree8cd39f99bede5bc8866c7a12944c124add281569 /libavcodec/mpeg12.c
parent77d89a5b160127b5b60ba0310cb999077a22525d (diff)
downloadffmpeg-streaming-25b7aa980bb8ecc6de085adf7d6b8e68a44bcbd4.zip
ffmpeg-streaming-25b7aa980bb8ecc6de085adf7d6b8e68a44bcbd4.tar.gz
Fix bit_rate in MPEG1/2 Video
In ISO/IEC 13818-2, bit rate is differently determined according to video type 1) MPEG1 Video Bit_rate and vbv_delay are set to 3FFFF and FFFF respectively to indicate variable bitrate. Other values are for constant bitrate. VBV is only defined for constant bit rate operation. Ths STD supersedes the VBV model for vbr. 2) MPEG2 Video Even if the bitrate is constant, the value of bit_rate may not be the actual bitrate since bit_rate need only be an upper bound to that actual bitrate. VBV is only defined for variable bit rate operation. Constant bit rate is viewed as a special case of vbr. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/mpeg12.c')
-rw-r--r--libavcodec/mpeg12.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index bdb6b00..b5bf68d 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -1278,8 +1278,12 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
return -2;
avcodec_set_dimensions(avctx, s->width, s->height);
- if (s->bit_rate && s->bit_rate != 0x3FFFF*400)
- avctx->bit_rate = s->bit_rate;
+ if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->bit_rate) {
+ avctx->rc_max_rate = s->bit_rate;
+ } else if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO && s->bit_rate &&
+ (s->bit_rate != 0x3FFFF*400 || s->vbv_delay != 0xFFFF)) {
+ avctx->bit_rate = s->bit_rate;
+ }
s1->save_aspect_info = s->aspect_ratio_info;
s1->save_width = s->width;
s1->save_height = s->height;
@@ -1378,6 +1382,7 @@ static int mpeg1_decode_picture(AVCodecContext *avctx,
return -1;
vbv_delay = get_bits(&s->gb, 16);
+ s->vbv_delay = vbv_delay;
if (s->pict_type == AV_PICTURE_TYPE_P || s->pict_type == AV_PICTURE_TYPE_B) {
s->full_pel[0] = get_bits1(&s->gb);
f_code = get_bits(&s->gb, 3);
OpenPOWER on IntegriCloud