diff options
author | Jan Ekström <jeebjp@gmail.com> | 2023-08-27 23:40:37 +0300 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2024-03-20 19:14:02 +0200 |
commit | d2bb22f6d5c1f44951e074f84233e1c8249dbad3 (patch) | |
tree | 56824ea693b9b4ade863a09bbc129a1abf70a662 /libavutil | |
parent | 28783896dca9e3393654d678e51031783f8dd3bc (diff) | |
download | ffmpeg-d2bb22f6d5c1f44951e074f84233e1c8249dbad3.tar.gz |
avutil/frame: split side data removal out to non-AVFrame function
This will make it possible to reuse logic in further commits.
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/frame.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/libavutil/frame.c b/libavutil/frame.c index 382e1f6d58..2a319adb86 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -83,6 +83,21 @@ void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd) wipe_side_data(sd, nb_sd); } +static void remove_side_data(AVFrameSideData ***sd, int *nb_side_data, + const enum AVFrameSideDataType type) +{ + for (int i = *nb_side_data - 1; i >= 0; i--) { + AVFrameSideData *entry = ((*sd)[i]); + if (entry->type != type) + continue; + + free_side_data(&entry); + + ((*sd)[i]) = ((*sd)[*nb_side_data - 1]); + (*nb_side_data)--; + } +} + AVFrame *av_frame_alloc(void) { AVFrame *frame = av_malloc(sizeof(*frame)); @@ -801,14 +816,7 @@ int av_frame_copy(AVFrame *dst, const AVFrame *src) void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type) { - for (int i = frame->nb_side_data - 1; i >= 0; i--) { - AVFrameSideData *sd = frame->side_data[i]; - if (sd->type == type) { - free_side_data(&frame->side_data[i]); - frame->side_data[i] = frame->side_data[frame->nb_side_data - 1]; - frame->nb_side_data--; - } - } + remove_side_data(&frame->side_data, &frame->nb_side_data, type); } const char *av_frame_side_data_name(enum AVFrameSideDataType type) |