From patchwork Thu Jun 22 12:56:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthieu Bouron X-Patchwork-Id: 4079 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.22.4 with SMTP id 4csp46394vsw; Thu, 22 Jun 2017 05:56:56 -0700 (PDT) X-Received: by 10.28.218.145 with SMTP id r139mr363752wmg.69.1498136216396; Thu, 22 Jun 2017 05:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498136216; cv=none; d=google.com; s=arc-20160816; b=OW09SRIHN7qJ6mYjkR+P7YQzPlELJjqaxp7JjTczc5OIlKFGL/1PYboRvbQNrBPOF5 8zidy8WeN0CC3d6BsEiyICmR5cgOczPePWomlg8cJhHoSvyRWY1JWtqvuR09Ct98n4LV 4RI2EkWGxWg2v3Y785MIoNWAm5+fKcTG5THWih0TrLLJVMM68I2wJE95TkZmHC6yBDIn BEw70ryE9q5SyVx+GPbXsX/2YPUi01Vp+YpW6fRwnva6vj42448nQTO/gI5e/FALHAvg fHw8rlxwEtqQ7RMaWic9zvdwhVlwV+XaHzEx2QqH+MleLbRWXIBcNEq4VRtLz7Z9xByL vRmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=U9+klk55K1RjHhNJmiCz37Lr/pLa4sUTsKbymEPhsIk=; b=eLEtD0FyGV7v9S1MWSsB4AZJXIOg6Co/vu0zjrAk9cm3r//Ltb6tiBssCn0k4PzH2Z h70plr9PImJtYnmEGJBrNLqDniW027PAOLGRLdeegTnPECuwAH9b5s+lzz1fwWHBq/+D Kdzf0nt20VU473ih2r1Du38M5bZp10fYCsGVAMjCQh+oGb5WGg+8+4Hg+IMjRl8xa9TP hkXeA6o8pGYUzJqfsGeykqB6kOhMTUUQJvwFGoXktsVbPoTcAeqp1/sE49XiDYijCj+/ rTZzIVCaRpRAZHeDjOEUmz7NTJc3HHgUEVrqz+GNBAuDUNSLk1mI6Ulh8aDGqohodu0X irhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.b=WRj0DpzW; 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=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l26si1321102wre.270.2017.06.22.05.56.55; Thu, 22 Jun 2017 05:56:56 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.b=WRj0DpzW; 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=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3B41F68A362; Thu, 22 Jun 2017 15:56:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 32B3168A326 for ; Thu, 22 Jun 2017 15:56:46 +0300 (EEST) Received: by mail-wr0-f193.google.com with SMTP id x23so4505969wrb.0 for ; Thu, 22 Jun 2017 05:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=74QlAAeaMhrAj5BLEFCvBeY6n6GGgRaS+ABh4Nu+vm0=; b=WRj0DpzWSNoATC7NRSuLmzsPTr8JajqU8HPPdQ0RqthQNcuHeGBtMhdxAWnguLgOKU bV9plUwOYWopxJ06V/ISluXM0jKX5XLpRNsRm0LCTJVUVuI4Zb9Q2SKmvBEZwKRq/cEw 5chAY9sz9W/emBNA5S9zRE0q3aq6F47/uUxZXdzBLTiSvdpN7x/0zJITRk9QMriRQsNE TRNEG7EZQIUKI4WjLulb/oEw3i/R6870lITd6bbWKMWC3y3TxliH2dxG9S0QNgztNMJ7 5eyLVbF6pRh9NV0M0VcnYn14kUx2wysV8cOUFtNVv/rLRD/+9rwmiuY7tJIaKeEPkhOZ 2Smg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=74QlAAeaMhrAj5BLEFCvBeY6n6GGgRaS+ABh4Nu+vm0=; b=GBbIOlXXyropv2mtsdRl6JGLQkKFvgFElhttnAWgU8MGAX8OLYfXyk9MfPsSz9NqTR H+qRQ7b+DJFbuOlP64zyukCNkWKUPBPUm4XFA5xbgkHfpki7d4rjzetw3mbbN6olZr8T fohrPlIUaLW6RvfQe7djNvSi2zonC+aC4gq6O69QSGfe4PAfL5bapkUg6RqV+jbpZNBC JT/SD5Fqq5vMj0VVCQlkTDDFwP2JZNDoFO2sKIrb1XR+qn712e1d6r5PevIRxChdIsv1 qVG/98ivAE9cDsTVaNTVOR2f7SwXRTlyTIQg/wA1KNNcCqbSTNiAu5Naj2FAXzfG7mFR t95Q== X-Gm-Message-State: AKS2vOzGWkiXoSpyRsskO7qyU9EfnhORZa5Y3xuYKpBOlJERZXHPn5fZ QnEkgf0ZMfZ1dKl2 X-Received: by 10.28.137.20 with SMTP id l20mr1686257wmd.54.1498136205057; Thu, 22 Jun 2017 05:56:45 -0700 (PDT) Received: from boken.gopro.lcl (73.136-14-84.ripe.coltfrance.com. [84.14.136.73]) by smtp.gmail.com with ESMTPSA id 6sm1176384wrg.61.2017.06.22.05.56.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 05:56:44 -0700 (PDT) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Jun 2017 14:56:27 +0200 Message-Id: <20170622125628.24516-1-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.13.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] checkasm: add sbrdsp tests 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 Cc: Matthieu Bouron Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- The following patchset applies on top of Clément's aacpsdsp patchset. --- tests/checkasm/Makefile | 3 +- tests/checkasm/checkasm.c | 1 + tests/checkasm/checkasm.h | 1 + tests/checkasm/sbrdsp.c | 297 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 301 insertions(+), 1 deletion(-) create mode 100644 tests/checkasm/sbrdsp.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 638e811931..60e80ab738 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -13,7 +13,8 @@ AVCODECOBJS-$(CONFIG_VP8DSP) += vp8dsp.o AVCODECOBJS-$(CONFIG_VIDEODSP) += videodsp.o # decoders/encoders -AVCODECOBJS-$(CONFIG_AAC_DECODER) += aacpsdsp.o +AVCODECOBJS-$(CONFIG_AAC_DECODER) += aacpsdsp.o \ + sbrdsp.o AVCODECOBJS-$(CONFIG_ALAC_DECODER) += alacdsp.o AVCODECOBJS-$(CONFIG_DCA_DECODER) += synth_filter.o AVCODECOBJS-$(CONFIG_JPEG2000_DECODER) += jpeg2000dsp.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index e66744b162..29f201b1b3 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -67,6 +67,7 @@ static const struct { #if CONFIG_AVCODEC #if CONFIG_AAC_DECODER { "aacpsdsp", checkasm_check_aacpsdsp }, + { "sbrdsp", checkasm_check_sbrdsp }, #endif #if CONFIG_ALAC_DECODER { "alacdsp", checkasm_check_alacdsp }, diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index dfb0ce561c..fa51e71e4b 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -50,6 +50,7 @@ void checkasm_check_hevc_idct(void); void checkasm_check_jpeg2000dsp(void); void checkasm_check_llviddsp(void); void checkasm_check_pixblockdsp(void); +void checkasm_check_sbrdsp(void); void checkasm_check_synth_filter(void); void checkasm_check_v210enc(void); void checkasm_check_vp8dsp(void); diff --git a/tests/checkasm/sbrdsp.c b/tests/checkasm/sbrdsp.c new file mode 100644 index 0000000000..8333510c6b --- /dev/null +++ b/tests/checkasm/sbrdsp.c @@ -0,0 +1,297 @@ +/* + * 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 "libavcodec/sbrdsp.h" + +#include "checkasm.h" + +#define randomize(buf, len) do { \ + int i; \ + for (i = 0; i < len; i++) { \ + const INTFLOAT f = (INTFLOAT)rnd() / UINT_MAX; \ + (buf)[i] = f; \ + } \ +} while (0) + +#define EPS 0.0001 + +static void test_sum64x5(void) +{ + LOCAL_ALIGNED_16(INTFLOAT, dst0, [64 + 256]); + LOCAL_ALIGNED_16(INTFLOAT, dst1, [64 + 256]); + + declare_func(void, INTFLOAT *z); + + randomize((INTFLOAT *)dst0, 64 + 256); + memcpy(dst1, dst0, (64 + 256) * sizeof(INTFLOAT)); + call_ref(dst0); + call_new(dst1); + if (!float_near_abs_eps_array(dst0, dst1, EPS, 64 + 256)) + fail(); + bench_new(dst1); +} + +static void test_sum_square(void) +{ + INTFLOAT res0; + INTFLOAT res1; + LOCAL_ALIGNED_16(INTFLOAT, src, [256], [2]); + + declare_func(INTFLOAT, INTFLOAT (*x)[2], int n); + + randomize((INTFLOAT *)src, 256 * 2); + res0 = call_ref(src, 256); + res1 = call_new(src, 256); + if (!float_near_abs_eps(res0, res1, EPS)) + fail(); + bench_new(src, 256); +} + +static void test_neg_odd_64(void) +{ + LOCAL_ALIGNED_16(INTFLOAT, dst0, [64]); + LOCAL_ALIGNED_16(INTFLOAT, dst1, [64]); + + declare_func(void, INTFLOAT *x); + + randomize((INTFLOAT *)dst0, 64); + memcpy(dst1, dst0, (64) * sizeof(INTFLOAT)); + call_ref(dst0); + call_new(dst1); + if (!float_near_abs_eps_array(dst0, dst1, EPS, 64)) + fail(); + bench_new(dst1); +} + +static void test_qmf_pre_shuffle(void) +{ + LOCAL_ALIGNED_16(INTFLOAT, dst0, [128]); + LOCAL_ALIGNED_16(INTFLOAT, dst1, [128]); + + declare_func(void, INTFLOAT *z); + + randomize((INTFLOAT *)dst0, 128); + memcpy(dst1, dst0, (128) * sizeof(INTFLOAT)); + call_ref(dst0); + call_new(dst1); + if (!float_near_abs_eps_array(dst0, dst1, EPS, 128)) + fail(); + bench_new(dst1); +} + +static void test_qmf_post_shuffle(void) +{ + LOCAL_ALIGNED_16(INTFLOAT, src, [64]); + LOCAL_ALIGNED_16(INTFLOAT, dst0, [32], [2]); + LOCAL_ALIGNED_16(INTFLOAT, dst1, [32], [2]); + + declare_func(void, INTFLOAT W[32][2], const INTFLOAT *z); + + randomize((INTFLOAT *)src, 64); + call_ref(dst0, src); + call_new(dst1, src); + if (!float_near_abs_eps_array((INTFLOAT *)dst0, (INTFLOAT *)dst1, EPS, 64)) + fail(); + bench_new(dst1, src); +} + +static void test_qmf_deint_neg(void) +{ + LOCAL_ALIGNED_16(INTFLOAT, src, [64]); + LOCAL_ALIGNED_16(INTFLOAT, dst0, [64]); + LOCAL_ALIGNED_16(INTFLOAT, dst1, [64]); + + declare_func(void, INTFLOAT *v, const INTFLOAT *src); + + randomize((INTFLOAT *)src, 64); + call_ref(dst0, src); + call_new(dst1, src); + if (!float_near_abs_eps_array(dst0, dst1, EPS, 64)) + fail(); + bench_new(dst1, src); +} + +static void test_qmf_deint_bfly(void) +{ + LOCAL_ALIGNED_16(INTFLOAT, src0, [64]); + LOCAL_ALIGNED_16(INTFLOAT, src1, [64]); + LOCAL_ALIGNED_16(INTFLOAT, dst0, [128]); + LOCAL_ALIGNED_16(INTFLOAT, dst1, [128]); + + declare_func(void, INTFLOAT *v, const INTFLOAT *src0, const INTFLOAT *src1); + + memset(dst0, 0, 128 * sizeof(INTFLOAT)); + memset(dst1, 0, 128 * sizeof(INTFLOAT)); + + randomize((INTFLOAT *)src0, 64); + randomize((INTFLOAT *)src1, 64); + call_ref(dst0, src0, src1); + call_new(dst1, src0, src1); + if (!float_near_abs_eps_array(dst0, dst1, EPS, 128)) + fail(); + bench_new(dst1, src0, src1); +} + +static void test_autocorrelate(void) +{ + LOCAL_ALIGNED_16(INTFLOAT, src, [40], [2]); + LOCAL_ALIGNED_16(INTFLOAT, dst0, [3], [2][2]); + LOCAL_ALIGNED_16(INTFLOAT, dst1, [3], [2][2]); + + declare_func(void, const INTFLOAT x[40][2], INTFLOAT phi[3][2][2]); + + memset(dst0, 0, 3 * 2 * 2 * sizeof(INTFLOAT)); + memset(dst1, 0, 3 * 2 * 2 * sizeof(INTFLOAT)); + + randomize((INTFLOAT *)src, 80); + call_ref(src, dst0); + call_new(src, dst1); + if (!float_near_abs_eps_array((INTFLOAT *)dst0, (INTFLOAT *)dst1, EPS, 3 * 2 * 2)) + fail(); + bench_new(src, dst1); +} + +static void test_hf_gen(void) +{ + LOCAL_ALIGNED_16(INTFLOAT, low, [128], [2]); + LOCAL_ALIGNED_16(INTFLOAT, alpha0, [2]); + LOCAL_ALIGNED_16(INTFLOAT, alpha1, [2]); + LOCAL_ALIGNED_16(INTFLOAT, dst0, [128], [2]); + LOCAL_ALIGNED_16(INTFLOAT, dst1, [128], [2]); + INTFLOAT bw = (INTFLOAT)rnd() / UINT_MAX; + int i; + + declare_func(void, INTFLOAT (*X_high)[2], const INTFLOAT (*X_low)[2], + const INTFLOAT alpha0[2], const INTFLOAT alpha1[2], + INTFLOAT bw, int start, int end); + + randomize((INTFLOAT *)low, 128 * 2); + randomize((INTFLOAT *)alpha0, 2); + randomize((INTFLOAT *)alpha1, 2); + for (i = 2; i < 64; i += 2) { + memset(dst0, 0, 128 * 2 * sizeof(INTFLOAT)); + memset(dst1, 0, 128 * 2 * sizeof(INTFLOAT)); + call_ref(dst0, low, alpha0, alpha1, 0.0, i, 128); + call_new(dst1, low, alpha0, alpha1, 0.0, i, 128); + if (!float_near_abs_eps_array((INTFLOAT *)dst0, (INTFLOAT *)dst1, EPS, 128 * 2)) + fail(); + bench_new(dst1, low, alpha0, alpha1, bw, i, 128); + } +} + +static void test_hf_g_filt(void) +{ + LOCAL_ALIGNED_16(INTFLOAT, high, [128], [40][2]); + LOCAL_ALIGNED_16(INTFLOAT, g_filt, [128]); + LOCAL_ALIGNED_16(INTFLOAT, dst0, [128], [2]); + LOCAL_ALIGNED_16(INTFLOAT, dst1, [128], [2]); + + declare_func(void, INTFLOAT (*Y)[2], const INTFLOAT (*X_high)[40][2], + const INTFLOAT *g_filt, int m_max, intptr_t ixh); + + randomize((INTFLOAT *)high, 128 * 40 * 2); + randomize((INTFLOAT *)g_filt, 128); + + call_ref(dst0, high, g_filt, 128, 20); + call_new(dst1, high, g_filt, 128, 20); + if (!float_near_abs_eps_array((INTFLOAT *)dst0, (INTFLOAT *)dst1, EPS, 128 * 2)) + fail(); + bench_new(dst1, high, g_filt, 128, 20); +} + +static void test_hf_apply_noise(void) +{ + LOCAL_ALIGNED_16(AAC_FLOAT, s_m, [128]); + LOCAL_ALIGNED_16(AAC_FLOAT, q_filt, [128]); + LOCAL_ALIGNED_16(INTFLOAT, ref, [128], [2]); + LOCAL_ALIGNED_16(INTFLOAT, dst0, [128], [2]); + LOCAL_ALIGNED_16(INTFLOAT, dst1, [128], [2]); + int noise = 0x2a; + int i; + + declare_func(void, INTFLOAT (*Y)[2], const AAC_FLOAT *s_m, + const AAC_FLOAT *q_filt, int noise, + int kx, int m_max); + + randomize((INTFLOAT *)ref, 128 * 2); + randomize((INTFLOAT *)s_m, 128); + randomize((INTFLOAT *)q_filt, 128); + for (i = 0; i < 2; i++) { + memcpy(dst0, ref, 128 * 2 * sizeof(INTFLOAT)); + memcpy(dst1, ref, 128 * 2 * sizeof(INTFLOAT)); + call_ref(dst0, s_m, q_filt, noise, i, 128); + call_new(dst1, s_m, q_filt, noise, i, 128); + if (!float_near_abs_eps_array((INTFLOAT *)dst0, (INTFLOAT *)dst1, EPS, 128 * 2)) + fail(); + bench_new(dst1, s_m, q_filt, noise, i, 128); + } +} + +void checkasm_check_sbrdsp(void) +{ + int i; + SBRDSPContext sbrdsp; + + ff_sbrdsp_init(&sbrdsp); + + if (check_func(sbrdsp.sum64x5, "sum64x5")) + test_sum64x5(); + report("sum64x5"); + + if (check_func(sbrdsp.sum_square, "sum_square")) + test_sum_square(); + report("sum_square"); + + if (check_func(sbrdsp.neg_odd_64, "neg_odd_64")) + test_neg_odd_64(); + report("neg_odd_64"); + + if (check_func(sbrdsp.qmf_pre_shuffle, "qmf_pre_shuffle")) + test_qmf_pre_shuffle(); + report("qmf_pre_shuffle"); + + if (check_func(sbrdsp.qmf_post_shuffle, "qmf_post_shuffle")) + test_qmf_post_shuffle(); + report("qmf_post_shuffle"); + + if (check_func(sbrdsp.qmf_deint_neg, "qmf_deint_neg")) + test_qmf_deint_neg(); + report("qmf_deint_neg"); + + if (check_func(sbrdsp.qmf_deint_bfly, "qmf_deint_bfly")) + test_qmf_deint_bfly(); + report("qmf_deint_bfly"); + + if (check_func(sbrdsp.autocorrelate, "autocorrelate")) + test_autocorrelate(); + report("autocorrelate"); + + if (check_func(sbrdsp.hf_gen, "hf_gen")) + test_hf_gen(); + report("hf_gen"); + + if (check_func(sbrdsp.hf_g_filt, "hf_g_filt")) + test_hf_g_filt(); + report("hf_g_filt"); + + for (i = 0; i < 4; i++) { + if (check_func(sbrdsp.hf_apply_noise[i], "hf_apply_noise_%d", i)) + test_hf_apply_noise(); + } + report("hf_apply_noise"); +}