aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas George <george@nsup.org>2016-12-23 21:39:46 +0100
committerNicolas George <george@nsup.org>2016-12-24 13:18:03 +0100
commit0ff5567a30be6d7c804e95997ae282d6bacd76c3 (patch)
tree530ee9349f7645b650fcb480953b7c0729e650d8
parent3b64e3ea45c580c5e158c086f2eb7c65635fc33b (diff)
downloadffmpeg-0ff5567a30be6d7c804e95997ae282d6bacd76c3.tar.gz
lavfi/buffersrc: push the frame deeper if requested.
Reduce peak memory consumption with ffmpeg in certain cases.
-rw-r--r--libavfilter/buffersrc.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 1314397a32..77fd174219 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -173,6 +173,20 @@ int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFra
return ret;
}
+static int push_frame(AVFilterGraph *graph)
+{
+ int ret;
+
+ while (1) {
+ ret = ff_filter_graph_run_once(graph);
+ if (ret == AVERROR(EAGAIN))
+ break;
+ if (ret < 0)
+ return ret;
+ }
+ return 0;
+}
+
static int av_buffersrc_add_frame_internal(AVFilterContext *ctx,
AVFrame *frame, int flags)
{
@@ -185,6 +199,11 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx,
if (!frame) {
s->eof = 1;
ff_avfilter_link_set_in_status(ctx->outputs[0], AVERROR_EOF, AV_NOPTS_VALUE);
+ if ((flags & AV_BUFFERSRC_FLAG_PUSH)) {
+ ret = push_frame(ctx->graph);
+ if (ret < 0)
+ return ret;
+ }
return 0;
} else if (s->eof)
return AVERROR(EINVAL);
@@ -239,6 +258,12 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx,
if ((ret = ctx->output_pads[0].request_frame(ctx->outputs[0])) < 0)
return ret;
+ if ((flags & AV_BUFFERSRC_FLAG_PUSH)) {
+ ret = push_frame(ctx->graph);
+ if (ret < 0)
+ return ret;
+ }
+
return 0;
}