diff options
author | Anton Khirnov <anton@khirnov.net> | 2014-01-16 11:06:02 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-01-17 10:30:45 +0100 |
commit | 104a97beaffa6348e6fd2c2d07d67c1402322bb3 (patch) | |
tree | 1f6e06e9998d57f8c6ab893d1f5966370a68bc25 /libavfilter | |
parent | 5ef11b8dcc054b230deb9b20493255c14a80597d (diff) | |
download | ffmpeg-104a97beaffa6348e6fd2c2d07d67c1402322bb3.tar.gz |
buffersrc: handle non-refcounted frames in av_buffersrc_add_frame() correctly
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/buffersrc.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index 1a7599078e..fd058d6c19 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -94,7 +94,7 @@ int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, { BufferSourceContext *s = ctx->priv; AVFrame *copy; - int ret; + int refcounted, ret; if (!frame) { s->eof = 1; @@ -102,6 +102,8 @@ int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, } else if (s->eof) return AVERROR(EINVAL); + refcounted = !!frame->buf[0]; + switch (ctx->outputs[0]->type) { case AVMEDIA_TYPE_VIDEO: CHECK_VIDEO_PARAM_CHANGE(ctx, s, frame->width, frame->height, @@ -122,10 +124,20 @@ int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, if (!(copy = av_frame_alloc())) return AVERROR(ENOMEM); - av_frame_move_ref(copy, frame); + + if (refcounted) { + av_frame_move_ref(copy, frame); + } else { + ret = av_frame_ref(copy, frame); + if (ret < 0) { + av_frame_free(©); + return ret; + } + } if ((ret = av_fifo_generic_write(s->fifo, ©, sizeof(copy), NULL)) < 0) { - av_frame_move_ref(frame, copy); + if (refcounted) + av_frame_move_ref(frame, copy); av_frame_free(©); return ret; } |