History

src_buffer: move buffer copy in a separate function.

This will make merging with the audio part easier.

Nicolas George committed 14 years ago

Commit cc14cde1 parent f94b1501 file · +26 −11Browse files

Unified · Split

libavfilter/src_buffer.c+26−11
@@ -133,11 +133,33 @@ static int check_format_change(AVFilterContext *buffer_filter, · 132 unmodified lines
133 }133 }
134}134}
135 135
136static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx,
137 AVFilterBufferRef *ref)
138{
139 AVFilterLink *outlink = ctx->outputs[0];
140 AVFilterBufferRef *buf;
141
142 switch (outlink->type) {
143
144 case AVMEDIA_TYPE_VIDEO:
145 buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
146 ref->video->w, ref->video->h);
147 av_image_copy(buf->data, buf->linesize,
148 (void*)ref->data, ref->linesize,
149 ref->format, ref->video->w, ref->video->h);
150 break;
151
152 default:
153 return NULL;
154 }
155 avfilter_copy_buffer_ref_props(buf, ref);
156 return buf;
157}
158
136int av_buffersrc_add_ref(AVFilterContext *buffer_filter,159int av_buffersrc_add_ref(AVFilterContext *buffer_filter,
137 AVFilterBufferRef *picref, int flags)160 AVFilterBufferRef *picref, int flags)
138{161{
139 BufferSourceContext *c = buffer_filter->priv;162 BufferSourceContext *c = buffer_filter->priv;
140 AVFilterLink *outlink = buffer_filter->outputs[0];
141 AVFilterBufferRef *buf;163 AVFilterBufferRef *buf;
142 int ret;164 int ret;
143 165
@@ -157,17 +179,10 @@ int av_buffersrc_add_ref(AVFilterContext *buffer_filter, · 13 unmodified lines
157 if (ret < 0)179 if (ret < 0)
158 return ret;180 return ret;
159 }181 }
160 if (flags & AV_BUFFERSRC_FLAG_NO_COPY) {182 if (flags & AV_BUFFERSRC_FLAG_NO_COPY)
161 buf = picref;183 buf = picref;
162 } else {184 else
163 buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,185 buf = copy_buffer_ref(buffer_filter, picref);
164 picref->video->w, picref->video->h);
165 av_image_copy(buf->data, buf->linesize,
166 (void*)picref->data, picref->linesize,
167 picref->format, picref->video->w, picref->video->h);
168 avfilter_copy_buffer_ref_props(buf, picref);
169
170 }
171 186
172 if ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {187 if ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {
173 if (buf != picref)188 if (buf != picref)

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