Re: [FFmpeg-devel] [PATCH 1/7 v5] avutil/frame: add helper for adding side data w/ AVBufferRef to array

2024-04-10 Thread James Almer

On 3/30/2024 2:39 PM, James Almer wrote:

On 3/28/2024 1:52 PM, James Almer wrote:

Signed-off-by: James Almer 
---
  libavutil/frame.c | 19 +++
  libavutil/frame.h | 24 
  2 files changed, 43 insertions(+)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index ef1613c344..87cc8450c8 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -812,6 +812,25 @@ AVFrameSideData 
*av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd,

  return ret;
  }
+AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int 
*nb_sd,

+    enum AVFrameSideDataType type,
+    AVBufferRef **pbuf, unsigned 
int flags)

+{
+    const AVSideDataDescriptor *desc = av_frame_side_data_desc(type);
+    AVFrameSideData *sd_dst  = NULL;
+    AVBufferRef *buf = *pbuf;
+
+    if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE)
+    remove_side_data(sd, nb_sd, type);
+
+    sd_dst = add_side_data_from_buf(sd, nb_sd, type, buf);
+    if (!sd_dst)
+    return NULL;
+
+    *pbuf = NULL;
+    return sd_dst;
+}
+
  int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd,
   const AVFrameSideData *src, unsigned 
int flags)

  {
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 3b6d746a16..8d16924432 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -1062,6 +1062,30 @@ AVFrameSideData 
*av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd,

  enum AVFrameSideDataType type,
  size_t size, unsigned int 
flags);

+/**
+ * Add a new side data entry to an array from an existing AVBufferRef.
+ *
+ * @param sd    pointer to array of side data to which to add another 
entry,

+ *  or to NULL in order to start a new array.
+ * @param nb_sd pointer to an integer containing the number of 
entries in

+ *  the array.
+ * @param type  type of the added side data
+ * @param buf   Pointer to AVBufferRef to add to the array. On success,
+ *  the function takes ownership of the AVBufferRef and 
*buf is
+ *  set to NULL, unless AV_FRAME_SIDE_DATA_FLAG_NEW_REF 
is set

+ *  in which case the ownership will remain with the caller.
+ * @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, 
or 0.

+ *
+ * @return newly added side data on success, NULL on error.
+ * @note In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of
+ *   matching AVFrameSideDataType will be removed before the 
addition

+ *   is attempted.
+ *
+ */
+AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int 
*nb_sd,

+    enum AVFrameSideDataType type,
+    AVBufferRef **buf, unsigned 
int flags);

+
  /**
   * Add a new side data entry to an array based on existing side 
data, taking

   * a reference towards the contained AVBufferRef.


Ping for the set.


Will apply the set soon.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/7 v5] avutil/frame: add helper for adding side data w/ AVBufferRef to array

2024-03-30 Thread James Almer

On 3/28/2024 1:52 PM, James Almer wrote:

Signed-off-by: James Almer 
---
  libavutil/frame.c | 19 +++
  libavutil/frame.h | 24 
  2 files changed, 43 insertions(+)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index ef1613c344..87cc8450c8 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -812,6 +812,25 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData 
***sd, int *nb_sd,
  return ret;
  }
  
+AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd,

+enum AVFrameSideDataType type,
+AVBufferRef **pbuf, unsigned int flags)
+{
+const AVSideDataDescriptor *desc = av_frame_side_data_desc(type);
+AVFrameSideData *sd_dst  = NULL;
+AVBufferRef *buf = *pbuf;
+
+if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE)
+remove_side_data(sd, nb_sd, type);
+
+sd_dst = add_side_data_from_buf(sd, nb_sd, type, buf);
+if (!sd_dst)
+return NULL;
+
+*pbuf = NULL;
+return sd_dst;
+}
+
  int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd,
   const AVFrameSideData *src, unsigned int flags)
  {
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 3b6d746a16..8d16924432 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -1062,6 +1062,30 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData 
***sd, int *nb_sd,
  enum AVFrameSideDataType type,
  size_t size, unsigned int flags);
  
+/**

+ * Add a new side data entry to an array from an existing AVBufferRef.
+ *
+ * @param sdpointer to array of side data to which to add another entry,
+ *  or to NULL in order to start a new array.
+ * @param nb_sd pointer to an integer containing the number of entries in
+ *  the array.
+ * @param type  type of the added side data
+ * @param buf   Pointer to AVBufferRef to add to the array. On success,
+ *  the function takes ownership of the AVBufferRef and *buf is
+ *  set to NULL, unless AV_FRAME_SIDE_DATA_FLAG_NEW_REF is set
+ *  in which case the ownership will remain with the caller.
+ * @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0.
+ *
+ * @return newly added side data on success, NULL on error.
+ * @note In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of
+ *   matching AVFrameSideDataType will be removed before the addition
+ *   is attempted.
+ *
+ */
+AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd,
+enum AVFrameSideDataType type,
+AVBufferRef **buf, unsigned int flags);
+
  /**
   * Add a new side data entry to an array based on existing side data, taking
   * a reference towards the contained AVBufferRef.


Ping for the set.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 1/7 v5] avutil/frame: add helper for adding side data w/ AVBufferRef to array

2024-03-28 Thread James Almer
Signed-off-by: James Almer 
---
 libavutil/frame.c | 19 +++
 libavutil/frame.h | 24 
 2 files changed, 43 insertions(+)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index ef1613c344..87cc8450c8 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -812,6 +812,25 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData 
***sd, int *nb_sd,
 return ret;
 }
 
+AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd,
+enum AVFrameSideDataType type,
+AVBufferRef **pbuf, unsigned int flags)
+{
+const AVSideDataDescriptor *desc = av_frame_side_data_desc(type);
+AVFrameSideData *sd_dst  = NULL;
+AVBufferRef *buf = *pbuf;
+
+if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE)
+remove_side_data(sd, nb_sd, type);
+
+sd_dst = add_side_data_from_buf(sd, nb_sd, type, buf);
+if (!sd_dst)
+return NULL;
+
+*pbuf = NULL;
+return sd_dst;
+}
+
 int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd,
  const AVFrameSideData *src, unsigned int flags)
 {
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 3b6d746a16..8d16924432 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -1062,6 +1062,30 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData 
***sd, int *nb_sd,
 enum AVFrameSideDataType type,
 size_t size, unsigned int flags);
 
+/**
+ * Add a new side data entry to an array from an existing AVBufferRef.
+ *
+ * @param sdpointer to array of side data to which to add another entry,
+ *  or to NULL in order to start a new array.
+ * @param nb_sd pointer to an integer containing the number of entries in
+ *  the array.
+ * @param type  type of the added side data
+ * @param buf   Pointer to AVBufferRef to add to the array. On success,
+ *  the function takes ownership of the AVBufferRef and *buf is
+ *  set to NULL, unless AV_FRAME_SIDE_DATA_FLAG_NEW_REF is set
+ *  in which case the ownership will remain with the caller.
+ * @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0.
+ *
+ * @return newly added side data on success, NULL on error.
+ * @note In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of
+ *   matching AVFrameSideDataType will be removed before the addition
+ *   is attempted.
+ *
+ */
+AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd,
+enum AVFrameSideDataType type,
+AVBufferRef **buf, unsigned int flags);
+
 /**
  * Add a new side data entry to an array based on existing side data, taking
  * a reference towards the contained AVBufferRef.
-- 
2.44.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".