1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

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.
This commit is contained in:
Niklas Haas
2024-12-04 12:37:15 +01:00
parent 3428a8d830
commit b88944a8aa
4 changed files with 28 additions and 1 deletions

View File

@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
API changes, most recent first: 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 2024-12-xx - xxxxxxxxxx - lavu 59.52.100 - frame.h
Add AV_SIDE_DATA_PROP_SIZE_DEPENDENT and AV_FRAME_DATA_PROP_COLOR_DEPENDENT. Add AV_SIDE_DATA_PROP_SIZE_DEPENDENT and AV_FRAME_DATA_PROP_COLOR_DEPENDENT.

View File

@@ -961,6 +961,22 @@ void av_frame_side_data_remove(AVFrameSideData ***sd, int *nb_sd,
remove_side_data(sd, nb_sd, type); 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, AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
enum AVFrameSideDataType type) enum AVFrameSideDataType type)
{ {

View File

@@ -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, void av_frame_side_data_remove(AVFrameSideData ***sd, int *nb_sd,
enum AVFrameSideDataType type); 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);
/** /**
* @} * @}
*/ */

View File

@@ -79,7 +79,7 @@
*/ */
#define LIBAVUTIL_VERSION_MAJOR 59 #define LIBAVUTIL_VERSION_MAJOR 59
#define LIBAVUTIL_VERSION_MINOR 52 #define LIBAVUTIL_VERSION_MINOR 53
#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \