[FFmpeg-devel] [PATCH v2 05/12] avutil/frame: add helper for adding side data to set

Anton Khirnov anton at khirnov.net
Wed Apr 12 11:41:02 EEST 2023


Quoting Jan Ekström (2023-04-11 23:20:45)
> ---
>  libavutil/frame.c | 12 ++++++++++++
>  libavutil/frame.h | 13 +++++++++++++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index ab1a4e7f6a..29e9b631f8 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -708,6 +708,18 @@ AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
>      return ret;
>  }
>  
> +
> +AVFrameSideData *av_new_side_data_to_set(AVFrameSideDataSet *set,
> +                                         enum AVFrameSideDataType type,
> +                                         size_t size)
> +{
> +    AVBufferRef     *buf = av_buffer_alloc(size);

unchecked allocation

> +    AVFrameSideData *ret = add_side_data_to_set_from_buf(set, type, buf);
> +    if (!ret)
> +        av_buffer_unref(&buf);
> +    return ret;
> +}
> +
>  AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
>                                          enum AVFrameSideDataType type)
>  {
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index 734ac3fe75..167a8f0ff6 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -998,6 +998,19 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type);
>   */
>  void av_side_data_set_wipe(AVFrameSideDataSet *set);
>  
> +/**
> + * Add a new side data entry to a set.
> + *
> + * @param set a set to which the side data should be added
> + * @param type type of the added side data
> + * @param size size of the side data
> + *
> + * @return newly added side data on success, NULL on error
> + */
> +AVFrameSideData *av_new_side_data_to_set(AVFrameSideDataSet *set,

av_side_data_set_add()?

Or possibly _new or _create, because 'add' suggests you're passing in
the thing to be added, while in fact it creates a new uninitialized
entry.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list