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

Message ID 20230331162205.428735-6-jeebjp@gmail.com
State New
Headers
Series encoder AVCodecContext configuration side data |

Checks

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

Commit Message

Jan Ekström March 31, 2023, 4:21 p.m. UTC
---
 libavutil/frame.c | 12 ++++++++++++
 libavutil/frame.h | 13 +++++++++++++
 2 files changed, 25 insertions(+)
  

Patch

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);
+    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,
+                                         enum AVFrameSideDataType type,
+                                         size_t size);
+
 /**
  * @}
  */