diff mbox series

[FFmpeg-devel,v2,03/12] avutil/frame: add helper for clearing out side data sets

Message ID 20230411212052.159889-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 April 11, 2023, 9:20 p.m. UTC
---
 libavutil/frame.c | 5 +++++
 libavutil/frame.h | 7 +++++++
 2 files changed, 12 insertions(+)

Comments

Anton Khirnov April 12, 2023, 8:27 a.m. UTC | #1
Quoting Jan Ekström (2023-04-11 23:20:43)
> ---
>  libavutil/frame.c | 5 +++++
>  libavutil/frame.h | 7 +++++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index 019613e4d2..24038cc0fa 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -90,6 +90,11 @@ static void wipe_side_data_from_frame(AVFrame *frame) {
>      wipe_side_data(&frame->side_data, &frame->nb_side_data);
>  }
>  
> +void av_side_data_set_wipe(AVFrameSideDataSet *set)
> +{
> +    wipe_side_data(&set->side_data, &set->nb_side_data);
> +}
> +
>  AVFrame *av_frame_alloc(void)
>  {
>      AVFrame *frame = av_malloc(sizeof(*frame));
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index 45024c2a03..734ac3fe75 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -991,6 +991,13 @@ int av_frame_apply_cropping(AVFrame *frame, int flags);
>   */
>  const char *av_frame_side_data_name(enum AVFrameSideDataType type);
>  
> +/**
> + * Clear all side data from a side data set
> + *
> + * @param set the set which should be cleared
> + */
> +void av_side_data_set_wipe(AVFrameSideDataSet *set);

The function name is 'wipe', the doxy says 'clear'. The operation it
actually performs is usually called 'uninit' or 'free' in other APIs
(e.g. av_packet_free_side_data()).

I would prefer to avoid inventing new terminology, because that leads to
confusion. av_side_data_set_uninit() would be my preference (not 'free'
because the struct itself is not freed).

The doxy should say what exactly the function does - free all side data
items and their contents and zero the struct.
diff mbox series

Patch

diff --git a/libavutil/frame.c b/libavutil/frame.c
index 019613e4d2..24038cc0fa 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -90,6 +90,11 @@  static void wipe_side_data_from_frame(AVFrame *frame) {
     wipe_side_data(&frame->side_data, &frame->nb_side_data);
 }
 
+void av_side_data_set_wipe(AVFrameSideDataSet *set)
+{
+    wipe_side_data(&set->side_data, &set->nb_side_data);
+}
+
 AVFrame *av_frame_alloc(void)
 {
     AVFrame *frame = av_malloc(sizeof(*frame));
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 45024c2a03..734ac3fe75 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -991,6 +991,13 @@  int av_frame_apply_cropping(AVFrame *frame, int flags);
  */
 const char *av_frame_side_data_name(enum AVFrameSideDataType type);
 
+/**
+ * Clear all side data from a side data set
+ *
+ * @param set the set which should be cleared
+ */
+void av_side_data_set_wipe(AVFrameSideDataSet *set);
+
 /**
  * @}
  */