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 : #include <stdint.h>
34 : #include "options.h"
35 : #include "math.h"
36 : #include "prot_fx.h"
37 : #include "ivas_rom_com.h"
38 : #include <assert.h>
39 : #include "wmc_auto.h"
40 : #include "ivas_prot_fx.h"
41 :
42 :
43 : /*-----------------------------------------------------------------------------------------*
44 : * Function ivas_quantise_real_values()
45 : *
46 : * Quantize real values
47 : *-----------------------------------------------------------------------------------------*/
48 862622 : void ivas_quantise_real_values_enc_fx_varq(
49 : const Word32 *values_fx,
50 : const Word16 q_levels,
51 : const Word32 min_value_fx,
52 : const Word32 max_value_fx,
53 : Word16 *index,
54 : Word32 *quant_fx,
55 : const Word16 dim,
56 : Word16 inp_q )
57 : {
58 : Word16 i;
59 : Word32 q_step_fx, one_by_q_step_fx;
60 862622 : test();
61 862622 : IF( EQ_16( q_levels, 1 ) )
62 : {
63 0 : FOR( i = 0; i < dim; i++ )
64 : {
65 0 : quant_fx[i] = 0;
66 0 : move32();
67 0 : index[i] = 0;
68 0 : move16();
69 : }
70 : }
71 862622 : ELSE IF( q_levels && NE_32( max_value_fx, min_value_fx ) )
72 862622 : {
73 862622 : Word16 nor_q_level = norm_l( sub( q_levels, 1 ) );
74 862622 : Word32 one_by_q_levels = divide3232( L_shl( 1, ( nor_q_level ) ), L_shl( sub( q_levels, 1 ), ( nor_q_level ) ) ); // Q15
75 862622 : one_by_q_levels = L_shl( one_by_q_levels, 16 ); // Q31
76 862622 : q_step_fx = Mpy_32_32( L_sub( max_value_fx, min_value_fx ), one_by_q_levels ); // Q28
77 : Word16 exp;
78 862622 : Word16 one_by_max_min = BASOP_Util_Divide3232_Scale( ONE_IN_Q28, L_sub( max_value_fx, min_value_fx ), &exp ); // Q(15-exp)
79 862622 : one_by_q_step_fx = L_mult0( sub( q_levels, 1 ), one_by_max_min ); // Q(15-exp)
80 : Word32 val_fx;
81 862622 : IF( LT_16( inp_q, Q28 ) )
82 : {
83 56509 : FOR( i = 0; i < dim; i++ )
84 : {
85 49234 : val_fx = L_max( L_shr( min_value_fx, sub( Q28, inp_q ) ), L_min( values_fx[i], L_shr( max_value_fx, sub( Q28, inp_q ) ) ) ); // Q(inp_q)
86 49234 : val_fx = L_shl( val_fx, sub( Q28, inp_q ) ); // Q28
87 49234 : index[i] = round_fx( L_shl( Mpy_32_32( one_by_q_step_fx, val_fx ), add( Q4, exp ) ) ); // Q0
88 49234 : move16();
89 49234 : quant_fx[i] = imult3216( q_step_fx, index[i] ); // Q28
90 49234 : move32();
91 : }
92 : }
93 : ELSE
94 : {
95 5681597 : FOR( i = 0; i < dim; i++ )
96 : {
97 4826250 : val_fx = L_max( min_value_fx, L_min( L_shr( values_fx[i], sub( inp_q, Q28 ) ), max_value_fx ) ); // Q28
98 4826250 : index[i] = round_fx( L_shl( Mpy_32_32( one_by_q_step_fx, val_fx ), add( Q4, exp ) ) ); // Q0
99 4826250 : move16();
100 4826250 : quant_fx[i] = imult3216( q_step_fx, index[i] ); // Q28
101 4826250 : move32();
102 : }
103 : }
104 : }
105 : ELSE
106 : {
107 0 : FOR( i = 0; i < dim; i++ )
108 : {
109 0 : quant_fx[i] = values_fx[i];
110 0 : move32();
111 : }
112 : }
113 862622 : return;
114 : }
115 :
116 :
117 6012 : void ivas_quantise_real_values_fx(
118 : const Word32 *values_fx, /*q28*/
119 : const Word16 q_levels,
120 : const Word32 min_value_fx, /*q28*/
121 : const Word32 max_value_fx, /*q28*/
122 : Word16 *index,
123 : Word32 *quant_fx, /*q28*/
124 : const Word16 dim )
125 : {
126 : Word16 i;
127 : Word32 q_step_fx, one_by_q_step_fx;
128 6012 : test();
129 6012 : IF( EQ_16( q_levels, 1 ) )
130 : {
131 1564 : FOR( i = 0; i < dim; i++ )
132 : {
133 782 : quant_fx[i] = 0;
134 782 : move32();
135 782 : index[i] = 0;
136 782 : move16();
137 : }
138 : }
139 5230 : ELSE IF( q_levels && NE_32( max_value_fx, min_value_fx ) )
140 5230 : {
141 5230 : Word16 nor_q_level = norm_l( sub( q_levels, 1 ) );
142 5230 : Word32 one_by_q_levels = divide3232( L_shl( 1, ( nor_q_level ) ), L_shl( sub( q_levels, 1 ), ( nor_q_level ) ) ); // q15
143 5230 : one_by_q_levels = L_shl( one_by_q_levels, 16 ); // q31
144 5230 : q_step_fx = Mpy_32_32( L_sub( max_value_fx, min_value_fx ), one_by_q_levels ); // q28
145 5230 : Word16 one_by_max_min = divide3232( ONE_IN_Q28, L_sub( max_value_fx, min_value_fx ) ); // q15
146 5230 : one_by_q_step_fx = L_mult0( sub( q_levels, 1 ), one_by_max_min ); // q15
147 : Word32 val_fx;
148 10460 : FOR( i = 0; i < dim; i++ )
149 : {
150 5230 : val_fx = L_max( min_value_fx, L_min( values_fx[i], max_value_fx ) ); // q28
151 5230 : index[i] = extract_l( L_shr( Mpy_32_32( one_by_q_step_fx, val_fx ), 12 ) ); // q15+q28-q31-q12=>q0
152 5230 : move16();
153 5230 : quant_fx[i] = imult3216( q_step_fx, index[i] ); // q28
154 5230 : move16();
155 : }
156 : }
157 : ELSE
158 : {
159 0 : FOR( i = 0; i < dim; i++ )
160 : {
161 0 : quant_fx[i] = values_fx[i]; // q28
162 0 : move32();
163 : }
164 : }
165 6012 : return;
166 : }
167 :
168 2510578 : void ivas_quantise_real_values_enc_fx(
169 : const Word32 *values_fx, // Q28
170 : const Word16 q_levels,
171 : const Word32 min_value_fx, // Q28
172 : const Word32 max_value_fx, // Q28
173 : Word16 *index,
174 : Word32 *quant_fx, // Q28
175 : const Word16 dim )
176 : {
177 : Word16 i;
178 : Word32 q_step_fx, one_by_q_step_fx;
179 2510578 : test();
180 2510578 : IF( EQ_16( q_levels, 1 ) )
181 : {
182 3052 : FOR( i = 0; i < dim; i++ )
183 : {
184 1526 : quant_fx[i] = 0;
185 1526 : move32();
186 1526 : index[i] = 0;
187 1526 : move16();
188 : }
189 : }
190 2509052 : ELSE IF( q_levels && NE_32( max_value_fx, min_value_fx ) )
191 2509052 : {
192 2509052 : Word16 nor_q_level = norm_l( sub( q_levels, 1 ) );
193 2509052 : Word32 one_by_q_levels = divide3232( L_shl( 1, ( nor_q_level ) ), L_shl( sub( q_levels, 1 ), ( nor_q_level ) ) ); // Q15
194 2509052 : one_by_q_levels = L_shl( one_by_q_levels, 16 ); // Q31
195 2509052 : q_step_fx = Mpy_32_32( L_sub( max_value_fx, min_value_fx ), one_by_q_levels ); // Q28
196 : Word16 exp;
197 2509052 : Word16 one_by_max_min = BASOP_Util_Divide3232_Scale( ONE_IN_Q28, L_sub( max_value_fx, min_value_fx ), &exp ); // Q(15-exp)
198 2509052 : one_by_q_step_fx = L_mult0( sub( q_levels, 1 ), one_by_max_min ); // Q(15-exp)
199 : Word32 val_fx;
200 12418072 : FOR( i = 0; i < dim; i++ )
201 : {
202 9909020 : val_fx = L_max( min_value_fx, L_min( values_fx[i], max_value_fx ) ); // Q28
203 9909020 : index[i] = round_fx( L_shl( Mpy_32_32( one_by_q_step_fx, val_fx ), add( Q4, exp ) ) ); //(Q(15-exp)+Q28-Q31)+Q4+Q(exp)=Q0
204 9909020 : move16();
205 9909020 : quant_fx[i] = imult3216( q_step_fx, index[i] ); // Q28
206 9909020 : move32();
207 : }
208 : }
209 : ELSE
210 : {
211 0 : FOR( i = 0; i < dim; i++ )
212 : {
213 0 : quant_fx[i] = values_fx[i]; // Q28
214 0 : move32();
215 : }
216 : }
217 :
218 2510578 : return;
219 : }
220 :
221 :
222 : /*-----------------------------------------------------------------------------------------*
223 : * Function ivas_spar_get_uniform_quant_strat()
224 : *
225 : * Sets the quant strat values
226 : *-----------------------------------------------------------------------------------------*/
227 :
228 5453 : void ivas_spar_get_uniform_quant_strat_fx(
229 : ivas_spar_md_com_cfg *pSpar_md_com_cfg,
230 : const Word16 table_idx )
231 : {
232 : Word16 i;
233 5453 : Word16 active_w = ivas_spar_br_table_consts[table_idx].active_w;
234 5453 : move16();
235 : Word16 PQ_q_lvl, C_q_lvl, Pr_q_lvl, Pc_q_lvl;
236 :
237 5453 : pSpar_md_com_cfg->num_quant_strats = MAX_QUANT_STRATS;
238 5453 : move16();
239 :
240 21812 : FOR( i = 0; i < pSpar_md_com_cfg->num_quant_strats; i++ )
241 : {
242 16359 : PQ_q_lvl = ivas_spar_br_table_consts[table_idx].q_lvls[i][0];
243 16359 : move16();
244 16359 : C_q_lvl = ivas_spar_br_table_consts[table_idx].q_lvls[i][1];
245 16359 : move16();
246 16359 : Pr_q_lvl = ivas_spar_br_table_consts[table_idx].q_lvls[i][2];
247 16359 : move16();
248 16359 : Pc_q_lvl = ivas_spar_br_table_consts[table_idx].q_lvls[i][3];
249 16359 : move16();
250 :
251 16359 : IF( active_w )
252 : {
253 5865 : pSpar_md_com_cfg->quant_strat[i].PR.q_levels[0] = PQ_q_lvl;
254 5865 : move16();
255 5865 : pSpar_md_com_cfg->quant_strat[i].PR.q_levels[1] = PQ_q_lvl;
256 5865 : move16();
257 5865 : pSpar_md_com_cfg->quant_strat[i].PR.min_fx = -322122547; // -1.2*Q28
258 5865 : move32();
259 5865 : pSpar_md_com_cfg->quant_strat[i].PR.max_fx = 322122547; // 1.2*Q28
260 5865 : move32();
261 :
262 5865 : pSpar_md_com_cfg->quant_strat[i].C.q_levels[0] = C_q_lvl;
263 5865 : move16();
264 5865 : pSpar_md_com_cfg->quant_strat[i].C.q_levels[1] = C_q_lvl;
265 5865 : move16();
266 5865 : pSpar_md_com_cfg->quant_strat[i].C.min_fx = -214748364; //-.8*Q28
267 5865 : move32();
268 5865 : pSpar_md_com_cfg->quant_strat[i].C.max_fx = 214748364; //.8*Q28
269 5865 : move32();
270 :
271 5865 : pSpar_md_com_cfg->quant_strat[i].P_r.q_levels[0] = Pr_q_lvl;
272 5865 : move16();
273 5865 : pSpar_md_com_cfg->quant_strat[i].P_r.q_levels[1] = Pr_q_lvl;
274 5865 : move16();
275 5865 : pSpar_md_com_cfg->quant_strat[i].P_r.min_fx = 0;
276 5865 : move32();
277 5865 : pSpar_md_com_cfg->quant_strat[i].P_r.max_fx = 214748364; //.8*Q28
278 5865 : move32();
279 :
280 5865 : pSpar_md_com_cfg->quant_strat[i].P_c.q_levels[0] = Pc_q_lvl;
281 5865 : move16();
282 5865 : pSpar_md_com_cfg->quant_strat[i].P_c.q_levels[1] = Pc_q_lvl;
283 5865 : move16();
284 5865 : pSpar_md_com_cfg->quant_strat[i].P_c.min_fx = -214748364; //-.8*Q28
285 5865 : move32();
286 5865 : pSpar_md_com_cfg->quant_strat[i].P_c.max_fx = 214748364; //.8*Q28
287 5865 : move32();
288 : }
289 : ELSE
290 : {
291 10494 : pSpar_md_com_cfg->quant_strat[i].PR.q_levels[0] = PQ_q_lvl;
292 10494 : move16();
293 10494 : pSpar_md_com_cfg->quant_strat[i].PR.q_levels[1] = PQ_q_lvl;
294 10494 : move16();
295 10494 : pSpar_md_com_cfg->quant_strat[i].PR.max_fx = ONE_IN_Q28; // 1 Q28
296 10494 : move32();
297 10494 : pSpar_md_com_cfg->quant_strat[i].PR.min_fx = -ONE_IN_Q28; //-1 Q28
298 10494 : move32();
299 :
300 10494 : pSpar_md_com_cfg->quant_strat[i].C.q_levels[0] = C_q_lvl;
301 10494 : move16();
302 10494 : pSpar_md_com_cfg->quant_strat[i].C.q_levels[1] = C_q_lvl;
303 10494 : move16();
304 10494 : pSpar_md_com_cfg->quant_strat[i].C.max_fx = ONE_IN_Q29; // 2 Q28
305 10494 : move32();
306 10494 : pSpar_md_com_cfg->quant_strat[i].C.min_fx = -ONE_IN_Q29; //-2 Q28
307 10494 : move32();
308 :
309 10494 : pSpar_md_com_cfg->quant_strat[i].P_r.q_levels[0] = Pr_q_lvl;
310 10494 : move16();
311 10494 : pSpar_md_com_cfg->quant_strat[i].P_r.q_levels[1] = Pr_q_lvl;
312 10494 : move16();
313 10494 : pSpar_md_com_cfg->quant_strat[i].P_r.max_fx = ONE_IN_Q28; // 1 Q28
314 10494 : move32();
315 10494 : pSpar_md_com_cfg->quant_strat[i].P_r.min_fx = 0; // Q28
316 10494 : move32();
317 :
318 10494 : pSpar_md_com_cfg->quant_strat[i].P_c.q_levels[0] = Pc_q_lvl;
319 10494 : move16();
320 10494 : pSpar_md_com_cfg->quant_strat[i].P_c.q_levels[1] = Pc_q_lvl;
321 10494 : move16();
322 10494 : pSpar_md_com_cfg->quant_strat[i].P_c.max_fx = ONE_IN_Q27; // 0.5 Q28
323 10494 : move32();
324 10494 : pSpar_md_com_cfg->quant_strat[i].P_c.min_fx = -ONE_IN_Q27; //-0.5 Q28
325 10494 : move32();
326 : }
327 : }
328 :
329 5453 : return;
330 : }
331 :
332 :
333 : /*-----------------------------------------------------------------------------------------*
334 : * Function ivas_map_prior_coeffs_quant()
335 : *
336 : * Map prior coeffs
337 : *-----------------------------------------------------------------------------------------*/
338 163847 : void ivas_map_prior_coeffs_quant(
339 : ivas_spar_md_prev_t *pSpar_md_prior,
340 : ivas_spar_md_com_cfg *pSpar_md_cfg,
341 : const Word16 qsi,
342 : const Word16 nB )
343 : {
344 : Word16 i, j;
345 :
346 163847 : IF( NE_16( qsi, pSpar_md_cfg->prev_quant_idx ) )
347 : {
348 1976 : ivas_quant_strat_t qs = pSpar_md_cfg->quant_strat[qsi];
349 1976 : ivas_quant_strat_t prev_qs = pSpar_md_cfg->quant_strat[pSpar_md_cfg->prev_quant_idx];
350 1976 : Word32 one_by_q_lvl_PR_fx = one_by_q_level[max( ( prev_qs.PR.q_levels[0] - 1 ), 1 )]; /*q31*/
351 1976 : move32();
352 1976 : Word32 one_by_q_lvl_C_fx = one_by_q_level[max( ( prev_qs.C.q_levels[0] - 1 ), 1 )]; /*q31*/
353 1976 : move32();
354 1976 : Word32 one_by_q_lvl_P_r_fx = one_by_q_level[max( ( prev_qs.P_r.q_levels[0] - 1 ), 1 )]; /*q31*/
355 1976 : move32();
356 17784 : FOR( i = 0; i < nB; i++ )
357 : {
358 173888 : FOR( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
359 : {
360 158080 : Word32 trial1 = L_mult0( sub( qs.PR.q_levels[0], 1 ), pSpar_md_prior->band_coeffs_idx[i].pred_index_re[j] ); /*q0*/
361 158080 : trial1 = L_shl( trial1, 16 ); /*q16*/
362 158080 : trial1 = round_fx( Mpy_32_32( trial1, one_by_q_lvl_PR_fx ) ); /*q16+q31-31-16->0*/
363 158080 : pSpar_md_prior->band_coeffs_idx_mapped[i].pred_index_re[j] = extract_l( trial1 ); /*q0*/
364 158080 : move16();
365 158080 : Word32 trial2 = L_mult0( sub( qs.P_r.q_levels[0], 1 ), pSpar_md_prior->band_coeffs_idx[i].decd_index_re[j] ); /*q0*/
366 158080 : trial2 = L_shl( trial2, 16 ); /*q16*/
367 158080 : trial2 = round_fx( Mpy_32_32( trial2, one_by_q_lvl_P_r_fx ) ); /*q16+q31-31-16->0*/
368 158080 : pSpar_md_prior->band_coeffs_idx_mapped[i].decd_index_re[j] = extract_l( trial2 ); /*q0*/
369 158080 : move16();
370 : }
371 347776 : FOR( j = 0; j < IVAS_SPAR_MAX_C_COEFF; j++ )
372 : {
373 331968 : Word32 trial1 = L_mult0( sub( qs.C.q_levels[0], 1 ), pSpar_md_prior->band_coeffs_idx[i].drct_index_re[j] ); /*q0*/
374 331968 : trial1 = L_shl( trial1, 16 ); /*q16*/
375 331968 : trial1 = round_fx( Mpy_32_32( trial1, one_by_q_lvl_C_fx ) ); /*q16+q31-31-16->0*/
376 331968 : pSpar_md_prior->band_coeffs_idx_mapped[i].drct_index_re[j] = extract_l( trial1 ); /*q0*/
377 331968 : move16();
378 : }
379 : }
380 : }
381 : ELSE
382 : {
383 1456839 : FOR( i = 0; i < nB; i++ )
384 : {
385 14244648 : FOR( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
386 : {
387 12949680 : pSpar_md_prior->band_coeffs_idx_mapped[i].pred_index_re[j] = pSpar_md_prior->band_coeffs_idx[i].pred_index_re[j];
388 12949680 : move16();
389 12949680 : pSpar_md_prior->band_coeffs_idx_mapped[i].decd_index_re[j] = pSpar_md_prior->band_coeffs_idx[i].decd_index_re[j];
390 12949680 : move16();
391 : }
392 28489296 : FOR( j = 0; j < IVAS_SPAR_MAX_C_COEFF; j++ )
393 : {
394 27194328 : pSpar_md_prior->band_coeffs_idx_mapped[i].drct_index_re[j] = pSpar_md_prior->band_coeffs_idx[i].drct_index_re[j];
395 27194328 : move16();
396 : }
397 : }
398 : }
399 :
400 163847 : return;
401 : }
402 :
403 : /*-----------------------------------------------------------------------------------------*
404 : * Function ivas_spar_quant_dtx_init()
405 : *
406 : * Init SPAR MD with minmax vals
407 : *-----------------------------------------------------------------------------------------*/
408 2004 : void ivas_spar_quant_dtx_init_fx(
409 : ivas_spar_md_t *spar_md,
410 : Word32 *min_max /*q28*/ )
411 : {
412 2004 : spar_md->min_max_fx[0] = min_max[0]; // q28
413 2004 : move32();
414 2004 : spar_md->min_max_fx[1] = min_max[1]; // q28
415 2004 : move32();
416 :
417 2004 : return;
418 : }
419 :
420 : /*-----------------------------------------------------------------------------------------*
421 : * Function ivas_copy_band_coeffs_idx_to_arr()
422 : *
423 : * Copy pred band coeffs to arr
424 : *-----------------------------------------------------------------------------------------*/
425 :
426 1661748 : void ivas_copy_band_coeffs_idx_to_arr(
427 : ivas_band_coeffs_ind_t *pBands_idx,
428 : const Word16 nB,
429 : Word16 *pSymbol_re,
430 : ivas_cell_dim_t *pCell_dims,
431 : const ivas_coeffs_type_t coeff_type )
432 : {
433 : Word16 i, len;
434 1661748 : Word16 *pPtr_idx = NULL;
435 :
436 14921284 : FOR( i = 0; i < nB; i++ )
437 : {
438 13259536 : SWITCH( coeff_type )
439 : {
440 3368332 : case PRED_COEFF:
441 : {
442 3368332 : pPtr_idx = pBands_idx[i].pred_index_re;
443 3368332 : BREAK;
444 : }
445 3360580 : case DRCT_COEFF:
446 : {
447 3360580 : pPtr_idx = pBands_idx[i].drct_index_re;
448 3360580 : BREAK;
449 : }
450 3360516 : case DECD_COEFF:
451 : {
452 3360516 : pPtr_idx = pBands_idx[i].decd_index_re;
453 3360516 : BREAK;
454 : }
455 3170108 : case DECX_COEFF:
456 : {
457 3170108 : BREAK;
458 : }
459 : }
460 13259536 : len = imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 );
461 13259536 : IF( NE_16( coeff_type, DECX_COEFF ) )
462 : {
463 10089428 : Copy( pPtr_idx, pSymbol_re, len );
464 10089428 : pSymbol_re += len;
465 : }
466 : }
467 :
468 :
469 1661748 : return;
470 : }
471 :
472 :
473 : /*-----------------------------------------------------------------------------------------*
474 : * Function ivas_clear_band_coeffs()
475 : *
476 : * clear band coeffs array in SPAR MD
477 : *-----------------------------------------------------------------------------------------*/
478 :
479 5677 : void ivas_clear_band_coeffs_fx(
480 : ivas_band_coeffs_t *pband_coeffs,
481 : const UWord16 num_bands )
482 : {
483 : UWord16 i;
484 :
485 73801 : FOR( i = 0; i < num_bands; i++ )
486 : {
487 68124 : set32_fx( (Word32 *) pband_coeffs[i].C_re_fx, 0, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) );
488 68124 : set32_fx( (Word32 *) pband_coeffs[i].P_re_fx, 0, ( IVAS_SPAR_MAX_CH - 1 ) );
489 68124 : set32_fx( (Word32 *) pband_coeffs[i].C_quant_re_fx, 0, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) );
490 68124 : set32_fx( (Word32 *) pband_coeffs[i].P_quant_re_fx, 0, ( IVAS_SPAR_MAX_CH - 1 ) );
491 68124 : set32_fx( pband_coeffs[i].pred_re_fx, 0, ( IVAS_SPAR_MAX_CH - 1 ) );
492 68124 : set32_fx( pband_coeffs[i].pred_quant_re_fx, 0, ( IVAS_SPAR_MAX_CH - 1 ) );
493 : }
494 :
495 5677 : return;
496 : }
497 : /*-----------------------------------------------------------------------------------------*
498 : * Function ivas_clear_band_coeff_idx()
499 : *
500 : * clear band coeffs index array in SPAR MD
501 : *-----------------------------------------------------------------------------------------*/
502 :
503 11448 : void ivas_clear_band_coeff_idx(
504 : ivas_band_coeffs_ind_t *pband_coeff_idx,
505 : const UWord16 num_bands )
506 : {
507 : UWord16 i;
508 148824 : FOR( i = 0; i < num_bands; i++ )
509 : {
510 137376 : set16_fx( pband_coeff_idx[i].pred_index_re, 0, ( sub( IVAS_SPAR_MAX_CH, 1 ) ) );
511 137376 : set16_fx( pband_coeff_idx[i].drct_index_re, 0, IVAS_SPAR_MAX_C_COEFF );
512 137376 : set16_fx( pband_coeff_idx[i].decd_index_re, 0, sub( IVAS_SPAR_MAX_CH, 1 ) );
513 : }
514 :
515 11448 : return;
516 : }
|