From patchwork Thu Jun 22 10:30:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgQsWTc2No?= X-Patchwork-Id: 4076 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.22.4 with SMTP id 4csp2307346vsw; Thu, 22 Jun 2017 03:31:19 -0700 (PDT) X-Received: by 10.28.93.79 with SMTP id r76mr1214250wmb.64.1498127479227; Thu, 22 Jun 2017 03:31:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498127479; cv=none; d=google.com; s=arc-20160816; b=XulaUd91keny2xhgvSQtJVDdqeHfCbkp+R6cdq7+VX103bzPcz4mVMUs7rOnimiFWI lMwPvNViWKZnWmDtEM63wH2PIxpG0DpQUpZbU9AaeON5kbd7dMtLr5kKdGk5cskoirIq +HssG5ilJw4Omb9DLm6LbTbI9ugPq11uq2z/+wYG3dgYTC4a9YZVtumfNSVJ4hAtS348 RZHNCUe0VQZr0Ywc8SfuyyCx+l3oKQRf1wcCfzcfJYjddwI+tBFRPsHp/23RtgyEfOAG 8/hM52BW3TH0HwxZXMkIa/5lmkKbk6IT4HUcEsPQ/Y9K4hQu9igqiO2zE8bWmXjgZb6z J6aw== 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:references:in-reply-to :message-id:date:to:from:delivered-to:arc-authentication-results; bh=yQ44Tt7rmqM+EUlbtmq2qVLJX5VHmqFgLGytuPfh67Y=; b=CTlP1EChtfFni4Y+Tx5RAaRrexVG10B4nf83rrrAvRi5wWw3dTVFlbbT/55F+iOmpY 6gz4vqW489KHQf8I7jzRBxgu6EchillapfOonr7NF4NP7xLjErDXZjOGueJtLZp2cXMZ El4vDZbfBPxBP/JPxOUtZxGB+mbNVyMhTrg5MHC2KCxciZkB8foRW2pEVhjEbXt/yjNs ccL0sf7J53VZ0yq5vMLTU+fFcvLGPd4jxJ/4/itwFkUn2RZi0hQTQzS4Uzi3US9sWTA+ fEzq/8Bknjuh6AerK29JCgonMvH0/23tEblz8wttR6Rn/6JJ4V2tRXv+UwtCZaLh45xf +HnA== 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l11si1314329wrl.217.2017.06.22.03.31.18; Thu, 22 Jun 2017 03:31: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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3022F68A3CD; Thu, 22 Jun 2017 13:31:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from golem.pkh.me (LStLambert-657-1-117-164.w92-154.abo.wanadoo.fr [92.154.28.164]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E64A868A399 for ; Thu, 22 Jun 2017 13:31:04 +0300 (EEST) Received: from localhost (golem.pkh.me [local]) by golem.pkh.me (OpenSMTPD) with ESMTPA id 367f1c45; Thu, 22 Jun 2017 10:30:59 +0000 (UTC) From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Jun 2017 12:30:55 +0200 Message-Id: <20170622103058.6855-2-u@pkh.me> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170622103058.6855-1-u@pkh.me> References: <20170622103058.6855-1-u@pkh.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/5] checkasm: add AAC PS 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: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= , James Almer Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Clément Bœsch This includes various fixes and improvements from James Almer. Signed-off-by: James Almer --- tests/checkasm/Makefile | 1 + tests/checkasm/aacpsdsp.c | 161 ++++++++++++++++++++++++++++++++++++++++++++++ tests/checkasm/checkasm.c | 3 + tests/checkasm/checkasm.h | 1 + tests/fate/checkasm.mak | 3 +- 5 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 tests/checkasm/aacpsdsp.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 73c2b35da7..638e811931 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -13,6 +13,7 @@ AVCODECOBJS-$(CONFIG_VP8DSP) += vp8dsp.o AVCODECOBJS-$(CONFIG_VIDEODSP) += videodsp.o # decoders/encoders +AVCODECOBJS-$(CONFIG_AAC_DECODER) += aacpsdsp.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/aacpsdsp.c b/tests/checkasm/aacpsdsp.c new file mode 100644 index 0000000000..077da7cbd1 --- /dev/null +++ b/tests/checkasm/aacpsdsp.c @@ -0,0 +1,161 @@ +/* + * 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/aacpsdsp.h" + +#include "checkasm.h" + +#define N 32 +#define STRIDE 128 +#define BUF_SIZE (N * STRIDE) + +#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.001 + +static void test_add_squares(void) +{ + LOCAL_ALIGNED_16(INTFLOAT, dst0, [BUF_SIZE]); + LOCAL_ALIGNED_16(INTFLOAT, dst1, [BUF_SIZE]); + LOCAL_ALIGNED_16(INTFLOAT, src, [BUF_SIZE], [2]); + + declare_func(void, INTFLOAT *dst, + const INTFLOAT (*src)[2], int n); + + randomize((INTFLOAT *)src, BUF_SIZE * 2); + randomize(dst0, BUF_SIZE); + memcpy(dst1, dst0, BUF_SIZE * sizeof(INTFLOAT)); + call_ref(dst0, src, BUF_SIZE); + call_new(dst1, src, BUF_SIZE); + if (!float_near_abs_eps_array(dst0, dst1, EPS, BUF_SIZE)) + fail(); + bench_new(dst1, src, BUF_SIZE); +} + +static void test_mul_pair_single(void) +{ + LOCAL_ALIGNED_16(INTFLOAT, dst0, [BUF_SIZE], [2]); + LOCAL_ALIGNED_16(INTFLOAT, dst1, [BUF_SIZE], [2]); + LOCAL_ALIGNED_16(INTFLOAT, src0, [BUF_SIZE], [2]); + LOCAL_ALIGNED_16(INTFLOAT, src1, [BUF_SIZE]); + + declare_func(void, INTFLOAT (*dst)[2], + INTFLOAT (*src0)[2], INTFLOAT *src1, int n); + + randomize((INTFLOAT *)src0, BUF_SIZE * 2); + randomize(src1, BUF_SIZE); + call_ref(dst0, src0, src1, BUF_SIZE); + call_new(dst1, src0, src1, BUF_SIZE); + if (!float_near_abs_eps_array((float *)dst0, (float *)dst1, EPS, BUF_SIZE * 2)) + fail(); + bench_new(dst1, src0, src1, BUF_SIZE); +} + +static void test_hybrid_analysis(void) +{ + LOCAL_ALIGNED_16(INTFLOAT, dst0, [BUF_SIZE], [2]); + LOCAL_ALIGNED_16(INTFLOAT, dst1, [BUF_SIZE], [2]); + LOCAL_ALIGNED_16(INTFLOAT, in, [12], [2]); + LOCAL_ALIGNED_16(INTFLOAT, filter, [N], [8][2]); + + declare_func(void, INTFLOAT (*out)[2], INTFLOAT (*in)[2], + const INTFLOAT (*filter)[8][2], + int stride, int n); + + randomize((INTFLOAT *)in, 12 * 2); + randomize((INTFLOAT *)filter, N * 8 * 2); + + randomize((INTFLOAT *)dst0, BUF_SIZE * 2); + memcpy(dst1, dst0, BUF_SIZE * 2 * sizeof(INTFLOAT)); + + call_ref(dst0, in, filter, STRIDE, N); + call_new(dst1, in, filter, STRIDE, N); + + if (!float_near_abs_eps_array((float *)dst0, (float *)dst1, EPS, BUF_SIZE * 2)) + fail(); + bench_new(dst1, in, filter, STRIDE, N); +} + +static void test_stereo_interpolate(PSDSPContext *psdsp) +{ + int i; + LOCAL_ALIGNED_16(INTFLOAT, l, [BUF_SIZE], [2]); + LOCAL_ALIGNED_16(INTFLOAT, r, [BUF_SIZE], [2]); + LOCAL_ALIGNED_16(INTFLOAT, l0, [BUF_SIZE], [2]); + LOCAL_ALIGNED_16(INTFLOAT, r0, [BUF_SIZE], [2]); + LOCAL_ALIGNED_16(INTFLOAT, l1, [BUF_SIZE], [2]); + LOCAL_ALIGNED_16(INTFLOAT, r1, [BUF_SIZE], [2]); + LOCAL_ALIGNED_16(INTFLOAT, h, [2], [4]); + LOCAL_ALIGNED_16(INTFLOAT, h_step, [2], [4]); + + declare_func(void, INTFLOAT (*l)[2], INTFLOAT (*r)[2], + INTFLOAT h[2][4], INTFLOAT h_step[2][4], int len); + + randomize((INTFLOAT *)l, BUF_SIZE * 2); + randomize((INTFLOAT *)r, BUF_SIZE * 2); + + randomize((INTFLOAT *)h, 2 * 4); + randomize((INTFLOAT *)h_step, 2 * 4); + + for (i = 0; i < 2; i++) { + if (check_func(psdsp->stereo_interpolate[i], "ps_stereo_interpolate%s", i ? "_ipdopd" : "")) { + memcpy(l0, l, BUF_SIZE * 2 * sizeof(INTFLOAT)); + memcpy(l1, l, BUF_SIZE * 2 * sizeof(INTFLOAT)); + memcpy(r0, r, BUF_SIZE * 2 * sizeof(INTFLOAT)); + memcpy(r1, r, BUF_SIZE * 2 * sizeof(INTFLOAT)); + + call_ref(l0, r0, h, h_step, BUF_SIZE); + call_new(l1, r1, h, h_step, BUF_SIZE); + if (!float_near_abs_eps_array((float *)l0, (float *)l1, EPS, BUF_SIZE * 2) || + !float_near_abs_eps_array((float *)r0, (float *)r1, EPS, BUF_SIZE * 2)) + fail(); + + memcpy(l1, l, BUF_SIZE * 2 * sizeof(INTFLOAT)); + memcpy(r1, r, BUF_SIZE * 2 * sizeof(INTFLOAT)); + bench_new(l1, r1, h, h_step, BUF_SIZE); + } + } +} + +void checkasm_check_aacpsdsp(void) +{ + PSDSPContext psdsp; + + ff_psdsp_init(&psdsp); + + if (check_func(psdsp.add_squares, "ps_add_squares")) + test_add_squares(); + report("add_squares"); + + if (check_func(psdsp.mul_pair_single, "ps_mul_pair_single")) + test_mul_pair_single(); + report("mul_pair_single"); + + if (check_func(psdsp.hybrid_analysis, "ps_hybrid_analysis")) + test_hybrid_analysis(); + report("hybrid_analysis"); + + test_stereo_interpolate(&psdsp); + report("stereo_interpolate"); +} diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 0b86627cc9..e66744b162 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -65,6 +65,9 @@ static const struct { void (*func)(void); } tests[] = { #if CONFIG_AVCODEC + #if CONFIG_AAC_DECODER + { "aacpsdsp", checkasm_check_aacpsdsp }, + #endif #if CONFIG_ALAC_DECODER { "alacdsp", checkasm_check_alacdsp }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 2093210b42..dfb0ce561c 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -31,6 +31,7 @@ #include "libavutil/lfg.h" #include "libavutil/timer.h" +void checkasm_check_aacpsdsp(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 cf84f477a8..61ce6cd74f 100644 --- a/tests/fate/checkasm.mak +++ b/tests/fate/checkasm.mak @@ -1,4 +1,5 @@ -FATE_CHECKASM = fate-checkasm-alacdsp \ +FATE_CHECKASM = fate-checkasm-aacpsdsp \ + fate-checkasm-alacdsp \ fate-checkasm-audiodsp \ fate-checkasm-blockdsp \ fate-checkasm-bswapdsp \