diff options
author | Mark Thompson <sw@jkqxz.net> | 2018-02-12 22:28:12 +0000 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2018-02-12 22:28:12 +0000 |
commit | bcab11a1a23d8b156198db352bbdb932740a966c (patch) | |
tree | 827e9acc1a7547c1d5d719e2b7db00971d62f281 | |
parent | 9471122a1b5dec34572c3d4c675737f0493d140e (diff) | |
parent | 6d86cef06ba36c0ed591e14a2382e9630059fc5d (diff) | |
download | ffmpeg-bcab11a1a23d8b156198db352bbdb932740a966c.tar.gz |
Merge commit '6d86cef06ba36c0ed591e14a2382e9630059fc5d'
* commit '6d86cef06ba36c0ed591e14a2382e9630059fc5d':
lavfi: Add support for increasing hardware frame pool sizes
Merged-by: Mark Thompson <sw@jkqxz.net>
-rw-r--r-- | doc/APIchanges | 3 | ||||
-rw-r--r-- | libavfilter/avfilter.c | 23 | ||||
-rw-r--r-- | libavfilter/avfilter.h | 16 | ||||
-rw-r--r-- | libavfilter/internal.h | 16 | ||||
-rw-r--r-- | libavfilter/version.h | 4 |
5 files changed, 60 insertions, 2 deletions
diff --git a/doc/APIchanges b/doc/APIchanges index e5c392ead5..8565cbeb09 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2018-02-xx - xxxxxxx - lavfi 7.12.100 - avfilter.h + Add AVFilterContext.extra_hw_frames. + 2018-02-xx - xxxxxxx - lavc 58.11.100 - avcodec.h Add AVCodecContext.extra_hw_frames. diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index ea75467a75..7553f7c36a 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -676,6 +676,8 @@ static const AVOption avfilter_options[] = { { "enable", "set enable expression", OFFSET(enable_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, { "threads", "Allowed number of threads", OFFSET(nb_threads), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS }, + { "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 }, }; @@ -1663,3 +1665,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; +} diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 62eed2168f..2d1195eeeb 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -406,6 +406,22 @@ struct AVFilterContext { * a higher value suggests a more urgent activation. */ unsigned ready; + + /** + * Sets the number of extra hardware frames which the filter will + * allocate on its output links for use in following filters or by + * the caller. + * + * Some hardware filters require all frames that they will use for + * output to be defined in advance before filtering starts. For such + * filters, any hardware frame pools used for output must therefore be + * of fixed size. The extra frames set here are on top of any number + * that the filter needs internally in order to operate normally. + * + * This field must be set before the graph containing this filter is + * configured. + */ + int extra_hw_frames; }; /** diff --git a/libavfilter/internal.h b/libavfilter/internal.h index f9679ed1d7..498bd3328d 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -411,4 +411,20 @@ static inline int ff_norm_qscale(int qscale, int type) */ int ff_filter_get_nb_threads(AVFilterContext *ctx); +/** + * Perform any additional setup required for hardware frames. + * + * link->hw_frames_ctx must be set before calling this function. + * Inside link->hw_frames_ctx, the fields format, sw_format, width and + * height must be set. If dynamically allocated pools are not supported, + * then initial_pool_size must also be set, to the minimum hardware frame + * pool size necessary for the filter to work (taking into account any + * frames which need to stored for use in operations as appropriate). If + * default_pool_size is nonzero, then it will be used as the pool size if + * no other modification takes place (this can be used to preserve + * compatibility). + */ +int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link, + int default_pool_size); + #endif /* AVFILTER_INTERNAL_H */ diff --git a/libavfilter/version.h b/libavfilter/version.h index 0f11721822..ca096962bb 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -30,8 +30,8 @@ #include "libavutil/version.h" #define LIBAVFILTER_VERSION_MAJOR 7 -#define LIBAVFILTER_VERSION_MINOR 11 -#define LIBAVFILTER_VERSION_MICRO 101 +#define LIBAVFILTER_VERSION_MINOR 12 +#define LIBAVFILTER_VERSION_MICRO 100 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ |