[FFmpeg-devel] [PATCH 1/6 v2] avutil/frame: add a flag to not create duplicate entries in a side data array

Anton Khirnov anton at khirnov.net
Wed Mar 27 10:05:51 EET 2024


Quoting James Almer (2024-03-25 21:05:57)
> +/**
> + * Remove existing entries before adding new ones.
> + */
>  #define AV_FRAME_SIDE_DATA_FLAG_UNIQUE (1 << 0)
> +/**
> + * Don't add a new entry if another of the same type exists.
> + */
> +#define AV_FRAME_SIDE_DATA_FLAG_DONT_APPEND (1 << 1)

I don't really like this API, because it leaves too much work to the
user.

With my descriptor set, we know when it makes sense to have duplicate
side data. So the cases that can occur when adding side data of type T
are:
* T not present, call succeeds
* T present, then
    * T does not have a MULTI prop, then user decides whether to
      replace or do nothing (or perhaps fail)
    * T does have a MULTI prop, then user decides whether to replace,
      add, or do nothing

I think the default behaviour for MULTI types should be adding, and the
other two cases should be covered by the user explicitly.

Then we only need a single flag, which only applies to non-MULTI types,
and chooses whether to replace or not.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list