Re: ABR encoder: bits in reservoir

Gabriel Bouvigne <[email protected]> Tue, 25 Jun 2019 12:07:34 +0200
Newsgroups gmane.comp.audio.mp3.lame
Message-ID <[email protected]>
On 2019-06-21 19:54, Elio Blanca via Lame-dev wrote:
> I'm investigating bug #501 ( https://sourceforge.net/p/lame/bugs/501/ )
[...]
> fullFrameBits:  maximum number of bits available for encoding the
> current frame.
> 
[...]
> and, as ResvMax value is 4088 (max reservoir for mpeg1 is 511 bytes, so
> 4088 bits), I would expect ResvSize to have values into [0..4088].

Hello,

Your assumption is correct: ResvSize values should not go below 0.
The bit reservoir is a strange concept from MPEG audio, in which unused 
space in previous frames can hold data for newer frames. A negative 
value (reservoir size)does not make sense there.

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 (or  
we are facing a memory corruption).

Regards,

--
Gabriel Bouvigne