Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (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 GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | * | ||
20 | * Note: Rounding-to-nearest used unless otherwise stated | ||
21 | * | ||
22 | */ | ||
23 | #include <stdint.h> | ||
24 | |||
25 | #include "config.h" | ||
26 | #include "libavutil/attributes.h" | ||
27 | #include "aacpsdsp.h" | ||
28 | |||
29 | 116779 | static void ps_add_squares_c(INTFLOAT *restrict dst, | |
30 | const INTFLOAT (*src)[2], int n) | ||
31 | { | ||
32 |
2/2✓ Branch 0 taken 3749120 times.
✓ Branch 1 taken 116779 times.
|
3865899 | for (int i = 0; i < n; i++) |
33 | 3749120 | dst[i] += (UINTFLOAT)AAC_MADD28(src[i][0], src[i][0], src[i][1], src[i][1]); | |
34 | 116779 | } | |
35 | |||
36 | 66259 | static void ps_mul_pair_single_c(INTFLOAT (*restrict dst)[2], | |
37 | INTFLOAT (*src0)[2], INTFLOAT *src1, | ||
38 | int n) | ||
39 | { | ||
40 |
2/2✓ Branch 0 taken 2132480 times.
✓ Branch 1 taken 66259 times.
|
2198739 | for (int i = 0; i < n; i++) { |
41 | 2132480 | dst[i][0] = AAC_MUL16(src0[i][0], src1[i]); | |
42 | 2132480 | dst[i][1] = AAC_MUL16(src0[i][1], src1[i]); | |
43 | } | ||
44 | 66259 | } | |
45 | |||
46 | 64771 | static void ps_hybrid_analysis_c(INTFLOAT (*restrict out)[2], | |
47 | INTFLOAT (*in)[2], | ||
48 | const INTFLOAT (*filter)[8][2], | ||
49 | ptrdiff_t stride, int n) | ||
50 | { | ||
51 | INT64FLOAT inre0[6], inre1[6], inim0[6], inim1[6]; | ||
52 | |||
53 |
2/2✓ Branch 0 taken 388626 times.
✓ Branch 1 taken 64771 times.
|
453397 | for (int j = 0; j < 6; j++) { |
54 | 388626 | inre0[j] = in[j][0] + in[12 - j][0]; | |
55 | 388626 | inre1[j] = in[j][1] - in[12 - j][1]; | |
56 | 388626 | inim0[j] = in[j][1] + in[12 - j][1]; | |
57 | 388626 | inim1[j] = in[j][0] - in[12 - j][0]; | |
58 | } | ||
59 | |||
60 |
2/2✓ Branch 0 taken 492128 times.
✓ Branch 1 taken 64771 times.
|
556899 | for (int i = 0; i < n; i++) { |
61 | 492128 | INT64FLOAT sum_re = (INT64FLOAT)filter[i][6][0] * in[6][0]; | |
62 | 492128 | INT64FLOAT sum_im = (INT64FLOAT)filter[i][6][0] * in[6][1]; | |
63 | |||
64 |
2/2✓ Branch 0 taken 2952768 times.
✓ Branch 1 taken 492128 times.
|
3444896 | for (int j = 0; j < 6; j++) { |
65 | 2952768 | sum_re += (INT64FLOAT)filter[i][j][0] * inre0[j] - | |
66 | 2952768 | (INT64FLOAT)filter[i][j][1] * inre1[j]; | |
67 | 2952768 | sum_im += (INT64FLOAT)filter[i][j][0] * inim0[j] + | |
68 | 2952768 | (INT64FLOAT)filter[i][j][1] * inim1[j]; | |
69 | } | ||
70 | #if USE_FIXED | ||
71 | ✗ | out[i * stride][0] = (int)((sum_re + 0x40000000) >> 31); | |
72 | ✗ | out[i * stride][1] = (int)((sum_im + 0x40000000) >> 31); | |
73 | #else | ||
74 | 492128 | out[i * stride][0] = sum_re; | |
75 | 492128 | out[i * stride][1] = sum_im; | |
76 | #endif /* USE_FIXED */ | ||
77 | } | ||
78 | 64771 | } | |
79 | |||
80 | 1622 | static void ps_hybrid_analysis_ileave_c(INTFLOAT (*restrict out)[32][2], | |
81 | INTFLOAT L[2][38][64], | ||
82 | int i, int len) | ||
83 | { | ||
84 |
2/2✓ Branch 0 taken 98732 times.
✓ Branch 1 taken 1622 times.
|
100354 | for (; i < 64; i++) { |
85 |
2/2✓ Branch 0 taken 3159424 times.
✓ Branch 1 taken 98732 times.
|
3258156 | for (int j = 0; j < len; j++) { |
86 | 3159424 | out[i][j][0] = L[0][j][i]; | |
87 | 3159424 | out[i][j][1] = L[1][j][i]; | |
88 | } | ||
89 | } | ||
90 | 1622 | } | |
91 | |||
92 | 3238 | static void ps_hybrid_synthesis_deint_c(INTFLOAT out[2][38][64], | |
93 | INTFLOAT (*restrict in)[32][2], | ||
94 | int i, int len) | ||
95 | { | ||
96 |
2/2✓ Branch 0 taken 197104 times.
✓ Branch 1 taken 3238 times.
|
200342 | for (; i < 64; i++) { |
97 |
2/2✓ Branch 0 taken 6307328 times.
✓ Branch 1 taken 197104 times.
|
6504432 | for (int n = 0; n < len; n++) { |
98 | 6307328 | out[0][n][i] = in[i][n][0]; | |
99 | 6307328 | out[1][n][i] = in[i][n][1]; | |
100 | } | ||
101 | } | ||
102 | 3238 | } | |
103 | |||
104 | 50520 | static void ps_decorrelate_c(INTFLOAT (*out)[2], INTFLOAT (*delay)[2], | |
105 | INTFLOAT (*ap_delay)[PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2], | ||
106 | const INTFLOAT phi_fract[2], const INTFLOAT (*Q_fract)[2], | ||
107 | const INTFLOAT *transient_gain, | ||
108 | INTFLOAT g_decay_slope, | ||
109 | int len) | ||
110 | { | ||
111 | static const INTFLOAT a[] = { Q31(0.65143905753106f), | ||
112 | Q31(0.56471812200776f), | ||
113 | Q31(0.48954165955695f) }; | ||
114 | INTFLOAT ag[PS_AP_LINKS]; | ||
115 | int m, n; | ||
116 | |||
117 |
2/2✓ Branch 0 taken 151560 times.
✓ Branch 1 taken 50520 times.
|
202080 | for (m = 0; m < PS_AP_LINKS; m++) |
118 | 151560 | ag[m] = AAC_MUL30(a[m], g_decay_slope); | |
119 | |||
120 |
2/2✓ Branch 0 taken 1616640 times.
✓ Branch 1 taken 50520 times.
|
1667160 | for (n = 0; n < len; n++) { |
121 | 1616640 | INTFLOAT in_re = AAC_MSUB30(delay[n][0], phi_fract[0], delay[n][1], phi_fract[1]); | |
122 | 1616640 | INTFLOAT in_im = AAC_MADD30(delay[n][0], phi_fract[1], delay[n][1], phi_fract[0]); | |
123 |
2/2✓ Branch 0 taken 4849920 times.
✓ Branch 1 taken 1616640 times.
|
6466560 | for (m = 0; m < PS_AP_LINKS; m++) { |
124 | 4849920 | INTFLOAT a_re = AAC_MUL31(ag[m], in_re); | |
125 | 4849920 | INTFLOAT a_im = AAC_MUL31(ag[m], in_im); | |
126 | 4849920 | INTFLOAT link_delay_re = ap_delay[m][n+2-m][0]; | |
127 | 4849920 | INTFLOAT link_delay_im = ap_delay[m][n+2-m][1]; | |
128 | 4849920 | INTFLOAT fractional_delay_re = Q_fract[m][0]; | |
129 | 4849920 | INTFLOAT fractional_delay_im = Q_fract[m][1]; | |
130 | 4849920 | INTFLOAT apd_re = in_re; | |
131 | 4849920 | INTFLOAT apd_im = in_im; | |
132 | 4849920 | in_re = AAC_MSUB30(link_delay_re, fractional_delay_re, | |
133 | link_delay_im, fractional_delay_im); | ||
134 | 4849920 | in_re -= (UINTFLOAT)a_re; | |
135 | 4849920 | in_im = AAC_MADD30(link_delay_re, fractional_delay_im, | |
136 | link_delay_im, fractional_delay_re); | ||
137 | 4849920 | in_im -= (UINTFLOAT)a_im; | |
138 | 4849920 | ap_delay[m][n+5][0] = apd_re + (UINTFLOAT)AAC_MUL31(ag[m], in_re); | |
139 | 4849920 | ap_delay[m][n+5][1] = apd_im + (UINTFLOAT)AAC_MUL31(ag[m], in_im); | |
140 | } | ||
141 | 1616640 | out[n][0] = AAC_MUL16(transient_gain[n], in_re); | |
142 | 1616640 | out[n][1] = AAC_MUL16(transient_gain[n], in_im); | |
143 | } | ||
144 | 50520 | } | |
145 | |||
146 | 141042 | static void ps_stereo_interpolate_c(INTFLOAT (*l)[2], INTFLOAT (*r)[2], | |
147 | INTFLOAT h[2][4], INTFLOAT h_step[2][4], | ||
148 | int len) | ||
149 | { | ||
150 | 141042 | INTFLOAT h0 = h[0][0]; | |
151 | 141042 | INTFLOAT h1 = h[0][1]; | |
152 | 141042 | INTFLOAT h2 = h[0][2]; | |
153 | 141042 | INTFLOAT h3 = h[0][3]; | |
154 | 141042 | UINTFLOAT hs0 = h_step[0][0]; | |
155 | 141042 | UINTFLOAT hs1 = h_step[0][1]; | |
156 | 141042 | UINTFLOAT hs2 = h_step[0][2]; | |
157 | 141042 | UINTFLOAT hs3 = h_step[0][3]; | |
158 | int n; | ||
159 | |||
160 |
2/2✓ Branch 0 taken 3628704 times.
✓ Branch 1 taken 141042 times.
|
3769746 | for (n = 0; n < len; n++) { |
161 | //l is s, r is d | ||
162 | 3628704 | INTFLOAT l_re = l[n][0]; | |
163 | 3628704 | INTFLOAT l_im = l[n][1]; | |
164 | 3628704 | INTFLOAT r_re = r[n][0]; | |
165 | 3628704 | INTFLOAT r_im = r[n][1]; | |
166 | 3628704 | h0 += hs0; | |
167 | 3628704 | h1 += hs1; | |
168 | 3628704 | h2 += hs2; | |
169 | 3628704 | h3 += hs3; | |
170 | 3628704 | l[n][0] = AAC_MADD30(h0, l_re, h2, r_re); | |
171 | 3628704 | l[n][1] = AAC_MADD30(h0, l_im, h2, r_im); | |
172 | 3628704 | r[n][0] = AAC_MADD30(h1, l_re, h3, r_re); | |
173 | 3628704 | r[n][1] = AAC_MADD30(h1, l_im, h3, r_im); | |
174 | } | ||
175 | 141042 | } | |
176 | |||
177 | 7387 | static void ps_stereo_interpolate_ipdopd_c(INTFLOAT (*l)[2], INTFLOAT (*r)[2], | |
178 | INTFLOAT h[2][4], INTFLOAT h_step[2][4], | ||
179 | int len) | ||
180 | { | ||
181 | 7387 | INTFLOAT h00 = h[0][0], h10 = h[1][0]; | |
182 | 7387 | INTFLOAT h01 = h[0][1], h11 = h[1][1]; | |
183 | 7387 | INTFLOAT h02 = h[0][2], h12 = h[1][2]; | |
184 | 7387 | INTFLOAT h03 = h[0][3], h13 = h[1][3]; | |
185 | 7387 | UINTFLOAT hs00 = h_step[0][0], hs10 = h_step[1][0]; | |
186 | 7387 | UINTFLOAT hs01 = h_step[0][1], hs11 = h_step[1][1]; | |
187 | 7387 | UINTFLOAT hs02 = h_step[0][2], hs12 = h_step[1][2]; | |
188 | 7387 | UINTFLOAT hs03 = h_step[0][3], hs13 = h_step[1][3]; | |
189 | int n; | ||
190 | |||
191 |
2/2✓ Branch 0 taken 132704 times.
✓ Branch 1 taken 7387 times.
|
140091 | for (n = 0; n < len; n++) { |
192 | //l is s, r is d | ||
193 | 132704 | INTFLOAT l_re = l[n][0]; | |
194 | 132704 | INTFLOAT l_im = l[n][1]; | |
195 | 132704 | INTFLOAT r_re = r[n][0]; | |
196 | 132704 | INTFLOAT r_im = r[n][1]; | |
197 | 132704 | h00 += hs00; | |
198 | 132704 | h01 += hs01; | |
199 | 132704 | h02 += hs02; | |
200 | 132704 | h03 += hs03; | |
201 | 132704 | h10 += hs10; | |
202 | 132704 | h11 += hs11; | |
203 | 132704 | h12 += hs12; | |
204 | 132704 | h13 += hs13; | |
205 | |||
206 | 132704 | l[n][0] = AAC_MSUB30_V8(h00, l_re, h02, r_re, h10, l_im, h12, r_im); | |
207 | 132704 | l[n][1] = AAC_MADD30_V8(h00, l_im, h02, r_im, h10, l_re, h12, r_re); | |
208 | 132704 | r[n][0] = AAC_MSUB30_V8(h01, l_re, h03, r_re, h11, l_im, h13, r_im); | |
209 | 132704 | r[n][1] = AAC_MADD30_V8(h01, l_im, h03, r_im, h11, l_re, h13, r_re); | |
210 | } | ||
211 | 7387 | } | |
212 | |||
213 | 389 | av_cold void AAC_RENAME(ff_psdsp_init)(PSDSPContext *s) | |
214 | { | ||
215 | 389 | s->add_squares = ps_add_squares_c; | |
216 | 389 | s->mul_pair_single = ps_mul_pair_single_c; | |
217 | 389 | s->hybrid_analysis = ps_hybrid_analysis_c; | |
218 | 389 | s->hybrid_analysis_ileave = ps_hybrid_analysis_ileave_c; | |
219 | 389 | s->hybrid_synthesis_deint = ps_hybrid_synthesis_deint_c; | |
220 | 389 | s->decorrelate = ps_decorrelate_c; | |
221 | 389 | s->stereo_interpolate[0] = ps_stereo_interpolate_c; | |
222 | 389 | s->stereo_interpolate[1] = ps_stereo_interpolate_ipdopd_c; | |
223 | |||
224 | #if !USE_FIXED | ||
225 | #if ARCH_ARM | ||
226 | ff_psdsp_init_arm(s); | ||
227 | #elif ARCH_AARCH64 | ||
228 | ff_psdsp_init_aarch64(s); | ||
229 | #elif ARCH_RISCV | ||
230 | ff_psdsp_init_riscv(s); | ||
231 | #elif ARCH_X86 | ||
232 | 354 | ff_psdsp_init_x86(s); | |
233 | #endif | ||
234 | #endif /* !USE_FIXED */ | ||
235 | 389 | } | |
236 |