[FFmpeg-devel] FLAC parser inefficiency

Uoti Urpala uoti.urpala
Thu Dec 9 05:22:17 CET 2010


The FLAC parser buffers input unnecessarily even when there's already
enough data to return the next packet. This leads to growing internal
buffer size and bad performance when data is fed in large enough chunks.

In flac_parse(), the only return statement that can return a read amount
less than the whole buf_size given as available input is the "return
get_best_header(fpc, poutbuf, poutbuf_size);" one, and that cannot
happen on two consecutive calls as the statement is under "if
(fpc->best_header_valid)" but get_best_header() sets that to false. Thus
if you consider a hypothetical case where a program provides say
buf_size=10M bytes of available input to each parse call then it's
obvious that things are not going to work - the code will return at most
one packet of output per call but will read at least 10 MB of input per
every two calls.


BTW how is client code supposed to avoid trying to decode the junk
packets produced (the "/* Output a junk frame. */" part)? Normally when
parsing before decoding you'd want to throw away that data instead.
Check for avctx->frame_size being 0 after the parse call? But is that
supposed to behave the same way with other parsers?




More information about the ffmpeg-devel mailing list