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
89int avfilter_fill_frame_from_buffer_ref(AVFrame *frame,89int avfilter_fill_frame_from_buffer_ref(AVFrame *frame,
90 const AVFilterBufferRef *ref);90 const AVFilterBufferRef *ref);
91 91
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 */
101int av_buffersrc_add_frame(AVFilterContext *buffer_src,
102 const AVFrame *frame, int flags);
103
92/**104/**
93 * Add frame data to buffer_src.105 * Add frame data to buffer_src.
94 *106 *
libavfilter/src_buffer.c+21−11
@@ -303,28 +303,38 @@ int av_buffersrc_buffer(AVFilterContext *s, AVFilterBufferRef *buf) · 302 unmodified lines
303#if CONFIG_AVCODEC303#if CONFIG_AVCODEC
304#include "avcodec.h"304#include "avcodec.h"
305 305
306int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src,306int av_buffersrc_add_frame(AVFilterContext *buffer_src,
307 const AVFrame *frame, int flags)307 const AVFrame *frame, int flags)
308{308{
309 BufferSourceContext *c = buffer_src->priv;
310 AVFilterBufferRef *picref;309 AVFilterBufferRef *picref;
311 int ret;310 int ret;
312 311
313 if (!frame) {312 if (!frame) /* NULL for EOF */
314 c->eof = 1;313 return av_buffersrc_add_ref(buffer_src, NULL, flags);
315 return 0;
316 } else if (c->eof)
317 return AVERROR(EINVAL);
318 314
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 }
320 if (!picref)325 if (!picref)
321 return AVERROR(ENOMEM);326 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);
323 picref->buf->data[0] = NULL;328 picref->buf->data[0] = NULL;
324 avfilter_unref_buffer(picref);329 avfilter_unref_buffer(picref);
325
326 return ret;330 return ret;
327}331}
332
333int 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}
328#endif338#endif
329 339
330unsigned av_vsrc_buffer_get_nb_failed_requests(AVFilterContext *buffer_src)340unsigned 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