Re: ABR encoder: bits in reservoir

Elio Blanca via Lame-dev <[email protected]> Tue, 25 Jun 2019 13:35:04 +0200
Newsgroups gmane.comp.audio.mp3.lame
Message-ID <20190625133504.1aff0bb5@cindy>

Il giorno Tue, 25 Jun 2019 12:07:34 +0200
Gabriel Bouvigne <[email protected]> ha scritto:

> Even though Lame is triggering the assert in this specific point,
> it's likely that the actual bug was triggered earlier in the call
> stack [...]

In fact, this is what actually happens.
The critical computation seems to be into 'ResvAdjust' (reservoir.c)
which updates the reservoir size:

gfc->sv_enc.ResvSize -= gi->part2_3_length + gi->part2_length;

without checking whether the resulting value goes below 0.
Even tough, when I add such test and then set ResvSize to zero, bad
things happen elsewhere. Mmmmmhhh.

Elio