diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-01-17 16:38:10 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-01-17 16:38:10 +0100 |
commit | cd259cdaa94717f7c6d2a0c87a7ba0171d1f0978 (patch) | |
tree | 198c75632969b62dc23856823599c705848a8dda | |
parent | 6e2d3ba0eea1592e182d87a3067ff5d485f2f383 (diff) | |
parent | 104a97beaffa6348e6fd2c2d07d67c1402322bb3 (diff) | |
download | ffmpeg-cd259cdaa94717f7c6d2a0c87a7ba0171d1f0978.tar.gz |
Merge commit '104a97beaffa6348e6fd2c2d07d67c1402322bb3'
* commit '104a97beaffa6348e6fd2c2d07d67c1402322bb3':
buffersrc: handle non-refcounted frames in av_buffersrc_add_frame() correctly
Conflicts:
libavfilter/buffersrc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-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 fb42c8e9dd..ae7cea2c6b 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -120,7 +120,7 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx, { BufferSourceContext *s = ctx->priv; AVFrame *copy; - int ret; + int refcounted, ret; s->nb_failed_requests = 0; @@ -130,6 +130,8 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx, } else if (s->eof) return AVERROR(EINVAL); + refcounted = !!frame->buf[0]; + if (!(flags & AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT)) { switch (ctx->outputs[0]->type) { @@ -157,10 +159,20 @@ static int av_buffersrc_add_frame_internal(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; } |