From: Hendrik Leppkes Date: Sat, 2 Jan 2016 11:38:46 +0000 (+0100) Subject: Merge commit 'e71b747e9dc56cb84f8a06ec8214d5f3bd98bb6d' X-Git-Tag: n3.1-dev~737 X-Git-Url: http://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff_plain/d882c0b9f9f1d81194a6ec0608c2ccac33ade0a1 Merge commit 'e71b747e9dc56cb84f8a06ec8214d5f3bd98bb6d' * commit 'e71b747e9dc56cb84f8a06ec8214d5f3bd98bb6d': checkasm: add tests for dcadsp Merged-by: Hendrik Leppkes --- d882c0b9f9f1d81194a6ec0608c2ccac33ade0a1 diff --cc tests/checkasm/Makefile index 1c0290b,a7d13d5..7f3d560 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@@ -1,13 -1,10 +1,14 @@@ # libavcodec tests +AVCODECOBJS-$(CONFIG_ALAC_DECODER) += alacdsp.o AVCODECOBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o + AVCODECOBJS-$(CONFIG_DCA_DECODER) += dcadsp.o +AVCODECOBJS-$(CONFIG_FLACDSP) += flacdsp.o AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o -AVCODECOBJS-$(CONFIG_HEVC_DECODER) += hevc_mc.o +AVCODECOBJS-$(CONFIG_JPEG2000_DECODER) += jpeg2000dsp.o +AVCODECOBJS-$(CONFIG_PIXBLOCKDSP) += pixblockdsp.o AVCODECOBJS-$(CONFIG_V210_ENCODER) += v210enc.o +AVCODECOBJS-$(CONFIG_VP9_DECODER) += vp9dsp.o CHECKASMOBJS-$(CONFIG_AVCODEC) += $(AVCODECOBJS-yes) diff --cc tests/checkasm/checkasm.c index 2009d81,a563eaf..6b482b8 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@@ -58,34 -58,23 +58,37 @@@ static const struct const char *name; void (*func)(void); } tests[] = { -#if CONFIG_BSWAPDSP - { "bswapdsp", checkasm_check_bswapdsp }, -#endif -#if CONFIG_DCA_DECODER - { "dcadsp", checkasm_check_dcadsp }, -#endif -#if CONFIG_H264PRED - { "h264pred", checkasm_check_h264pred }, -#endif -#if CONFIG_H264QPEL - { "h264qpel", checkasm_check_h264qpel }, -#endif -#if CONFIG_HEVC_DECODER - { "hevc_mc", checkasm_check_hevc_mc }, -#endif -#if CONFIG_V210_ENCODER - { "v210enc", checkasm_check_v210enc }, +#if CONFIG_AVCODEC + #if CONFIG_ALAC_DECODER + { "alacdsp", checkasm_check_alacdsp }, + #endif + #if CONFIG_BSWAPDSP + { "bswapdsp", checkasm_check_bswapdsp }, + #endif ++ #if CONFIG_DCA_DECODER ++ { "dcadsp", checkasm_check_dcadsp }, ++ #endif + #if CONFIG_FLACDSP + { "flacdsp", checkasm_check_flacdsp }, + #endif + #if CONFIG_H264PRED + { "h264pred", checkasm_check_h264pred }, + #endif + #if CONFIG_H264QPEL + { "h264qpel", checkasm_check_h264qpel }, + #endif + #if CONFIG_JPEG2000_DECODER + { "jpeg2000dsp", checkasm_check_jpeg2000dsp }, + #endif + #if CONFIG_PIXBLOCKDSP + { "pixblockdsp", checkasm_check_pixblockdsp }, + #endif + #if CONFIG_V210_ENCODER + { "v210enc", checkasm_check_v210enc }, + #endif + #if CONFIG_VP9_DECODER + { "vp9dsp", checkasm_check_vp9dsp }, + #endif #endif { NULL } }; diff --cc tests/checkasm/checkasm.h index ca6acee,eb8b6dd..b2fe129 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@@ -30,15 -30,12 +30,16 @@@ #include "libavutil/lfg.h" #include "libavutil/timer.h" +void checkasm_check_alacdsp(void); void checkasm_check_bswapdsp(void); + void checkasm_check_dcadsp(void); +void checkasm_check_flacdsp(void); void checkasm_check_h264pred(void); void checkasm_check_h264qpel(void); -void checkasm_check_hevc_mc(void); +void checkasm_check_jpeg2000dsp(void); +void checkasm_check_pixblockdsp(void); void checkasm_check_v210enc(void); +void checkasm_check_vp9dsp(void); void *checkasm_check_func(void *func, const char *name, ...) av_printf_format(2, 3); int checkasm_bench_func(void); diff --cc tests/checkasm/dcadsp.c index 0000000,1665cbb..e0a4f4d mode 000000,100644..100644 --- a/tests/checkasm/dcadsp.c +++ b/tests/checkasm/dcadsp.c @@@ -1,0 -1,137 +1,137 @@@ + /* + * Copyright (c) 2015 Janne Grunau + * - * This file is part of Libav. ++ * This file is part of FFmpeg. + * - * Libav is free software; you can redistribute it and/or modify ++ * 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. + * - * Libav is distributed in the hope that it will be useful, ++ * 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 Libav; if not, write to the Free Software Foundation, Inc., ++ * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + + #include + #include + #include + + #include "libavutil/internal.h" + #include "libavutil/intfloat.h" + #include "libavcodec/dca.h" + #include "libavcodec/dcadsp.h" + #include "libavcodec/dcadata.h" + + #include "checkasm.h" + + #define randomize_lfe_fir(size) \ + do { \ + int i; \ + for (i = 0; i < size; i++) { \ + float f = (float)rnd() / (UINT_MAX >> 1) - 1.0f; \ + in[i] = f; \ + } \ + for (i = 0; i < 256; i++) { \ + float f = (float)rnd() / (UINT_MAX >> 1) - 1.0f; \ + coeffs[i] = f; \ + } \ + } while (0) + + #define check_lfe_fir(decifactor, eps) \ + do { \ + LOCAL_ALIGNED_16(float, in, [256 / decifactor]); \ + LOCAL_ALIGNED_16(float, out0, [decifactor * 2]); \ + LOCAL_ALIGNED_16(float, out1, [decifactor * 2]); \ + LOCAL_ALIGNED_16(float, coeffs, [256]); \ + int i; \ + const float * in_ptr = in + (256 / decifactor) - 1; \ + declare_func(void, float *out, const float *in, const float *coeffs); \ + /* repeat the test several times */ \ + for (i = 0; i < 32; i++) { \ + int j; \ + memset(out0, 0, sizeof(*out0) * 2 * decifactor); \ + memset(out1, 0xFF, sizeof(*out1) * 2 * decifactor); \ + randomize_lfe_fir(256 / decifactor); \ + call_ref(out0, in_ptr, coeffs); \ + call_new(out1, in_ptr, coeffs); \ + for (j = 0; j < 2 * decifactor; j++) { \ + if (!float_near_abs_eps(out0[j], out1[j], eps)) { \ + if (0) { \ + union av_intfloat32 x, y; x.f = out0[j]; y.f = out1[j]; \ + fprintf(stderr, "%3d: %11g (0x%08x); %11g (0x%08x)\n", \ + j, x.f, x.i, y.f, y.i); \ + } \ + fail(); \ + break; \ + } \ + } \ + bench_new(out1, in_ptr, coeffs); \ + } \ + } while (0) + + #define randomize_decode_hf() \ + do { \ + int i; \ + for (i = 0; i < DCA_SUBBANDS; i++) { \ + vq_num[i] = rnd() >> 22; \ + scale[i][0] = rnd() >> 26; \ + scale[i][1] = INT32_MIN; \ + } \ + } while (0) + + void checkasm_check_dcadsp(void) + { + DCADSPContext c; + + ff_dcadsp_init(&c); + + /* values are limited to {-8, 8} so absolute epsilon is good enough */ + if (check_func(c.lfe_fir[0], "dca_lfe_fir0")) + check_lfe_fir(32, 1.0e-6f); + + if (check_func(c.lfe_fir[1], "dca_lfe_fir1")) + check_lfe_fir(64, 1.0e-6f); + + if (check_func(c.decode_hf, "dca_decode_hf")) { + LOCAL_ALIGNED_16(float, dst0, [DCA_SUBBANDS], [8]); + LOCAL_ALIGNED_16(float, dst1, [DCA_SUBBANDS], [8]); + LOCAL_ALIGNED_16(int32_t, scale, [DCA_SUBBANDS], [2]); + LOCAL_ALIGNED_16(int32_t, vq_num, [DCA_SUBBANDS]); + intptr_t start, end = 32, offset; + + declare_func(void, float[DCA_SUBBANDS][8], const int32_t[DCA_SUBBANDS], + const int8_t[1024][DCA_SUBBANDS], intptr_t, int32_t[DCA_SUBBANDS][2], + intptr_t, intptr_t); + + for (start = 0; start < 32; start++) { + for (offset = 0; offset < 32; offset += 8) { + int j; + for (j = 0; j < DCA_SUBBANDS; j++) { + memset(dst0[j], 0, sizeof(*(dst0[j])) * 8); + memset(dst1[j], 0, sizeof(*(dst1[j])) * 8); + } + randomize_decode_hf(); + + call_ref(dst0, vq_num, ff_dca_high_freq_vq, offset, scale, start, end); + call_new(dst1, vq_num, ff_dca_high_freq_vq, offset, scale, start, end); + + for (j = 0; j < 8 * DCA_SUBBANDS; j++) { + if (!float_near_ulp(dst0[j>>3][j&7], dst1[j>>3][j&7], 1)) { + fail(); + break; + } + } + + bench_new(dst1, vq_num, ff_dca_high_freq_vq, offset, scale, start, end); + } + } + } + + report("dcadsp"); + }