avfilter/avfiltergraph: fix constant string comparision
[ffmpeg.git] / tests / checkasm / dcadsp.c
1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 #include <stdint.h>
20 #include <string.h>
21
22 #include "libavcodec/dcadata.h"
23 #include "libavcodec/dcadsp.h"
24 #include "libavutil/common.h"
25 #include "libavutil/mem_internal.h"
26
27 #include "checkasm.h"
28
29 #define N 32
30 #define BLOCKSIZE 128
31 #define BUF_SIZE (N * BLOCKSIZE)
32 #define LFE_HISTORY 8
33 #define LFE_SIZE (N + LFE_HISTORY + 1)
34
35 /* sign_extend(rnd(), 23) would be the correct approach here,
36 * but it results in differences that would require a much
37 * bigger EPS value, thus we use 16 (simplified as a cast). */
38 #define randomize(buf, len) do { \
39 for (int i = 0; i < len; i++) \
40 (buf)[i] = (int16_t)rnd(); \
41 } while (0)
42
43 #define EPS 0.0005f
44
45 static void test_lfe_fir_float(const DCADSPContext *dca)
46 {
47 LOCAL_ALIGNED_16(float, dst0, [BUF_SIZE]);
48 LOCAL_ALIGNED_16(float, dst1, [BUF_SIZE]);
49 LOCAL_ALIGNED_16(int32_t, lfe, [LFE_SIZE]);
50
51 declare_func(void, float *pcm_samples, const int32_t *lfe_samples,
52 const float *filter_coeff, ptrdiff_t npcmblocks);
53
54 for (int i = 0; i < 2; i++) {
55 const float *coeffs = i ? ff_dca_lfe_fir_128 : ff_dca_lfe_fir_64;
56 if (check_func(dca->lfe_fir_float[i], "lfe_fir%d_float", i)) {
57 memset(dst0, 0, BUF_SIZE * sizeof(float));
58 memset(dst1, 0, BUF_SIZE * sizeof(float));
59 randomize(lfe, LFE_SIZE);
60 call_ref(dst0, lfe + LFE_HISTORY, coeffs, N);
61 call_new(dst1, lfe + LFE_HISTORY, coeffs, N);
62 if (!float_near_abs_eps_array(dst0, dst1, EPS, BUF_SIZE))
63 fail();
64 bench_new(dst1, lfe + LFE_HISTORY, coeffs, N);
65 }
66 }
67 }
68
69 static void test_lfe_fir_fixed(void)
70 {
71 LOCAL_ALIGNED_16(int32_t, dst0, [BUF_SIZE]);
72 LOCAL_ALIGNED_16(int32_t, dst1, [BUF_SIZE]);
73 LOCAL_ALIGNED_16(int32_t, lfe, [LFE_SIZE]);
74 const int32_t *coeffs = ff_dca_lfe_fir_64_fixed;
75
76 declare_func(void, int32_t *pcm_samples, const int32_t *lfe_samples,
77 const int32_t *filter_coeff, ptrdiff_t npcmblocks);
78
79 memset(dst0, 0, BUF_SIZE * sizeof(int32_t));
80 memset(dst1, 0, BUF_SIZE * sizeof(int32_t));
81 randomize(lfe, LFE_SIZE);
82 call_ref(dst0, lfe + LFE_HISTORY, coeffs, N);
83 call_new(dst1, lfe + LFE_HISTORY, coeffs, N);
84 if (memcmp(dst0, dst1, BUF_SIZE * sizeof(int32_t)))
85 fail();
86 bench_new(dst1, lfe + LFE_HISTORY, coeffs, N);
87 }
88
89 void checkasm_check_dcadsp(void)
90 {
91 DCADSPContext dca;
92
93 ff_dcadsp_init(&dca);
94
95 test_lfe_fir_float(&dca);
96 report("lfe_fir_float");
97
98 if (check_func(dca.lfe_fir_fixed, "lfe_fir_fixed"))
99 test_lfe_fir_fixed();
100 report("lfe_fir_fixed");
101 }