diff options
author | Mark Thompson <sw@jkqxz.net> | 2017-03-27 21:10:53 +0100 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2018-02-11 22:11:06 +0000 |
commit | 6d86cef06ba36c0ed591e14a2382e9630059fc5d (patch) | |
tree | a99bae90444587b92120c1df0d53029f052c6884 /libavfilter/avfilter.c | |
parent | cad739dace55e3446ef7180de688173cd19fb000 (diff) |
lavfi: Add support for increasing hardware frame pool sizes
AVFilterContext.extra_hw_frames functions identically to the field of
the same name in AVCodecContext.
Diffstat (limited to 'libavfilter/avfilter.c')
-rw-r--r-- | libavfilter/avfilter.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 83c1a7c20d..2c4a385ea9 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -368,6 +368,8 @@ static const AVOption avfilter_options[] = { { "thread_type", "Allowed thread types", OFFSET(thread_type), AV_OPT_TYPE_FLAGS, { .i64 = AVFILTER_THREAD_SLICE }, 0, INT_MAX, FLAGS, "thread_type" }, { "slice", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVFILTER_THREAD_SLICE }, .unit = "thread_type" }, + { "extra_hw_frames", "Number of extra hardware frames to allocate for the user", + OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS }, { NULL }, }; @@ -707,3 +709,24 @@ const AVClass *avfilter_get_class(void) { return &avfilter_class; } + +int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link, + int default_pool_size) +{ + AVHWFramesContext *frames; + + // Must already be set by caller. + av_assert0(link->hw_frames_ctx); + + frames = (AVHWFramesContext*)link->hw_frames_ctx->data; + + if (frames->initial_pool_size == 0) { + // Dynamic allocation is necessarily supported. + } else if (avctx->extra_hw_frames >= 0) { + frames->initial_pool_size += avctx->extra_hw_frames; + } else { + frames->initial_pool_size = default_pool_size; + } + + return 0; +} |