summaryrefslogtreecommitdiff
path: root/libavfilter/src_buffer.c
diff options
context:
space:
mode:
authorNicolas George <nicolas.george@normalesup.org>2012-04-28 15:01:41 +0200
committerNicolas George <nicolas.george@normalesup.org>2012-05-04 23:26:40 +0200
commit7bac2a78c2241df4bcc1665703bb71afd9a3e692 (patch)
treef025d8ab1792cac598cefd504910c4c2a4d108e1 /libavfilter/src_buffer.c
parenta96cd73ff25795ab4162252d2df87a8b46c782da (diff)
src_buffer: implement av_buffersrc_add_frame.
It supersedes av_vsrc_buffer_add_frame and handles both audio and video.
Diffstat (limited to 'libavfilter/src_buffer.c')
-rw-r--r--libavfilter/src_buffer.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/libavfilter/src_buffer.c b/libavfilter/src_buffer.c
index 9a4d249507..15c30d6505 100644
--- a/libavfilter/src_buffer.c
+++ b/libavfilter/src_buffer.c
@@ -303,28 +303,38 @@ int av_buffersrc_buffer(AVFilterContext *s, AVFilterBufferRef *buf)
#if CONFIG_AVCODEC
#include "avcodec.h"
-int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src,
- const AVFrame *frame, int flags)
+int av_buffersrc_add_frame(AVFilterContext *buffer_src,
+ const AVFrame *frame, int flags)
{
- BufferSourceContext *c = buffer_src->priv;
AVFilterBufferRef *picref;
int ret;
- if (!frame) {
- c->eof = 1;
- return 0;
- } else if (c->eof)
- return AVERROR(EINVAL);
+ if (!frame) /* NULL for EOF */
+ return av_buffersrc_add_ref(buffer_src, NULL, flags);
- picref = avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE);
+ switch (buffer_src->outputs[0]->type) {
+ case AVMEDIA_TYPE_VIDEO:
+ picref = avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE);
+ break;
+ case AVMEDIA_TYPE_AUDIO:
+ picref = avfilter_get_audio_buffer_ref_from_frame(frame, AV_PERM_WRITE);
+ break;
+ default:
+ return AVERROR(ENOSYS);
+ }
if (!picref)
return AVERROR(ENOMEM);
- ret = av_vsrc_buffer_add_video_buffer_ref(buffer_src, picref, flags);
+ ret = av_buffersrc_add_ref(buffer_src, picref, flags);
picref->buf->data[0] = NULL;
avfilter_unref_buffer(picref);
-
return ret;
}
+
+int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src,
+ const AVFrame *frame, int flags)
+{
+ return av_buffersrc_add_frame(buffer_src, frame, 0);
+}
#endif
unsigned av_vsrc_buffer_get_nb_failed_requests(AVFilterContext *buffer_src)