1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-10-06 05:47:18 +02:00

tests/checkasm: add a test for dcadsp

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2025-10-04 14:14:32 -03:00
parent 99034b581f
commit 95850f339e
5 changed files with 105 additions and 1 deletions

View File

@@ -31,7 +31,7 @@ AVCODECOBJS-$(CONFIG_AAC_DECODER) += aacpsdsp.o \
AVCODECOBJS-$(CONFIG_AAC_ENCODER) += aacencdsp.o AVCODECOBJS-$(CONFIG_AAC_ENCODER) += aacencdsp.o
AVCODECOBJS-$(CONFIG_ALAC_DECODER) += alacdsp.o AVCODECOBJS-$(CONFIG_ALAC_DECODER) += alacdsp.o
AVCODECOBJS-$(CONFIG_APV_DECODER) += apv_dsp.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_DIRAC_DECODER) += diracdsp.o
AVCODECOBJS-$(CONFIG_EXR_DECODER) += exrdsp.o AVCODECOBJS-$(CONFIG_EXR_DECODER) += exrdsp.o
AVCODECOBJS-$(CONFIG_FLAC_DECODER) += flacdsp.o AVCODECOBJS-$(CONFIG_FLAC_DECODER) += flacdsp.o

View File

@@ -142,6 +142,7 @@ static const struct {
{ "bswapdsp", checkasm_check_bswapdsp }, { "bswapdsp", checkasm_check_bswapdsp },
#endif #endif
#if CONFIG_DCA_DECODER #if CONFIG_DCA_DECODER
{ "dcadsp", checkasm_check_dcadsp },
{ "synth_filter", checkasm_check_synth_filter }, { "synth_filter", checkasm_check_synth_filter },
#endif #endif
#if CONFIG_DIRAC_DECODER #if CONFIG_DIRAC_DECODER

View File

@@ -92,6 +92,7 @@ void checkasm_check_blockdsp(void);
void checkasm_check_bswapdsp(void); void checkasm_check_bswapdsp(void);
void checkasm_check_colordetect(void); void checkasm_check_colordetect(void);
void checkasm_check_colorspace(void); void checkasm_check_colorspace(void);
void checkasm_check_dcadsp(void);
void checkasm_check_diracdsp(void); void checkasm_check_diracdsp(void);
void checkasm_check_exrdsp(void); void checkasm_check_exrdsp(void);
void checkasm_check_fdctdsp(void); void checkasm_check_fdctdsp(void);

101
tests/checkasm/dcadsp.c Normal file
View File

@@ -0,0 +1,101 @@
/*
* 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)
/* sign_extend(rnd(), 23) would be the correct approach here,
* but it results in differences that would require a much
* bigger EPS value, thus we use 16 (simplified as a cast). */
#define randomize(buf, len) do { \
for (int i = 0; i < len; i++) \
(buf)[i] = (int16_t)rnd(); \
} 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);
}
}
}
static void test_lfe_fir_fixed(void)
{
LOCAL_ALIGNED_16(int32_t, dst0, [BUF_SIZE]);
LOCAL_ALIGNED_16(int32_t, dst1, [BUF_SIZE]);
LOCAL_ALIGNED_16(int32_t, lfe, [LFE_SIZE]);
const int32_t *coeffs = ff_dca_lfe_fir_64_fixed;
declare_func(void, int32_t *pcm_samples, const int32_t *lfe_samples,
const int32_t *filter_coeff, ptrdiff_t npcmblocks);
memset(dst0, 0, BUF_SIZE * sizeof(int32_t));
memset(dst1, 0, BUF_SIZE * sizeof(int32_t));
randomize(lfe, LFE_SIZE);
call_ref(dst0, lfe + LFE_HISTORY, coeffs, N);
call_new(dst1, lfe + LFE_HISTORY, coeffs, N);
if (memcmp(dst0, dst1, BUF_SIZE * sizeof(int32_t)))
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");
if (check_func(dca.lfe_fir_fixed, "lfe_fir_fixed"))
test_lfe_fir_fixed();
report("lfe_fir_fixed");
}

View File

@@ -9,6 +9,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp \
fate-checkasm-av_tx \ fate-checkasm-av_tx \
fate-checkasm-blockdsp \ fate-checkasm-blockdsp \
fate-checkasm-bswapdsp \ fate-checkasm-bswapdsp \
fate-checkasm-dcadsp \
fate-checkasm-diracdsp \ fate-checkasm-diracdsp \
fate-checkasm-exrdsp \ fate-checkasm-exrdsp \
fate-checkasm-fdctdsp \ fate-checkasm-fdctdsp \