2 * Copyright (c) 2015 Janne Grunau
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "libavutil/internal.h"
26 #include "libavutil/intfloat.h"
27 #include "libavcodec/dca.h"
28 #include "libavcodec/dcadsp.h"
29 #include "libavcodec/dcadata.h"
33 #define randomize_lfe_fir(size) \
36 for (i = 0; i < size; i++) { \
37 float f = (float)rnd() / (UINT_MAX >> 1) - 1.0f; \
40 for (i = 0; i < 256; i++) { \
41 float f = (float)rnd() / (UINT_MAX >> 1) - 1.0f; \
46 #define check_lfe_fir(decifactor, eps) \
48 LOCAL_ALIGNED_16(float, in, [256 / decifactor]); \
49 LOCAL_ALIGNED_16(float, out0, [decifactor * 2]); \
50 LOCAL_ALIGNED_16(float, out1, [decifactor * 2]); \
51 LOCAL_ALIGNED_16(float, coeffs, [256]); \
53 const float * in_ptr = in + (256 / decifactor) - 1; \
54 declare_func(void, float *out, const float *in, const float *coeffs); \
55 /* repeat the test several times */ \
56 for (i = 0; i < 32; i++) { \
58 memset(out0, 0, sizeof(*out0) * 2 * decifactor); \
59 memset(out1, 0xFF, sizeof(*out1) * 2 * decifactor); \
60 randomize_lfe_fir(256 / decifactor); \
61 call_ref(out0, in_ptr, coeffs); \
62 call_new(out1, in_ptr, coeffs); \
63 for (j = 0; j < 2 * decifactor; j++) { \
64 if (!float_near_abs_eps(out0[j], out1[j], eps)) { \
66 union av_intfloat32 x, y; x.f = out0[j]; y.f = out1[j]; \
67 fprintf(stderr, "%3d: %11g (0x%08x); %11g (0x%08x)\n", \
68 j, x.f, x.i, y.f, y.i); \
74 bench_new(out1, in_ptr, coeffs); \
78 void checkasm_check_dcadsp(void)
84 /* values are limited to {-8, 8} so absolute epsilon is good enough */
85 if (check_func(c.lfe_fir[0], "dca_lfe_fir0"))
86 check_lfe_fir(32, 1.0e-6f);
88 if (check_func(c.lfe_fir[1], "dca_lfe_fir1"))
89 check_lfe_fir(64, 1.0e-6f);