From patchwork Fri Oct 22 08:52:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 31210 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp1557108ioa; Fri, 22 Oct 2021 01:53:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrzaId0f0cMjzpf2V46k5FWPzyYd7DWY2r91miF3sMz7NWUnJFt4EQ+B54sf+XbU+On+Lq X-Received: by 2002:aa7:cd88:: with SMTP id x8mr14728497edv.203.1634892799260; Fri, 22 Oct 2021 01:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634892799; cv=none; d=google.com; s=arc-20160816; b=GxwqMGb20yo508YoYpnDPTDMwGpKeUBDJtVFBn1oiDFpkw+bbsvhl7rjnWrZ1z2JwB bKOPITuWwPZYwxdc+7dDBcNQiShf3yl/xwwM2GE6UpLAYACfSuC+Om0UNPLU2SwfyXsC xbu8HVgj1KPKcZPYXUfAV2AzIyifC8xXWZwGZF/7pyVK9IWOUAPI7RH87MFn8ITxx5gq TK8aVUypQ18i9W8Y8qOuIkUL6+LtkK7OKoiSQ7At/90sN03AA5GgcIVulfCI2dWckrqK CnwvK7n2tPc0snmbEN6YEBj3fvglObkvg6N4T8+GVCuBuY9fjdZFSnxdW7KgWI/F7tRq ohLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to; bh=THrkBvsyZIPzavz0aKVbbjYepkw/1GuokGVqjJkrRNk=; b=kJCm7S1YwEJ64fCKY0nZTKqknYo6McVmSEbFTp8AxO7AAIewCj7wiQwH5GQbAjRxSs kVAsyXmngcNOYEFwOw5Ai6M+naJmL+DjZ5Jxf7EjJd7gGHCwXPYgzVs8YjTVKuHAU2ht qwInbsj351h76tKJOVx1RZw2DWIIrwLmTjGlzC0nMl8+7FA42KpfBJF4K/kYadRSolY2 quHIniz9Yyi3T7mrvrf93PK86W8pCevRtqwIzTPUUvixULPYmotXytLSWl0saAOc6Tvk CdwF4R7uN2us326pKlw1Sx6RkWLki57HgJ+Xvx6bX++AMm0pflsTn48AZYHSZcR+1MYP WL2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hp24si15455925ejc.400.2021.10.22.01.53.18; Fri, 22 Oct 2021 01:53:19 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6342068A71A; Fri, 22 Oct 2021 11:53:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6AAF768A242 for ; Fri, 22 Oct 2021 11:53:01 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10144"; a="216176982" X-IronPort-AV: E=Sophos;i="5.87,172,1631602800"; d="scan'208";a="216176982" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 01:52:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,172,1631602800"; d="scan'208";a="495586607" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by orsmga008.jf.intel.com with ESMTP; 22 Oct 2021 01:52:49 -0700 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Oct 2021 16:52:28 +0800 Message-Id: <20211022085231.93931-1-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/4] avfilter/x86/vf_exposure: add x86 SIMD optimization 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: Wu Jianhua MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: FC9JHz/gWxQQ Performance data(Less is better): exposure_c: 857394 exposure_asm: 327589 Signed-off-by: Wu Jianhua --- libavfilter/exposure.h | 36 +++++++++++++++++++ libavfilter/vf_exposure.c | 36 +++++++++---------- libavfilter/x86/Makefile | 2 ++ libavfilter/x86/vf_exposure.asm | 55 ++++++++++++++++++++++++++++++ libavfilter/x86/vf_exposure_init.c | 36 +++++++++++++++++++ 5 files changed, 147 insertions(+), 18 deletions(-) create mode 100644 libavfilter/exposure.h create mode 100644 libavfilter/x86/vf_exposure.asm create mode 100644 libavfilter/x86/vf_exposure_init.c diff --git a/libavfilter/exposure.h b/libavfilter/exposure.h new file mode 100644 index 0000000000..e76a517826 --- /dev/null +++ b/libavfilter/exposure.h @@ -0,0 +1,36 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_EXPOSURE_H +#define AVFILTER_EXPOSURE_H +#include "avfilter.h" + +typedef struct ExposureContext { + const AVClass *class; + + float exposure; + float black; + float scale; + + void (*exposure_func)(float *ptr, int length, float black, float scale); +} ExposureContext; + +void ff_exposure_init(ExposureContext *s); +void ff_exposure_init_x86(ExposureContext *s); + +#endif diff --git a/libavfilter/vf_exposure.c b/libavfilter/vf_exposure.c index 108fba7930..045ae710d3 100644 --- a/libavfilter/vf_exposure.c +++ b/libavfilter/vf_exposure.c @@ -26,23 +26,20 @@ #include "formats.h" #include "internal.h" #include "video.h" +#include "exposure.h" -typedef struct ExposureContext { - const AVClass *class; - - float exposure; - float black; +static void exposure_c(float *ptr, int length, float black, float scale) +{ + int i; - float scale; - int (*do_slice)(AVFilterContext *s, void *arg, - int jobnr, int nb_jobs); -} ExposureContext; + for (i = 0; i < length; i++) + ptr[i] = (ptr[i] - black) * scale; +} static int exposure_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) { ExposureContext *s = ctx->priv; AVFrame *frame = arg; - const int width = frame->width; const int height = frame->height; const int slice_start = (height * jobnr) / nb_jobs; const int slice_end = (height * (jobnr + 1)) / nb_jobs; @@ -52,24 +49,27 @@ static int exposure_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_job for (int p = 0; p < 3; p++) { const int linesize = frame->linesize[p] / 4; float *ptr = (float *)frame->data[p] + slice_start * linesize; - for (int y = slice_start; y < slice_end; y++) { - for (int x = 0; x < width; x++) - ptr[x] = (ptr[x] - black) * scale; - - ptr += linesize; - } + s->exposure_func(ptr, linesize * (slice_end - slice_start), black, scale); } return 0; } +void ff_exposure_init(ExposureContext *s) +{ + s->exposure_func = exposure_c; + + if (ARCH_X86) + ff_exposure_init_x86(s); +} + static int filter_frame(AVFilterLink *inlink, AVFrame *frame) { AVFilterContext *ctx = inlink->dst; ExposureContext *s = ctx->priv; s->scale = 1.f / (exp2f(-s->exposure) - s->black); - ff_filter_execute(ctx, s->do_slice, frame, NULL, + ff_filter_execute(ctx, exposure_slice, frame, NULL, FFMIN(frame->height, ff_filter_get_nb_threads(ctx))); return ff_filter_frame(ctx->outputs[0], frame); @@ -80,7 +80,7 @@ static av_cold int config_input(AVFilterLink *inlink) AVFilterContext *ctx = inlink->dst; ExposureContext *s = ctx->priv; - s->do_slice = exposure_slice; + ff_exposure_init(s); return 0; } diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile index a29941eaeb..e84a388aa5 100644 --- a/libavfilter/x86/Makefile +++ b/libavfilter/x86/Makefile @@ -8,6 +8,7 @@ OBJS-$(CONFIG_BWDIF_FILTER) += x86/vf_bwdif_init.o OBJS-$(CONFIG_COLORSPACE_FILTER) += x86/colorspacedsp_init.o OBJS-$(CONFIG_CONVOLUTION_FILTER) += x86/vf_convolution_init.o OBJS-$(CONFIG_EQ_FILTER) += x86/vf_eq_init.o +OBJS-$(CONFIG_EXPOSURE_FILTER) += x86/vf_exposure_init.o OBJS-$(CONFIG_FSPP_FILTER) += x86/vf_fspp_init.o OBJS-$(CONFIG_GBLUR_FILTER) += x86/vf_gblur_init.o OBJS-$(CONFIG_GRADFUN_FILTER) += x86/vf_gradfun_init.o @@ -49,6 +50,7 @@ X86ASM-OBJS-$(CONFIG_BWDIF_FILTER) += x86/vf_bwdif.o X86ASM-OBJS-$(CONFIG_COLORSPACE_FILTER) += x86/colorspacedsp.o X86ASM-OBJS-$(CONFIG_CONVOLUTION_FILTER) += x86/vf_convolution.o X86ASM-OBJS-$(CONFIG_EQ_FILTER) += x86/vf_eq.o +X86ASM-OBJS-$(CONFIG_EXPOSURE_FILTER) += x86/vf_exposure.o X86ASM-OBJS-$(CONFIG_FRAMERATE_FILTER) += x86/vf_framerate.o X86ASM-OBJS-$(CONFIG_FSPP_FILTER) += x86/vf_fspp.o X86ASM-OBJS-$(CONFIG_GBLUR_FILTER) += x86/vf_gblur.o diff --git a/libavfilter/x86/vf_exposure.asm b/libavfilter/x86/vf_exposure.asm new file mode 100644 index 0000000000..3351c6fb3b --- /dev/null +++ b/libavfilter/x86/vf_exposure.asm @@ -0,0 +1,55 @@ +;***************************************************************************** +;* x86-optimized functions for exposure filter +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "libavutil/x86/x86util.asm" + +SECTION .text + +;******************************************************************************* +; void ff_exposure(float *ptr, int length, float black, float scale); +;******************************************************************************* +%macro EXPOSURE 0 +cglobal exposure, 2, 2, 4, ptr, length, black, scale + movsxdifnidn lengthq, lengthd +%if WIN64 + VBROADCASTSS m0, xmm2 + VBROADCASTSS m1, xmm3 +%else + VBROADCASTSS m0, xmm0 + VBROADCASTSS m1, xmm1 +%endif + +.loop: + movu m2, [ptrq] + subps m2, m2, m0 + mulps m2, m2, m1 + movu [ptrq], m2 + add ptrq, mmsize + sub lengthq, mmsize/4 + + jg .loop + + RET +%endmacro + +%if ARCH_X86_64 +INIT_XMM sse +EXPOSURE +%endif diff --git a/libavfilter/x86/vf_exposure_init.c b/libavfilter/x86/vf_exposure_init.c new file mode 100644 index 0000000000..de1b360f6c --- /dev/null +++ b/libavfilter/x86/vf_exposure_init.c @@ -0,0 +1,36 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/x86/cpu.h" +#include "libavfilter/exposure.h" + +void ff_exposure_sse(float *ptr, int length, float black, float scale); + +av_cold void ff_exposure_init_x86(ExposureContext *s) +{ + int cpu_flags = av_get_cpu_flags(); + +#if ARCH_X86_64 + if (EXTERNAL_SSE(cpu_flags)) + s->exposure_func = ff_exposure_sse; +#endif +} From patchwork Fri Oct 22 08:52:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 31209 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp1556994ioa; Fri, 22 Oct 2021 01:53:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7Mjv+eqxHTkl1ELkHU3KEm6jgWgw4M4NWeZxz8hHzICtIKO5DFtdWrKn/Vf7USBW8fp+r X-Received: by 2002:a17:906:f2d0:: with SMTP id gz16mr13839728ejb.102.1634892787837; Fri, 22 Oct 2021 01:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634892787; cv=none; d=google.com; s=arc-20160816; b=OgQ4/Y4eSDpA3wcemOn/MOvg7J6OmbhkFBUqp/AIezhMp8mTCjYGWe7kAmj/XaEeXB XtbwQSvcusqx+aviDUhhIrHBUgyWhxmKGmMCdUDNbYpWaGkoP9gHD6cyDakcu9I69G/m PK4zy3PjU72Ng9oFbTsNljT1RCmnjtyIrZdPM2qju+rqWnoEWqHb5htrh/aV0xbBSBOd bpgLrzoceabutoiKOGweKDUAzi7tizj/np2Yv/K33wT3Rt97XUewkgqUrMh7v+LR/N4n lF2iHydBVqKlXa0o+Ge14EZ3P6Y8QX4OH7seCOpGpMpLdj85wFZA66C7VJjbVncuO8GR uapQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=e2Ep8H6WgXCXLq5mnWsP8Ba5dgsSx1mSwXk+ry3TR5Y=; b=J/yxDdpNRit39+L12gi2U7FVJQS+Nbt1Np9VtT9oV6VyY8pY/ruPasrpc7UNctf2U5 T63utj6W9wujBCdUAj5R/AR3l3ILHX6Vm71jF6ceVQjJ0T20BSj/dZnUa4FsUAR/RSMR pTOR0E2KCcBI5NEq3x+WZRCzpg6EK6vmJlU+dtwxCjAOr2hlECTkt0mFD1XJBove8kJl BmvqbQLRJafPEADIb9LsA5LisRK5SBpjQV3wDNqhGF4GD05gpAxSTghg6AkY/0pn8v/l tbkQfn9Bxxj1np1Ddx/kwciHJR/1rRpOBMoih4RkYOgznkLenU2hcbC8NIExtRnenDhT Arcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ne15si16325761ejc.403.2021.10.22.01.53.07; Fri, 22 Oct 2021 01:53:07 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2A52F680C0F; Fri, 22 Oct 2021 11:53:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 29ED468A242 for ; Fri, 22 Oct 2021 11:52:54 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10144"; a="216176983" X-IronPort-AV: E=Sophos;i="5.87,172,1631602800"; d="scan'208";a="216176983" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 01:52:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,172,1631602800"; d="scan'208";a="495586614" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by orsmga008.jf.intel.com with ESMTP; 22 Oct 2021 01:52:50 -0700 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Oct 2021 16:52:29 +0800 Message-Id: <20211022085231.93931-2-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211022085231.93931-1-jianhua.wu@intel.com> References: <20211022085231.93931-1-jianhua.wu@intel.com> Subject: [FFmpeg-devel] [PATCH 2/4] avfilter/x86/vf_exposure: add ff_exposure_avx2 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: Wu Jianhua MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +nRFElsNiS5t Signed-off-by: Wu Jianhua --- libavfilter/x86/vf_exposure.asm | 5 +++++ libavfilter/x86/vf_exposure_init.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/libavfilter/x86/vf_exposure.asm b/libavfilter/x86/vf_exposure.asm index 3351c6fb3b..a0d25afbc4 100644 --- a/libavfilter/x86/vf_exposure.asm +++ b/libavfilter/x86/vf_exposure.asm @@ -52,4 +52,9 @@ cglobal exposure, 2, 2, 4, ptr, length, black, scale %if ARCH_X86_64 INIT_XMM sse EXPOSURE + +%if HAVE_AVX2_EXTERNAL +INIT_YMM avx2 +EXPOSURE +%endif %endif diff --git a/libavfilter/x86/vf_exposure_init.c b/libavfilter/x86/vf_exposure_init.c index de1b360f6c..80dae6164e 100644 --- a/libavfilter/x86/vf_exposure_init.c +++ b/libavfilter/x86/vf_exposure_init.c @@ -24,6 +24,7 @@ #include "libavfilter/exposure.h" void ff_exposure_sse(float *ptr, int length, float black, float scale); +void ff_exposure_avx2(float *ptr, int length, float black, float scale); av_cold void ff_exposure_init_x86(ExposureContext *s) { @@ -32,5 +33,10 @@ av_cold void ff_exposure_init_x86(ExposureContext *s) #if ARCH_X86_64 if (EXTERNAL_SSE(cpu_flags)) s->exposure_func = ff_exposure_sse; + +#if HAVE_AVX2_EXTERNAL + if (EXTERNAL_AVX2_FAST(cpu_flags)) + s->exposure_func = ff_exposure_avx2; +#endif #endif } From patchwork Fri Oct 22 08:52:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 31207 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp1557231ioa; Fri, 22 Oct 2021 01:53:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXN0DE1I4RGHQJVo+aBRo1zhZ6ErPK00LuqLD5/dbCsk57xa3XZ5RzO6JVa3ts1XkOFHaT X-Received: by 2002:a17:906:5d13:: with SMTP id g19mr13588400ejt.172.1634892809469; Fri, 22 Oct 2021 01:53:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634892809; cv=none; d=google.com; s=arc-20160816; b=p6nDHSG55eFhs46+DlFv1yxtUeqBV90YUebRrjAqkdzfKQM+S8dd9g993MpTpOL/mV z9EeSIv6dYJwqXo/1mQ7SeJcESzZzuysStuIomFXQGbTGzcbEHH+IRwFMuBX256gA7CE G6gK83EPmuJxX5GahB9IKo8WECCTJyNAAoVp9WW06v5C0uGb1+ylip9zje2qH+4s6cFS 88Iz9/sOuWfJ6Gixz2IvJbYqlChq85FXZ8kT7QNjk4f1Ulr7hd2YODRNNOQnZ9EYBQF8 Uv9rQqisXK5pWCzywL715ORPVCwLWpMF539bh2IUx/ryofjCina93P13zxiuOsIYfyrm VF6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=95ZIbQlpUfxrUjgtSFvAJicSt7WDEiwOyH1ib5Y2/kQ=; b=Dz6/je/mugayyhAijcXPOCRyESDy69xchZn5dQh6imq0SovR/rpV+b87T8T1RzQ7M2 zQO7myciBgXOXNRFynxM/E7RjwQrPTmgA75v/+4UF43BdCMgnj4GaWRtg30NdOPOabwQ TUh2yck9iGEbpqZjc+/QrPOBzr3IT6cRJZ2eYGicnM56xOMUsQtxcC8RJ7WXkX3WQ6Ak d1XDdMEdKSN9A//DCJEIGfK8Mrd79PWOrUSCoKSrF5o07mVu4QuithXdQGvFPoxySKRZ PDvTnLtcPleRa2sz7oSW8g+uMKkyx5M8ED/R7EWNOgyID4u8kmQN6DRnIhyq8j8ah0n6 AaXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w12si15859520edc.118.2021.10.22.01.53.29; Fri, 22 Oct 2021 01:53:29 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A646168A84C; Fri, 22 Oct 2021 11:53:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AFB9468A71A for ; Fri, 22 Oct 2021 11:53:02 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10144"; a="216176985" X-IronPort-AV: E=Sophos;i="5.87,172,1631602800"; d="scan'208";a="216176985" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 01:52:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,172,1631602800"; d="scan'208";a="495586622" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by orsmga008.jf.intel.com with ESMTP; 22 Oct 2021 01:52:51 -0700 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Oct 2021 16:52:30 +0800 Message-Id: <20211022085231.93931-3-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211022085231.93931-1-jianhua.wu@intel.com> References: <20211022085231.93931-1-jianhua.wu@intel.com> Subject: [FFmpeg-devel] [PATCH 3/4] avfilter/vf_exposure: calculate scale when initializing filter 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: Wu Jianhua MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 6lwHVofbHtZC Signed-off-by: Wu Jianhua --- libavfilter/vf_exposure.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavfilter/vf_exposure.c b/libavfilter/vf_exposure.c index 045ae710d3..9fd9f88293 100644 --- a/libavfilter/vf_exposure.c +++ b/libavfilter/vf_exposure.c @@ -57,6 +57,7 @@ static int exposure_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_job void ff_exposure_init(ExposureContext *s) { + s->scale = 1.f / (exp2f(-s->exposure) - s->black); s->exposure_func = exposure_c; if (ARCH_X86) @@ -66,9 +67,7 @@ void ff_exposure_init(ExposureContext *s) static int filter_frame(AVFilterLink *inlink, AVFrame *frame) { AVFilterContext *ctx = inlink->dst; - ExposureContext *s = ctx->priv; - s->scale = 1.f / (exp2f(-s->exposure) - s->black); ff_filter_execute(ctx, exposure_slice, frame, NULL, FFMIN(frame->height, ff_filter_get_nb_threads(ctx))); From patchwork Fri Oct 22 08:52:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 31208 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp1557375ioa; Fri, 22 Oct 2021 01:53:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJ15GkvKq+IL6sel97tcJPiDq1gKb7O6W0vITpnpDUYgWE9GN4U0YMZRsVTn+rp9WSdDrz X-Received: by 2002:aa7:cb8a:: with SMTP id r10mr15292456edt.237.1634892819595; Fri, 22 Oct 2021 01:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634892819; cv=none; d=google.com; s=arc-20160816; b=hQLDfx/jno13xzxcX3oc4Ry6LUQHXpCAvPclSfCnmMZRQtN/dAzT4LHAXrmR+A3Pxb 1Q31X1e3pJCk9l5JIKTa4cTaIo6aD0bmW/g93ZTumZkz6mRk2UUWeTCbHbiBy66n1ALb 19zPL0idZckTRQC/wiEPSxMbY1T/YlomsO5UE8NhGOXit6rL6u5QzGjYbM6CdvwVsf+U MzrH/HoBYLpEiJKBJYKT/PUFfhfFolZmLiHkeRk6uGUAWjuOglr5WOekMWlkd60Y6OdO M7xSaszINKTMCt7bAOWfhCawViry5v9ipII4CrXNjnAtf8dBAa8ba1PBPX9R4O7fhJYg 27RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=9/AbSYrer0OkGa3hKUx0m3BU5OjaKZZLDfvjQweH0YI=; b=Y4dwhjG8gSfXcK/idB0EV3RcuK4h8jr9hZvbz+3xPXPoPD5IPkDLH8tuK8NR+EeARS nWZDzbYLe+QSC8Vjb259NG6q9qOPLTljyLmg2Brp6kwhT83x5pQeR+Eq1avxSDRTuIMx jfa/jQpqV7Z58L2GNHjVOzX0RyOLe/OlP5FqQ6WIhvNOYX7Q1wECTp84kaBh7dsylxNv U56aKh397D8AIpCRrC6gC94nRrncxYOr2peITRxM17XtXyUnolrzlH96PyMeNRhEUV5S RpK9k9MklffJvPw7Yx4h/h91mltwFLxUuCLoDuSKl1ZNvJQEVUffnkPJ8KdR/EUZlG3S ZH4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dr16si12227250ejc.246.2021.10.22.01.53.39; Fri, 22 Oct 2021 01:53:39 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D1AEF68A881; Fri, 22 Oct 2021 11:53:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 55D5368A755 for ; Fri, 22 Oct 2021 11:53:07 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10144"; a="216176990" X-IronPort-AV: E=Sophos;i="5.87,172,1631602800"; d="scan'208";a="216176990" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 01:52:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,172,1631602800"; d="scan'208";a="495586630" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by orsmga008.jf.intel.com with ESMTP; 22 Oct 2021 01:52:52 -0700 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Oct 2021 16:52:31 +0800 Message-Id: <20211022085231.93931-4-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211022085231.93931-1-jianhua.wu@intel.com> References: <20211022085231.93931-1-jianhua.wu@intel.com> Subject: [FFmpeg-devel] [PATCH 4/4] tests/checkasm: add check for vf_exposure 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: Wu Jianhua MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: laCrvskSGyuc Signed-off-by: Wu Jianhua --- tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 3 ++ tests/checkasm/checkasm.h | 1 + tests/checkasm/vf_exposure.c | 68 ++++++++++++++++++++++++++++++++++++ tests/fate/checkasm.mak | 1 + 5 files changed, 74 insertions(+) create mode 100644 tests/checkasm/vf_exposure.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 4ef5fa87da..7b86ffca6b 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -37,6 +37,7 @@ AVFILTEROBJS-$(CONFIG_AFIR_FILTER) += af_afir.o AVFILTEROBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o AVFILTEROBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o AVFILTEROBJS-$(CONFIG_EQ_FILTER) += vf_eq.o +AVFILTEROBJS-$(CONFIG_EXPOSURE_FILTER) += vf_exposure.o AVFILTEROBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o AVFILTEROBJS-$(CONFIG_HFLIP_FILTER) += vf_hflip.o AVFILTEROBJS-$(CONFIG_THRESHOLD_FILTER) += vf_threshold.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index b1353f7cbe..50961d9961 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -169,6 +169,9 @@ static const struct { #if CONFIG_EQ_FILTER { "vf_eq", checkasm_check_vf_eq }, #endif + #if CONFIG_EXPOSURE_FILTER + { "vf_exposure", checkasm_check_vf_exposure }, + #endif #if CONFIG_GBLUR_FILTER { "vf_gblur", checkasm_check_vf_gblur }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 68b0697d3e..b402894ad3 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -78,6 +78,7 @@ void checkasm_check_utvideodsp(void); void checkasm_check_v210dec(void); void checkasm_check_v210enc(void); void checkasm_check_vf_eq(void); +void checkasm_check_vf_exposure(void); void checkasm_check_vf_gblur(void); void checkasm_check_vf_hflip(void); void checkasm_check_vf_threshold(void); diff --git a/tests/checkasm/vf_exposure.c b/tests/checkasm/vf_exposure.c new file mode 100644 index 0000000000..fb79c920df --- /dev/null +++ b/tests/checkasm/vf_exposure.c @@ -0,0 +1,68 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include "checkasm.h" +#include "libavfilter/exposure.h" + +#define PIXELS 256 +#define BUF_SIZE (PIXELS * 4) + +#define randomize_buffers(buf, size) \ + do { \ + int j; \ + float *tmp_buf = (float *)buf; \ + for (j = 0; j < size; j++) \ + tmp_buf[j] = (float)(rnd() & 0xFF); \ + } while (0) + +static void check_exposure(float *dst_ref, float *dst_new, float black, float scale) +{ + declare_func(void, float *dst, int length, float black, float scale); + call_ref(dst_ref, PIXELS, black, scale); + call_new(dst_new, PIXELS, black, scale); + + if (!float_near_abs_eps_array(dst_ref, dst_new, 0.01f, PIXELS)) { + fail(); + } + bench_new(dst_new, PIXELS, black, scale); +} + +void checkasm_check_vf_exposure(void) +{ + float *dst_ref = av_malloc(BUF_SIZE); + float *dst_new = av_malloc(BUF_SIZE); + ExposureContext s; + + s.black = 0.1; + s.exposure = 1.4; + + randomize_buffers(dst_ref, PIXELS); + memcpy(dst_new, dst_ref, BUF_SIZE); + + ff_exposure_init(&s); + + if (check_func(s.exposure_func, "exposure")) { + check_exposure(dst_ref, dst_new, s.black, s.scale); + } + report("exposure"); + + av_freep(&dst_ref); + av_freep(&dst_new); +} diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak index 6e7edbe655..4d4cd6cc88 100644 --- a/tests/fate/checkasm.mak +++ b/tests/fate/checkasm.mak @@ -34,6 +34,7 @@ FATE_CHECKASM = fate-checkasm-aacpsdsp \ fate-checkasm-vf_blend \ fate-checkasm-vf_colorspace \ fate-checkasm-vf_eq \ + fate-checkasm-vf_exposure \ fate-checkasm-vf_gblur \ fate-checkasm-vf_hflip \ fate-checkasm-vf_nlmeans \