avutil/frame: Treat frame as uninitialized in get_frame_defaults()

Currently, it also tests whether extended_data points to something
different than the AVFrame's data array and frees extended_data
if it is different. Yet this is only necessary for one of its three
callers, namely av_frame_unref(); meanwhile the other two callers
took measures to avoid this (or rather, to make it to an av_free(NULL)).

This commit moves this chunk to av_frame_unref() (so that
get_frame_defaults() now treats its input as uninitialized)
and removes the now superfluous code in the other two callers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
pull/375/head
Andreas Rheinhardt 3 years ago
parent fc01a703de
commit 6c57e0b4a8
  1. 10
      libavutil/frame.c

@ -52,9 +52,6 @@ const char *av_get_colorspace_name(enum AVColorSpace val)
#endif
static void get_frame_defaults(AVFrame *frame)
{
if (frame->extended_data != frame->data)
av_freep(&frame->extended_data);
memset(frame, 0, sizeof(*frame));
frame->pts =
@ -99,12 +96,11 @@ static void wipe_side_data(AVFrame *frame)
AVFrame *av_frame_alloc(void)
{
AVFrame *frame = av_mallocz(sizeof(*frame));
AVFrame *frame = av_malloc(sizeof(*frame));
if (!frame)
return NULL;
frame->extended_data = NULL;
get_frame_defaults(frame);
return frame;
@ -457,6 +453,9 @@ void av_frame_unref(AVFrame *frame)
av_buffer_unref(&frame->opaque_ref);
av_buffer_unref(&frame->private_ref);
if (frame->extended_data != frame->data)
av_freep(&frame->extended_data);
get_frame_defaults(frame);
}
@ -468,7 +467,6 @@ void av_frame_move_ref(AVFrame *dst, AVFrame *src)
*dst = *src;
if (src->extended_data == src->data)
dst->extended_data = dst->data;
memset(src, 0, sizeof(*src));
get_frame_defaults(src);
}

Loading…
Cancel
Save