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

Unified · Split

2 files
  1. libavfilter/avcodec.h +12 −0
  2. libavfilter/src_buffer.c +21 −11
libavfilter/avcodec.h+12−0
@@ -89,6 +89,18 @@ int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame, · 88 unmodified lines
8989 int avfilter_fill_frame_from_buffer_ref(AVFrame *frame,
9090 const AVFilterBufferRef *ref);
9191
92+/**
93+ * Add frame data to buffer_src.
94+ *
95+ * @param buffer_src pointer to a buffer source context
96+ * @param frame a frame, or NULL to mark EOF
97+ * @param flags a combination of AV_BUFFERSRC_FLAG_*
98+ * @return >= 0 in case of success, a negative AVERROR code
99+ * in case of failure
100+ */
101+int av_buffersrc_add_frame(AVFilterContext *buffer_src,
102+ const AVFrame *frame, int flags);
103+
92104 /**
93105 * Add frame data to buffer_src.
94106 *
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