From: James Almer via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Cc: James Almer <code@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH] tests/checkasm: add a test for dcadsp (PR #20646) Date: Sat, 04 Oct 2025 17:23:13 -0000 Message-ID: <175959859414.69.16185432441262168876@bf249f23a2c8> (raw) PR #20646 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20646 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20646.patch >From 99034b581f5608c1bb4edd52864b1bc973ad2dfb Mon Sep 17 00:00:00 2001 From: James Almer <jamrial@gmail.com> Date: Sat, 4 Oct 2025 14:18:16 -0300 Subject: [PATCH 1/2] avcodec/dcadsp: constify lfe_samples parameter Signed-off-by: James Almer <jamrial@gmail.com> --- libavcodec/dcadsp.c | 8 ++++---- libavcodec/dcadsp.h | 4 ++-- libavcodec/x86/dcadsp_init.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/dcadsp.c b/libavcodec/dcadsp.c index 5ad1f644f2..d5fc5c4eb2 100644 --- a/libavcodec/dcadsp.c +++ b/libavcodec/dcadsp.c @@ -54,7 +54,7 @@ static void decode_joint_c(int32_t **dst, int32_t **src, } } -static void lfe_fir_float_c(float *pcm_samples, int32_t *lfe_samples, +static void lfe_fir_float_c(float *pcm_samples, const int32_t *lfe_samples, const float *filter_coeff, ptrdiff_t npcmblocks, int dec_select) { @@ -84,13 +84,13 @@ static void lfe_fir_float_c(float *pcm_samples, int32_t *lfe_samples, } } -static void lfe_fir0_float_c(float *pcm_samples, int32_t *lfe_samples, +static void lfe_fir0_float_c(float *pcm_samples, const int32_t *lfe_samples, const float *filter_coeff, ptrdiff_t npcmblocks) { lfe_fir_float_c(pcm_samples, lfe_samples, filter_coeff, npcmblocks, 0); } -static void lfe_fir1_float_c(float *pcm_samples, int32_t *lfe_samples, +static void lfe_fir1_float_c(float *pcm_samples, const int32_t *lfe_samples, const float *filter_coeff, ptrdiff_t npcmblocks) { lfe_fir_float_c(pcm_samples, lfe_samples, filter_coeff, npcmblocks, 1); @@ -193,7 +193,7 @@ static void sub_qmf64_float_c(SynthFilterContext *synth, } } -static void lfe_fir_fixed_c(int32_t *pcm_samples, int32_t *lfe_samples, +static void lfe_fir_fixed_c(int32_t *pcm_samples, const int32_t *lfe_samples, const int32_t *filter_coeff, ptrdiff_t npcmblocks) { // Select decimation factor diff --git a/libavcodec/dcadsp.h b/libavcodec/dcadsp.h index c29755267b..b99ec55619 100644 --- a/libavcodec/dcadsp.h +++ b/libavcodec/dcadsp.h @@ -40,7 +40,7 @@ typedef struct DCADSPContext { ptrdiff_t sb_start, ptrdiff_t sb_end, ptrdiff_t ofs, ptrdiff_t len); - void (*lfe_fir_float[2])(float *pcm_samples, int32_t *lfe_samples, + void (*lfe_fir_float[2])(float *pcm_samples, const int32_t *lfe_samples, const float *filter_coeff, ptrdiff_t npcmblocks); void (*lfe_x96_float)(float *dst, const float *src, @@ -56,7 +56,7 @@ typedef struct DCADSPContext { const float *filter_coeff, ptrdiff_t npcmblocks, float scale); - void (*lfe_fir_fixed)(int32_t *pcm_samples, int32_t *lfe_samples, + void (*lfe_fir_fixed)(int32_t *pcm_samples, const int32_t *lfe_samples, const int32_t *filter_coeff, ptrdiff_t npcmblocks); void (*lfe_x96_fixed)(int32_t *dst, const int32_t *src, diff --git a/libavcodec/x86/dcadsp_init.c b/libavcodec/x86/dcadsp_init.c index 0c78dd1c9e..c01bfffaba 100644 --- a/libavcodec/x86/dcadsp_init.c +++ b/libavcodec/x86/dcadsp_init.c @@ -22,9 +22,9 @@ #include "libavcodec/dcadsp.h" #define LFE_FIR_FLOAT_FUNC(opt) \ -void ff_lfe_fir0_float_##opt(float *pcm_samples, int32_t *lfe_samples, \ +void ff_lfe_fir0_float_##opt(float *pcm_samples, const int32_t *lfe_samples, \ const float *filter_coeff, ptrdiff_t npcmblocks); \ -void ff_lfe_fir1_float_##opt(float *pcm_samples, int32_t *lfe_samples, \ +void ff_lfe_fir1_float_##opt(float *pcm_samples, const int32_t *lfe_samples, \ const float *filter_coeff, ptrdiff_t npcmblocks); LFE_FIR_FLOAT_FUNC(sse2) -- 2.49.1 >From 8fb6c8f16c8ad9e9a5019059089d1f1dc6d91933 Mon Sep 17 00:00:00 2001 From: James Almer <jamrial@gmail.com> Date: Sat, 4 Oct 2025 14:14:32 -0300 Subject: [PATCH 2/2] tests/checkasm: add a test for dcadsp Signed-off-by: James Almer <jamrial@gmail.com> --- tests/checkasm/Makefile | 2 +- tests/checkasm/checkasm.c | 1 + tests/checkasm/checkasm.h | 1 + tests/checkasm/dcadsp.c | 74 +++++++++++++++++++++++++++++++++++++++ tests/fate/checkasm.mak | 1 + 5 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 tests/checkasm/dcadsp.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 1589a15e2f..82bcc21b01 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -31,7 +31,7 @@ AVCODECOBJS-$(CONFIG_AAC_DECODER) += aacpsdsp.o \ AVCODECOBJS-$(CONFIG_AAC_ENCODER) += aacencdsp.o AVCODECOBJS-$(CONFIG_ALAC_DECODER) += alacdsp.o AVCODECOBJS-$(CONFIG_APV_DECODER) += apv_dsp.o -AVCODECOBJS-$(CONFIG_DCA_DECODER) += synth_filter.o +AVCODECOBJS-$(CONFIG_DCA_DECODER) += dcadsp.o synth_filter.o AVCODECOBJS-$(CONFIG_DIRAC_DECODER) += diracdsp.o AVCODECOBJS-$(CONFIG_EXR_DECODER) += exrdsp.o AVCODECOBJS-$(CONFIG_FLAC_DECODER) += flacdsp.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index e59d366f2b..d542f953e8 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -142,6 +142,7 @@ static const struct { { "bswapdsp", checkasm_check_bswapdsp }, #endif #if CONFIG_DCA_DECODER + { "dcadsp", checkasm_check_dcadsp }, { "synth_filter", checkasm_check_synth_filter }, #endif #if CONFIG_DIRAC_DECODER diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index eda806e870..0382963daa 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -92,6 +92,7 @@ void checkasm_check_blockdsp(void); void checkasm_check_bswapdsp(void); void checkasm_check_colordetect(void); void checkasm_check_colorspace(void); +void checkasm_check_dcadsp(void); void checkasm_check_diracdsp(void); void checkasm_check_exrdsp(void); void checkasm_check_fdctdsp(void); diff --git a/tests/checkasm/dcadsp.c b/tests/checkasm/dcadsp.c new file mode 100644 index 0000000000..d76e3f0765 --- /dev/null +++ b/tests/checkasm/dcadsp.c @@ -0,0 +1,74 @@ +/* + * 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 <stdint.h> +#include <string.h> + +#include "libavcodec/dcadata.h" +#include "libavcodec/dcadsp.h" +#include "libavutil/common.h" +#include "libavutil/mem_internal.h" + +#include "checkasm.h" + +#define N 32 +#define BLOCKSIZE 128 +#define BUF_SIZE (N * BLOCKSIZE) +#define LFE_HISTORY 8 +#define LFE_SIZE (N + LFE_HISTORY + 1) + +#define randomize(buf, len) do { \ + for (int i = 0; i < len; i++) \ + (buf)[i] = av_clip_intp2(rnd(), 16); \ +} while (0) + +#define EPS 0.0005f + +static void test_lfe_fir_float(const DCADSPContext *dca) +{ + LOCAL_ALIGNED_16(float, dst0, [BUF_SIZE]); + LOCAL_ALIGNED_16(float, dst1, [BUF_SIZE]); + LOCAL_ALIGNED_16(int32_t, lfe, [LFE_SIZE]); + + declare_func(void, float *pcm_samples, const int32_t *lfe_samples, + const float *filter_coeff, ptrdiff_t npcmblocks); + + for (int i = 0; i < 2; i++) { + const float *coeffs = i ? ff_dca_lfe_fir_128 : ff_dca_lfe_fir_64; + if (check_func(dca->lfe_fir_float[i], "lfe_fir%d_float", i)) { + memset(dst0, 0, BUF_SIZE * sizeof(float)); + memset(dst1, 0, BUF_SIZE * sizeof(float)); + randomize(lfe, LFE_SIZE); + call_ref(dst0, lfe + LFE_HISTORY, coeffs, N); + call_new(dst1, lfe + LFE_HISTORY, coeffs, N); + if (!float_near_abs_eps_array(dst0, dst1, EPS, BUF_SIZE)) + fail(); + bench_new(dst1, lfe + LFE_HISTORY, coeffs, N); + } + } +} + +void checkasm_check_dcadsp(void) +{ + DCADSPContext dca; + + ff_dcadsp_init(&dca); + + test_lfe_fir_float(&dca); + report("lfe_fir_float"); +} diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak index 178b630fba..233950023c 100644 --- a/tests/fate/checkasm.mak +++ b/tests/fate/checkasm.mak @@ -9,6 +9,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp \ fate-checkasm-av_tx \ fate-checkasm-blockdsp \ fate-checkasm-bswapdsp \ + fate-checkasm-dcadsp \ fate-checkasm-diracdsp \ fate-checkasm-exrdsp \ fate-checkasm-fdctdsp \ -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-10-04 17:23 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=175959859414.69.16185432441262168876@bf249f23a2c8 \ --to=ffmpeg-devel@ffmpeg.org \ --cc=code@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror http://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ http://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git