From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 6C7F54666A for ; Thu, 29 Jun 2023 18:00:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2AD0B68C43D; Thu, 29 Jun 2023 20:58:38 +0300 (EEST) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 94D6F68C39C for ; Thu, 29 Jun 2023 20:58:30 +0300 (EEST) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-3fbc0609cd6so6733125e9.1 for ; Thu, 29 Jun 2023 10:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kynesim-co-uk.20221208.gappssmtp.com; s=20221208; t=1688061509; x=1690653509; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jL3eY1NlYyK1cmFkxNofu288S3SJwEoOYaWc0ZFN/uA=; b=e9MjVk/I2Uw+GZAU4Ps2Sf+XY/00PaoqSEhn7eRuGG0UxbKtab6PzGT3WaLKI7hmbg a5CeYtnxmrDXnuI6nwTM+31T0kFCnAACBga64M1Xn+t4210sXVvWGFUPbpG1lYTnwcQP 1HqP9pgKhD4xg4Uq0Qz8zrre7rCLKWmHO6KTvRpSzVc0BgyV/LN2Rkla9X0/TpC3qtqt zpl5SQnuBdnDDVFkfvEv/WmPJR16grbx2UMhxKZrV5M9PkFkHdhJIG1yfB+yL8vPXPNa mYSeqCO1/cdOHib0nDhePpZENMECFKdsUXf6ISNCuHYq+JeMlyLzSGQTtXo6mNu19Ggc ejyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688061509; x=1690653509; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jL3eY1NlYyK1cmFkxNofu288S3SJwEoOYaWc0ZFN/uA=; b=agal633cfMw7ZE5uaWC2SLU4xVneAnbWLTMUqV8wKKMrkb1umAzBpXU3Q2YfDxzweB wMzfXpNQi7gsksazgDV8U//OKUmV//Js7QyPzyqli465tvHByg1Wbayfj6COAhMAUnxZ y+wr8Ux/B5jp6+wDtaBtev/1zbE6gS0nGDOnJSSqqWVkSxhogZstkMN+Ujj0zOTuIXAq WZ4qAUw4GWQxyRcNQO+tvzHoy1tJp1Gy33cw6kY19cadZjDJQgjsnPh54+5uRVRsfll8 5EM+uHTlld5O/Mf6S2s69WI9UmaIsRH0P/yghgs5cFlpqITEsxyBFyeQxAkANzOKW8jd tD8Q== X-Gm-Message-State: AC+VfDxt/tazIlKQtTNtB7Wpqo46x6ht1hCGYlxnOZn9jxjk2G2IzoCO czBpeijLf8An8Ae9Kj8Mifz6kcrnsUd/WtxFEpY= X-Google-Smtp-Source: ACHHUZ5DCfl6xfUiTfiBeSxyebZmnIjldwDoAVRFmReEwtcmCEUSTw3IgYpiEKeWV590fBPfqUoKlA== X-Received: by 2002:a7b:c7d5:0:b0:3f9:70f:8b99 with SMTP id z21-20020a7bc7d5000000b003f9070f8b99mr103979wmk.7.1688061509743; Thu, 29 Jun 2023 10:58:29 -0700 (PDT) Received: from sucnaath.outer.uphall.net (cpc1-cmbg20-2-0-cust759.5-4.cable.virginm.net. [86.21.218.248]) by smtp.gmail.com with ESMTPSA id f26-20020a7bcd1a000000b003fbba5f21b6sm2041541wmj.28.2023.06.29.10.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 10:58:29 -0700 (PDT) From: John Cox To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Jun 2023 17:57:29 +0000 Message-Id: <20230629175729.224383-16-jc@kynesim.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230629175729.224383-1-jc@kynesim.co.uk> References: <20230629175729.224383-1-jc@kynesim.co.uk> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/15] avfilter/vf_bwdif: Block filter slices into a multiple of 4 lines X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: thomas.mundt@hr.de, John Cox Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Round job start lines down to a multiple of 4. This means that if filter_line3 exists then filter_line will not sometimes be called once at the end of a slice depending on thread count. The final slice may do up to 3 extra lines but filter_edge is faster than filter_line so it is unlikely to create any noticable thread load variation. Signed-off-by: John Cox --- libavfilter/vf_bwdif.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_bwdif.c b/libavfilter/vf_bwdif.c index 52bc676cf8..6701208efe 100644 --- a/libavfilter/vf_bwdif.c +++ b/libavfilter/vf_bwdif.c @@ -237,6 +237,13 @@ static void filter_edge_16bit(void *dst1, void *prev1, void *cur1, void *next1, FILTER2() } +// Round job start line down to multiple of 4 so that if filter_line3 exists +// and the frame is a multiple of 4 high then filter_line will never be called +static inline int job_start(const int jobnr, const int nb_jobs, const int h) +{ + return jobnr >= nb_jobs ? h : ((h * jobnr) / nb_jobs) & ~3; +} + static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) { BWDIFContext *s = ctx->priv; @@ -246,8 +253,8 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) int clip_max = (1 << (yadif->csp->comp[td->plane].depth)) - 1; int df = (yadif->csp->comp[td->plane].depth + 7) / 8; int refs = linesize / df; - int slice_start = (td->h * jobnr ) / nb_jobs; - int slice_end = (td->h * (jobnr+1)) / nb_jobs; + int slice_start = job_start(jobnr, nb_jobs, td->h); + int slice_end = job_start(jobnr + 1, nb_jobs, td->h); int y; for (y = slice_start; y < slice_end; y++) { @@ -310,7 +317,7 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic, td.plane = i; ff_filter_execute(ctx, filter_slice, &td, NULL, - FFMIN(h, ff_filter_get_nb_threads(ctx))); + FFMIN((h+3)/4, ff_filter_get_nb_threads(ctx))); } if (yadif->current_field == YADIF_FIELD_END) { yadif->current_field = YADIF_FIELD_NORMAL; -- 2.39.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".