From 5b1907142dca052c3254d0b4ca3e2ff7ddc7d96b Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 27 Aug 2016 22:22:58 +0200 Subject: [PATCH] avfilter: add ff_filter_get_nb_threads() --- libavfilter/avfilter.c | 7 +++++++ libavfilter/internal.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index a8e5a5a73d..b2365354a2 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -783,6 +783,13 @@ void avfilter_free(AVFilterContext *filter) av_free(filter); } +int ff_filter_get_nb_threads(AVFilterContext *ctx) +{ + if (ctx->nb_threads > 0) + return FFMIN(ctx->nb_threads, ctx->graph->nb_threads); + return ctx->graph->nb_threads; +} + static int process_options(AVFilterContext *ctx, AVDictionary **options, const char *args) { diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 769e65b2fc..3856012aa9 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -402,4 +402,10 @@ static inline int ff_norm_qscale(int qscale, int type) return qscale; } +/** + * Get number of threads for current filter instance. + * This number is always same or less than graph->nb_threads. + */ +int ff_filter_get_nb_threads(AVFilterContext *ctx); + #endif /* AVFILTER_INTERNAL_H */