From patchwork Thu Aug 15 10:48:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 14524 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 A64084475B0 for ; Thu, 15 Aug 2019 13:48:10 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8FABF68A996; Thu, 15 Aug 2019 13:48:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8525D6808AE for ; Thu, 15 Aug 2019 13:48:03 +0300 (EEST) Received: from w2.tutanota.de (unknown [192.168.1.163]) by w4.tutanota.de (Postfix) with ESMTP id 1884B10600E9 for ; Thu, 15 Aug 2019 10:48:03 +0000 (UTC) Authentication-Results: w4.tutanota.de; dkim=pass (2048-bit key; secure) header.d=lynne.ee header.i=@lynne.ee header.b="FYx+NEp2"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1565866083; s=s1; d=lynne.ee; h=Date:From:To:Message-ID:In-Reply-To:References:Subject:MIME-Version:Content-Type; bh=J1OZl9KwPp/jTbKd/nHbg8jUmi4CvpjrYZy4aJPoKH8=; b=FYx+NEp2lkBeH6L0c8p6znv9TUa4xvWi5yix45s3TIFpV/9d+riMQVbeErPQ/lS3 +4hCuFkUTuYxN2u17g1TZpyn9Z9RylSbOLeO+SleDlfEfODURAcdQZA7PDmGHxnjNy6 ewHNT+AiNGRnzKUbpckQW2sapRFnHHocuJ40e/VzBLPus+dyoj3Ojz5f8azl7usNI+z xeRH4Vad4AZWyK/lUtQWyl3CtOm8dARSw7vvdYZa8g9UU3rBlvAlDr9RDARj+iM3jMM uAYrw399x79Y9Hk0HejyWPK720TbDQoWOdPYNV2awDSRVZvRGYQvdAwxQCsYExQP9Kz qLBxRajiRA== Date: Thu, 15 Aug 2019 12:48:03 +0200 (CEST) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] checkasm: add opusdsp 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Patch attached. From 399dd39c2e99ee3aa3d284019eb8c01abbdedcc0 Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 15 Aug 2019 11:42:19 +0100 Subject: [PATCH 2/2] checkasm: add opusdsp tests --- tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 3 ++ tests/checkasm/checkasm.h | 1 + tests/checkasm/opusdsp.c | 103 ++++++++++++++++++++++++++++++++++++++ tests/fate/checkasm.mak | 1 + 5 files changed, 109 insertions(+) create mode 100644 tests/checkasm/opusdsp.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index f5780eedb2..0112ff603e 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -22,6 +22,7 @@ AVCODECOBJS-$(CONFIG_DCA_DECODER) += synth_filter.o AVCODECOBJS-$(CONFIG_EXR_DECODER) += exrdsp.o AVCODECOBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuvdsp.o AVCODECOBJS-$(CONFIG_JPEG2000_DECODER) += jpeg2000dsp.o +AVCODECOBJS-$(CONFIG_OPUS_DECODER) += opusdsp.o AVCODECOBJS-$(CONFIG_PIXBLOCKDSP) += pixblockdsp.o AVCODECOBJS-$(CONFIG_HEVC_DECODER) += hevc_add_res.o hevc_idct.o hevc_sao.o AVCODECOBJS-$(CONFIG_UTVIDEO_DECODER) += utvideodsp.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 3e2ec377be..d9a5c7f401 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -130,6 +130,9 @@ static const struct { #if CONFIG_LLVIDENCDSP { "llviddspenc", checkasm_check_llviddspenc }, #endif + #if CONFIG_OPUS_DECODER + { "opusdsp", checkasm_check_opusdsp }, + #endif #if CONFIG_PIXBLOCKDSP { "pixblockdsp", checkasm_check_pixblockdsp }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index aed15b5fa4..fdf9eeb75d 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -64,6 +64,7 @@ void checkasm_check_jpeg2000dsp(void); void checkasm_check_llviddsp(void); void checkasm_check_llviddspenc(void); void checkasm_check_nlmeans(void); +void checkasm_check_opusdsp(void); void checkasm_check_pixblockdsp(void); void checkasm_check_sbrdsp(void); void checkasm_check_synth_filter(void); diff --git a/tests/checkasm/opusdsp.c b/tests/checkasm/opusdsp.c new file mode 100644 index 0000000000..279a92e5c6 --- /dev/null +++ b/tests/checkasm/opusdsp.c @@ -0,0 +1,103 @@ +/* + * 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/opusdsp.h" + +#include "checkasm.h" + +#define randomize_float(buf, len) \ + do { \ + for (int i = 0; i < len; i++) { \ + float f = (float)rnd() / (UINT_MAX >> 5) - 16.0f; \ + buf[i] = f; \ + } \ + } while (0) + +#define EPS 0.005 +#define MAX_SIZE (960) + +/* period is between 15 and 1022, inclusive */ +static void test_postfilter(int period) +{ + LOCAL_ALIGNED(16, float, data0, [MAX_SIZE + 1024]); + LOCAL_ALIGNED(16, float, data1, [MAX_SIZE + 1024]); + + /* This filter can explode very easily, so use a tapset from the codec. + * In the codec these are usually multiplied by at least 0.09375f, + * so its outside the largest filter value, but the filter is still stable + * so use it. */ + float gains[3] = { 0.3066406250f, 0.2170410156f, 0.1296386719f }; + + /* The codec will always call with an offset which is aligned once + * (period + 2) is subtracted, but here we have to align it outselves. */ + int offset = FFALIGN(period + 2, 4); + + declare_func(void, float *data, int period, float *gains, int len); + + randomize_float(data0, MAX_SIZE + 1024); + memcpy(data1, data0, (MAX_SIZE + 1024)*sizeof(float)); + + call_ref(data0 + offset, period, gains, MAX_SIZE); + call_new(data1 + offset, period, gains, MAX_SIZE); + + if (!float_near_abs_eps_array(data0 + offset, data1 + offset, EPS, MAX_SIZE)) + fail(); + bench_new(data1 + offset, period, gains, MAX_SIZE); +} + +static void test_deemphasis(void) +{ + LOCAL_ALIGNED(16, float, src, [FFALIGN(MAX_SIZE, 4)]); + LOCAL_ALIGNED(16, float, dst0, [FFALIGN(MAX_SIZE, 4)]); + LOCAL_ALIGNED(16, float, dst1, [FFALIGN(MAX_SIZE, 4)]); + float coeff0 = (float)rnd() / (UINT_MAX >> 5) - 16.0f, coeff1 = coeff0; + + declare_func(float, float *out, float *in, float coeff, int len); + + randomize_float(src, MAX_SIZE); + + coeff0 = call_ref(dst0, src, coeff0, MAX_SIZE); + coeff1 = call_new(dst1, src, coeff1, MAX_SIZE); + + if (!float_near_abs_eps(coeff0, coeff1, EPS) || + !float_near_abs_eps_array(dst0, dst1, EPS, MAX_SIZE)) + fail(); + bench_new(dst1, src, coeff1, MAX_SIZE); +} + +void checkasm_check_opusdsp(void) +{ + OpusDSP ctx; + ff_opus_dsp_init(&ctx); + + if (check_func(ctx.postfilter, "postfilter_15")) + test_postfilter(15); + report("postfilter_15"); + + if (check_func(ctx.postfilter, "postfilter_512")) + test_postfilter(512); + report("postfilter_512"); + + if (check_func(ctx.postfilter, "postfilter_1022")) + test_postfilter(1022); + report("postfilter_1022"); + + if (check_func(ctx.deemphasis, "deemphasis")) + test_deemphasis(); + report("deemphasis"); +} diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak index 618bde509f..389324547c 100644 --- a/tests/fate/checkasm.mak +++ b/tests/fate/checkasm.mak @@ -19,6 +19,7 @@ FATE_CHECKASM = fate-checkasm-aacpsdsp \ fate-checkasm-jpeg2000dsp \ fate-checkasm-llviddsp \ fate-checkasm-llviddspenc \ + fate-checkasm-opusdsp \ fate-checkasm-pixblockdsp \ fate-checkasm-sbrdsp \ fate-checkasm-synth_filter \ -- 2.23.0.rc1