diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-06-18 12:53:35 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-06-18 12:53:42 +0200 |
commit | 40c9d43086890df11389ceefd88f517471e41202 (patch) | |
tree | 5c2b7d011601788d6a5dfcdf6f09897e18c7c1ed | |
parent | 7f5296005c392d72f574b66324c1db8d1a7a6484 (diff) | |
parent | 44671b57866aab8dd36715ff010e985e25baaf19 (diff) | |
download | ffmpeg-40c9d43086890df11389ceefd88f517471e41202.tar.gz |
Merge commit '44671b57866aab8dd36715ff010e985e25baaf19'
* commit '44671b57866aab8dd36715ff010e985e25baaf19':
AVFrame: factor out freeing the side data
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavutil/frame.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/libavutil/frame.c b/libavutil/frame.c index b6b755f5dd..fdfbc46753 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -113,6 +113,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)); @@ -360,9 +369,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); @@ -493,9 +500,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); @@ -661,9 +666,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--; } |