diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/checkasm/Makefile | 1 | ||||
-rw-r--r-- | tests/checkasm/checkasm.c | 3 | ||||
-rw-r--r-- | tests/checkasm/checkasm.h | 1 | ||||
-rw-r--r-- | tests/checkasm/lpc.c | 80 |
4 files changed, 85 insertions, 0 deletions
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index ac02670e64..f330d3a8ab 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -11,6 +11,7 @@ AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o AVCODECOBJS-$(CONFIG_IDCTDSP) += idctdsp.o AVCODECOBJS-$(CONFIG_LLVIDDSP) += llviddsp.o AVCODECOBJS-$(CONFIG_LLVIDENCDSP) += llviddspenc.o +AVCODECOBJS-$(CONFIG_LPC) += lpc.o AVCODECOBJS-$(CONFIG_ME_CMP) += motion.o AVCODECOBJS-$(CONFIG_VC1DSP) += vc1dsp.o AVCODECOBJS-$(CONFIG_VP8DSP) += vp8dsp.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 6b4a0f22b2..8fd9bba0b0 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -135,6 +135,9 @@ static const struct { #if CONFIG_LLVIDENCDSP { "llviddspenc", checkasm_check_llviddspenc }, #endif + #if CONFIG_LPC + { "lpc", checkasm_check_lpc }, + #endif #if CONFIG_ME_CMP { "motion", checkasm_check_motion }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 171dd06b47..97e909170f 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -68,6 +68,7 @@ void checkasm_check_idctdsp(void); void checkasm_check_jpeg2000dsp(void); void checkasm_check_llviddsp(void); void checkasm_check_llviddspenc(void); +void checkasm_check_lpc(void); void checkasm_check_motion(void); void checkasm_check_nlmeans(void); void checkasm_check_opusdsp(void); diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c new file mode 100644 index 0000000000..b68ce05bfa --- /dev/null +++ b/tests/checkasm/lpc.c @@ -0,0 +1,80 @@ +/* + * 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 "libavutil/mem_internal.h" + +#include "libavcodec/lpc.h" + +#include "checkasm.h" + +#define randomize_int32(buf, len) \ + do { \ + for (int i = 0; i < len; i++) { \ + int32_t f = rnd() >> 8; \ + buf[i] = f; \ + } \ + } while (0) + +#define EPS 0.005 + +static void test_window(int len) +{ + LOCAL_ALIGNED(16, int32_t, src, [5000]); + LOCAL_ALIGNED(16, double, dst0, [5000]); + LOCAL_ALIGNED(16, double, dst1, [5000]); + + declare_func(void, int32_t *in, int len, double *out); + + randomize_int32(src, len); + + call_ref(src, len, dst0); + call_new(src, len, dst1); + + if (!double_near_abs_eps_array(dst0, dst1, EPS, len)) + fail(); + + bench_new(src, len, dst1); +} + +void checkasm_check_lpc(void) +{ + LPCContext ctx; + ff_lpc_init(&ctx, 32, 16, FF_LPC_TYPE_DEFAULT); + + if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_even")) { + for (int i = 0; i < 64; i += 2) + test_window(i); + } + report("apply_welch_window_even"); + + if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_odd")) { + for (int i = 1; i < 64; i += 2) + test_window(i); + } + report("apply_welch_window_odd"); + + if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_4096")) + test_window(4096); + report("apply_welch_window_4096"); + + if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_4097")) + test_window(4097); + report("apply_welch_window_4097"); + + ff_lpc_end(&ctx); +} |