aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorHenry Mason <talus25@speakeasy.net>2002-09-02 09:51:52 +0000
committerMichael Niedermayer <michaelni@gmx.at>2002-09-02 09:51:52 +0000
commitecfd40b390732056dc9cb3b79b1ab63c22c7700a (patch)
tree8037d7c90f02b92b3d80456b0478604a55d4da98 /libavcodec
parentab6c65f69307bff2a2d073a94b839619ab64386b (diff)
downloadffmpeg-ecfd40b390732056dc9cb3b79b1ab63c22c7700a.tar.gz
new vbv calculation patch by (Henry Mason <talus25 at speakeasy dot net>) with slight modification by me
Originally committed as revision 899 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mpeg12.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index ba52a36725..97c2e98ccb 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -142,9 +142,12 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
v = 0x3ffff;
put_bits(&s->pb, 18, v);
put_bits(&s->pb, 1, 1); /* marker */
- /* vbv buffer size: slightly greater than an I frame. We add
- some margin just in case */
- vbv_buffer_size = (3 * s->I_frame_bits) / (2 * 8);
+
+ 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);
put_bits(&s->pb, 1, 1); /* constrained parameter flag */
put_bits(&s->pb, 1, 0); /* no custom intra matrix */