[FFmpeg-devel] [PATCH v2 07/12] avutil/frame: add helper for extending a set of side data
Jan Ekström
jeebjp at gmail.com
Wed Apr 12 00:20:47 EEST 2023
---
libavutil/frame.c | 21 +++++++++++++++++++++
libavutil/frame.h | 11 +++++++++++
2 files changed, 32 insertions(+)
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 3386cda627..ec4e44a11f 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -720,6 +720,27 @@ AVFrameSideData *av_new_side_data_to_set(AVFrameSideDataSet *set,
return ret;
}
+int av_extend_side_data_set(AVFrameSideDataSet *dst,
+ const AVFrameSideDataSet src)
+{
+ for (int i = 0; i < src.nb_side_data; i++) {
+ const AVFrameSideData *sd_src = src.side_data[i];
+ AVFrameSideData *sd_dst =
+ av_new_side_data_to_set(dst, sd_src->type,
+ sd_src->size);
+ if (!sd_dst) {
+ av_side_data_set_wipe(dst);
+ return AVERROR(ENOMEM);
+ }
+
+ memcpy(sd_dst->data, sd_src->data, sd_src->size);
+
+ av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0);
+ }
+
+ return 0;
+}
+
AVFrameSideData *av_get_side_data_from_set(const AVFrameSideDataSet set,
enum AVFrameSideDataType type)
{
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 8aa50e3ad8..da8ac3237b 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -1011,6 +1011,17 @@ AVFrameSideData *av_new_side_data_to_set(AVFrameSideDataSet *set,
enum AVFrameSideDataType type,
size_t size);
+/**
+ * Add multiple side data entries to a set in one go.
+ *
+ * @param dst a set to which the side data should be added
+ * @param src a set from which the side data should be copied from
+ *
+ * @return negative error code on failure, >=0 on success.
+ */
+int av_extend_side_data_set(AVFrameSideDataSet *dst,
+ const AVFrameSideDataSet src);
+
/**
* @param set a set to which the side data should be added
* @param type type of the added side data
--
2.40.0
More information about the ffmpeg-devel
mailing list