[Libav-user] Audio quality loss while encoding

Claudio Freire klaussfreire at gmail.com
Wed May 1 12:53:10 CEST 2013


On Wed, May 1, 2013 at 4:26 AM, Claudio Freire <klaussfreire at gmail.com> wrote:
>> But still, not perfect... I gave it 256k, and it produced 140k. Lots
>> of room for improvement still, but I thought I'd share this bit. I'll
>> keep looking.
>
>
> Aaand mostly finally in aaccoder.c:713, search_for_quantizers_twoloop
> ignores lambda, so there's no effective rate control.
>
>
> Replacing
>
> int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels;
>
> with
>
> int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate /
> avctx->channels * lambda;
>
> Results in general bliss. Will check the other search methods.


Ok... I had to forfeit my right to sleep, but here it is. Managed to
make both the fast and 2loop methods work reasonably well (albeit I
don't know why anyone would use fast, because it's not faster. I
assume it's an experiment?).

I don't have access to AAC standards, though, since they're paywalled
(at least the ones I found), so most of the changes were done blind,
assuming from what I know of audio codecs, and by trial and error.

In particular, fast has some magic numbers there that I got from trial
and error, and nothing more... profound.

In any case, attached it is, git diff.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: aac_bit_alloc.patch
Type: application/octet-stream
Size: 3380 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130501/4bcedf72/attachment.obj>


More information about the Libav-user mailing list