From patchwork Sun Feb 14 14:32:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 25614 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 11A4D44851B for ; Sun, 14 Feb 2021 16:32:21 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CB5316899EB; Sun, 14 Feb 2021 16:32:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7A4FB687F71 for ; Sun, 14 Feb 2021 16:32:14 +0200 (EET) Received: by mail-ej1-f54.google.com with SMTP id jt13so7182170ejb.0 for ; Sun, 14 Feb 2021 06:32:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=+JNmlVZOzsbtMfjpce1BNFndgQ0M68lmY67ANPAMjT0=; b=UGTeNQ/dnnM0duq1SmjDMmneh8Sf62DIiBXicy5HXeefimsA5paQ/SJ/SBGYohQ/up Sk8A9JXLrxQG2DKDoWl7yXNBoBR94X/X7VJHEwc4hnZcKO3DFVefOOc2DnlufjQLqlSM qNu5mnHu9tZ+bLvzkNzpgvyA3RfzmeDiuzVVpBGwE2GHhlwt8ZnNen6uURPYoqW1BG9A feEDedswZi3lJq2OdDCX8oVBM91Yx62mZBkng8xyTwrsLxkkTlSNZ9m8t3i/E6ZAwacR G37fujuJz/eciorC+wsRiSMzG4rMhk/J5cys6+w8NCkco3EOQJXcnXp+iMKZkoyBSJUY x2vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=+JNmlVZOzsbtMfjpce1BNFndgQ0M68lmY67ANPAMjT0=; b=RSCeEJWwEfLeTIRCQQAaZu1hUhJPDPFRGDiI0yescOZhRNqEDqSYmOMqA5z7ab6IVU f1/rhS/1w/KhFkmPn9X7gBbsBYF1G0A6oHVbkwtMDfiHy6v/RlNO3SAkASPTXJrtWljI tcQnNmYBkJ9/urQR0UdBbHlPVqgqJ20modgj+LlcYSep0T23SGSKiCNONlvGQTLIzxlL HleP7Y4wiyzZ3tYYPZu3KrSFKg2G6zQ3fFouUXnzwxRdj839l0vYIECe/OnXWPhRcjo6 qqfwWi+Vx/fXCUGNoi69ad459THb72SHWuFLqjnd3jMN6/0ooPxd1EPwqkZr2tzQNIgN gG3w== X-Gm-Message-State: AOAM533rdfnOqA9pqnpqVaYaFXK8a5MFOf/dpDb7knkxDTTEMr1GtzwA tQsbNYhj8KL2HvuoDltmttmCSZE2PD/xwg== X-Google-Smtp-Source: ABdhPJzTNlriYcz8gLd+bIyx8bokm+945G2pgzQVQt/SXhqmSTf/awnsk549pqtJ/edbY7rviVLRgA== X-Received: by 2002:a17:906:dbd0:: with SMTP id yc16mr11778123ejb.524.1613313132968; Sun, 14 Feb 2021 06:32:12 -0800 (PST) Received: from localhost.localdomain ([94.250.162.225]) by smtp.gmail.com with ESMTPSA id ks13sm1915838ejb.69.2021.02.14.06.32.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Feb 2021 06:32:12 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Sun, 14 Feb 2021 15:32:04 +0100 Message-Id: <20210214143205.9320-1-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/2] avfilter/vf_gblur: factor out postscale function X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Paul B Mahol --- libavfilter/gblur.h | 2 ++ libavfilter/vf_gblur.c | 23 ++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/libavfilter/gblur.h b/libavfilter/gblur.h index 15a8167fe5..dce50671f6 100644 --- a/libavfilter/gblur.h +++ b/libavfilter/gblur.h @@ -50,7 +50,9 @@ typedef struct GBlurContext { float nuV; int nb_planes; void (*horiz_slice)(float *buffer, int width, int height, int steps, float nu, float bscale); + void (*postscale_slice)(float *buffer, int length, float postscale, float min, float max); } GBlurContext; + void ff_gblur_init(GBlurContext *s); void ff_gblur_init_x86(GBlurContext *s); #endif diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c index 68a2ed3520..70e2a668b4 100644 --- a/libavfilter/vf_gblur.c +++ b/libavfilter/vf_gblur.c @@ -54,6 +54,15 @@ typedef struct ThreadData { int width; } ThreadData; +static void postscale_c(float *buffer, int length, + float postscale, float min, float max) +{ + for (int i = 0; i < length; i++) { + buffer[i] *= postscale; + buffer[i] = av_clipf(buffer[i], min, max); + } +} + static void horiz_slice_c(float *buffer, int width, int height, int steps, float nu, float bscale) { @@ -154,7 +163,6 @@ static int filter_vertically(AVFilterContext *ctx, void *arg, int jobnr, int nb_ return 0; } - static int filter_postscale(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) { GBlurContext *s = ctx->priv; @@ -164,16 +172,12 @@ static int filter_postscale(AVFilterContext *ctx, void *arg, int jobnr, int nb_j const int height = td->height; const int width = td->width; const int64_t numpixels = width * (int64_t)height; - const unsigned slice_start = (numpixels * jobnr ) / nb_jobs; - const unsigned slice_end = (numpixels * (jobnr+1)) / nb_jobs; + const int slice_start = (numpixels * jobnr ) / nb_jobs; + const int slice_end = (numpixels * (jobnr+1)) / nb_jobs; const float postscale = s->postscale * s->postscaleV; - float *buffer = s->buffer; - unsigned i; + float *buffer = s->buffer + slice_start; - for (i = slice_start; i < slice_end; i++) { - buffer[i] *= postscale; - buffer[i] = av_clipf(buffer[i], min, max); - } + s->postscale_slice(buffer, slice_end - slice_start, postscale, min, max); return 0; } @@ -228,6 +232,7 @@ static int query_formats(AVFilterContext *ctx) void ff_gblur_init(GBlurContext *s) { s->horiz_slice = horiz_slice_c; + s->postscale_slice = postscale_c; if (ARCH_X86_64) ff_gblur_init_x86(s); }