[FFmpeg-devel] [PATCH] make FLAC parser return frames when it has the required amount (without buffering)
Thu Dec 16 01:08:48 CET 2010
On 12/15/2010 03:22 PM, Justin Ruggles wrote:
> On 12/15/2010 01:01 PM, Michael Chinen wrote:
>> On Sun, Dec 12, 2010 at 4:53 AM, Justin Ruggles
>> <justin.ruggles at gmail.com> wrote:
>>> Well, it would catch up after several frames... Maybe an LPC function
>>> to predict frame size would do better... it is FLAC after all. ;)
>>> Anyway, anything that's even remotely predictive is better than a fixed
>>> value. 8192 bytes is very certainly a big overestimate for silent frames.
>> Okay, how about using 8192 bytes initially and make it the largest
>> average found so far?
>> This should handle the silent and small sections.
Well, after some discussions on IRC with Uoti, I think it would make
more sense to keep the fixed value as-is or higher and make the parser
read more data from the input if it is available instead of returning if
fpc->nb_headers_buffered < FLAC_MIN_HEADERS.
This would not take as large a performance hit for buffering multiple
times because the caller would not have to increment and resend the data.
On a related note, it was also pointed out to me that feeding the parser
arbitrary (or even all zero) data could lead to it buffering until
memory runs out because it never finds a header. So there needs to be a
sanity check added. (8-channel 32-bit audio with frame size of 65535
and no compression would be approx. 20MB)
More information about the ffmpeg-devel