History

src_buffer: implement av_buffersrc_add_frame.

It supersedes av_vsrc_buffer_add_frame and handles both audio and video.

Nicolas George committed 14 years ago

Commit 7bac2a71 parent a96cd732 files · +33 −11Browse files

Showing the changes to libavfilter/src_buffer.c (1 of 2 files). Show all

Unified · Split

libavfilter/src_buffer.c+21−11
@@ -303,28 +303,38 @@ int av_buffersrc_buffer(AVFilterContext *s, AVFilterBufferRef *buf) · 302 unmodified lines
303303 #if CONFIG_AVCODEC
304304 #include "avcodec.h"
305305
306−int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src,
307− const AVFrame *frame, int flags)
306+int av_buffersrc_add_frame(AVFilterContext *buffer_src,
307+ const AVFrame *frame, int flags)
308308 {
309− BufferSourceContext *c = buffer_src->priv;
310309 AVFilterBufferRef *picref;
311310 int ret;
312311
313− if (!frame) {
314− c->eof = 1;
315− return 0;
316− } else if (c->eof)
317− return AVERROR(EINVAL);
312+ if (!frame) /* NULL for EOF */
313+ return av_buffersrc_add_ref(buffer_src, NULL, flags);
318314
319− picref = avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE);
315+ switch (buffer_src->outputs[0]->type) {
316+ case AVMEDIA_TYPE_VIDEO:
317+ picref = avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE);
318+ break;
319+ case AVMEDIA_TYPE_AUDIO:
320+ picref = avfilter_get_audio_buffer_ref_from_frame(frame, AV_PERM_WRITE);
321+ break;
322+ default:
323+ return AVERROR(ENOSYS);
324+ }
320325 if (!picref)
321326 return AVERROR(ENOMEM);
322− ret = av_vsrc_buffer_add_video_buffer_ref(buffer_src, picref, flags);
327+ ret = av_buffersrc_add_ref(buffer_src, picref, flags);
323328 picref->buf->data[0] = NULL;
324329 avfilter_unref_buffer(picref);
325−
326330 return ret;
327331 }
332+
333+int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src,
334+ const AVFrame *frame, int flags)
335+{
336+ return av_buffersrc_add_frame(buffer_src, frame, 0);
337+}
328338 #endif
329339
330340 unsigned av_vsrc_buffer_get_nb_failed_requests(AVFilterContext *buffer_src)

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