mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-28 12:32:17 +02:00
buffersrc: handle non-refcounted frames in av_buffersrc_add_frame() correctly
This commit is contained in:
parent
5ef11b8dcc
commit
104a97beaf
@ -94,7 +94,7 @@ int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx,
|
|||||||
{
|
{
|
||||||
BufferSourceContext *s = ctx->priv;
|
BufferSourceContext *s = ctx->priv;
|
||||||
AVFrame *copy;
|
AVFrame *copy;
|
||||||
int ret;
|
int refcounted, ret;
|
||||||
|
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
s->eof = 1;
|
s->eof = 1;
|
||||||
@ -102,6 +102,8 @@ int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx,
|
|||||||
} else if (s->eof)
|
} else if (s->eof)
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
|
|
||||||
|
refcounted = !!frame->buf[0];
|
||||||
|
|
||||||
switch (ctx->outputs[0]->type) {
|
switch (ctx->outputs[0]->type) {
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
CHECK_VIDEO_PARAM_CHANGE(ctx, s, frame->width, frame->height,
|
CHECK_VIDEO_PARAM_CHANGE(ctx, s, frame->width, frame->height,
|
||||||
@ -122,9 +124,19 @@ int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx,
|
|||||||
|
|
||||||
if (!(copy = av_frame_alloc()))
|
if (!(copy = av_frame_alloc()))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
|
if (refcounted) {
|
||||||
av_frame_move_ref(copy, frame);
|
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) {
|
if ((ret = av_fifo_generic_write(s->fifo, ©, sizeof(copy), NULL)) < 0) {
|
||||||
|
if (refcounted)
|
||||||
av_frame_move_ref(frame, copy);
|
av_frame_move_ref(frame, copy);
|
||||||
av_frame_free(©);
|
av_frame_free(©);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user