aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/frame.c
diff options
context:
space:
mode:
authorRoman Savchenko <gmstima@gmail.com>2014-06-18 08:11:05 +0200
committerAnton Khirnov <anton@khirnov.net>2014-06-18 08:11:05 +0200
commit44671b57866aab8dd36715ff010e985e25baaf19 (patch)
tree2fa194313f4641dac9e6e0a666a726910eae298f /libavutil/frame.c
parent9affa784a0743b95bde135b5acfce2183afc35d8 (diff)
downloadffmpeg-44671b57866aab8dd36715ff010e985e25baaf19.tar.gz
AVFrame: factor out freeing the side data
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavutil/frame.c')
-rw-r--r--libavutil/frame.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 9539d90c5a..4b44075f44 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -47,6 +47,15 @@ static void get_frame_defaults(AVFrame *frame)
#endif
}
+static void free_side_data(AVFrameSideData **ptr_sd)
+{
+ AVFrameSideData *sd = *ptr_sd;
+
+ av_freep(&sd->data);
+ av_dict_free(&sd->metadata);
+ av_freep(ptr_sd);
+}
+
AVFrame *av_frame_alloc(void)
{
AVFrame *frame = av_mallocz(sizeof(*frame));
@@ -278,9 +287,7 @@ void av_frame_unref(AVFrame *frame)
int i;
for (i = 0; i < frame->nb_side_data; i++) {
- av_freep(&frame->side_data[i]->data);
- av_dict_free(&frame->side_data[i]->metadata);
- av_freep(&frame->side_data[i]);
+ free_side_data(&frame->side_data[i]);
}
av_freep(&frame->side_data);
@@ -396,9 +403,7 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
sd_src->size);
if (!sd_dst) {
for (i = 0; i < dst->nb_side_data; i++) {
- av_freep(&dst->side_data[i]->data);
- av_dict_free(&dst->side_data[i]->metadata);
- av_freep(&dst->side_data[i]);
+ free_side_data(&dst->side_data[i]);
}
av_freep(&dst->side_data);
return AVERROR(ENOMEM);
@@ -548,9 +553,7 @@ void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
for (i = 0; i < frame->nb_side_data; i++) {
AVFrameSideData *sd = frame->side_data[i];
if (sd->type == type) {
- av_freep(&sd->data);
- av_dict_free(&sd->metadata);
- av_freep(&frame->side_data[i]);
+ free_side_data(&frame->side_data[i]);
frame->side_data[i] = frame->side_data[frame->nb_side_data - 1];
frame->nb_side_data--;
}