From patchwork Sat Feb 13 11:10:37 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: 25605 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 53C1A441BE4 for ; Sat, 13 Feb 2021 13:10:59 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1897E689E14; Sat, 13 Feb 2021 13:10:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1042668819D for ; Sat, 13 Feb 2021 13:10:52 +0200 (EET) Received: by mail-ej1-f45.google.com with SMTP id y9so3517561ejp.10 for ; Sat, 13 Feb 2021 03:10:52 -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=t/cckEPzE93K4y+dxfgh8RtF3Pto1D7rgbqNb4o9PXaQ5jwMy7zxy2gBWiazvRNQxQ 1Pt5WkC5EDzSuQRokMZGVpj6HYSdoWw6yYSNsezfi71mNtRVkPuAKRZxdjVjzt7EizwR A2OS/SAdcUQ5nHD/G4cBSQkEQjneAfaEBnwA6Smm3KwERFzMYs2/MTR9EUdyAURAxRgo c7SM0E8bDhNozbxNIC9U2HSd0NoGQh7gaieOkm7P8ZTFdf9WDuOeGYR0k39BZFDPPA1z JxSxuQbbD2D9hSbcCla2iJoisfQwMK7SNQtv98ZbhvVmeIStb86s0G91tCbXfi5hBa+c x5eg== 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=qbNo5S68JH8de5tkZcsInBFnrhUBYMKCPEDxnJPe8s7VK4vUS2fr/Im49qvD4kOS0V QSE+BAYyD0R0tgNJ41sMBbpq659CttmneYo2pOHOofZUm6eUFmHO9Mx+CXSTUHhf+dD7 wzUF1zPt+01kzLwGuiWHyq5Ik2mJgCXDidw+lULt8SZTtdRotIFTVAIScSSFysb2x2sb ISszI99qG5196tHN25auTNj0KWdzCsx3bCwQjUHpeZ+rDz7Rkt9visdvsqd+NSUN/SR9 tnv8z0QW8PppvPfy2zMSBSb1I6Ly1jcWAsArpal1t852xm2blphAindEFba2jfJeu73i ARcg== X-Gm-Message-State: AOAM532tIHPD+EGnnpj6DRcqjuGf1tq/3fxA6ujuxwjQatKW3wzo80ZH kxQuNrMMvyTK5+1cIQLOSBkjWjQHF9CNWQ== X-Google-Smtp-Source: ABdhPJykr6qF8XMgGL41fXwrUViIj5SRJqK9HFpmYrAqqmcTi7HAkNxq1ZKm7BdLf2bNwVQ28e7Bcw== X-Received: by 2002:a17:906:2a8b:: with SMTP id l11mr7174628eje.1.1613214651414; Sat, 13 Feb 2021 03:10:51 -0800 (PST) Received: from localhost.localdomain ([212.15.167.195]) by smtp.gmail.com with ESMTPSA id hr3sm7095100ejc.41.2021.02.13.03.10.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Feb 2021 03:10:51 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Sat, 13 Feb 2021 12:10:37 +0100 Message-Id: <20210213111038.14840-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); }