[FFmpeg-devel] [PATCH] Fix ratecontrol bug when time_base.num > 1
michaelni at gmx.at
Fri Nov 16 14:59:58 CET 2012
On Fri, Nov 16, 2012 at 12:01:11PM +0000, Joseph Artsimovich wrote:
> When encoding long-GOP MPEG2 with time_base of 24/600 (with reduces
> to 1/25, but I need it for compatibility with some proprietary
> software) I noticed blow up of encoded frame size and "rc buffer
> underflow" errors. I traced it back to the following line in
> wanted_bits = (uint64_t)(s->bit_rate*(double)dts_pic->f.pts / fps);
> which doesn't take pts units into account.
> A patch is attached.
> @@ -708,7 +708,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
> if (!dts_pic || dts_pic->f.pts == AV_NOPTS_VALUE)
> wanted_bits= (uint64_t)(s->bit_rate*(double)picture_number/fps);
> - wanted_bits = (uint64_t)(s->bit_rate*(double)dts_pic->f.pts / fps);
> + wanted_bits = (uint64_t)(s->bit_rate*(double)dts_pic->f.pts / (fps*(double)s->dts_delta));
dts_delta is only set in some cases and only based
on the first frames.
The durations of later frames can be entirely different from the
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: Digital signature
More information about the ffmpeg-devel