[FFmpeg-devel] [RFC] v4l2_m2m: Fix races around freeing data on close

Hendrik Leppkes h.leppkes at gmail.com
Thu Oct 19 12:30:19 EEST 2017


On Thu, Oct 19, 2017 at 9:28 AM, Jorge Ramirez
<jorge.ramirez-ortiz at linaro.org> wrote:
> On 10/19/2017 02:10 AM, Mark Thompson wrote:
>>
>> Refcount all of the context information.
>> ---
>> As discussed in the other thread, something like this.  We move most of
>> the context into a refcounted buffer and AVCodecContext.priv_data is left as
>> a stub holding a reference to it.
>
>
> um, ok ... please could you send a patch so I can apply it? I see several
> problems in v4l2_free_buffer.
>
> To sum up the RFC, instead of using private_data to place the codec's
> context, it uses private data to place a _pointer_ to an allocated codec
> context "just" so it wont be deallocated after the codec is closed (codec
> close frees the private_data)
>
> Personally I think adding AV_CODEC_FLAG2_PRESERVE_PRIVDATA_ONCLOSE and use
> private_data to hold the codec context is a cleaner/simpler approach.
>

Using ref-counting is a mechanism we already have in-place for this
kind of thing, adding another global flag only used by one decoder is
not a preferred approach.

- Hendrik


More information about the ffmpeg-devel mailing list