aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-08-29 19:42:23 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-08-29 19:42:23 +0000
commit12dccd4e60b6b7f1c2a3d51717ea5718a1cd3756 (patch)
tree2ca6547fbff29762996bd76f522666ce331e0743 /libavcodec
parent904736b519f774df6eabb7ce9a54a2b71a10c2af (diff)
downloadffmpeg-12dccd4e60b6b7f1c2a3d51717ea5718a1cd3756.tar.gz
bit_rate in mpeg1/2 should be 0x3FFFF for vbr or at least >= max_bitrate
Originally committed as revision 2180 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mpeg12.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index c9284b27b1..713b42d18f 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -227,18 +227,25 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
put_bits(&s->pb, 4, s->aspect_ratio_info);
put_bits(&s->pb, 4, s->frame_rate_index);
- v = (s->bit_rate + 399) / 400;
- if (v > 0x3ffff && s->codec_id == CODEC_ID_MPEG1VIDEO)
- v = 0x3ffff;
- put_bits(&s->pb, 18, v & 0x3FFFF);
- put_bits(&s->pb, 1, 1); /* marker */
+
+ if(s->avctx->rc_max_rate){
+ v = (s->avctx->rc_max_rate + 399) / 400;
+ if (v > 0x3ffff && s->codec_id == CODEC_ID_MPEG1VIDEO)
+ v = 0x3ffff;
+ }else{
+ v= 0x3FFFF;
+ }
if(s->avctx->rc_buffer_size)
vbv_buffer_size = s->avctx->rc_buffer_size;
else
/* VBV calculation: Scaled so that a VCD has the proper VBV size of 40 kilobytes */
- vbv_buffer_size = (( 20 * s->bit_rate) / (1151929 / 2)) * 8 * 1024;
- put_bits(&s->pb, 10, ((vbv_buffer_size + 16383) / 16384) & 0x3FF);
+ vbv_buffer_size = (( 20 * s->bit_rate) / (1151929 / 2)) * 8 * 1024;
+ vbv_buffer_size= (vbv_buffer_size + 16383) / 16384;
+
+ put_bits(&s->pb, 18, v & 0x3FFFF);
+ put_bits(&s->pb, 1, 1); /* marker */
+ put_bits(&s->pb, 10, vbv_buffer_size & 0x3FF);
put_bits(&s->pb, 1, 1); /* constrained parameter flag */
ff_write_quant_matrix(&s->pb, s->avctx->intra_matrix);