[FFmpeg-devel] [PATCH] Fix quadratic memory use in ff_h2645_extract_rbsp() when multiple NALUs exist in packet.

Derek Buitenhuis derek.buitenhuis at gmail.com
Fri Nov 3 01:38:40 EET 2017

On 11/2/2017 10:48 PM, Kieran Kunhya wrote:
> I have tried this using the following patch but it does not work:
> https://www.irccloud.com/pastebin/qobTcW9d/
> Nothing obviously seems wrong so I suspect it's not possible to do this
> whilst reusing the code between decoder and parser.
> The old code use to write to a per-slice context, not a per packet one so
> this might be related.

As discussed on IRC, the issue was dangling pointers due to the realloc.

It can be allocated based on the full packet size, outside the function,
or on first call, I think.


Do we have some preferred way to address the cumulative memory issue
I mentioned in my previous mail, or is it a DNC situation? I haven't
thought of a good way to solve that - only stuff like going back
to in-place NAL parsing, or shrinking the buffer after some time based
on some metric (ew...).

- Derek

More information about the ffmpeg-devel mailing list