[FFmpeg-devel] Help needed with ratecontrol

Michael Niedermayer michaelni
Tue Sep 2 00:58:47 CEST 2008


On Mon, Sep 01, 2008 at 08:07:40PM +0300, Kostya wrote:
> As you may know, I'm working on AAC encoder.
> Today I've managed to add trellis-based scalefactor quantizer selection.
> While it looks like optimal selection (at least in terms of time spent
> on search :-S, but I'm pretty sure it's optimal except for quantization
> procedure itself), it depends on parameter lambda which I don't know
> how to control.
> 
> Can somebody tell me how to manipulate lambda to achieve desired bitrate?
> I'm not sure I can use ratecontrol.c for that (it's too complex
> and mpegvideo-oriented).
> 
> Code snippets and links to clear papers are accepted.

There are many ways to manipulate lambda it all depends on what you want ...

The first and most important thing is that lambda must be adjusted for
each band (and frame) depending on psy model stuff.

ratecontrol, that is reaching a specific final file size can the be achived
by 3 ways (at least)

if you encode strict constant bitrate (probably not a terribly good idea)
a simple binary search of lambda can be used to find the optimal encoding,
for the given constant amount of bits available, this can be
optimized quite a bit by using a wiser method than bisection/binary search
like described on http://en.wikipedia.org/wiki/Root-finding_algorithm

If you encode constant quality then the best values for lamda before being
adjust by the psymodel is constant for the whole file. This requires 2 passes
over the file at least.

if you encode near constant quality in a single pass then setting lambda
before the psy model so that it is the lamda that would have achived
the wanted bitrate for the past seen frames and compensating for the actual
size error so far would the the logic thing. bitrate_tolerance should be
used here to adjust the amount of correction to be applied.
I suggest you use ratecontrol.c for this and the previous mode, it surely
may be needed to change ratecontrol.c a little to make it not depend on
mpegenccontext but reimplementing ratecontrol.c might be more work ...


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080902/c48c41a1/attachment.pgp>



More information about the ffmpeg-devel mailing list