aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mpegvideo.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-12-17 19:53:05 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-12-17 19:53:05 +0000
commitd60a8f85d7016af8a412acfc8e220445a3c3436d (patch)
tree2cb76e762ac95f7655916125cd73a0b8564c3d20 /libavcodec/mpegvideo.c
parent044007c220ddda46e33432fc0501c1c244caa6fb (diff)
downloadffmpeg-d60a8f85d7016af8a412acfc8e220445a3c3436d.tar.gz
vbv_delay
Originally committed as revision 2623 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r--libavcodec/mpegvideo.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 61976d7d16..18a3a67fde 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1865,7 +1865,23 @@ int MPV_encode_picture(AVCodecContext *avctx,
flush_put_bits(&s->pb);
s->frame_bits = (pbBufPtr(&s->pb) - s->pb.buf) * 8;
}
-
+
+ /* update mpeg1/2 vbv_delay for CBR */
+ if(s->avctx->rc_max_rate && s->avctx->rc_min_rate == s->avctx->rc_max_rate){
+ int vbv_delay;
+
+ assert(s->repeat_first_field==0 && s->avctx->repeat_pic==0);
+
+ vbv_delay= lrint(90000 * s->rc_context.buffer_index / s->avctx->rc_max_rate);
+ assert(vbv_delay < 0xFFFF);
+
+ s->vbv_delay_ptr[0] &= 0xF8;
+ s->vbv_delay_ptr[0] |= vbv_delay>>13;
+ s->vbv_delay_ptr[1] = vbv_delay>>5;
+ s->vbv_delay_ptr[2] &= 0x07;
+ s->vbv_delay_ptr[2] |= vbv_delay<<3;
+ }
+
s->total_bits += s->frame_bits;
avctx->frame_bits = s->frame_bits;