aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2023-03-19 14:38:43 +0200
committerJan Ekström <jeebjp@gmail.com>2024-03-20 19:14:02 +0200
commit28783896dca9e3393654d678e51031783f8dd3bc (patch)
tree2fe93cb6a13397e5a0be051f479a0dfb501fafd1 /libavutil
parent919c9cdbe6d2d69beb6c675d879dd77588f4f001 (diff)
downloadffmpeg-28783896dca9e3393654d678e51031783f8dd3bc.tar.gz
avutil/frame: split side_data_from_buf to base and AVFrame func
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/frame.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/libavutil/frame.c b/libavutil/frame.c
index baac0706db..382e1f6d58 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -679,23 +679,23 @@ AVBufferRef *av_frame_get_plane_buffer(const AVFrame *frame, int plane)
return NULL;
}
-AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame,
- enum AVFrameSideDataType type,
- AVBufferRef *buf)
+static AVFrameSideData *add_side_data_from_buf(AVFrameSideData ***sd,
+ int *nb_sd,
+ enum AVFrameSideDataType type,
+ AVBufferRef *buf)
{
AVFrameSideData *ret, **tmp;
if (!buf)
return NULL;
- if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1)
+ if (*nb_sd > INT_MAX / sizeof(*sd) - 1)
return NULL;
- tmp = av_realloc(frame->side_data,
- (frame->nb_side_data + 1) * sizeof(*frame->side_data));
+ tmp = av_realloc(*sd, (*nb_sd + 1) * sizeof(*sd));
if (!tmp)
return NULL;
- frame->side_data = tmp;
+ *sd = tmp;
ret = av_mallocz(sizeof(*ret));
if (!ret)
@@ -706,11 +706,20 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame,
ret->size = buf->size;
ret->type = type;
- frame->side_data[frame->nb_side_data++] = ret;
+ (*sd)[(*nb_sd)++] = ret;
return ret;
}
+AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame,
+ enum AVFrameSideDataType type,
+ AVBufferRef *buf)
+{
+ return
+ add_side_data_from_buf(
+ &frame->side_data, &frame->nb_side_data, type, buf);
+}
+
AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
enum AVFrameSideDataType type,
size_t size)