From patchwork Thu Jan 3 00:43:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 11640 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 446CC44DD4B for ; Thu, 3 Jan 2019 02:52:04 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EC65F68A26C; Thu, 3 Jan 2019 02:52:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C3BE3689F1F for ; Thu, 3 Jan 2019 02:51:54 +0200 (EET) Received: by mail-qk1-f195.google.com with SMTP id z18so2894256qkj.10 for ; Wed, 02 Jan 2019 16:52:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=mG8DFOkaRbX7C6KmX0UDPawLpMVIe6BmdVaQaVWU/is=; b=oyZIupjc6FkdRs09qO00GY1vqQwiKOLoFtQSSNdwOxNljQGdA95ii35sQAe8eEVq0z z3WOUB5lJzz6zYUrwe3ofufAJHLTYGDucyHiD/gtHSoogWNdDBNug/zmJY723xPRT9hq 3ZQw6/8XqP/qunn0hbb2xtuIb5I3d4HiDLBAwJ0ALrMP6dRHTuM9VAXcr7WwFWGANq+D 17YMouskt4jJ4hf99egHTMYbZqMfNyL4gS2zYsXaD1ns60icLo2/Hns+Ff8RimOsO3Q2 j/49SJ+QIEJLO8sbJ2O1ijktInUR4OeX0nUIsgw5JWpgkhqtzus1qSyUIJsh9KEmcu80 QYOw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=mG8DFOkaRbX7C6KmX0UDPawLpMVIe6BmdVaQaVWU/is=; b=tHaGOH3MCks/PiJIUJb6C7EOApXcSRR+sR06M8Ie6LM2yYgEmXsxjyS4x3QTPG4fC9 DRfynJxGZatwSNWCB0IRsCfULSE+XK/ZppheoleV+4smfR2q4WJYKgF88sSyCWKMQHlb ulaXlcD3G29CO6be6BM+G9kO+ZKostLxeivPt6YOGKUSJ4lam4tk+H7czK2grXbHzrcN kNipMurSyPyscF8YgzCnk9asbuhcjNm8pZaJaRfO+HDov7/A4T5uIpTcKn+cd7Vn/ioT 4pDLMJ2AGP/03mcKOAvJ88YaMB0dFnu6WiKY7CCrE59IuBLXjb9+J54UTYjR/aAUvnH4 SUhA== X-Gm-Message-State: AJcUukdLZYGJx7g6FVWFRJVYKQVTR/JyjBZIStsZRs4oSapDC5YKihx+ VhpFlCUhTRPCy1DGyRLQOYaKyon4RyY= X-Google-Smtp-Source: ALg8bN47aatzjul5XO5tGEPlrlB+Fxmy7Jri/KiMZbJL8o+ADfGK0ofrq2YaS7PU3ZxxFvmAqwHP3g== X-Received: by 2002:a37:a604:: with SMTP id p4mr41581332qke.253.1546476252167; Wed, 02 Jan 2019 16:44:12 -0800 (PST) Received: from localhost.localdomain ([179.38.167.144]) by smtp.gmail.com with ESMTPSA id o34sm23090515qte.4.2019.01.02.16.44.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Jan 2019 16:44:11 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Jan 2019 21:43:56 -0300 Message-Id: <20190103004357.5604-3-jamrial@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190103004357.5604-1-jamrial@gmail.com> References: <20190103004357.5604-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] checkasm: add an af_afir test 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: James Almer --- tests/checkasm/Makefile | 1 + tests/checkasm/af_afir.c | 83 +++++++++++++++++++++++++++++++++++++++ tests/checkasm/checkasm.c | 3 ++ tests/checkasm/checkasm.h | 1 + tests/fate/checkasm.mak | 1 + 5 files changed, 89 insertions(+) create mode 100644 tests/checkasm/af_afir.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 9484acbbd7..47b7b06d28 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -31,6 +31,7 @@ AVCODECOBJS-$(CONFIG_VP9_DECODER) += vp9dsp.o CHECKASMOBJS-$(CONFIG_AVCODEC) += $(AVCODECOBJS-yes) # libavfilter tests +AVFILTEROBJS-$(CONFIG_AFIR_FILTER) += af_afir.o AVFILTEROBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o AVFILTEROBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o AVFILTEROBJS-$(CONFIG_HFLIP_FILTER) += vf_hflip.o diff --git a/tests/checkasm/af_afir.c b/tests/checkasm/af_afir.c new file mode 100644 index 0000000000..54e2f68d6c --- /dev/null +++ b/tests/checkasm/af_afir.c @@ -0,0 +1,83 @@ +/* + * 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 "config.h" + +#include +#include + +#include "libavfilter/af_afir.h" +#include "libavutil/internal.h" +#include "checkasm.h" + +#define LEN 256 + +#define randomize_buffer(buf) \ +do { \ + int i; \ + double bmg[2], stddev = 10.0, mean = 0.0; \ + \ + for (i = 0; i < LEN*2+8; i += 2) { \ + av_bmg_get(&checkasm_lfg, bmg); \ + buf[i] = bmg[0] * stddev + mean; \ + buf[i + 1] = bmg[1] * stddev + mean; \ + } \ +} while(0); + +static void test_fcmul_add(const float *src0, const float *src1, const float *src2) +{ + LOCAL_ALIGNED_32(float, cdst, [LEN*2+8]); + LOCAL_ALIGNED_32(float, odst, [LEN*2+8]); + int i; + + declare_func(void, float *sum, const float *t, const float *c, + ptrdiff_t len); + + memcpy(cdst, src0, (LEN*2+8) * sizeof(float)); + memcpy(odst, src0, (LEN*2+8) * sizeof(float)); + call_ref(cdst, src1, src2, LEN); + call_new(odst, src1, src2, LEN); + for (i = 0; i <= LEN*2; i++) { + if (!float_near_abs_eps(cdst[i], odst[i], FLT_EPSILON)) { + fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", + i, cdst[i], odst[i], cdst[i] - odst[i]); + fail(); + break; + } + } + memcpy(odst, src0, (LEN*2+8) * sizeof(float)); + bench_new(odst, src1, src2, LEN); +} + +void checkasm_check_afir(void) +{ + LOCAL_ALIGNED_32(float, src0, [LEN*2+8]); + LOCAL_ALIGNED_32(float, src1, [LEN*2+8]); + LOCAL_ALIGNED_32(float, src2, [LEN*2+8]); + AudioFIRDSPContext fir = { 0 }; + + ff_afir_init(&fir); + + randomize_buffer(src0); + randomize_buffer(src1); + randomize_buffer(src2); + + if (check_func(fir.fcmul_add, "fcmul_add")) + test_fcmul_add(src0, src1, src2); + report("fcmul_add"); +} diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 721a0912fb..c3f5160132 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -150,6 +150,9 @@ static const struct { #endif #endif #if CONFIG_AVFILTER + #if CONFIG_AFIR_FILTER + { "af_afir", checkasm_check_afir }, + #endif #if CONFIG_BLEND_FILTER { "vf_blend", checkasm_check_blend }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index c45cfb46f8..9e8e879fd3 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -40,6 +40,7 @@ #include "libavutil/timer.h" void checkasm_check_aacpsdsp(void); +void checkasm_check_afir(void); void checkasm_check_alacdsp(void); void checkasm_check_audiodsp(void); void checkasm_check_blend(void); diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak index a722b4a917..d59e9d293a 100644 --- a/tests/fate/checkasm.mak +++ b/tests/fate/checkasm.mak @@ -1,4 +1,5 @@ FATE_CHECKASM = fate-checkasm-aacpsdsp \ + fate-checkasm-af_afir \ fate-checkasm-alacdsp \ fate-checkasm-audiodsp \ fate-checkasm-blockdsp \