diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-12-19 03:57:12 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-12-19 03:57:59 +0100 |
commit | bce06eb059a22fa1cd76a13112c36a4353894cca (patch) | |
tree | 0660196a55595b624ce0eae77c39df11b49371f5 /libavutil | |
parent | 1137ccef706650138e8f449deb5724e13da7236b (diff) | |
parent | 5d839778b9f3edb682b7f71dde4f80f07c75b098 (diff) | |
download | ffmpeg-bce06eb059a22fa1cd76a13112c36a4353894cca.tar.gz |
Merge commit '5d839778b9f3edb682b7f71dde4f80f07c75b098'
* commit '5d839778b9f3edb682b7f71dde4f80f07c75b098':
lavu: Refactor side data wiping
Conflicts:
libavutil/frame.c
See: a400edbb6d00c0211de38e4f1b4f593681db91d8
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/frame.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/libavutil/frame.c b/libavutil/frame.c index 5c9aa2914c..12fe0a6273 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -120,6 +120,18 @@ static void free_side_data(AVFrameSideData **ptr_sd) av_freep(ptr_sd); } +static void wipe_side_data(AVFrame *frame) +{ + int i; + + for (i = 0; i < frame->nb_side_data; i++) { + free_side_data(&frame->side_data[i]); + } + frame->nb_side_data = 0; + + av_freep(&frame->side_data); +} + AVFrame *av_frame_alloc(void) { AVFrame *frame = av_mallocz(sizeof(*frame)); @@ -366,10 +378,7 @@ void av_frame_unref(AVFrame *frame) { int i; - for (i = 0; i < frame->nb_side_data; i++) { - free_side_data(&frame->side_data[i]); - } - av_freep(&frame->side_data); + wipe_side_data(frame); for (i = 0; i < FF_ARRAY_ELEMS(frame->buf); i++) av_buffer_unref(&frame->buf[i]); @@ -499,11 +508,7 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src) sd_dst = av_frame_new_side_data(dst, sd_src->type, sd_src->size); if (!sd_dst) { - for (i = 0; i < dst->nb_side_data; i++) { - free_side_data(&dst->side_data[i]); - } - av_freep(&dst->side_data); - dst->nb_side_data = 0; + wipe_side_data(dst); return AVERROR(ENOMEM); } memcpy(sd_dst->data, sd_src->data, sd_src->size); |