[FFmpeg-devel] [PATCH v0 02/14] avcodec: move AVCodecInternal allocation to avcodec_alloc_context3

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Mar 24 19:26:21 EET 2023


Michael Niedermayer:
> On Tue, Mar 21, 2023 at 01:33:56AM +0200, Jan Ekström wrote:
>> This allows for private values to be stored before the {de,en}coder
>> has been opened and initialized.
>>
>> Add a new unsigned boolean entry to specifically note that a
>> context has been opened instead of just depending on the internal
>> pointer.
>> ---
>>  libavcodec/avcodec.c              | 18 +++++++++++-------
>>  libavcodec/frame_thread_encoder.c |  7 ++++---
>>  libavcodec/internal.h             |  5 +++++
>>  libavcodec/options.c              | 20 +++++++++++++++++++-
>>  4 files changed, 39 insertions(+), 11 deletions(-)
> 
> this causes memory corruption with mjpeg
> ./ffmpeg_g -i lena.pnm -qscale 4 -intra_matrix 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10 -chroma_intra_matrix 400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400 -bitexact file-custommatrix10,400.jpg
> 
> i see
> 
> video:19kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
> corrupted size vs. prev_size
> Aborted (core dumped)
> 
> i can provide more details if it isnt reproduceable
> 

This is an example of the double-frees due to using
avcodec_free_context() to free the worker threads that I mentioned in my
reply.

- Andreas



More information about the ffmpeg-devel mailing list