src_buffer: implement av_buffersrc_add_frame.
It supersedes av_vsrc_buffer_add_frame and handles both audio and video.
This commit is contained in:
parent
a96cd73ff2
commit
7bac2a78c2
@ -89,6 +89,18 @@ int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
|
|||||||
int avfilter_fill_frame_from_buffer_ref(AVFrame *frame,
|
int avfilter_fill_frame_from_buffer_ref(AVFrame *frame,
|
||||||
const AVFilterBufferRef *ref);
|
const AVFilterBufferRef *ref);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add frame data to buffer_src.
|
||||||
|
*
|
||||||
|
* @param buffer_src pointer to a buffer source context
|
||||||
|
* @param frame a frame, or NULL to mark EOF
|
||||||
|
* @param flags a combination of AV_BUFFERSRC_FLAG_*
|
||||||
|
* @return >= 0 in case of success, a negative AVERROR code
|
||||||
|
* in case of failure
|
||||||
|
*/
|
||||||
|
int av_buffersrc_add_frame(AVFilterContext *buffer_src,
|
||||||
|
const AVFrame *frame, int flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add frame data to buffer_src.
|
* Add frame data to buffer_src.
|
||||||
*
|
*
|
||||||
|
@ -303,28 +303,38 @@ int av_buffersrc_buffer(AVFilterContext *s, AVFilterBufferRef *buf)
|
|||||||
#if CONFIG_AVCODEC
|
#if CONFIG_AVCODEC
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
|
||||||
int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src,
|
int av_buffersrc_add_frame(AVFilterContext *buffer_src,
|
||||||
const AVFrame *frame, int flags)
|
const AVFrame *frame, int flags)
|
||||||
{
|
{
|
||||||
BufferSourceContext *c = buffer_src->priv;
|
|
||||||
AVFilterBufferRef *picref;
|
AVFilterBufferRef *picref;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!frame) {
|
if (!frame) /* NULL for EOF */
|
||||||
c->eof = 1;
|
return av_buffersrc_add_ref(buffer_src, NULL, flags);
|
||||||
return 0;
|
|
||||||
} else if (c->eof)
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
|
|
||||||
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)
|
if (!picref)
|
||||||
return AVERROR(ENOMEM);
|
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;
|
picref->buf->data[0] = NULL;
|
||||||
avfilter_unref_buffer(picref);
|
avfilter_unref_buffer(picref);
|
||||||
|
|
||||||
return ret;
|
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
|
#endif
|
||||||
|
|
||||||
unsigned av_vsrc_buffer_get_nb_failed_requests(AVFilterContext *buffer_src)
|
unsigned av_vsrc_buffer_get_nb_failed_requests(AVFilterContext *buffer_src)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user