On 12/23/2024 10:13 AM, Niklas Haas wrote:
On Mon, 23 Dec 2024 10:02:48 -0300 James Almer <jamr...@gmail.com> wrote:On 12/23/2024 9:48 AM, Niklas Haas wrote:From: Niklas Haas <g...@haasn.dev>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. --- doc/APIchanges | 3 +++ libavutil/frame.c | 16 ++++++++++++++++ libavutil/frame.h | 13 +++++++++++++ libavutil/version.h | 2 +- 4 files changed, 33 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)Maybe enum AVSideDataProps instead of int?Technically C does not guarantee that A|B fits into a value of type enum { A, B }; I can change it if you'd prefer, though it is relying on non-standard behaviour, however ubiquitous in practice.
Ok, leave it as is then.
+{ + 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..5dfcd85c47 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1013,6 +1013,11 @@ AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, */ void av_frame_remove_side_data(AVFrame *frame, 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_remove_side_data_by_props(AVFrame *frame, int props);You forgot to remove this prototype.Thanks, fixed.LGTM aside from that. _______________________________________________ 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 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".
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ 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".