[FFmpeg-cvslog] avutil/frame: add av_frame_side_data_remove_by_props()
Niklas Haas
git at videolan.org
Mon Dec 23 15:23:26 EET 2024
ffmpeg | branch: master | Niklas Haas <git at haasn.dev> | Wed Dec 4 12:37:15 2024 +0100| [b88944a8aa599be0f16603380e7bc51402d3caf8] | committer: Niklas Haas
avutil/frame: add av_frame_side_data_remove_by_props()
As discussed in the previous commit, we often need a convenient way of
stripping all side data related to a certain aspect of the frame. This helper
accomplishes just that.
I considered also adding a way to match only side data matching *all*
properties, but I think this is sufficiently useless in practise to not warrant
inclusion in the API.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b88944a8aa599be0f16603380e7bc51402d3caf8
---
doc/APIchanges | 3 +++
libavutil/frame.c | 16 ++++++++++++++++
libavutil/frame.h | 8 ++++++++
libavutil/version.h | 2 +-
4 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index f6c4b6797e..4fa4db142f 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
API changes, most recent first:
+2024-12-xx - xxxxxxxxxx - lavu 59.53.100 - frame.h
+ Add av_frame_side_data_remove_by_props().
+
2024-12-xx - xxxxxxxxxx - lavu 59.52.100 - frame.h
Add AV_SIDE_DATA_PROP_SIZE_DEPENDENT and AV_FRAME_DATA_PROP_COLOR_DEPENDENT.
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 1dced3b52b..342079b5a1 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -961,6 +961,22 @@ void av_frame_side_data_remove(AVFrameSideData ***sd, int *nb_sd,
remove_side_data(sd, nb_sd, type);
}
+void av_frame_side_data_remove_by_props(AVFrameSideData ***sd, int *nb_sd,
+ int props)
+{
+ for (int i = *nb_sd - 1; i >= 0; i--) {
+ AVFrameSideData *entry = ((*sd)[i]);
+ const AVSideDataDescriptor *desc = av_frame_side_data_desc(entry->type);
+ if (!desc || !(desc->props & props))
+ continue;
+
+ free_side_data(&entry);
+
+ ((*sd)[i]) = ((*sd)[*nb_sd - 1]);
+ (*nb_sd)--;
+ }
+}
+
AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
enum AVFrameSideDataType type)
{
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 8345010e22..929dbb885e 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -1183,6 +1183,14 @@ const AVFrameSideData *av_frame_side_data_get(AVFrameSideData * const *sd,
*/
void av_frame_side_data_remove(AVFrameSideData ***sd, int *nb_sd,
enum AVFrameSideDataType type);
+
+/**
+ * Remove and free all side data instances that match any of the given
+ * side data properties. (See enum AVSideDataProps)
+ */
+void av_frame_side_data_remove_by_props(AVFrameSideData ***sd, int *nb_sd,
+ int props);
+
/**
* @}
*/
diff --git a/libavutil/version.h b/libavutil/version.h
index 0eb07e5e3d..b430555c88 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 59
-#define LIBAVUTIL_VERSION_MINOR 52
+#define LIBAVUTIL_VERSION_MINOR 53
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
More information about the ffmpeg-cvslog
mailing list