Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS). | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
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. | ||
10 | * | ||
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. | ||
15 | * | ||
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. | ||
19 | */ | ||
20 | |||
21 | #include <string.h> | ||
22 | |||
23 | #include "libavutil/mem_internal.h" | ||
24 | |||
25 | #include "libavcodec/aacenc_utils.h" | ||
26 | #include "libavcodec/aacencdsp.h" | ||
27 | #include "libavcodec/aactab.h" | ||
28 | |||
29 | #include "checkasm.h" | ||
30 | |||
31 | #define randomize_float(buf, len) \ | ||
32 | do { \ | ||
33 | int i; \ | ||
34 | for (i = 0; i < len; i++) { \ | ||
35 | float f = (float)rnd() / (UINT_MAX >> 5) - 16.0f; \ | ||
36 | buf[i] = f; \ | ||
37 | } \ | ||
38 | } while (0) | ||
39 | |||
40 | #define randomize_elem(tab) (tab[rnd() % FF_ARRAY_ELEMS(tab)]) | ||
41 | |||
42 | 13 | static void test_abs_pow34(AACEncDSPContext *s) | |
43 | { | ||
44 | #define BUF_SIZE 1024 | ||
45 | 13 | LOCAL_ALIGNED_32(float, in, [BUF_SIZE]); | |
46 | |||
47 | 13 | declare_func(void, float *, const float *, int); | |
48 | |||
49 |
2/2✓ Branch 1 taken 13312 times.
✓ Branch 2 taken 13 times.
|
13325 | randomize_float(in, BUF_SIZE); |
50 | |||
51 |
2/2✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
|
13 | if (check_func(s->abs_pow34, "abs_pow34")) { |
52 | 2 | LOCAL_ALIGNED_32(float, out, [BUF_SIZE]); | |
53 | 2 | LOCAL_ALIGNED_32(float, out2, [BUF_SIZE]); | |
54 | |||
55 | 2 | call_ref(out, in, BUF_SIZE); | |
56 | 2 | call_new(out2, in, BUF_SIZE); | |
57 | |||
58 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!float_near_ulp_array(out, out2, 1, BUF_SIZE)) |
59 | ✗ | fail(); | |
60 | |||
61 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
2 | bench_new(out, in, BUF_SIZE); |
62 | } | ||
63 | |||
64 | 13 | report("abs_pow34"); | |
65 | 13 | } | |
66 | |||
67 | 13 | static void test_quant_bands(AACEncDSPContext *s) | |
68 | { | ||
69 | 13 | int maxval = randomize_elem(aac_cb_maxval); | |
70 | 13 | float q34 = randomize_elem(ff_aac_pow34sf_tab); | |
71 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 2 taken 8 times.
|
13 | float rounding = (rnd() & 1) ? ROUND_TO_ZERO : ROUND_STANDARD; |
72 | 13 | LOCAL_ALIGNED_16(float, in, [BUF_SIZE]); | |
73 | 13 | LOCAL_ALIGNED_16(float, scaled, [BUF_SIZE]); | |
74 | |||
75 | 13 | declare_func(void, int *, const float *, const float *, int, int, int, | |
76 | const float, const float); | ||
77 | |||
78 |
2/2✓ Branch 1 taken 13312 times.
✓ Branch 2 taken 13 times.
|
13325 | randomize_float(in, BUF_SIZE); |
79 |
2/2✓ Branch 1 taken 13312 times.
✓ Branch 2 taken 13 times.
|
13325 | randomize_float(scaled, BUF_SIZE); |
80 | |||
81 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 13 times.
|
39 | for (int sign = 0; sign <= 1; sign++) { |
82 |
4/4✓ Branch 2 taken 13 times.
✓ Branch 3 taken 13 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 20 times.
|
26 | if (check_func(s->quant_bands, "quant_bands_%s", |
83 | sign ? "signed" : "unsigned")) { | ||
84 | 6 | LOCAL_ALIGNED_32(int, out, [BUF_SIZE]); | |
85 | 6 | LOCAL_ALIGNED_32(int, out2, [BUF_SIZE]); | |
86 | |||
87 | 6 | call_ref(out, in, scaled, BUF_SIZE, sign, maxval, q34, rounding); | |
88 | 6 | call_new(out2, in, scaled, BUF_SIZE, sign, maxval, q34, rounding); | |
89 | |||
90 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (memcmp(out, out2, BUF_SIZE * sizeof (int))) |
91 | ✗ | fail(); | |
92 | |||
93 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
6 | bench_new(out, in, scaled, BUF_SIZE, sign, maxval, q34, rounding); |
94 | } | ||
95 | } | ||
96 | |||
97 | 13 | report("quant_bands"); | |
98 | 13 | } | |
99 | |||
100 | 13 | void checkasm_check_aacencdsp(void) | |
101 | { | ||
102 | 13 | AACEncDSPContext s = { 0 }; | |
103 | 13 | ff_aacenc_dsp_init(&s); | |
104 | |||
105 | 13 | test_abs_pow34(&s); | |
106 | 13 | test_quant_bands(&s); | |
107 | 13 | } | |
108 |