Line data Source code
1 : /******************************************************************************************************
2 :
3 : (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
4 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
5 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
6 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
7 : contributors to this repository. All Rights Reserved.
8 :
9 : This software is protected by copyright law and by international treaties.
10 : The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
11 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
12 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
13 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
14 : contributors to this repository retain full ownership rights in their respective contributions in
15 : the software. This notice grants no license of any kind, including but not limited to patent
16 : license, nor is any license granted by implication, estoppel or otherwise.
17 :
18 : Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
19 : contributions.
20 :
21 : This software is provided "AS IS", without any express or implied warranties. The software is in the
22 : development stage. It is intended exclusively for experts who have experience with such software and
23 : solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
24 : and fitness for a particular purpose are hereby disclaimed and excluded.
25 :
26 : Any dispute, controversy or claim arising under or in relation to providing this software shall be
27 : submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
28 : accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
29 : the United Nations Convention on Contracts on the International Sales of Goods.
30 :
31 : *******************************************************************************************************/
32 :
33 : /*====================================================================================
34 : EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
35 : ====================================================================================*/
36 :
37 : #include <stdint.h>
38 : #include "options.h"
39 : #include "cnst.h"
40 : #include "prot_fx.h"
41 : #include "rom_com.h"
42 : #include <assert.h>
43 : #include "wmc_auto.h"
44 :
45 :
46 12399 : void wtda_fx32(
47 : const Word32 *new_audio, /* i : input audio Q11 */
48 : Word32 *wtda_audio, /* o : windowed audio Q11 */
49 : Word32 *old_wtda, /* i/o: windowed audio from previous frame */
50 : const Word16 left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */
51 : const Word16 right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
52 : const Word16 L /* i : length */
53 : )
54 : {
55 : Word16 i, decimate, decay;
56 : Word16 idx1, idx2, idx3, idx4;
57 : Word16 n, windecay48, windecay16;
58 : const Word32 *allsig_l, *allsig_r;
59 : Word16 win_right[R2_48];
60 : Word16 win_int_left[R1_16];
61 : Word16 win_left[R1_48];
62 : Word16 win_int_right[R2_16];
63 :
64 12399 : tcx_get_windows_mode1( left_mode, right_mode, win_left, win_right, win_int_left, win_int_right, L );
65 :
66 12399 : decimate = 1; /* L_FRAME 48k */
67 12399 : move16();
68 12399 : decay = 0;
69 12399 : move16();
70 12399 : windecay48 = extract_l( WINDECAY48 ); // (int16_t)(2 * ((float)L_FRAME48k * N_ZERO_MDCT_NS / FRAME_SIZE_NS)) + R1_48
71 :
72 12399 : test();
73 12399 : IF( EQ_16( L, L_FRAME32k ) || EQ_16( L, L_FRAME16k ) )
74 : {
75 1997 : decimate = 3;
76 1997 : move16();
77 1997 : decay = 1;
78 1997 : move16();
79 : }
80 10402 : ELSE IF( EQ_16( L, L_FRAME8k ) )
81 : {
82 0 : decimate = 6;
83 0 : move16();
84 0 : decay = 2;
85 0 : move16();
86 : }
87 :
88 12399 : SWITCH( L ) // (int16_t)((float)L * N_ZERO_MDCT_NS / FRAME_SIZE_NS)
89 : {
90 1245 : case L_FRAME16k:
91 1245 : n = 90;
92 1245 : move16();
93 1245 : BREAK;
94 752 : case L_FRAME32k:
95 752 : n = 180;
96 752 : move16();
97 752 : BREAK;
98 10402 : case L_FRAME48k:
99 10402 : n = 270;
100 10402 : move16();
101 10402 : BREAK;
102 0 : default:
103 0 : n = (Word16) ( ( L * N_ZERO_MDCT_NS ) / FRAME_SIZE_NS );
104 0 : move16();
105 0 : BREAK;
106 : }
107 :
108 12399 : windecay16 = extract_l( WINDECAY16 ); // (int16_t)(2 * ((float)L_FRAME16k * N_ZERO_MDCT_NS / FRAME_SIZE_NS)) + R1_16;
109 :
110 : /* algorithmic delay reduction */
111 12399 : i = 0;
112 12399 : move16();
113 :
114 12399 : IF( old_wtda == NULL )
115 : {
116 0 : allsig_r = new_audio + n;
117 0 : allsig_l = new_audio + n - L;
118 : }
119 : ELSE
120 : {
121 12399 : allsig_r = new_audio + n;
122 12399 : allsig_l = old_wtda + n;
123 : }
124 :
125 12399 : IF( EQ_16( L, L_FRAME32k ) )
126 : {
127 53392 : FOR( i = 0; i < ( L / 2 - n ); i += 2 )
128 : {
129 52640 : idx1 = sub( sub( shr( L, 1 ), i ), 1 );
130 52640 : idx2 = sub( sub( 3 * L_FRAME16k / 2 - 1, shr( i, 1 ) ), windecay16 );
131 52640 : idx3 = add( shr( L, 1 ), i );
132 52640 : idx4 = sub( add( 3 * L_FRAME16k / 2, shr( i, 1 ) ), windecay16 );
133 52640 : wtda_audio[i] = L_sub_sat( Mpy_32_16_1( -allsig_r[idx1], win_int_right[idx2] ), Mpy_32_16_1( allsig_r[idx3], win_int_right[idx4] ) );
134 52640 : move32();
135 :
136 52640 : idx1 = sub( sub( shr( L, 1 ), add( i, 1 ) ), 1 );
137 52640 : idx2 = sub( add( i_mult( ( sub( sub( 3 * L_FRAME16k / 2, shr( i, 1 ) ), 1 ) ), decimate ), decay ), windecay48 );
138 52640 : idx3 = add( add( shr( L, 1 ), i ), 1 );
139 52640 : idx4 = sub( sub( sub( i_mult( ( add( 3 * L_FRAME16k / 2 + 1, shr( i, 1 ) ) ), decimate ), decay ), 1 ), windecay48 );
140 52640 : wtda_audio[i + 1] = L_sub_sat( Mpy_32_16_1( -allsig_r[idx1], win_right[idx2] ), Mpy_32_16_1( allsig_r[idx3], win_right[idx4] ) );
141 52640 : move32();
142 : }
143 :
144 68432 : FOR( i = L / 2 - n; i < L / 2; i += 2 )
145 : {
146 67680 : wtda_audio[i] = L_negate( allsig_r[( ( ( L >> 1 ) - i ) - 1 )] );
147 67680 : move32();
148 67680 : wtda_audio[i + 1] = L_negate( allsig_r[( ( ( L >> 1 ) - ( i + 1 ) ) - 1 )] );
149 67680 : move32();
150 : }
151 68432 : FOR( i = 0; i < n; i += 2 )
152 : {
153 67680 : wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[i], win_left[( ( ( i >> 1 ) * decimate ) + decay )] ), new_audio[( ( n - i ) - 1 )] );
154 67680 : move32();
155 67680 : wtda_audio[( ( i + ( L >> 1 ) ) + 1 )] = L_sub_sat( Mpy_32_16_1( allsig_l[i + 1], win_int_left[i / 2] ), new_audio[( ( n - ( i + 1 ) ) - 1 )] );
156 67680 : move32();
157 : }
158 :
159 53392 : FOR( i = n; i < L / 2; i += 2 )
160 : {
161 52640 : idx1 = i;
162 52640 : move16();
163 52640 : idx2 = add( i_mult( shr( i, 1 ), decimate ), decay );
164 52640 : idx3 = sub( sub( L, i ), 1 );
165 52640 : idx4 = sub( sub( i_mult( sub( shr( L, 1 ), shr( i, 1 ) ), decimate ), 1 ), decay );
166 52640 : wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_left[idx4] ) );
167 52640 : move32();
168 :
169 52640 : idx1 = add( i, 1 );
170 52640 : idx2 = shr( i, 1 );
171 52640 : idx3 = sub( sub( L, add( i, 1 ) ), 1 );
172 52640 : idx4 = sub( sub( shr( L, 1 ), shr( i, 1 ) ), 1 );
173 52640 : wtda_audio[( ( i + ( L >> 1 ) ) + 1 )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_int_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_int_left[idx4] ) );
174 52640 : move32();
175 : }
176 : }
177 : ELSE
178 : {
179 2283217 : FOR( i = 0; i < L / 2 - n; i++ )
180 : {
181 2271570 : idx1 = sub( sub( shr( L, 1 ), i ), 1 );
182 2271570 : idx2 = sub( add( sub( i_mult( i_mult( 3, shr( L, 1 ) ), decimate ), i_mult( add( i, 1 ), decimate ) ), decay ), windecay48 );
183 2271570 : idx3 = add( shr( L, 1 ), i );
184 2271570 : idx4 = sub( sub( add( sub( i_mult( i_mult( 3, shr( L, 1 ) ), decimate ), 1 ), i_mult( add( i, 1 ), decimate ) ), decay ), windecay48 );
185 2271570 : wtda_audio[i] = L_sub_sat( Mpy_32_16_1( -allsig_r[idx1], win_right[idx2] ), Mpy_32_16_1( allsig_r[idx3], win_right[idx4] ) );
186 2271570 : move32();
187 : }
188 :
189 2932237 : FOR( i = L / 2 - n; i < L / 2; i++ )
190 : {
191 2920590 : wtda_audio[i] = L_negate( allsig_r[( ( ( L >> 1 ) - i ) - 1 )] );
192 2920590 : move32();
193 : }
194 :
195 2932237 : FOR( i = 0; i < n; i++ )
196 : {
197 2920590 : wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[i], win_left[( ( i * decimate ) + decay )] ), new_audio[( ( n - i ) - 1 )] );
198 2920590 : move32();
199 : }
200 :
201 2283217 : FOR( i = n; i < L / 2; i++ )
202 : {
203 2271570 : idx1 = i;
204 2271570 : move16();
205 2271570 : idx2 = add( i_mult( i, decimate ), decay );
206 2271570 : idx3 = sub( sub( L, i ), 1 );
207 2271570 : idx4 = sub( sub( sub( i_mult( L, decimate ), i_mult( i, decimate ) ), 1 ), decay );
208 2271570 : wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_left[idx4] ) );
209 2271570 : move32();
210 : }
211 : }
212 :
213 12399 : IF( old_wtda != NULL )
214 : {
215 12399 : Copy32( new_audio, old_wtda, L );
216 : }
217 :
218 12399 : return;
219 : }
|