On Wed, Jul 04, 2018 at 11:35:09AM -0700, Baptiste Coudurier wrote: > --- > libavcodec/ratecontrol.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c > index 49d169ba25..28bdddbad1 100644 > --- a/libavcodec/ratecontrol.c > +++ b/libavcodec/ratecontrol.c > @@ -705,16 +705,16 @@ int ff_vbv_update(MpegEncContext *s, int frame_size) > rcc->buffer_index += av_clip(left, min_rate, max_rate); > > if (rcc->buffer_index > buffer_size) { > - int stuffing = ceil((rcc->buffer_index - buffer_size) / 8); > + int stuffing = rcc->buffer_index - buffer_size; > > - if (stuffing < 4 && s->codec_id == AV_CODEC_ID_MPEG4) > - stuffing = 4; > - rcc->buffer_index -= 8 * stuffing; > + if (stuffing < 32 && s->codec_id == AV_CODEC_ID_MPEG4) > + stuffing = 32; > + rcc->buffer_index -= stuffing; > > if (s->avctx->debug & FF_DEBUG_RC) > - av_log(s->avctx, AV_LOG_DEBUG, "stuffing %d bytes\n", > stuffing); > + av_log(s->avctx, AV_LOG_DEBUG, "stuffing %d bytes\n", > stuffing>>3); > > - return stuffing; > + return stuffing>>3; > }
This would break VBV for most codecs buffer_index is a double, the if() condition is triggered if the current frame is too small. All the rounding has to be up as in the ceil() that was there. The stuffing that is added, is minimal, so a decrease would be expected to break cases occasionally Can you explain how this code fails, in what exact case (max/min rate/ buffer_size/fps) ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
signature.asc
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel