diff mbox series

[FFmpeg-devel,v4,03/13] avutil/frame: add helper for uninitializing side data sets

Message ID 20230901203828.275197-4-jeebjp@gmail.com
State New
Headers show
Series encoder AVCodecContext configuration side data | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Jan Ekström Sept. 1, 2023, 8:38 p.m. UTC
---
 libavutil/frame.c | 5 +++++
 libavutil/frame.h | 8 ++++++++
 2 files changed, 13 insertions(+)

Comments

James Almer Sept. 2, 2023, 1:12 p.m. UTC | #1
On 9/1/2023 5:38 PM, Jan Ekström wrote:
> ---
>   libavutil/frame.c | 5 +++++
>   libavutil/frame.h | 8 ++++++++
>   2 files changed, 13 insertions(+)
> 
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index 4b8481b756..b03f8d6c73 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -90,6 +90,11 @@ static void frame_side_data_wipe(AVFrame *frame)
>       wipe_side_data(&frame->side_data, &frame->nb_side_data);
>   }
>   
> +void av_frame_side_data_set_uninit(AVFrameSideDataSet *set)
> +{
> +    wipe_side_data(&set->sd, &set->nb_sd);
> +}
> +
>   AVFrame *av_frame_alloc(void)
>   {
>       AVFrame *frame = av_malloc(sizeof(*frame));
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index 6155226c1d..dc87d38adc 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -1057,6 +1057,14 @@ int av_frame_apply_cropping(AVFrame *frame, int flags);
>    */
>   const char *av_frame_side_data_name(enum AVFrameSideDataType type);
>   
> +/**
> + * Free all side data items and their contents, then zeroes out the
> + * struct values.
> + *
> + * @param set the set which should be uninitialized
> + */
> +void av_frame_side_data_set_uninit(AVFrameSideDataSet *set);

av_frame_side_data_set_free()?

> +
>   /**
>    * @}
>    */
Anton Khirnov Sept. 5, 2023, 11:48 a.m. UTC | #2
Quoting James Almer (2023-09-02 15:12:20)
> On 9/1/2023 5:38 PM, Jan Ekström wrote:
> > ---
> >   libavutil/frame.c | 5 +++++
> >   libavutil/frame.h | 8 ++++++++
> >   2 files changed, 13 insertions(+)
> > 
> > diff --git a/libavutil/frame.c b/libavutil/frame.c
> > index 4b8481b756..b03f8d6c73 100644
> > --- a/libavutil/frame.c
> > +++ b/libavutil/frame.c
> > @@ -90,6 +90,11 @@ static void frame_side_data_wipe(AVFrame *frame)
> >       wipe_side_data(&frame->side_data, &frame->nb_side_data);
> >   }
> >   
> > +void av_frame_side_data_set_uninit(AVFrameSideDataSet *set)
> > +{
> > +    wipe_side_data(&set->sd, &set->nb_sd);
> > +}
> > +
> >   AVFrame *av_frame_alloc(void)
> >   {
> >       AVFrame *frame = av_malloc(sizeof(*frame));
> > diff --git a/libavutil/frame.h b/libavutil/frame.h
> > index 6155226c1d..dc87d38adc 100644
> > --- a/libavutil/frame.h
> > +++ b/libavutil/frame.h
> > @@ -1057,6 +1057,14 @@ int av_frame_apply_cropping(AVFrame *frame, int flags);
> >    */
> >   const char *av_frame_side_data_name(enum AVFrameSideDataType type);
> >   
> > +/**
> > + * Free all side data items and their contents, then zeroes out the
> > + * struct values.
> > + *
> > + * @param set the set which should be uninitialized
> > + */
> > +void av_frame_side_data_set_uninit(AVFrameSideDataSet *set);
> 
> av_frame_side_data_set_free()?

uninit is better IMO because the function cleans the struct contents,
but does not free the struct itself.
James Almer Sept. 5, 2023, 11:53 a.m. UTC | #3
On 9/5/2023 8:48 AM, Anton Khirnov wrote:
> Quoting James Almer (2023-09-02 15:12:20)
>> On 9/1/2023 5:38 PM, Jan Ekström wrote:
>>> ---
>>>    libavutil/frame.c | 5 +++++
>>>    libavutil/frame.h | 8 ++++++++
>>>    2 files changed, 13 insertions(+)
>>>
>>> diff --git a/libavutil/frame.c b/libavutil/frame.c
>>> index 4b8481b756..b03f8d6c73 100644
>>> --- a/libavutil/frame.c
>>> +++ b/libavutil/frame.c
>>> @@ -90,6 +90,11 @@ static void frame_side_data_wipe(AVFrame *frame)
>>>        wipe_side_data(&frame->side_data, &frame->nb_side_data);
>>>    }
>>>    
>>> +void av_frame_side_data_set_uninit(AVFrameSideDataSet *set)
>>> +{
>>> +    wipe_side_data(&set->sd, &set->nb_sd);
>>> +}
>>> +
>>>    AVFrame *av_frame_alloc(void)
>>>    {
>>>        AVFrame *frame = av_malloc(sizeof(*frame));
>>> diff --git a/libavutil/frame.h b/libavutil/frame.h
>>> index 6155226c1d..dc87d38adc 100644
>>> --- a/libavutil/frame.h
>>> +++ b/libavutil/frame.h
>>> @@ -1057,6 +1057,14 @@ int av_frame_apply_cropping(AVFrame *frame, int flags);
>>>     */
>>>    const char *av_frame_side_data_name(enum AVFrameSideDataType type);
>>>    
>>> +/**
>>> + * Free all side data items and their contents, then zeroes out the
>>> + * struct values.
>>> + *
>>> + * @param set the set which should be uninitialized
>>> + */
>>> +void av_frame_side_data_set_uninit(AVFrameSideDataSet *set);
>>
>> av_frame_side_data_set_free()?
> 
> uninit is better IMO because the function cleans the struct contents,
> but does not free the struct itself.

Ok. Will amend my set then.
diff mbox series

Patch

diff --git a/libavutil/frame.c b/libavutil/frame.c
index 4b8481b756..b03f8d6c73 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -90,6 +90,11 @@  static void frame_side_data_wipe(AVFrame *frame)
     wipe_side_data(&frame->side_data, &frame->nb_side_data);
 }
 
+void av_frame_side_data_set_uninit(AVFrameSideDataSet *set)
+{
+    wipe_side_data(&set->sd, &set->nb_sd);
+}
+
 AVFrame *av_frame_alloc(void)
 {
     AVFrame *frame = av_malloc(sizeof(*frame));
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 6155226c1d..dc87d38adc 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -1057,6 +1057,14 @@  int av_frame_apply_cropping(AVFrame *frame, int flags);
  */
 const char *av_frame_side_data_name(enum AVFrameSideDataType type);
 
+/**
+ * Free all side data items and their contents, then zeroes out the
+ * struct values.
+ *
+ * @param set the set which should be uninitialized
+ */
+void av_frame_side_data_set_uninit(AVFrameSideDataSet *set);
+
 /**
  * @}
  */