History

buffersrc: handle non-refcounted frames in av_buffersrc_add_frame() correctly

Anton Khirnov committed 12 years ago

Commit 104a97b1 parent 5ef11b81 file · +15 −3Browse files

Unified · Split

libavfilter/buffersrc.c+15−3
@@ -94,7 +94,7 @@ int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, · 93 unmodified lines
94{94{
95 BufferSourceContext *s = ctx->priv;95 BufferSourceContext *s = ctx->priv;
96 AVFrame *copy;96 AVFrame *copy;
97 int ret;97 int refcounted, ret;
98 98
99 if (!frame) {99 if (!frame) {
100 s->eof = 1;100 s->eof = 1;
@@ -102,6 +102,8 @@ int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, · 1 unmodified line
102 } else if (s->eof)102 } else if (s->eof)
103 return AVERROR(EINVAL);103 return AVERROR(EINVAL);
104 104
105 refcounted = !!frame->buf[0];
106
105 switch (ctx->outputs[0]->type) {107 switch (ctx->outputs[0]->type) {
106 case AVMEDIA_TYPE_VIDEO:108 case AVMEDIA_TYPE_VIDEO:
107 CHECK_VIDEO_PARAM_CHANGE(ctx, s, frame->width, frame->height,109 CHECK_VIDEO_PARAM_CHANGE(ctx, s, frame->width, frame->height,
@@ -122,10 +124,20 @@ int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, · 14 unmodified lines
122 124
123 if (!(copy = av_frame_alloc()))125 if (!(copy = av_frame_alloc()))
124 return AVERROR(ENOMEM);126 return AVERROR(ENOMEM);
125 av_frame_move_ref(copy, frame);127
128 if (refcounted) {
129 av_frame_move_ref(copy, frame);
130 } else {
131 ret = av_frame_ref(copy, frame);
132 if (ret < 0) {
133 av_frame_free(&copy);
134 return ret;
135 }
136 }
126 137
127 if ((ret = av_fifo_generic_write(s->fifo, &copy, sizeof(copy), NULL)) < 0) {138 if ((ret = av_fifo_generic_write(s->fifo, &copy, sizeof(copy), NULL)) < 0) {
128 av_frame_move_ref(frame, copy);139 if (refcounted)
140 av_frame_move_ref(frame, copy);
129 av_frame_free(&copy);141 av_frame_free(&copy);
130 return ret;142 return ret;
131 }143 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t