AVFilterBufferRef *avfilter_get_buffer_ref_from_frame(enum AVMediaType type, const AVFrame *frame, int perms) { switch (type) { case AVMEDIA_TYPE_VIDEO: return avfilter_get_video_buffer_ref_from_frame(frame, perms); case AVMEDIA_TYPE_AUDIO: return avfilter_get_audio_buffer_ref_from_frame(frame, perms); default: return NULL; } }
int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src, const AVFrame *frame, int flags) { int ret; AVFilterBufferRef *picref = avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE); if (!picref) return AVERROR(ENOMEM); ret = av_vsrc_buffer_add_video_buffer_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) { BufferSourceContext *c = buffer_src->priv; AVFilterBufferRef *picref; int ret; if (!frame) { c->eof = 1; return 0; } else if (c->eof) return AVERROR(EINVAL); picref = avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE); if (!picref) return AVERROR(ENOMEM); ret = av_vsrc_buffer_add_video_buffer_ref(buffer_src, picref, flags); picref->buf->data[0] = NULL; avfilter_unref_buffer(picref); return ret; }