return av_buffersrc_add_frame_flags(ctx, frame, 0);
}
-static int av_buffersrc_add_frame_internal(AVFilterContext *ctx,
- AVFrame *frame, int flags);
-
-int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
-{
- AVFrame *copy = NULL;
- int ret = 0;
-
- if (frame && frame->channel_layout &&
- av_get_channel_layout_nb_channels(frame->channel_layout) != frame->channels) {
- av_log(ctx, AV_LOG_ERROR, "Layout indicates a different number of channels than actually present\n");
- return AVERROR(EINVAL);
- }
-
- if (!(flags & AV_BUFFERSRC_FLAG_KEEP_REF) || !frame)
- return av_buffersrc_add_frame_internal(ctx, frame, flags);
-
- if (!(copy = av_frame_alloc()))
- return AVERROR(ENOMEM);
- ret = av_frame_ref(copy, frame);
- if (ret >= 0)
- ret = av_buffersrc_add_frame_internal(ctx, copy, flags);
-
- av_frame_free(©);
- return ret;
-}
-
static int push_frame(AVFilterGraph *graph)
{
int ret;
return 0;
}
-static int av_buffersrc_add_frame_internal(AVFilterContext *ctx,
- AVFrame *frame, int flags)
+int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
{
BufferSourceContext *s = ctx->priv;
AVFrame *copy;
int refcounted, ret;
+ if (frame && frame->channel_layout &&
+ av_get_channel_layout_nb_channels(frame->channel_layout) != frame->channels) {
+ av_log(ctx, AV_LOG_ERROR, "Layout indicates a different number of channels than actually present\n");
+ return AVERROR(EINVAL);
+ }
+
s->nb_failed_requests = 0;
if (!frame)
if (!(copy = av_frame_alloc()))
return AVERROR(ENOMEM);
- if (refcounted) {
+ if (refcounted && !(flags & AV_BUFFERSRC_FLAG_KEEP_REF)) {
av_frame_move_ref(copy, frame);
} else {
ret = av_frame_ref(copy, frame);
}
ret = ff_filter_frame(ctx->outputs[0], copy);
- if (ret < 0) {
- av_frame_free(©);
+ if (ret < 0)
return ret;
- }
if ((flags & AV_BUFFERSRC_FLAG_PUSH)) {
ret = push_frame(ctx->graph);
{ NULL }
};
-AVFilter ff_vsrc_buffer = {
+const AVFilter ff_vsrc_buffer = {
.name = "buffer",
.description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them accessible to the filterchain."),
.priv_size = sizeof(BufferSourceContext),
{ NULL }
};
-AVFilter ff_asrc_abuffer = {
+const AVFilter ff_asrc_abuffer = {
.name = "abuffer",
.description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them accessible to the filterchain."),
.priv_size = sizeof(BufferSourceContext),