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 : #ifndef PROT_H
38 : #define PROT_H
39 :
40 : #include <stdio.h>
41 : #include <stdlib.h>
42 : #include <stdint.h>
43 : #include "options.h"
44 : #ifdef DEBUGGING
45 : #include "debug.h"
46 : #endif
47 : #include "typedef.h"
48 : #include "stat_enc.h"
49 : #include "stat_dec.h"
50 : #include "stat_com.h"
51 : #include "ivas_stat_com.h"
52 : #include "ivas_stat_enc.h"
53 : #include "ivas_stat_dec.h"
54 : #include "cnst.h"
55 : #include "stl.h"
56 : #include "ivas_error_utils.h"
57 :
58 :
59 : /*----------------------------------------------------------------------------------*
60 : * Prototypes of global macros
61 : *----------------------------------------------------------------------------------*/
62 :
63 : #ifndef min
64 : #define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
65 : #endif
66 :
67 : #ifndef max
68 : #define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
69 : #endif
70 :
71 : #ifndef TRUNC
72 : #define TRUNC( x ) ( (int16_t) ( ( ( x ) >= 32767. ? 32767 : ( ( x ) <= -32768. ? -32768 : ( x ) ) ) + 0.5 ) )
73 : #endif
74 :
75 : #define log_base_2( x ) ( (double) log( (double) ( x ) ) * 1.4426950408889634074f )
76 : #define round_f( x ) ( ( ( x ) > 0 ) ? (int32_t) ( ( x ) + 0.5f ) : ( -(int32_t) ( ( -x ) + 0.5f ) ) )
77 :
78 : #ifndef ABSVAL
79 : #define ABSVAL( a ) ( ( a ) >= 0 ? ( a ) : ( -( a ) ) )
80 : #endif
81 :
82 : #ifndef SQR
83 : #define SQR( a ) ( ( a ) * ( a ) )
84 : #endif
85 :
86 : #ifndef SWAP
87 : #define SWAP( a, b ) \
88 : { \
89 : tempr = ( a ); \
90 : ( a ) = ( b ); \
91 : ( b ) = tempr; \
92 : }
93 : #endif
94 :
95 : #ifndef swap
96 : #define swap( x, y, type ) \
97 : { \
98 : type u__p; \
99 : u__p = x; \
100 : x = y; \
101 : y = u__p; \
102 : }
103 : #endif
104 :
105 : #define set_max( a, b ) \
106 : { \
107 : if ( ( b ) > *a ) \
108 : { \
109 : *a = ( b ); \
110 : } \
111 : } /* If the first argument is already the highes or lowest, nothing is done. */
112 : #define set_min( a, b ) \
113 : { \
114 : if ( ( b ) < *a ) \
115 : { \
116 : *a = ( b ); \
117 : } \
118 : } /* Otherwise, the 2nd arg is stored at the address of the first arg. */
119 :
120 686520 : static __inline Word16 L_Extract_lc( const Word32 L_32, Word16 *p_hi )
121 : {
122 686520 : *p_hi = extract_h( L_32 );
123 686520 : return lshr( extract_l( L_32 ), 1 );
124 : }
125 :
126 : /*----------------------------------------------------------------------------------*
127 : * MODE1 prototypes
128 : *----------------------------------------------------------------------------------*/
129 :
130 : /*! r: inverse square root of input value */
131 : float inv_sqrt(
132 : const float x /* i : input value */
133 : );
134 :
135 : /*! r: inverse square root of input value (float) */
136 : float inv_sqrtf(
137 : const float x /* i : input value */
138 : );
139 :
140 : /*! r: output random value */
141 : int16_t own_random(
142 : int16_t *seed /* i/o: random seed */
143 : );
144 :
145 : /*! r: sign of x (+1/-1) */
146 : float sign(
147 : const float x /* i : input value of x */
148 : );
149 :
150 : /*! r: logarithm2 of x */
151 : float log2_f(
152 : const float x /* i : input value of x */
153 : );
154 :
155 : int16_t norm_ul(
156 : uint32_t UL_var1 );
157 :
158 : /*! r: sum of all vector elements */
159 : int16_t sum_s(
160 : const int16_t *vec, /* i : input vector */
161 : const int16_t lvec /* i : length of input vector */
162 : );
163 :
164 : #ifdef DEBUGGING
165 : /*! r: sum of all vector elements */
166 : int32_t sum_l(
167 : const int32_t *vec, /* i : input vector */
168 : const int16_t lvec /* i : length of input vector */
169 : );
170 :
171 : #endif
172 : /*! r: sum of all vector elements */
173 : float sum_f(
174 : const float *vec, /* i : input vector */
175 : const int16_t lvec /* i : length of input vector */
176 : );
177 :
178 : /*! r: sum of all squared vector elements */
179 : float sum2_f(
180 : const float *vec, /* i : input vector */
181 : const int16_t lvec /* i : length of input vector */
182 : );
183 :
184 : void set_c(
185 : int8_t y[], /* i/o: Vector to set */
186 : const int8_t a, /* i : Value to set the vector to */
187 : const int32_t N /* i : Length of the vector */
188 : );
189 :
190 : void set_s(
191 : int16_t y[], /* i/o: Vector to set */
192 : const int16_t a, /* i : Value to set the vector to */
193 : const int16_t N /* i : Lenght of the vector */
194 : );
195 :
196 : void set_l(
197 : int32_t y[], /* i/o: Vector to set */
198 : const int32_t a, /* i : Value to set the vector to */
199 : const int16_t N /* i : Length of the vector */
200 : );
201 :
202 : void set_f(
203 : float y[], /* i/o: Vector to set */
204 : const float a, /* i : Value to set the vector to */
205 : const int16_t N /* i : Lenght of the vector */
206 : );
207 :
208 : void set_zero(
209 : float *vec, /* o : input vector */
210 : const int16_t lvec /* i : length of the vector */
211 : );
212 :
213 : void mvr2r(
214 : const float x[], /* i : input vector */
215 : float y[], /* o : output vector */
216 : const int16_t n /* i : vector size */
217 : );
218 :
219 : void mvs2s(
220 : const int16_t x[], /* i : input vector */
221 : int16_t y[], /* o : output vector */
222 : const int16_t n /* i : vector size */
223 : );
224 :
225 : #ifdef DEBUGGING
226 : /*! r: number of overload samples */
227 : uint32_t check_clipping(
228 : const float x[], /* i : input vector */
229 : const int16_t n, /* i : vector size */
230 : float *maxOverload, /* i/o: max overload value */
231 : float *minOverload /* i/o: max overload value */
232 : );
233 :
234 : #endif
235 : /*! r: number of clipped samples */
236 : uint32_t mvr2s(
237 : const float x[], /* i : input vector */
238 : int16_t y[], /* o : output vector */
239 : const int16_t n /* i : vector size */
240 : );
241 :
242 : void mvs2r(
243 : const int16_t x[], /* i : input vector */
244 : float y[], /* o : output vector */
245 : const int16_t n /* i : vector size */
246 : );
247 :
248 : void mvl2l(
249 : const int32_t x[], /* i : input vector */
250 : int32_t y[], /* o : output vector */
251 : const int16_t n /* i : vector size */
252 : );
253 :
254 : void AGC_dec(
255 : float x[], /* i/o: input/output vector */
256 : float mem[], /* i/o: mem[2] should be init to [0,0] */
257 : const int16_t n /* i : vector size */
258 : );
259 :
260 : /*! r: index of the maximum value in the input vector */
261 : int16_t maximum(
262 : const float *vec, /* i : input vector */
263 : const int16_t lvec, /* i : length of input vector */
264 : float *max_val /* o : maximum value in the input vector */
265 : );
266 :
267 : /*! r: index of the maximum value in the input vector */
268 : int16_t maximum_s(
269 : const int16_t *vec, /* i : input vector */
270 : const int16_t lvec, /* i : length of input vector */
271 : int16_t *max /* o : maximum value in the input vector */
272 : );
273 :
274 : /*! r: index of the maximum value in the input vector */
275 : int16_t maximumAbs(
276 : const float *vec, /* i : input vector */
277 : const int16_t lvec, /* i : length of input vector */
278 : float *max_val /* o : maximum value in the input vector */
279 : );
280 :
281 : /*! r: index of the minimum value in the input vector */
282 : int16_t minimum(
283 : const float *vec, /* i : input vector */
284 : const int16_t lvec, /* i : length of input vector */
285 : float *min_val /* o : minimum value in the input vector */
286 : );
287 :
288 : /*! r: index of the minimum value in the input vector */
289 : int16_t minimum_s(
290 : const int16_t *vec, /* i : Input vector */
291 : const int16_t lvec, /* i : Vector length */
292 : int16_t *min_val /* o : minimum value in the input vector */
293 : );
294 :
295 : /*! r: return index with max energy value in vector */
296 : int16_t emaximum(
297 : const float *vec, /* i : input vector */
298 : const int16_t lvec, /* i : length of input vector */
299 : float *ener_max /* o : maximum energy value */
300 : );
301 :
302 : /*! r: vector mean */
303 : float mean(
304 : const float *vec, /* i : input vector */
305 : const int16_t lvec /* i : length of input vector */
306 : );
307 :
308 : /*! r: dot product of x[] and y[] */
309 : float dotp(
310 : const float x[], /* i : vector x[] */
311 : const float y[], /* i : vector y[] */
312 : const int16_t n /* i : vector length */
313 : );
314 :
315 : void conv(
316 : const float x[], /* i : input vector */
317 : const float h[], /* i : impulse response (or second input vector) */
318 : float y[], /* o : output vetor (result of convolution) */
319 : const int16_t L /* i : vector size */
320 : );
321 :
322 : void fir(
323 : const float x[], /* i : input vector */
324 : const float h[], /* i : impulse response of the FIR filter */
325 : float y[], /* o : output vector (result of filtering) */
326 : float mem[], /* i/o: memory of the input signal (M samples) */
327 : const int16_t L, /* i : input vector size */
328 : const int16_t K, /* i : order of the FIR filter (M+1 coefs.) */
329 : const int16_t upd /* i : 1 = update the memory, 0 = not */
330 : );
331 :
332 : void v_add(
333 : const float x1[], /* i : Input vector 1 */
334 : const float x2[], /* i : Input vector 2 */
335 : float y[], /* o : Output vector that contains vector 1 + vector 2 */
336 : const int16_t N /* i : Vector length */
337 : );
338 :
339 : void v_sub(
340 : const float x1[], /* i : Input vector 1 */
341 : const float x2[], /* i : Input vector 2 */
342 : float y[], /* o : Output vector that contains vector 1 - vector 2 */
343 : const int16_t N /* i : Vector length */
344 : );
345 :
346 : void v_mult(
347 : const float x1[], /* i : Input vector 1 */
348 : const float x2[], /* i : Input vector 2 */
349 : float y[], /* o : Output vector that contains vector 1 .* vector 2*/
350 : const int16_t N /* i : Vector length */
351 : );
352 :
353 : void v_multc(
354 : const float x[], /* i : Input vector */
355 : const float c, /* i : Constant */
356 : float y[], /* o : Output vector that contains c*x */
357 : const int16_t N /* i : Vector length */
358 : );
359 :
360 : void v_sub_s(
361 : const int16_t x1[], /* i : Input vector 1 */
362 : const int16_t x2[], /* i : Input vector 2 */
363 : int16_t y[], /* o : Output vector that contains vector 1 - vector 2 */
364 : const int16_t N /* i : Vector length */
365 : );
366 :
367 : /*! r: index of the winning codeword */
368 : int16_t squant(
369 : const float x, /* i : scalar value to quantize */
370 : float *xq, /* o : quantized value */
371 : const float cb[], /* i : codebook */
372 : const int16_t cbsize /* i : codebook size */
373 : );
374 :
375 : int16_t squant_int(
376 : uint8_t x, /* i : scalar value to quantize */
377 : uint8_t *xq, /* o : quantized value */
378 : const uint8_t *cb, /* i : codebook */
379 : const int16_t cbsize /* i : codebook size */
380 : );
381 :
382 : /*! r: index of the winning codevector */
383 : int16_t vquant(
384 : float x[], /* i : vector to quantize */
385 : const float x_mean[], /* i : vector mean to subtract (0 if none) */
386 : float xq[], /* o : quantized vector */
387 : const float cb[], /* i : codebook */
388 : const int16_t dim, /* i : dimension of codebook vectors */
389 : const int16_t cbsize /* i : codebook size */
390 : );
391 :
392 : /*! r: index of the winning codevector */
393 : int16_t w_vquant(
394 : float x[], /* i : vector to quantize */
395 : const float x_mean[], /* i : vector mean to subtract (0 if none) */
396 : const int16_t weights[], /* i : error weights */
397 : float xq[], /* o : quantized vector */
398 : const float cb[], /* i : codebook */
399 : const int16_t dim, /* i : dimension of codebook vectors */
400 : const int16_t cbsize, /* i : codebook size */
401 : const int16_t reverse /* i : reverse codebook vectors */
402 : );
403 :
404 : /*! r: index of the winning codeword */
405 : int16_t usquant(
406 : const float x, /* i : scalar value to quantize */
407 : float *xq, /* o : quantized value */
408 : const float qlow, /* i : lowest codebook entry (index 0) */
409 : const float delta, /* i : quantization step */
410 : const int16_t cbsize /* i : codebook size */
411 : );
412 :
413 : /*! r: dequanzited gain */
414 : float usdequant(
415 : const int16_t idx, /* i : quantizer index */
416 : const float qlow, /* i : lowest codebook entry (index 0) */
417 : const float delta /* i : quantization step */
418 : );
419 :
420 : void v_sort(
421 : float *r, /* i/o: Vector to be sorted in place */
422 : const int16_t lo, /* i : Low limit of sorting range */
423 : const int16_t up /* i : High limit of sorting range */
424 : );
425 :
426 : void sort(
427 : uint16_t *x, /* i/o: Vector to be sorted */
428 : uint16_t len /* i/o: vector length */
429 : );
430 :
431 : /*! r: variance of vector */
432 : float var(
433 : const float *x, /* i : input vector */
434 : const int16_t len /* i : length of inputvector */
435 : );
436 :
437 : /*! r: standard deviation */
438 : float std_dev(
439 : const float *x, /* i : input vector */
440 : const int16_t len /* i : length of the input vector */
441 : );
442 :
443 : /*! r: the dot product x'*A*x */
444 : float dot_product_mat(
445 : const float *x, /* i : vector x */
446 : const float *A, /* i : matrix A */
447 : const int16_t m /* i : vector length */
448 : );
449 :
450 : float root_a(
451 : float a );
452 :
453 : float root_a_over_b(
454 : float a,
455 : float b );
456 :
457 : void polezero_filter(
458 : const float *in, /* i : input vector */
459 : float *out, /* o : output vector */
460 : const int16_t N, /* i : input vector size */
461 : const float *b, /* i : numerator coefficients */
462 : const float *a, /* i : denominator coefficients */
463 : const int16_t order, /* i : filter order */
464 : float *mem /* i/o: filter memory */
465 : );
466 :
467 : double rint_new(
468 : double x /* i/o: Round to the nearest integer with mid point exception */
469 : );
470 :
471 : double anint(
472 : double x /* i/o: Round to the nearest integer */
473 : );
474 :
475 : /*! r: Output either 1 if Numeric, 0 if NaN or Inf */
476 : int16_t is_numeric_float(
477 : float x /* i : Input value which is checked if numeric or not */
478 : );
479 :
480 : void delay_signal(
481 : float x[], /* i/o: signal to be delayed */
482 : const int16_t len, /* i : length of the input signal */
483 : float mem[], /* i/o: synchronization memory */
484 : const int16_t delay /* i : delay in samples */
485 : );
486 :
487 :
488 : ivas_error push_indice(
489 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
490 : int16_t id, /* i : ID of the indice */
491 : uint16_t value, /* i : value of the quantized indice */
492 : int16_t nb_bits /* i : number of bits used to quantize the indice */
493 : );
494 :
495 : #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS )
496 : #define push_next_indice( ... ) push_next_indice_( __func__, __VA_ARGS__ )
497 : #define push_next_bits( ... ) push_next_bits_( __func__, __VA_ARGS__ );
498 : #endif
499 :
500 :
501 : #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS )
502 : ivas_error push_next_indice_(
503 : const char *caller,
504 : #else
505 : ivas_error push_next_indice(
506 : #endif
507 : BSTR_ENC_HANDLE hBstr,
508 : uint16_t value, /* i : value of the quantized indice */
509 : int16_t nb_bits /* i : number of bits used to quantize the indice */
510 : );
511 :
512 : #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS )
513 : ivas_error push_next_bits_(
514 : const char *caller,
515 : #else
516 : ivas_error push_next_bits(
517 : #endif
518 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
519 : const uint16_t bits[], /* i : bit buffer to pack, sequence of single bits */
520 : const int16_t nb_bits /* i : number of bits to pack */
521 : );
522 :
523 : /*! r: maximum number of indices */
524 : int16_t get_ivas_max_num_indices(
525 : const IVAS_FORMAT ivas_format, /* i : IVAS format */
526 : const int32_t ivas_total_brate /* i : IVAS total bitrate */
527 : );
528 :
529 : /*! r: maximum number of indices */
530 : int16_t get_BWE_max_num_indices(
531 : const int32_t extl_brate /* i : extensiona layer bitrate */
532 : );
533 :
534 : /*! r: maximum number of indices */
535 : int16_t get_ivas_max_num_indices_metadata(
536 : const IVAS_FORMAT ivas_format, /* i : IVAS format */
537 : const int32_t ivas_total_brate /* i : IVAS total bitrate */
538 : );
539 :
540 : ivas_error ind_list_realloc(
541 : INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */
542 : const int16_t max_num_indices, /* i : new maximum number of allowed indices in the list */
543 : Encoder_Struct *st_ivas /* i : IVAS encoder structure */
544 : );
545 :
546 : ivas_error check_ind_list_limits(
547 : BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
548 : );
549 :
550 : void move_indices(
551 : INDICE_HANDLE old_ind_list, /* i/o: old location of indices */
552 : INDICE_HANDLE new_ind_list, /* i/o: new location of indices */
553 : const int16_t nb_indices /* i : number of moved indices */
554 : );
555 :
556 : /*! r: index of the indice in the list, -1 if not found */
557 : int16_t find_indice(
558 : BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */
559 : const int16_t id, /* i : ID of the indice */
560 : uint16_t *value, /* o : value of the quantized indice */
561 : int16_t *nb_bits /* o : number of bits used to quantize the indice */
562 : );
563 :
564 : /*! r: number of deleted indices */
565 : uint16_t delete_indice(
566 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
567 : const int16_t id /* i : ID of the indice */
568 : );
569 :
570 : /*! r: value of the indice */
571 : uint16_t get_next_indice(
572 : Decoder_State *st, /* i/o: decoder state structure */
573 : int16_t nb_bits /* i : number of bits that were used to quantize the indice */
574 : );
575 :
576 : /*! r: value of the indice */
577 : uint16_t get_next_indice_1(
578 : Decoder_State *st /* i/o: decoder state structure */
579 : );
580 :
581 : void get_next_indice_tmp(
582 : Decoder_State *st, /* o : decoder state structure */
583 : int16_t nb_bits /* i : number of bits that were used to quantize the indice */
584 : );
585 :
586 : /*! r: value of the indice */
587 : uint16_t get_indice(
588 : Decoder_State *st, /* i/o: decoder state structure */
589 : int16_t pos, /* i : absolute position in the bitstream */
590 : int16_t nb_bits /* i : number of bits that were used to quantize the indice */
591 : );
592 :
593 : /*! r: value of the indice */
594 : uint16_t get_indice_1(
595 : Decoder_State *st, /* i/o: decoder state structure */
596 : int16_t pos /* i : absolute position in the bitstream */
597 : );
598 :
599 : void reset_indices_enc(
600 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
601 : const int16_t max_num_indices /* i : max number of indices */
602 : );
603 :
604 : void reset_indices_dec(
605 : Decoder_State *st /* i/o: decoder state structure */
606 : );
607 :
608 : ivas_error write_indices_ivas(
609 : Encoder_Struct *st_ivas, /* i/o: encoder state structure */
610 : uint16_t *bit_stream, /* i/o: output bitstream */
611 : uint16_t *num_bits /* i/o: number of bits written to output */
612 : );
613 :
614 : Word16 rate2EVSmode(
615 : const Word32 brate, /* i : bitrate */
616 : int16_t *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */
617 : );
618 :
619 :
620 : /*! r: 1 = OK, 0 = something wrong */
621 : ivas_error read_indices(
622 : Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
623 : uint16_t bit_stream[], /* i : bitstream buffer */
624 : UWord16 num_bits, /* i : number of bits in bitstream */
625 : int16_t *prev_ft_speech,
626 : int16_t *CNG,
627 : int16_t bfi /* i : bad frame indicator */
628 : );
629 :
630 : #ifdef DEBUGGING
631 : /*! r: 1 = reading OK, 0 = problem */
632 : ivas_error preview_indices(
633 : Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
634 : uint16_t bit_stream[], /* i : bitstream buffer */
635 : UWord16 num_bits /* i : number of bits in bitstream */
636 : );
637 : #endif
638 :
639 : void ivas_set_bitstream_pointers(
640 : Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
641 : );
642 :
643 : Decoder_State **reset_elements(
644 : Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
645 : );
646 :
647 :
648 : void convertSerialToBytestream(
649 : const uint16_t *const serial, /* i : input serial bitstream with values 0 and 1 */
650 : const uint16_t num_bits, /* i : number of bits in the input bitstream */
651 : uint8_t *const bytestream /* o : output compact bitstream (bytestream) */
652 : );
653 :
654 : void convertBytestreamToSerial(
655 : const uint8_t *const bytestream, /* i : input compact bitstream (bytestream) */
656 : const uint16_t num_bits, /* i : number of bits in the input bitstream */
657 : uint16_t *const serial /* o : output serial bitstream with values 0 and 1 */
658 : );
659 :
660 : void mdct_switching_dec(
661 : Decoder_State *st /* i/o: decoder state structure */
662 : );
663 :
664 : void evs_dec_previewFrame(
665 : uint8_t *bitstream, /* i : bitstream pointer */
666 : int16_t bitstreamSize, /* i : bitstream size */
667 : int16_t *partialCopyFrameType, /* o : frame type of the partial copy */
668 : int16_t *partialCopyOffset /* o : offset of the partial copy relative to the primary copy */
669 : );
670 :
671 :
672 : void getPartialCopyInfo(
673 : Decoder_State *st, /* i : decoder state structure */
674 : int16_t *sharpFlag );
675 :
676 : void get_NextCoderType(
677 : uint8_t *bitstream, /* i : bitstream */
678 : int16_t *next_coder_type /* o : next coder type */
679 : );
680 :
681 : int16_t print_disclaimer(
682 : FILE *fPtr );
683 :
684 : void autocorr(
685 : const float *x, /* i : input signal */
686 : float *r, /* o : autocorrelations vector */
687 : const int16_t m, /* i : order of LP filter */
688 : const int16_t len, /* i : window size */
689 : const float *wind, /* i : window */
690 : const int16_t rev_flag, /* i : flag to reverse window */
691 : const int16_t sym_flag, /* i : symmetric window flag */
692 : const int16_t no_thr /* i : flag to avoid thresholding */
693 : );
694 :
695 : /*! r: energy of prediction error */
696 : int16_t lev_dur(
697 : float *a, /* o : LP coefficients (a[0] = 1.0) */
698 : const float *r, /* i : vector of autocorrelations */
699 : const int16_t m, /* i : order of LP filter */
700 : float epsP[] /* o : prediction error energy */
701 : );
702 :
703 : /*! r: delay value in ns */
704 : int32_t get_delay(
705 : const int16_t enc_dec, /* i : encoder/decoder flag */
706 : const int32_t io_fs, /* i : input/output sampling frequency */
707 : const IVAS_FORMAT ivas_format, /* i : IVAS format */
708 : HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */
709 : const int16_t flag_binaural_split_coded /* i : split rendering on/off flag */
710 : );
711 :
712 : void decision_matrix_enc(
713 : Encoder_State *st, /* i/o: encoder state structure */
714 : int16_t *hq_core_type /* o : HQ core type */
715 : );
716 :
717 : void signaling_enc(
718 : Encoder_State *st /* i : encoder state structure */
719 : );
720 :
721 : int16_t signaling_mode1_tcx20_enc(
722 : Encoder_State *st, /* i/o: encoder state structure */
723 : const int16_t push /* i : flag to push indice */
724 : );
725 :
726 : void decision_matrix_dec(
727 : Decoder_State *st, /* i/o: decoder state structure */
728 : int16_t *sharpFlag, /* o : formant sharpening flag */
729 : int16_t *hq_core_type, /* o : HQ core type */
730 : int16_t *core_switching_flag /* o : ACELP->HQ switching frame flag */
731 : );
732 :
733 : /*! r: LP filter stability */
734 : float lsf_stab(
735 : const float *lsf, /* i : LSF vector */
736 : const float *lsfold, /* i : old LSF vector */
737 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
738 : const int16_t L_frame /* i : frame length */
739 : );
740 :
741 : void amr_wb_dec_init(
742 : AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */
743 : );
744 :
745 : void hf_synth_amr_wb_init(
746 : AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */
747 : );
748 :
749 : void hf_synth_amr_wb_reset(
750 : AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */
751 : ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */
752 : );
753 :
754 : void hf_synth_amr_wb(
755 : AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */
756 : ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */
757 : const int32_t core_brate, /* i : core bitrate */
758 : const int16_t output_frame, /* i : output frame length */
759 : const float *Aq, /* i : quantized Az */
760 : const float *exc, /* i : excitation at 12.8 kHz */
761 : float *synth, /* i/o: synthesis signal at 12.8 kHz */
762 : int16_t *amr_io_class, /* i : signal class (determined by FEC algorithm) */
763 : float *synth_out, /* i/o: synthesis signal at output Fs */
764 : float fmerit, /* i : classify parameter from FEC */
765 : const int16_t *hf_gain, /* i : decoded HF gain */
766 : const float *voice_factors, /* i : voicing factors */
767 : const float pitch_buf[], /* i : pitch buffer */
768 : const float ng_ener_ST, /* i : Noise gate - short-term energy */
769 : const float *lsf_new /* i : ISF vector */
770 : );
771 :
772 : void hf_cod_init(
773 : float *mem_hp400_enc, /* o : memory of hp 400 Hz filter */
774 : float *mem_hf1_enc, /* o : HF band-pass filter memory */
775 : float *mem_syn_hf_enc, /* o : HF synthesis memory */
776 : float *mem_hf2_enc, /* o : HF band-pass filter memory */
777 : float *gain_alpha /* o : smoothing gain for transitions between active and inactive frames */
778 : );
779 :
780 : void hf_cod(
781 : const int32_t core_brate, /* i : core bitrate */
782 : const float *speech16k, /* i : original speech at 16 kHz */
783 : const float Aq[], /* i : quantized Aq */
784 : const float exc[], /* i : excitation at 12.8 kHz */
785 : float synth[], /* i : 12.8kHz synthesis signal */
786 : int16_t *seed2_enc, /* i/o: random seed for HF noise gen */
787 : float *mem_hp400_enc, /* i/o: memory of hp 400 Hz filter */
788 : float *mem_syn_hf_enc, /* i/o: HF synthesis memory */
789 : float *mem_hf1_enc, /* i/o: HF band-pass filter memory */
790 : float *mem_hf2_enc, /* i/o: HF band-pass filter memory */
791 : const int16_t *dtxHangoverCount,
792 : float *gain_alpha, /* i/o: smoothing gain for transitions between active and inactive frames */
793 : int16_t *hf_gain /* o : HF gain to be transmitted to decoder */
794 : );
795 :
796 : void hf_synth_init(
797 : ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */
798 : );
799 :
800 : void hf_synth_reset(
801 : ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */
802 : );
803 :
804 : void hf_synth(
805 : ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */
806 : const int32_t core_brate, /* i : core bitrate */
807 : const int16_t output_frame, /* i : output frame length */
808 : const float *Aq, /* i : quantized Az */
809 : const float *exc, /* i : excitation at 12.8 kHz */
810 : float *synth, /* i/o: 12.8kHz synthesis signal */
811 : float *synth16k /* i/o: 16kHz synthesis signal */
812 : );
813 :
814 : int16_t lsp_convert_poly(
815 : float w[], /* i/o: LSP or ISP parameters */
816 : const int16_t L_frame, /* i : flag for up or down conversion */
817 : const int16_t Opt_AMRWB /* i : flag for the AMR-WB IO mode */
818 : );
819 :
820 : /*! r: pulse position */
821 : int16_t findpulse(
822 : const int16_t L_frame, /* i : length of the frame */
823 : const float res[], /* i : residual signal */
824 : const int16_t T0, /* i : integer pitch */
825 : const int16_t enc_dec, /* i : flag enc/dec, 0 - enc, 1 - dec */
826 : int16_t *sign /* i/o: sign of the maximum */
827 : );
828 :
829 : void fft_rel(
830 : float x[], /* i/o: input/output vector */
831 : const int16_t n, /* i : vector length */
832 : const int16_t m /* i : log2 of vector length */
833 : );
834 :
835 : void ifft_rel(
836 : float io[], /* i/o: input/output vector */
837 : const int16_t n, /* i : vector length */
838 : const int16_t m /* i : log2 of vector length */
839 : );
840 :
841 : void preemph(
842 : float *signal, /* i/o: signal */
843 : const float mu, /* i : preemphasis factor */
844 : const int16_t L, /* i : vector size */
845 : float *mem /* i/o: memory (x[-1]) */
846 : );
847 :
848 : void cb_shape(
849 : const int16_t preemphFlag, /* i : flag for pre-emphasis */
850 : const int16_t pitchFlag, /* i : flag for pitch sharpening */
851 : const int16_t scramblingFlag, /* i : flag for phase scrambling */
852 : const int16_t formantFlag, /* i : flag for formant sharpening */
853 : const int16_t formantTiltFlag, /* i : flag for formant tilt */
854 : const float g1, /* i : formant sharpening numerator weighting */
855 : const float g2, /* i : formant sharpening denominator weighting */
856 : const float *p_Aq, /* i : LP filter coefficients */
857 : float *code, /* i/o: signal to shape */
858 : const float tilt_code, /* i : tilt of code */
859 : const float pt_pitch, /* i : pointer to current subframe fractional pitch*/
860 : const int16_t L_subfr /* i : subfframe length */
861 : );
862 :
863 : void isp2a(
864 : const float *isp, /* i : ISP vector (in the cosine domain) */
865 : float *a, /* o : LP filter coefficients */
866 : const int16_t m /* i : order of LP analysis */
867 : );
868 :
869 : void isp2isf(
870 : const float isp[], /* i : isp[m] (range: -1<=val<1) */
871 : float isf[], /* o : isf[m] normalized (range: 0<=val<=fs/2) */
872 : const int16_t m, /* i : LPC order */
873 : const int32_t Fs /* i : sampling frequency */
874 : );
875 :
876 : void isf2isp(
877 : const float isf[], /* i : isf[m] normalized (range: 0<=val<=fs/2) */
878 : float isp[], /* o : isp[m] (range: -1<=val<1) */
879 : const int16_t m, /* i : LPC order */
880 : const int32_t Fs /* i : sampling frequency */
881 : );
882 :
883 : void reorder_isf(
884 : float *isf, /* i/o: vector of isfs in the frequency domain (0..0.5)*/
885 : const float min_dist, /* i : minimum required distance */
886 : const int16_t n, /* i : LPC order */
887 : const float Fs /* i : sampling frequency */
888 : );
889 :
890 : void lsp2lsf(
891 : const float lsp[], /* i : isp[m] (range: -1<=val<1) */
892 : float lsf[], /* o : isf[m] normalized (range: 0<=val<=fs/2) */
893 : const int16_t m, /* i : LPC order */
894 : const int32_t Fs /* i : sampling frequency */
895 : );
896 :
897 : void lsf2lsp(
898 : const float lsf[], /* i : isf[m] normalized (range: 0<=val<=fs/2) */
899 : float lsp[], /* o : isp[m] (range: -1<=val<1) */
900 : const int16_t m, /* i : LPC order */
901 : const int32_t Fs /* i : sampling frequency */
902 : );
903 :
904 : void lsp2isp(
905 : const float *lsp, /* i : LSP vector */
906 : float *isp, /* o : ISP filter coefficients */
907 : float *stable_isp, /* i/o: ISP filter coefficients */
908 : const int16_t m /* i : order of LP analysis */
909 : );
910 :
911 : void isp2lsp(
912 : const float *isp, /* i : LSP vector */
913 : float *lsp, /* o : ISP filter coefficients */
914 : float *stable_lsp, /* i/o: stable LSP filter coefficients */
915 : const int16_t m /* i : order of LP analysis */
916 : );
917 :
918 : void reorder_lsf(
919 : float *lsf, /* i/o: vector of lsfs in the frequency domain (0..0.5)*/
920 : const float min_dist, /* i : minimum required distance */
921 : const int16_t n, /* i : LPC order */
922 : const int32_t Fs /* i : sampling frequency */
923 : );
924 :
925 : void CNG_exc(
926 : const int32_t core_brate, /* i : core bitrate */
927 : const int16_t L_frame, /* i : length of the frame */
928 : float *Enew, /* i/o: decoded SID energy */
929 : int16_t *seed, /* i/o: random generator seed */
930 : float exc[], /* o : current non-enhanced excitation */
931 : float exc2[], /* o : current enhanced excitation */
932 : float *lp_ener, /* i/o: LP filtered E */
933 : const int32_t last_core_brate, /* i : previous frame core bitrate */
934 : int16_t *first_CNG, /* i/o: first CNG frame flag for energy init. */
935 : int16_t *cng_ener_seed, /* i/o: random generator seed for CNG energy */
936 : float bwe_exc[], /* o : excitation for SWB TBE */
937 : const int16_t allow_cn_step, /* i : allow CN step */
938 : int16_t *last_allow_cn_step, /* i/o: last CN_step */
939 : const int16_t num_ho, /* i : number of selected hangover frames */
940 : float q_env[],
941 : float *lp_env,
942 : float *old_env,
943 : float *exc_mem,
944 : float *exc_mem1,
945 : int16_t *sid_bw,
946 : int16_t *cng_ener_seed1,
947 : float exc3[],
948 : const int16_t Opt_AMR_WB, /* i : AMR-WB interop flag */
949 : const int16_t element_mode /* i : IVAS Element mode */
950 : );
951 :
952 : void cng_params_upd(
953 : const float lsp_new[], /* i : LSP aprameters */
954 : const float exc2[], /* i : current enhanced excitation */
955 : const int16_t L_frame, /* i : frame length */
956 : int16_t *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers */
957 : float ho_ener_circ[], /* o : energy buffer for CNG averaging */
958 : int16_t *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging */
959 : float ho_lsp_circ[], /* o : old LSP buffer for CNG averaging */
960 : const int16_t enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */
961 : float ho_env_circ[], /* i/o: Envelope buffer */
962 : int16_t *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */
963 : float cng_exc2_buf[], /* i/o: Excitation buffer */
964 : int32_t cng_brate_buf[], /* i/o: last_active_brate buffer */
965 : const int32_t last_active_brate, /* i : Last active bitrate */
966 : const int16_t element_mode, /* i : Element mode */
967 : const int16_t bwidth /* i : audio bandwidth */
968 : );
969 :
970 : void cng_params_postupd(
971 : const int16_t ho_circ_ptr, /* i : pointer for CNG averaging buffers */
972 : int16_t *cng_buf_cnt, /* i/o: counter for CNG store buffers */
973 : const float *cng_exc2_buf, /* i : Excitation buffer */
974 : const int32_t *cng_brate_buf, /* i : bitrate buffer */
975 : float ho_env_circ[], /* i/o: Envelope buffer */
976 : const int16_t element_mode, /* i : Element mode */
977 : const int16_t bwidth /* i : audio bandwidth */
978 : );
979 :
980 : void calculate_hangover_attenuation_gain(
981 : Encoder_State *st, /* i : encoder state structure */
982 : float *att, /* o : attenuation factor */
983 : const int16_t vad_hover_flag /* i : VAD hangover flag */
984 : );
985 :
986 : int16_t get_cng_mode(
987 : const int32_t last_active_brate /* i : last active bitrate */
988 : );
989 :
990 : void disf_ns_28b(
991 : int16_t *indice, /* i : quantized indices, use indice[0] = -1 in the decoder*/
992 : float *isf_q /* o : ISF in the frequency domain (0..6400) */
993 : );
994 :
995 : void limit_T0(
996 : const int16_t L_frame, /* i : length of the frame */
997 : const int16_t delta, /* i : Half the close-loop searched interval */
998 : const int16_t pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */
999 : const int16_t limit_flag, /* i : flag for limits (0=restrained, 1=extended) */
1000 : const int16_t T0, /* i : rough pitch estimate around which the search is done */
1001 : const int16_t T0_frac, /* i : pitch estimate fractional part */
1002 : int16_t *T0_min, /* o : lower pitch limit */
1003 : int16_t *T0_max /* o : higher pitch limit */
1004 : );
1005 :
1006 : /*! r: interpolated value */
1007 : float interpolation(
1008 : const float *x, /* i : input vector */
1009 : const float *win, /* i : interpolation window */
1010 : const int16_t frac, /* i : fraction */
1011 : const int16_t up_samp, /* i : upsampling factor */
1012 : const int16_t nb_coef /* i : nb of filter coef */
1013 : );
1014 :
1015 : void deemph(
1016 : float *signal, /* i/o: signal */
1017 : const float mu, /* i : deemphasis factor */
1018 : const int16_t L, /* i : vector size */
1019 : float *mem /* i/o: memory (y[-1]) */
1020 : );
1021 :
1022 : /*! r: tilt of the code */
1023 : float est_tilt(
1024 : const float *adpt_exc, /* i : adaptive excitation vector */
1025 : const float gain_pit, /* i : adaptive gain */
1026 : const float *fixe_exc, /* i : algebraic exctitation vector */
1027 : const float gain_code, /* i : algebraic code gain */
1028 : float *voice_fac, /* o : voicing factor */
1029 : const int16_t L_subfr, /* i : subframe size */
1030 : const int16_t flag_tilt /* i : flag for special tilt */
1031 : );
1032 :
1033 : void weight_a(
1034 : const float *a, /* i : LP filter coefficients */
1035 : float *ap, /* o : weighted LP filter coefficients */
1036 : const float gamma, /* i : weighting factor */
1037 : const int16_t m /* i : order of LP filter */
1038 : );
1039 :
1040 : void weight_a_subfr(
1041 : const int16_t nb_subfr, /* i : number of subframes */
1042 : const float *a, /* i : LP filter coefficients */
1043 : float *ap, /* o : weighted LP filter coefficients */
1044 : const float gamma, /* i : weighting factor */
1045 : const int16_t m /* i : order of LP filter */
1046 : );
1047 :
1048 : void syn_12k8(
1049 : const int16_t L_frame, /* i : length of the frame */
1050 : const float *Aq, /* i : LP filter coefficients */
1051 : const float *exc, /* i : input signal */
1052 : float *synth, /* o : output signal */
1053 : float *mem, /* i/o: initial filter states */
1054 : const int16_t update_m /* i : update memory flag: 0 --> no memory update */
1055 : ); /* 1 --> update of memory */
1056 :
1057 : void syn_filt(
1058 : const float a[], /* i : LP filter coefficients */
1059 : const int16_t m, /* i : order of LP filter */
1060 : const float x[], /* i : input signal */
1061 : float y[], /* o : output signal */
1062 : const int16_t l, /* i : size of filtering */
1063 : float mem[], /* i/o: initial filter states */
1064 : const int16_t update_m /* i : update memory flag: 0 --> no memory update */
1065 : ); /* 1 --> update of memory */
1066 :
1067 : void synth_mem_updt2(
1068 : const int16_t L_frame, /* i : frame length */
1069 : const int16_t last_L_frame, /* i : frame length */
1070 : float old_exc[], /* i/o: excitation buffer */
1071 : float mem_syn_r[], /* i/o: synthesis filter memory */
1072 : float mem_syn2[], /* o : synthesis filter memory for find_target */
1073 : float mem_syn[], /* o : synthesis filter memory for find_target */
1074 : const int16_t dec /* i : flag for decoder indication */
1075 : );
1076 :
1077 : void int_lsp(
1078 : const int16_t L_frame, /* i : length of the frame */
1079 : const float lsp_old[], /* i : LSPs from past frame */
1080 : const float lsp_new[], /* i : LSPs from present frame */
1081 : float *Aq, /* o : LP coefficients in both subframes */
1082 : const int16_t m, /* i : order of LP filter */
1083 : const float *int_coeffs, /* i : interpolation coefficients */
1084 : const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
1085 : );
1086 :
1087 : void int_lsp4(
1088 : const int16_t L_frame, /* i : length of the frame */
1089 : const float lsp_old[], /* i : previous end-frame LSPs */
1090 : const float lsp_mid[], /* i : current mid-frame LSPs */
1091 : const float lsp_new[], /* i : current end-frame LSPs */
1092 : float *Aq, /* o : LP coefficients in both subframes */
1093 : const int16_t m, /* i : order of LP filter */
1094 : int16_t relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */
1095 : );
1096 :
1097 : /*! r: length of output */
1098 : int16_t modify_Fs(
1099 : const float sigIn[], /* i : signal to decimate */
1100 : const int16_t lg, /* i : length of input */
1101 : const int32_t fin, /* i : frequency of input */
1102 : float sigOut[], /* o : decimated signal */
1103 : const int32_t fout, /* i : frequency of output */
1104 : float mem[], /* i/o: filter memory */
1105 : const int16_t nblp /* i : flag indicating if NB low-pass is applied */
1106 : );
1107 :
1108 : void pred_lt4(
1109 : const float excI[], /* i : input excitation buffer */
1110 : float excO[], /* o : output excitation buffer */
1111 : const int16_t T0, /* i : integer pitch lag */
1112 : int16_t frac, /* i : fraction of lag */
1113 : const int16_t L_subfr, /* i : subframe size */
1114 : const float *win, /* i : interpolation window */
1115 : const int16_t nb_coef, /* i : nb of filter coef */
1116 : const int16_t up_sample /* i : up_sample */
1117 : );
1118 :
1119 : void pred_lt4_tc(
1120 : float exc[], /* i : excitation buffer */
1121 : const int16_t T0, /* i : integer pitch lag */
1122 : int16_t frac, /* i : fraction of lag */
1123 : const float *win, /* i : interpolation window */
1124 : const int16_t imp_pos, /* i : glottal impulse position */
1125 : const int16_t i_subfr /* i : subframe index */
1126 : );
1127 :
1128 : void residu(
1129 : const float *a, /* i : LP filter coefficients */
1130 : const int16_t m, /* i : order of LP filter */
1131 : const float *x, /* i : input signal (usually speech) */
1132 : float *y, /* o : output signal (usually residual) */
1133 : const int16_t l /* i : size of filtering */
1134 : );
1135 :
1136 : void calc_residu(
1137 : const float *speech, /* i : weighted speech signal */
1138 : float *res, /* o : residual signal */
1139 : const float *p_Aq, /* i : quantized LP filter coefficients */
1140 : const int16_t L_frame /* i : size of frame */
1141 : );
1142 :
1143 : /*! r: impulse response energy */
1144 : float enr_1_Az(
1145 : const float Aq[], /* i : LP filter coefs */
1146 : const int16_t len /* i : impulse response length */
1147 : );
1148 :
1149 : void Es_pred_enc(
1150 : float *Es_pred, /* o : predicited scaled innovation energy */
1151 : int16_t *Es_pred_indice, /* o : indice corresponding to above parameter */
1152 : const int16_t L_frame, /* i : length of the frame */
1153 : const int16_t L_subfr, /* i : length of the subframe */
1154 : const float *res, /* i : residual signal */
1155 : const float *voicing, /* i : normal. correlattion in three 1/2frames */
1156 : const int16_t nb_bits, /* i : allocated number of bits */
1157 : const int16_t no_ltp /* i : no_ltp flag */
1158 : );
1159 :
1160 : void create_offset(
1161 : UWord32 *offset_scale1,
1162 : UWord32 *offset_scale2,
1163 : const int16_t mode,
1164 : const int16_t prediction_flag );
1165 :
1166 : float mslvq(
1167 : float *pTmp, /* i : M-dimensional input vector */
1168 : float *quant, /* o : quantized vector */
1169 : float *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */
1170 : int16_t *idx_lead, /* o : leader index for each 8-dim subvector */
1171 : int16_t *idx_scale, /* o : scale index for each subvector */
1172 : const float *w, /* i : weights for LSF quantization */
1173 : const int16_t mode, /* i : number indicating the coding mode */
1174 : const int16_t mode_glb, /* i : LVQ coding mode */
1175 : const int16_t pred_flag /* i : prediction flag (0: safety net, 1 - predictive )*/
1176 : );
1177 :
1178 : void permute(
1179 : float *pTmp1, /* i/o: vector whose components are to be permuted */
1180 : const int16_t *perm /* i : permutation info (indexes that should be interchanged), max two perms */
1181 : );
1182 :
1183 : void sort_desc_ind(
1184 : float *s,
1185 : const int16_t len,
1186 : int16_t *ind );
1187 :
1188 : float mslvq_cng(
1189 : int16_t idx_cv, /* i : index of cv from previous stage */
1190 : float *pTmp, /* i : 16 dimensional input vector */
1191 : float *quant, /* o : quantized vector */
1192 : float *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */
1193 : int16_t *idx_lead, /* o : leader index for each 8-dim subvector */
1194 : int16_t *idx_scale, /* o : scale index for each subvector */
1195 : const float *w /* i : weights for LSF quantization */
1196 : );
1197 :
1198 : int16_t deindex_lvq_cng(
1199 : int16_t *index, /* i : index to be decoded, as an array of 3 short */
1200 : float *x_lvq, /* o : decoded codevector */
1201 : const int16_t idx_cv, /* i : relative mode_lvq, wrt START_CNG */
1202 : const int16_t no_bits /* i : number of bits for lattice */
1203 : );
1204 :
1205 : void multiply32_32_64(
1206 : UWord32 x, /* i : operand 1 */
1207 : UWord32 y, /* i : operand 2 */
1208 : UWord32 *res /* o : result as array of two uint32 */
1209 : );
1210 :
1211 : int16_t deindex_lvq(
1212 : int16_t *index, /* i : index to be decoded, as an array of 3 short */
1213 : float *x_lvq, /* o : decoded codevector */
1214 : const int16_t mode, /* i : LVQ coding mode (select scales & no_lead ), or idx_cv */
1215 : const int16_t sf_flag, /* i : safety net flag */
1216 : const int16_t no_bits /* i : number of bits for lattice */
1217 : );
1218 :
1219 : int16_t vq_dec_lvq(
1220 : int16_t sf_flag, /* i : safety net flag */
1221 : float x[], /* o : Decoded vector */
1222 : int16_t indices[], /* i : Indices */
1223 : const int16_t stages, /* i : Number of stages */
1224 : const int16_t N, /* i : Vector dimension */
1225 : const int16_t mode, /* i : lvq coding type */
1226 : const int16_t no_bits /* i : no. bits for lattice */
1227 : );
1228 :
1229 : void index_lvq(
1230 : float *quant, /* i : codevector to be indexed (2 8-dim subvectors) */
1231 : int16_t *idx_lead, /* i : leader class index for each subvector */
1232 : int16_t *idx_scale, /* i : scale index for each subvector */
1233 : const int16_t mode, /* i : integer signaling the quantizer structure for the current bitrate */
1234 : int16_t *index, /* o : encoded index (represented on 3 short each with 15 bits ) */
1235 : const int16_t prediction_flag /* i : predictive mode or not */
1236 : );
1237 :
1238 : int16_t qlsf_ARSN_tcvq_Dec_16k(
1239 : float *y, /* o : Quantized LSF vector */
1240 : int16_t *indice, /* i : Indices */
1241 : const int16_t nBits /* i : number of bits */
1242 : );
1243 :
1244 : int16_t lsf_bctcvq_encprm(
1245 : BSTR_ENC_HANDLE hBstr,
1246 : const int16_t *param_lpc,
1247 : const int16_t *bits_param_lpc,
1248 : const int16_t no_indices );
1249 :
1250 : int16_t lsf_bctcvq_decprm(
1251 : Decoder_State *st,
1252 : int16_t *param_lpc );
1253 :
1254 : ivas_error lsf_allocate(
1255 : const int16_t nBits, /* i : Number of bits to use for quantization */
1256 : const int16_t framemode, /* i : ISF quantizer mode */
1257 : const int16_t framemode_p, /* i : ISF quantizer mode */
1258 : int16_t *stages0, /* o : Number of stages for safety-net quantizer */
1259 : int16_t *stages1, /* o : Number of stages for predictive quantizer */
1260 : int16_t levels0[], /* o : Number of vectors for each stage for SFNET */
1261 : int16_t levels1[], /* o : Number of vectors for each stage for pred */
1262 : int16_t bits0[], /* o : Number of bits for each stage safety net */
1263 : int16_t bits1[] /* o : Number of bits for each stage predictive */
1264 : );
1265 :
1266 : void disf_2s_36b(
1267 : int16_t *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */
1268 : float *isf_q, /* o : quantized ISFs in the cosine domain */
1269 : float *mem_AR, /* i/o: quantizer memory for AR model */
1270 : float *mem_MA /* i/o: quantizer memory for MA model */
1271 : );
1272 :
1273 : void disf_2s_46b(
1274 : int16_t *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */
1275 : float *isf_q, /* o : quantized ISFs in the cosine domain */
1276 : float *mem_AR, /* o : quantizer memory for AR model */
1277 : float *mem_MA /* i/o: quantizer memory for MA model */
1278 : );
1279 :
1280 : void re8_k2y(
1281 : const int16_t *k, /* i : Voronoi index k[0..7] */
1282 : const int16_t m, /* i : Voronoi modulo (m = 2^r = 1<<r, where r is integer >=2) */
1283 : int16_t *y /* o : 8-dimensional point y[0..7] in RE8 */
1284 : );
1285 :
1286 : void re8_PPV(
1287 : const float x[], /* i : point in R^8 */
1288 : int16_t y[] /* o : point in RE8 (8-dimensional integer vector) */
1289 : );
1290 :
1291 : void enhancer(
1292 : const int16_t codec_mode, /* i : flag indicating Codec Mode */
1293 : const int32_t core_brate, /* i : core bitrate */
1294 : const int16_t cbk_index, /* i : */
1295 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
1296 : const int16_t coder_type, /* i : coding type */
1297 : const int16_t L_frame, /* i : frame size */
1298 : const float voice_fac, /* i : subframe voicing estimation */
1299 : const float stab_fac, /* i : LP filter stablility measure */
1300 : const float norm_gain_code, /* i : normalized innovative cb. gain */
1301 : const float gain_inov, /* i : gain of the unscaled innovation */
1302 : float *gc_threshold, /* i/o: code threshold */
1303 : float *code, /* i/o: innovation */
1304 : float *exc2, /* i/o: adapt. excitation/total exc. */
1305 : const float gain_pit, /* i : Quantized pitch gain */
1306 : float *dispMem /* i/o: Phase dispersion algorithm memory */
1307 : );
1308 :
1309 : void phase_dispersion(
1310 : const float gain_code, /* i : gain of code */
1311 : const float gain_pit, /* i : gain of pitch */
1312 : float code[], /* i/o: code vector */
1313 : const int16_t mode, /* i : level, 0=hi, 1=lo, 2=off */
1314 : float disp_mem[] /* i/o: static memory (size = 8) */
1315 : );
1316 :
1317 : void re8_vor(
1318 : int16_t y[], /* i : point in RE8 (8-dimensional integer vector) */
1319 : int16_t *n, /* o : codebook number n=0,2,3,4,... (scalar integer) */
1320 : int16_t k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 */
1321 : int16_t c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c */
1322 : int16_t *ka /* o : identifier of absolute leader (needed to index c)*/
1323 : );
1324 :
1325 : void edct(
1326 : const float *x, /* i : input signal */
1327 : float *y, /* o : output transform */
1328 : const int16_t length, /* i : length */
1329 : const int16_t element_mode /* i : IVAS element mode */
1330 : );
1331 :
1332 : void edst(
1333 : const float *x, /* i : input signal */
1334 : float *y, /* o : output transform */
1335 : const int16_t length, /* i : length */
1336 : const int16_t element_mode /* i : IVAS element mode */
1337 : );
1338 :
1339 : void edxt(
1340 : const float *x, /* i : input signal */
1341 : float *y, /* o : output transform */
1342 : const int16_t length, /* i : length */
1343 : const uint16_t kernelType, /* i : kernel type (0 - 3) */
1344 : const uint16_t synthesis /* i : nonzero for inverse */
1345 : );
1346 :
1347 : void iedct_short(
1348 : const float *in, /* i : input vector */
1349 : float *out, /* o : output vector */
1350 : const int16_t segment_length, /* i : length */
1351 : const int16_t element_mode /* i : IVAS element mode */
1352 : );
1353 :
1354 : void DoRTFT480(
1355 : float *x, /* i/o: real part of input and output data */
1356 : float *y /* i/o: imaginary part of input and output data */
1357 : );
1358 :
1359 : void DoRTFT320(
1360 : float *x, /* i/o: real part of input and output data */
1361 : float *y /* i/o: imaginary part of input and output data */
1362 : );
1363 :
1364 : void DoRTFT160(
1365 : float *x, /* i/o: real part of input and output data */
1366 : float *y /* i/o: imaginary part of input and output data */
1367 : );
1368 :
1369 : void DoRTFT128(
1370 : float *x, /* i/o: real part of input and output data */
1371 : float *y /* i/o: imaginary part of input and output data */
1372 : );
1373 :
1374 : void DoRTFT120(
1375 : float *x, /* i/o: real part of input and output data */
1376 : float *y /* i/o: imaginary part of input and output data */
1377 : );
1378 :
1379 : void DoRTFT80(
1380 : float *x, /* i/o: real part of input and output data */
1381 : float *y /* i/o: imaginary part of input and output data */
1382 : );
1383 :
1384 : void DoRTFT20(
1385 : float *x, /* i/o: real part of input and output data */
1386 : float *y /* i/o: imaginary part of input and output data */
1387 : );
1388 :
1389 : void DoRTFT40(
1390 : float *x, /* i/o: real part of input and output data */
1391 : float *y /* i/o: imaginary part of input and output data */
1392 : );
1393 :
1394 : void DoRTFTn(
1395 : float *x, /* i/o: real part of input and output data */
1396 : float *y, /* i/o: imaginary part of input and output data */
1397 : const int16_t n /* i : size of the FFT n=(2^k) up to 1024 */
1398 : );
1399 :
1400 : void BASOP_cfft(
1401 : Word32 *re, /* i/o: real part */
1402 : Word32 *im, /* i/o: imag part */
1403 : Word16 s, /* i : stride real and imag part */
1404 : Word16 *scale /* i : scalefactor */
1405 : );
1406 :
1407 : void fft(
1408 : float *re, /* i/o: real part */
1409 : float *im, /* i/o: imag part */
1410 : const int16_t length, /* i : length of fft */
1411 : const int16_t s /* i : sign */
1412 : );
1413 :
1414 : void rfft(
1415 : float *x, /* i/o: values */
1416 : const float *w, /* i : window */
1417 : const int16_t length, /* i : length of fft */
1418 : const int16_t isign /* i : sign */
1419 : );
1420 :
1421 : void sinq(
1422 : const float tmp, /* i : sinus factor cos(tmp*i+phi) */
1423 : const float phi, /* i : sinus phase cos(tmp*i+phi) */
1424 : const int16_t N, /* i : size of output */
1425 : float x[] /* o : output vector */
1426 : );
1427 :
1428 : void edct2(
1429 : const int16_t n,
1430 : const int16_t isgn,
1431 : float *in,
1432 : float *a,
1433 : const int16_t *ip,
1434 : const float *w );
1435 :
1436 : void stat_noise_uv_mod(
1437 : const int16_t coder_type, /* i : coder type */
1438 : float noisiness, /* i : noisiness parameter */
1439 : const float *const lsp_old, /* i : old LSP vector at 4th sfr */
1440 : const float *const lsp_new, /* i : LSP vector at 4th sfr */
1441 : const float *const lsp_mid, /* i : LSP vector at 2nd sfr */
1442 : float *Aq, /* o : A(z) quantized for the 4 subframes */
1443 : float *exc2, /* o : excitation buffer */
1444 : const int16_t bfi, /* i : bad frame indicator */
1445 : float *ge_sm, /* i/o: smoothed excitation gain */
1446 : int16_t *uv_count, /* i/o: unvoiced counter */
1447 : int16_t *act_count, /* i/o: activation counter */
1448 : float lspold_s[], /* i/o: old LSP */
1449 : int16_t *noimix_seed, /* i/o: mixture seed */
1450 : float *st_min_alpha, /* i/o: minimum alpha */
1451 : float *exc_pe, /* i/o: memory of the preemphasis filter */
1452 : const int32_t bitrate, /* i : core bitrate */
1453 : const int16_t bwidth /* i : audio bandwidth */
1454 : );
1455 :
1456 : void pre_echo_att(
1457 : float *Last_frame_ener, /* i/o: Energy of the last frame */
1458 : float *exc, /* i/o: Excitation of the current frame */
1459 : const int16_t attack_flag, /* i : attack flag (GSC or TC) */
1460 : const int16_t last_coder_type, /* i : Last coder type */
1461 : const int16_t L_frame /* i : frame length */
1462 : );
1463 :
1464 : void limit_band_noise_level_calc(
1465 : const int16_t *wnorm, /* i : reordered norm of sub-vectors */
1466 : int16_t *limit, /* o : highest band of bit allocation */
1467 : const int32_t core_brate, /* i : core bitrate */
1468 : float *noise_level /* o : noise level */
1469 : );
1470 :
1471 : /*! r: hqswb_clas */
1472 : int16_t peak_avrg_ratio(
1473 : const int32_t total_brate, /* i : total bitrate */
1474 : const float *input_hi, /* i : input signal */
1475 : const int16_t N, /* i : number of coefficients */
1476 : int16_t *mode_count, /* i/o: HQ_HARMONIC mode count */
1477 : int16_t *mode_count1 /* i/o: HQ_NORMAL mode count */
1478 : );
1479 :
1480 : /*! r: Number of coefficients in nf codebook */
1481 : int16_t build_nf_codebook(
1482 : const int16_t flag_32K_env_ho, /* i : Envelope attenuation hangover flag */
1483 : const float *coeff, /* i : Coded spectral coefficients */
1484 : const int16_t *sfm_start, /* i : Subband start indices */
1485 : const int16_t *sfmsize, /* i : Subband widths */
1486 : const int16_t *sfm_end, /* i : Subband end indices */
1487 : const int16_t nb_sfm, /* i : Last coded band */
1488 : const int16_t *R, /* i : Per-band bit allocation */
1489 : float *CodeBook, /* o : Noise-fill codebook */
1490 : float *CodeBook_mod /* o : Densified noise-fill codebook */
1491 : );
1492 :
1493 : void apply_noisefill_HQ(
1494 : const int16_t *R, /* i : bit allocation */
1495 : const int16_t length, /* i : input frame length */
1496 : const int16_t flag_32K_env_ho, /* i : envelope stability hangover flag */
1497 : const int32_t core_brate, /* i : core bitrate */
1498 : const int16_t last_sfm, /* i : last coded subband */
1499 : const float *CodeBook, /* i : Noise-fill codebook */
1500 : const float *CodeBook_mod, /* i : Densified noise-fill codebook */
1501 : const int16_t cb_size, /* i : Codebook length */
1502 : const int16_t *sfm_start, /* i : Subband start coefficient */
1503 : const int16_t *sfm_end, /* i : Subband end coefficient */
1504 : const int16_t *sfmsize, /* i : Subband band width */
1505 : float *coeff /* i/o: coded/noisefilled spectrum */
1506 : );
1507 :
1508 : void harm_bwe_fine(
1509 : const int16_t *R, /* i : bit allocation */
1510 : const int16_t last_sfm, /* i : last coded subband */
1511 : const int16_t high_sfm, /* i : higher transition band to BWE */
1512 : const int16_t num_sfm, /* i : total number of bands */
1513 : const int16_t *norm, /* i : quantization indices for norms */
1514 : const int16_t *sfm_start, /* i : Subband start coefficient */
1515 : const int16_t *sfm_end, /* i : Subband end coefficient */
1516 : int16_t *prev_L_swb_norm, /* i/o: last normalize length */
1517 : float *coeff, /* i/o: coded/noisefilled normalized spectrum */
1518 : float *coeff_out, /* o : coded/noisefilled spectrum */
1519 : float *coeff_fine /* o : BWE fine structure */
1520 : );
1521 :
1522 : void hvq_bwe_fine(
1523 : const int16_t last_sfm, /* i : last coded subband */
1524 : const int16_t num_sfm, /* i : total number of bands */
1525 : const int16_t *sfm_end, /* i : Subband end coefficient */
1526 : const int16_t *peak_idx, /* i : Peak index */
1527 : const int16_t Npeaks, /* i : Number of peaks */
1528 : int16_t *peak_pos, /* i/o: Peak positions */
1529 : int16_t *prev_L_swb_norm, /* i/o: last normalize length */
1530 : float *coeff, /* i/o: coded/noisefilled normalized spectrum */
1531 : int16_t *bwe_peaks, /* o : Positions of peaks in BWE */
1532 : float *coeff_fine /* o : HVQ BWE fine structure */
1533 : );
1534 :
1535 : void hq_fold_bwe(
1536 : const int16_t last_sfm, /* i : last coded subband */
1537 : const int16_t *sfm_end, /* i : Subband end coefficient */
1538 : const int16_t num_sfm, /* i : Number of subbands */
1539 : float *coeff /* i/o: coded/noisefilled normalized spectrum */
1540 : );
1541 :
1542 : void apply_nf_gain(
1543 : const int16_t nf_idx, /* i : noise fill gain index */
1544 : const int16_t last_sfm, /* i : last coded subband */
1545 : const int16_t *R, /* i : bit allocation */
1546 : const int16_t *sfm_start, /* i : Subband start coefficient */
1547 : const int16_t *sfm_end, /* i : Subband end coefficient */
1548 : float *coeff /* i/o: coded/noisefilled normalized spectrum */
1549 :
1550 : );
1551 :
1552 : void hq_generic_fine(
1553 : float *coeff, /* i : coded/noisefilled normalized spectrum */
1554 : const int16_t last_sfm, /* i : Last coded band */
1555 : const int16_t *sfm_start, /* i : Subband start coefficient */
1556 : const int16_t *sfm_end, /* i : Subband end coefficient */
1557 : int16_t *bwe_seed, /* i/o: random seed for generating BWE input */
1558 : float *coeff_out1 /* o : HQ GENERIC input */
1559 : );
1560 :
1561 : void harm_bwe(
1562 : const float *coeff_fine, /* i : fine structure for BWE */
1563 : const float *coeff, /* i : coded/noisefilled normalized spectrum */
1564 : const int16_t num_sfm, /* i : Number of subbands */
1565 : const int16_t *sfm_start, /* i : Subband start coefficient */
1566 : const int16_t *sfm_end, /* i : Subband end coefficient */
1567 : const int16_t last_sfm, /* i : last coded subband */
1568 : const int16_t high_sfm, /* i : higher transition band to BWE */
1569 : const int16_t *R, /* i : bit allocation */
1570 : const int16_t prev_hq_mode, /* i : previous hq mode */
1571 : int16_t *norm, /* i/o: quantization indices for norms */
1572 : float *noise_level, /* i/o: noise levels for harmonic modes */
1573 : float *prev_noise_level, /* i/o: noise factor in previous frame */
1574 : int16_t *bwe_seed, /* i/o: random seed for generating BWE input */
1575 : float *coeff_out, /* o : coded/noisefilled spectrum */
1576 : const int16_t element_mode /* i : element mode */
1577 : );
1578 :
1579 : void hvq_bwe(
1580 : const float *coeff, /* i : coded/noisefilled spectrum */
1581 : const float *coeff_fine, /* i : BWE fine structure */
1582 : const int16_t *sfm_start, /* i : Subband start coefficient */
1583 : const int16_t *sfm_end, /* i : Subband end coefficient */
1584 : const int16_t *sfm_len, /* i : Subband length */
1585 : const int16_t last_sfm, /* i : last coded subband */
1586 : const int16_t prev_hq_mode, /* i : previous hq mode */
1587 : const int16_t *bwe_peaks, /* i : HVQ bwe peaks */
1588 : const int16_t bin_th, /* i : HVQ transition bin */
1589 : const int16_t num_sfm, /* i : Number of bands */
1590 : const int32_t core_brate, /* i : Core bitrate */
1591 : const int16_t *R, /* i : Bit allocation */
1592 : int16_t *norm, /* i/o: quantization indices for norms */
1593 : float *noise_level, /* i/o: noise levels for harmonic modes */
1594 : float *prev_noise_level, /* i/o: noise factor in previous frame */
1595 : int16_t *bwe_seed, /* i/o: random seed for generating BWE input */
1596 : float *coeff_out /* o : coded/noisefilled spectrum */
1597 : );
1598 :
1599 : void hvq_concat_bands(
1600 : const int16_t pvq_bands, /* i : Number of bands in concatenated PVQ target */
1601 : const int16_t *sel_bnds, /* i : Array of selected high bands */
1602 : const int16_t n_sel_bnds, /* i : Number of selected high bands */
1603 : int16_t *hvq_band_start, /* o : Band start indices */
1604 : int16_t *hvq_band_width, /* o : Band widths */
1605 : int16_t *hvq_band_end /* o : Band end indices */
1606 : );
1607 :
1608 : void hq_generic_bwe(
1609 : const int16_t HQ_mode, /* i : HQ mode */
1610 : float *coeff_out1, /* i/o: BWE input & temporary buffer */
1611 : const float *hq_generic_fenv, /* i : SWB frequency envelopes */
1612 : float *coeff_out, /* o : SWB signal in MDCT domain */
1613 : const int16_t hq_generic_offset, /* i : frequency offset for representing hq generic*/
1614 : int16_t *prev_L_swb_norm, /* i/o: last normalize length */
1615 : const int16_t hq_generic_exc_clas, /* i : hq generic hf excitation class */
1616 : const int16_t *sfm_end, /* i : End of bands */
1617 : const int16_t num_sfm, /* i : Number of bands */
1618 : const int16_t num_env_bands, /* i : Number of coded envelope bands */
1619 : const int16_t *R /* i : Bit allocation */
1620 : );
1621 :
1622 : void logqnorm_2(
1623 : const float *env_fl, /* o : index */
1624 : const int16_t L, /* i : codebook length */
1625 : const int16_t n_env_band, /* i : sub-vector size */
1626 : const int16_t nb_sfm, /* i : sub-vector size */
1627 : int16_t *ynrm, /* o : norm indices */
1628 : int16_t *normqlg2, /* o : quantized norm values */
1629 : const float *thren /* i : quantization thresholds */
1630 : );
1631 :
1632 : void map_hq_generic_fenv_norm(
1633 : const int16_t hqswb_clas, /* i : signal classification flag */
1634 : const float *hq_generic_fenv, /* i : HQ GENERIC envelope */
1635 : int16_t *ynrm, /* o : high band norm indices */
1636 : int16_t *normqlg2, /* o : high band norm values */
1637 : const int16_t num_env_bands, /* i : Number coded envelope bands */
1638 : const int16_t nb_sfm, /* i : Number of envelope bands */
1639 : const int16_t hq_generic_offset /* i : Freq offset for HQ GENERIC */
1640 : );
1641 :
1642 : /*! r: Number of bits consumed for the delta coding */
1643 : int16_t calc_nor_delta_hf(
1644 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
1645 : const float *t_audio, /* i : transform-domain coefficients */
1646 : int16_t *ynrm, /* i/o: norm indices */
1647 : int16_t *Rsubband, /* i/o: sub-band bit allocation */
1648 : const int16_t num_env_bands, /* i : Number coded envelope bands */
1649 : const int16_t nb_sfm, /* i : Number of envelope bands */
1650 : const int16_t *sfmsize, /* i : band length */
1651 : const int16_t *sfm_start, /* i : Start index of bands */
1652 : const int16_t core_sfm /* i : index of the end band for core */
1653 : );
1654 :
1655 : /*! r: Number of bits consumed for the delta coding */
1656 : int16_t get_nor_delta_hf(
1657 : Decoder_State *st, /* i/o: Decoder state */
1658 : int16_t *ynrm, /* i/o: norm indices */
1659 : int16_t *Rsubband, /* i/o: sub-band bit allocation */
1660 : const int16_t num_env_bands, /* i : Number coded envelope bands */
1661 : const int16_t nb_sfm, /* i : Number of envelope bands */
1662 : const int16_t core_sfm ); /* i : index of the end band for core */
1663 :
1664 : void hq_wb_nf_bwe(
1665 : const float *coeff, /* i : coded/noisefilled normal. spectrum */
1666 : const int16_t is_transient, /* i : is transient flag */
1667 : const int16_t prev_bfi, /* i : previous bad frame indicator */
1668 : const float *normq_v, /* i : norms */
1669 : const int16_t num_sfm, /* i : Number of subbands */
1670 : const int16_t *sfm_start, /* i : Subband start coefficient */
1671 : const int16_t *sfm_end, /* i : Subband end coefficient */
1672 : const int16_t *sfmsize, /* i : Subband band width */
1673 : const int16_t last_sfm, /* i : last coded subband */
1674 : const int16_t *R, /* i : bit allocation */
1675 : const int16_t prev_is_transient, /* i : previous transient flag */
1676 : float *prev_normq, /* i/o: previous norms */
1677 : float *prev_env, /* i/o: previous noise envelopes */
1678 : int16_t *bwe_seed, /* i/o: random seed for generating BWE input */
1679 : float *prev_coeff_out, /* i/o: decoded spectrum in previous frame */
1680 : int16_t *prev_R, /* i/o: previous frame bit allocation info. */
1681 : float *coeff_out /* o : coded/noisefilled spectrum */
1682 : );
1683 :
1684 : /*! r: Number of bits */
1685 : int16_t encode_envelope_indices(
1686 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
1687 : const int16_t num_sfm, /* i : Number of subbands */
1688 : const int16_t numnrmibits, /* i : Bitrate of fall-back coding mode */
1689 : int16_t *difidx, /* i/o: Diff indices/encoded diff indices */
1690 : int16_t *LCmode, /* o : Coding mode */
1691 : const int16_t flag_pack, /* i : indicator of packing or estimating bits */
1692 : const int16_t flag_HQ2, /* i : indicator of HQ2 core */
1693 : const int16_t is_transient /* i : transient flag */
1694 : );
1695 :
1696 : void diff_envelope_coding(
1697 : const int16_t is_transient, /* i : transient indicator */
1698 : const int16_t num_env_bands, /* i : number of envelope bands to code */
1699 : const int16_t start_norm, /* i : start of envelope coding */
1700 : int16_t *ynrm, /* i/o: quantization indices for norms */
1701 : int16_t *normqlg2, /* i/o: quantized norms */
1702 : int16_t *difidx /* o : differential code */
1703 : );
1704 :
1705 : /*! r: Number of bits */
1706 : int16_t decode_envelope_indices(
1707 : Decoder_State *st, /* i/o: decoder state structure */
1708 : const int16_t start_norm, /* i : First SDE encoded norm */
1709 : const int16_t num_sfm, /* i : Number of norms */
1710 : const int16_t numnrmibits, /* i : Bitrate of fall-back coding mode */
1711 : int16_t *ynrm, /* o : Decoded norm indices */
1712 : const int16_t flag_HQ2, /* i : indicator of HQ2 core */
1713 : const int16_t is_transient /* i : transient flag */
1714 : );
1715 :
1716 : /*! r: Number of bits */
1717 : void dequantize_norms(
1718 : Decoder_State *st, /* i/o: decoder state structure */
1719 : const int16_t start_norm, /* i : First SDE encoded norm */
1720 : const int16_t num_sfm, /* i : Number of norms */
1721 : const int16_t is_transient, /* i : Transient flag */
1722 : int16_t *ynrm, /* o : Decoded norm indices */
1723 : int16_t *normqlg2 /* o : Log2 of decoded norms */
1724 : );
1725 :
1726 : void hq_configure(
1727 : const int16_t length, /* i : Frame length */
1728 : const int16_t hqswb_clas, /* i : HQ SWB class */
1729 : const int32_t core_brate, /* i : core bitrate */
1730 : int16_t *num_sfm, /* o : Total number of subbands */
1731 : int16_t *nb_sfm, /* o : Total number of coded bands */
1732 : int16_t *start_norm, /* o : First norm to be SDE encoded */
1733 : int16_t *num_sde_norm, /* o : Number of norms for SDE encoding */
1734 : int16_t *numnrmibits, /* o : Number of bits in fall-back norm encoding */
1735 : int16_t *hq_generic_offset, /* o : Freq offset for HQ GENERIC */
1736 : int16_t *sfmsize, /* o : Subband bandwidths */
1737 : int16_t *sfm_start, /* o : Subband start coefficients */
1738 : int16_t *sfm_end /* o : Subband end coefficients */
1739 : );
1740 :
1741 : /*! r: Consumed bits */
1742 : int16_t hvq_enc(
1743 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
1744 : const int16_t bwidth, /* i : audio bandwidth */
1745 : #ifdef DEBUGGING
1746 : const int16_t idchan, /* i : channel ID */
1747 : #endif
1748 : const int32_t core_brate, /* i : core bitrate */
1749 : const int16_t hvq_bits, /* i : HVQ bit budget */
1750 : const int16_t Npeaks, /* i : Number of peaks */
1751 : const int16_t *ynrm, /* i : Envelope coefficients */
1752 : int16_t *R, /* i/o: Bit allocation/updated bit allocation */
1753 : int16_t *peaks, /* i/o: Peak pos. / Encoded peak pos. */
1754 : float *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */
1755 : float *noise_level, /* o : Quantized noise level */
1756 : const float *pe_gains, /* i : Peak gains */
1757 : const float *coefs, /* i : spectrum coefficients */
1758 : float *coefs_out /* o : encoded spectrum coefficients */
1759 : );
1760 :
1761 : /*! r: Consumed bits */
1762 : int16_t hq_classifier_enc(
1763 : Encoder_State *st, /* i/o: encoder state structure */
1764 : const int16_t length, /* i : Frame length */
1765 : const float *coefs, /* i : Spectral coefficients */
1766 : const int16_t is_transient, /* i : Transient flag */
1767 : int16_t *Npeaks, /* o : Number of identified peaks */
1768 : int16_t *peaks, /* o : Peak indices */
1769 : float *pe_gains, /* o : Peak gains */
1770 : float *nf_gains, /* o : Noise-fill gains */
1771 : int16_t *hqswb_clas /* o : HQ class */
1772 : );
1773 :
1774 : /*! r: Consumed bits */
1775 : int16_t hq_classifier_dec(
1776 : Decoder_State *st, /* i/o: decoder state structure */
1777 : const int32_t core_brate, /* i : Core bitrate */
1778 : const int16_t length, /* i : Frame length */
1779 : int16_t *is_transient, /* o : Transient flag */
1780 : int16_t *hqswb_clas /* o : HQ class */
1781 : );
1782 :
1783 : void hq_bit_allocation(
1784 : const int32_t core_brate, /* i : Core bitrate */
1785 : const int16_t length, /* i : Frame length */
1786 : const int16_t hqswb_clas, /* i : HQ class */
1787 : int16_t *num_bits, /* i/o: Remaining bit budget */
1788 : const int16_t *normqlg2, /* i : Quantized norms */
1789 : const int16_t nb_sfm, /* i : Number sub bands to be encoded */
1790 : const int16_t *sfmsize, /* i : Sub band bandwidths */
1791 : float *noise_level, /* o : HVQ noise level */
1792 : int16_t *R, /* o : Bit allocation per sub band */
1793 : int16_t *Rsubband, /* o : Fractional bit allocation (Q3) */
1794 : int16_t *sum, /* o : Sum of allocated shape bits */
1795 : int16_t *core_sfm, /* o : Last coded band in core */
1796 : const int16_t num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */
1797 : );
1798 :
1799 : void enforce_zero_for_min_envelope(
1800 : const int16_t hqswb_clas, /* i : HQ coding class */
1801 : const int16_t *ynrm, /* i : Envelope indices */
1802 : float *coefsq, /* i/o: Quantized spectrum/zeroed spectrum */
1803 : int16_t nb_sfm, /* i : Number of coded sub bands */
1804 : const int16_t *sfm_start, /* i : Sub band start indices */
1805 : const int16_t *sfm_end /* i : Sub band end indices */
1806 : );
1807 :
1808 : /*! r: Number of assigned gain bits */
1809 : int16_t assign_gain_bits(
1810 : const int16_t core, /* i : HQ core */
1811 : const int16_t BANDS, /* i : Number of bands */
1812 : const int16_t *band_width, /* i : Sub band bandwidth */
1813 : int16_t *Rk, /* i/o: Bit allocation/Adjusted bit alloc. (Q3) */
1814 : int16_t *gain_bits_array, /* o : Assigned gain bits */
1815 : int16_t *Rcalc /* o : Bit budget for shape quantizer (Q3) */
1816 : );
1817 :
1818 : void apply_envelope(
1819 : const float *coeff, /* i/o: Coded/noisefilled normalized spectrum */
1820 : const int16_t *norm, /* i : Envelope */
1821 : const float *norm_adj, /* i : Envelope adjustment */
1822 : const int16_t num_sfm, /* i : Total number of bands */
1823 : const int16_t last_sfm, /* i : Last coded band */
1824 : const int16_t HQ_mode, /* i : HQ mode */
1825 : const int16_t length, /* i : Frame length */
1826 : const int16_t *sfm_start, /* i : Sub band start indices */
1827 : const int16_t *sfm_end, /* i : Sub band end indices */
1828 : float *normq_v, /* o : Envelope with adjustment */
1829 : float *coeff_out, /* o : coded/noisefilled spectrum */
1830 : float *coeff_out1 /* o : noisefilled spectrum for HQ SWB BWE */
1831 : );
1832 :
1833 : void apply_envelope_enc(
1834 : float *coeff, /* i/o: Normalized/scaled normalized spectrum */
1835 : const int16_t *norm, /* i : Envelope */
1836 : const int16_t num_sfm, /* i : Total number of bands */
1837 : const int16_t *sfm_start, /* i : Sub band start indices */
1838 : const int16_t *sfm_end /* i : Sub band end indices */
1839 : );
1840 :
1841 : /*! r: Leading_sign_index, index, size, k_val */
1842 : PvqEntry mpvq_encode_vec(
1843 : const int16_t *vec_in, /* i : Signed pulse train */
1844 : const int16_t dim_in, /* i : Dimension */
1845 : int16_t k_val_local /* i/o: Num unit pulses */
1846 : );
1847 :
1848 : /*! r: Size, dim, k_val */
1849 : PvqEntry get_size_mpvq_calc_offset(
1850 : const int16_t dim_in, /* i : Dimension */
1851 : const int16_t k_val_in, /* i : Num unit pulses */
1852 : uint32_t *h_mem /* o : Offsets */
1853 : );
1854 :
1855 : void mpvq_decode_vec(
1856 : const PvqEntry *entry, /* i : Sign_ind, index, dim, k_val */
1857 : uint32_t *h_mem, /* i : A/U offsets */
1858 : int16_t *vec_out /* o : Pulse train */
1859 : );
1860 :
1861 : /*! r: Multiplication result */
1862 : uint32_t UMult_32_32(
1863 : const uint32_t UL_var1, /* i : factor 1 */
1864 : const uint32_t UL_var2 /* i : factor 2 */
1865 : );
1866 :
1867 : /*! r: inverse */
1868 : uint32_t UL_inverse(
1869 : const uint32_t UL_val, /* i : input value Q_exp */
1870 : int16_t *exp /* i/o: input exp / result exp */
1871 : );
1872 :
1873 : /*! r: ratio */
1874 : Word16 ratio(
1875 : const Word32 numer, /* i : numerator */
1876 : const Word32 denom, /* i : denominator */
1877 : Word16 *expo /* i/o: input exp / result exp */
1878 : );
1879 :
1880 : /*! r: Angle between 0 and EVS_PI/2 radian (Q14) */
1881 : Word16 atan2_fx(
1882 : const Word32 y, /* i : near side (Argument must be positive) (Q15) */
1883 : const Word32 x /* i : opposite side (Q15) */
1884 : );
1885 :
1886 : void pvq_encode_frame(
1887 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
1888 : const float *coefs_norm, /* i : normalized coefficients to encode */
1889 : float *coefs_quant, /* o : quantized coefficients */
1890 : float *gopt, /* o : optimal shape gains */
1891 : int16_t *npulses, /* o : number of pulses per band */
1892 : int16_t *pulse_vector, /* o : non-normalized pulse shapes */
1893 : const int16_t *sfm_start, /* i : indices of first coefficients in the bands */
1894 : const int16_t *sfm_end, /* i : indices of last coefficients in the bands */
1895 : const int16_t *sfmsize, /* i : band sizes */
1896 : const int16_t nb_sfm, /* i : total number of bands */
1897 : const int16_t *R, /* i : bitallocation per band (Q3) */
1898 : const int16_t pvq_bits, /* i : number of bits avaiable */
1899 : const int16_t core /* i : core */
1900 : );
1901 :
1902 : void pvq_decode_frame(
1903 : Decoder_State *st, /* i/o: Decoder state */
1904 : float *coefs_quant, /* o : quantized coefficients */
1905 : int16_t *npulses, /* o : number of pulses per band */
1906 : int16_t *pulse_vector, /* o : non-normalized pulse shapes */
1907 : const int16_t *sfm_start, /* i : indices of first coeffs in the bands */
1908 : const int16_t *sfm_end, /* i : indices of last coeffs in the bands */
1909 : const int16_t *sfmsize, /* i : band sizes */
1910 : const int16_t nb_sfm, /* i : total number of bands */
1911 : const int16_t *R, /* i : bitallocation per band (Q3) */
1912 : const int16_t pvq_bits, /* i : number of bits avaiable */
1913 : const int16_t core /* i : core */
1914 : );
1915 :
1916 : void srt_vec_ind(
1917 : const int16_t *linear, /* linear input */
1918 : int16_t *srt, /* sorted output */
1919 : int16_t *I, /* index for sorted output */
1920 : const int16_t length );
1921 :
1922 : void srt_vec_ind_f(
1923 : const float *linear, /* linear input */
1924 : float *srt, /* sorted output */
1925 : int16_t *I, /* index for sorted output */
1926 : const int16_t length /* length of vector */
1927 : );
1928 :
1929 : /*! r: floor(sqrt(input)) */
1930 : uint32_t floor_sqrt_exact(
1931 : const uint32_t input /* i : unsigned input [0.. UINT_MAX/4] */
1932 : );
1933 :
1934 : void fine_gain_quant(
1935 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
1936 : const int16_t *ord, /* i : Indices for energy order */
1937 : const int16_t num_sfm, /* i : Number of bands */
1938 : const int16_t *gain_bits, /* i : Gain adjustment bits per sub band */
1939 : float *fg_pred, /* i/o: Predicted gains / Corrected gains */
1940 : const float *gopt /* i : Optimal gains */
1941 : );
1942 :
1943 : void apply_gain(
1944 : const int16_t *ord, /* i : Indices for energy order */
1945 : const int16_t *band_start, /* i : Sub band start indices */
1946 : const int16_t *band_end, /* i : Sub band end indices */
1947 : const int16_t num_sfm, /* i : Number of bands */
1948 : const float *gains, /* i : Band gain vector */
1949 : float *xq /* i/o: float synthesis / gain adjusted synth */
1950 : );
1951 :
1952 : void fine_gain_pred(
1953 : const int16_t *sfm_start, /* i : Sub band start indices */
1954 : const int16_t *sfm_end, /* i : Sub band end indices */
1955 : const int16_t *sfm_size, /* i : Sub band bandwidths */
1956 : const int16_t *i_sort, /* i : Energy sorting indices */
1957 : const int16_t *K, /* i : Number of pulses per band */
1958 : const int16_t *maxpulse, /* i : Maximum pulse per band */
1959 : const int16_t *R, /* i : Bits per sub band (Q3) */
1960 : const int16_t num_sfm, /* i : Number of sub bands */
1961 : float *xq, /* i/o: Quantized vector /quantized vector with finegain adj */
1962 : int16_t *y, /* i/o: Quantized vector */
1963 : float *fg_pred, /* o : Predicted fine gains */
1964 : const int16_t core /* i : Core */
1965 : );
1966 :
1967 : void fine_gain_dec(
1968 : Decoder_State *st, /* i/o: Decoder state struct */
1969 : const int16_t *ord, /* i : Indices for energy order */
1970 : const int16_t num_sfm, /* i : Number of bands */
1971 : const int16_t *gain_bits, /* i : Gain adjustment bits per sub band */
1972 : float *fg_pred /* i/o: Predicted gains / Corrected gains */
1973 : );
1974 :
1975 : void get_max_pulses(
1976 : const int16_t *band_start, /* i : Sub band start indices */
1977 : const int16_t *band_end, /* i : Sub band end indices */
1978 : const int16_t *k_sort, /* i : Indices for sorting by energy */
1979 : const int16_t *npulses, /* i : Pulses per sub band */
1980 : const int16_t BANDS, /* i : Number of bands */
1981 : int16_t *inp_vector, /* i/o: Encoded shape vectors */
1982 : int16_t *maxpulse /* o : Maximum pulse height per band */
1983 : );
1984 :
1985 : Word32 ar_div(
1986 : Word32 num,
1987 : Word32 denum );
1988 :
1989 : void ar_encoder_start(
1990 : PARCODEC arInst,
1991 : TCQ_PBITSTREAM bsInst,
1992 : int16_t max_bits );
1993 :
1994 : void ar_decoder_start(
1995 : PARCODEC arInst,
1996 : TCQ_PBITSTREAM bsInst );
1997 :
1998 : void ar_encoder_done(
1999 : PARCODEC arInst );
2000 :
2001 : void ar_decoder_done(
2002 : PARCODEC arInst );
2003 :
2004 : float GetISCScale(
2005 : float *quants,
2006 : int16_t size,
2007 : Word32 bits_fx,
2008 : float *magn,
2009 : float *qscale,
2010 : Word32 *surplus_fx,
2011 : float *pulses,
2012 : int32_t *savedstates,
2013 : int16_t noTCQ,
2014 : int32_t *nzpout,
2015 : int16_t *bcount,
2016 : float *abuffer,
2017 : float *mbuffer,
2018 : float *sbuffer );
2019 :
2020 : Word32 Mult_32_16(
2021 : Word32 a,
2022 : Word16 b );
2023 :
2024 : Word32 Mult_32_32(
2025 : Word32 a,
2026 : Word32 b );
2027 :
2028 : void decode_position_ari_fx(
2029 : PARCODEC pardec,
2030 : Word16 size,
2031 : Word16 npulses,
2032 : Word16 *nz,
2033 : Word32 *position );
2034 :
2035 : void decode_magnitude_usq_fx(
2036 : ARCODEC *pardec,
2037 : Word16 size,
2038 : Word16 npulses,
2039 : Word16 nzpos,
2040 : Word32 *positions,
2041 : Word32 *out );
2042 :
2043 : void decode_mangitude_tcq_fx(
2044 : ARCODEC *pardec,
2045 : Word16 size,
2046 : Word16 npulses,
2047 : Word16 nzpos,
2048 : Word32 *positions,
2049 : Word32 *out,
2050 : Word32 *surplus_fx );
2051 :
2052 : void decode_signs_fx(
2053 : ARCODEC *pardec,
2054 : Word16 size,
2055 : Word32 *out );
2056 :
2057 : void srt_vec_ind_fx(
2058 : const Word32 *linear,
2059 : Word32 *srt,
2060 : Word16 *I,
2061 : Word16 length );
2062 :
2063 : Word16 GetScale_fx(
2064 : Word16 blen,
2065 : Word32 bits_fx /*Q16*/,
2066 : Word32 *surplus_fx /*Q16*/
2067 : );
2068 :
2069 : void bit_allocation_second_fx(
2070 : Word32 *Rk,
2071 : Word32 *Rk_sort,
2072 : Word16 BANDS,
2073 : const Word16 *band_width,
2074 : Word16 *k_sort,
2075 : Word16 *k_num,
2076 : const Word16 *p2a_flags,
2077 : const Word16 p2a_bands,
2078 : const Word16 *last_bitalloc,
2079 : const Word16 input_frame );
2080 :
2081 : Word32 encode_position_ari_fx(
2082 : PARCODEC parenc,
2083 : float *quants,
2084 : Word16 size,
2085 : Word32 *est_bits_frame_fx );
2086 :
2087 : Word32 encode_magnitude_tcq_fx(
2088 : ARCODEC *parenc,
2089 : float *magn_fx,
2090 : Word16 size,
2091 : Word16 npulses,
2092 : Word16 nzpos,
2093 : Word32 *savedstates,
2094 : Word32 *est_frame_bits_fx );
2095 :
2096 : Word32 encode_signs_fx(
2097 : ARCODEC *parenc,
2098 : float *magn,
2099 : Word16 size,
2100 : Word16 npos,
2101 : Word32 *est_frame_bits_fx );
2102 :
2103 : Word32 encode_magnitude_usq_fx(
2104 : ARCODEC *parenc,
2105 : float *magn_fx,
2106 : Word16 size,
2107 : Word16 npulses,
2108 : Word16 nzpos,
2109 : Word32 *est_frame_bits_fx );
2110 :
2111 : ivas_error tcq_core_LR_enc(
2112 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
2113 : #ifdef DEBUGGING
2114 : const int16_t idchan,
2115 : #endif
2116 : int32_t inp_vector[],
2117 : const float coefs_norm[],
2118 : float coefs_quant[],
2119 : const int16_t bit_budget, /* number of bits */
2120 : const int16_t nb_sfm,
2121 : const int16_t *sfm_start,
2122 : const int16_t *sfm_end,
2123 : const int16_t *sfmsize,
2124 : Word32 *Rk_fx,
2125 : int16_t *npulses,
2126 : int16_t *k_sort,
2127 : const int16_t *p2a_flags,
2128 : const int16_t p2a_bands,
2129 : const int16_t *last_bitalloc,
2130 : const int16_t input_frame,
2131 : const int16_t adjustFlag,
2132 : const int16_t is_transient );
2133 :
2134 : void tcq_core_LR_dec(
2135 : Decoder_State *st,
2136 : int32_t *inp_vector,
2137 : const int16_t bit_budget,
2138 : const int16_t bands,
2139 : const int16_t *band_start,
2140 : const int16_t *band_width,
2141 : Word32 *Rk_fx,
2142 : int16_t npulses[],
2143 : int16_t *k_sort,
2144 : const int16_t *p2a_flags,
2145 : const int16_t p2a_bands,
2146 : const int16_t *last_bitalloc,
2147 : const int16_t input_frame,
2148 : const int16_t adjustFlag,
2149 : const int16_t *is_transient );
2150 :
2151 : void InitLSBTCQ(
2152 : int16_t *bcount );
2153 :
2154 : void TCQLSB(
2155 : int16_t bcount,
2156 : float *abuffer,
2157 : float *mbuffer,
2158 : float *sbuffer,
2159 : int16_t *dpath );
2160 :
2161 : void RestoreTCQ(
2162 : float *magn,
2163 : int16_t size,
2164 : int16_t *bcount,
2165 : float *mbuffer );
2166 :
2167 : void SaveTCQdata(
2168 : PARCODEC arInst,
2169 : int16_t *dpath,
2170 : int16_t bcount );
2171 :
2172 : void LoadTCQdata(
2173 : PARCODEC arInst,
2174 : int16_t *dpath,
2175 : int16_t bcount );
2176 :
2177 : void RestoreTCQdec(
2178 : int32_t *magn,
2179 : int16_t size,
2180 : int16_t *bcount,
2181 : float *mbuffer );
2182 :
2183 : void TCQLSBdec(
2184 : int16_t *dpath,
2185 : float *mbuffer,
2186 : int16_t bcount );
2187 :
2188 : void bit_allocation_second_fx(
2189 : Word32 *Rk,
2190 : Word32 *Rk_sort,
2191 : Word16 BANDS,
2192 : const Word16 *band_width,
2193 : Word16 *k_sort,
2194 : Word16 *k_num,
2195 : const Word16 *p2a_flags,
2196 : const Word16 p2a_bands,
2197 : const Word16 *last_bitalloc,
2198 : const Word16 input_frame );
2199 :
2200 : void io_ini_enc(
2201 : const int32_t argc, /* i : command line arguments number */
2202 : char *argv[], /* i : command line arguments */
2203 : FILE **f_input, /* o : input signal file */
2204 : FILE **f_stream, /* o : output bitstream file */
2205 : FILE **f_rate, /* o : bitrate switching profile (0 if N/A) */
2206 : FILE **f_bwidth, /* o : bandwidth switching profile (0 if N/A) */
2207 : FILE **f_metadata, /* o : metadata files (NULL if N/A) */
2208 : #ifdef DEBUGGING
2209 : FILE **f_force, /* o : force switching profile (0 if N/A) */
2210 : #endif
2211 : FILE **f_rf, /* o : channel aware configuration file */
2212 : int16_t *quietMode, /* o : limit printouts */
2213 : int16_t *noDelayCmp, /* o : turn off delay compensation */
2214 : Encoder_Struct *st /* o : IVAS encoder structure */
2215 : );
2216 :
2217 : void read_next_rfparam(
2218 : int16_t *rf_fec_offset, /* o : RF offset */
2219 : int16_t *rf_fec_indicator, /* o : RF FEC indicator */
2220 : FILE *f_rf /* i : file pointer to read parameters */
2221 : );
2222 :
2223 : void read_next_brate(
2224 : int32_t *total_brate, /* i/o: total bitrate */
2225 : const int32_t last_total_brate, /* i : last total bitrate */
2226 : FILE *f_rate, /* i : bitrate switching profile (0 if N/A) */
2227 : const int16_t element_mode, /* i : IVAS element mode */
2228 : int32_t input_Fs, /* i : input sampling frequency */
2229 : int16_t *Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
2230 : int16_t *Opt_SC_VBR, /* i/o: SC-VBR flag */
2231 : int16_t *codec_mode /* i/o: Mode 1 or 2 */
2232 : );
2233 :
2234 : void read_next_bwidth(
2235 : int16_t *max_bwidth, /* i/o: maximum encoded bandwidth */
2236 : FILE *f_bwidth, /* i : bandwidth switching profile (0 if N/A) */
2237 : int32_t *bwidth_profile_cnt, /* i/o: counter of frames for bandwidth switching profile file */
2238 : int32_t input_Fs /* i : input sampling rate */
2239 : );
2240 :
2241 : #ifdef DEBUGGING
2242 : void read_next_force(
2243 : int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/
2244 : FILE *f_force, /* i : force switching profile (0 if N/A) */
2245 : int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */
2246 : );
2247 : #endif
2248 :
2249 : ivas_error init_encoder(
2250 : Encoder_State *st, /* i/o: state structure */
2251 : Encoder_Struct *st_ivas, /* i/o: encoder state structure */
2252 : const int16_t idchan, /* i : channel ID */
2253 : const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */
2254 : const int16_t interval_SID, /* i : interval for SID update */
2255 : const int16_t vad_only_flag, /* i : flag to indicate front-VAD structure */
2256 : const ISM_MODE ism_mode, /* i : ISM mode */
2257 : const int32_t element_brate /* element bitrate */
2258 : );
2259 :
2260 : void LPDmem_enc_init(
2261 : LPD_state_HANDLE hLPDmem /* i/o: LP memories */
2262 : );
2263 :
2264 : void destroy_cldfb_encoder(
2265 : Encoder_State *st /* i/o: state structure */
2266 : );
2267 : ivas_error evs_enc(
2268 : Encoder_State *st, /* i/o: state structure */
2269 : const int16_t *data, /* i : input signal */
2270 : float *mem_hp20_in, /* i/o: hp20 filter memory */
2271 : const int16_t n_samples /* i : number of input samples */
2272 : );
2273 : void amr_wb_enc(
2274 : Encoder_State *st, /* i/o: encoder state structure */
2275 : const int16_t *data, /* i : input signal */
2276 : float *mem_hp20_in, /* i/o: hp20 filter memory */
2277 : const int16_t n_samples /* i : number of input samples */
2278 : );
2279 :
2280 : void sc_vbr_enc_init(
2281 : SC_VBR_ENC_HANDLE hSC_VBR /* i/o: SC-VBR encoder handle */
2282 : );
2283 :
2284 : void amr_wb_enc_init(
2285 : AMRWB_IO_ENC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO encoder handle */
2286 : );
2287 :
2288 : void pre_proc(
2289 : Encoder_State *st, /* i/o: encoder state structure */
2290 : const int16_t input_frame, /* i : frame length */
2291 : float old_inp_12k8[], /* i/o: buffer of old input signal */
2292 : float old_inp_16k[], /* i/o: buffer of old input signal @ 16kHz */
2293 : float **inp, /* o : ptr. to inp. signal in the current frame*/
2294 : float fr_bands[2 * NB_BANDS], /* i : energy in frequency bands */
2295 : float *ener, /* o : residual energy from Levinson-Durbin */
2296 : #ifndef FIX_I4_OL_PITCH
2297 : int16_t pitch_orig[3], /* o : open-loop pitch values for quantization */
2298 : #endif
2299 : float A[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */
2300 : float Aw[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */
2301 : float epsP[M + 1], /* i/o: LP prediction errors */
2302 : float lsp_new[M], /* i/o: LSPs at the end of the frame */
2303 : float lsp_mid[M], /* i/o: LSPs in the middle of the frame */
2304 : int16_t *vad_hover_flag, /* i : VAD hangover flag */
2305 : int16_t *attack_flag, /* o : attack flag */
2306 : float *new_inp_resamp16k, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
2307 : int16_t *Voicing_flag, /* o : voicing flag for HQ FEC */
2308 : float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */
2309 : float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */
2310 : int16_t *hq_core_type /* o : HQ core type */
2311 : );
2312 : #endif
2313 :
2314 : /*! r: HQ_CORE/TCX_20_CORE decision */
2315 : int16_t mdct_classifier(
2316 : Encoder_State *st, /* i/o: Encoder state variable */
2317 : const float *fft_buff, /* i : FFT spectrum from fft_rel */
2318 : const float enerBuffer[], /* i : energy buffer */
2319 : const int32_t brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */
2320 : );
2321 :
2322 : void MDCT_selector(
2323 : Encoder_State *st, /* i/o: Encoder State */
2324 : const float sp_floor, /* i : Noise floor estimate */
2325 : const float Etot, /* i : Total energy */
2326 : const float cor_map_sum, /* i : sum of correlation map */
2327 : const float enerBuffer[] /* i : energy buffer */
2328 : );
2329 :
2330 : void MDCT_selector_reset(
2331 : TCX_ENC_HANDLE hTcxEnc /* i/o: TCX Encoder Handle */
2332 : );
2333 :
2334 : void MDCT_classifier_reset(
2335 : TCX_ENC_HANDLE hTcxEnc /* i/o: TCX Encoder Handle */
2336 : );
2337 :
2338 : ivas_error acelp_core_enc(
2339 : Encoder_State *st, /* i/o: encoder state structure */
2340 : const float inp[], /* i : input signal of the current frame */
2341 : const float ener, /* i : residual energy from Levinson-Durbin */
2342 : float A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes */
2343 : float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes */
2344 : const float epsP[M + 1], /* i : LP prediction errors */
2345 : float lsp_new[M], /* i : LSPs at the end of the frame */
2346 : float lsp_mid[M], /* i : LSPs in the middle of the frame */
2347 : const int16_t vad_hover_flag, /* i : VAD hangover flag */
2348 : const int16_t attack_flag, /* i : attack flag (GSC or TC) */
2349 : float bwe_exc_extended[], /* i/o: bandwidth extended excitation */
2350 : float *voice_factors, /* o : voicing factors */
2351 : float old_syn_12k8_16k[], /* o : ACELP core synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
2352 : float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */
2353 : int16_t *unbits, /* o : number of unused bits */
2354 : STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
2355 : const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
2356 : );
2357 :
2358 : ivas_error acelp_core_switch_dec_bfi(
2359 : Decoder_State *st /* i/o: decoder state structure */
2360 : );
2361 :
2362 : void acelp_core_switch_enc(
2363 : Encoder_State *st, /* i/o: encoder state structure */
2364 : const float inp12k8[], /* i : input signal @12.8 kHz */
2365 : const float inp16k[], /* i : input signal @16 kHz */
2366 : const float A[NB_SUBFR16k * ( M + 1 )] /* i : A(z) unquantized for the 4 subframes */
2367 : );
2368 :
2369 : /*! r: length of output */
2370 : int16_t modify_Fs_intcub3m_sup(
2371 : const float sigIn[], /* i : signal to decimate with memory of 2 samples (indexes -2 & -1) */
2372 : const int16_t lg, /* i : length of input */
2373 : const int32_t fin, /* i : frequency of input */
2374 : float sigOut[], /* o : decimated signal */
2375 : const int32_t fout, /* i : frequency of output */
2376 : int16_t *delayout /* o : delay of output */
2377 : );
2378 :
2379 : void core_switching_OLA(
2380 : const float *mem_over_hp, /* i : upsampling filter memory */
2381 : const int16_t last_L_frame, /* i : last L_frame lengthture */
2382 : const int32_t output_Fs, /* i : output sampling rate */
2383 : float *synth, /* i/o: synthesized signal from HQ core */
2384 : const float *synth_subfr_out, /* i : synthesized signal from ACELP core */
2385 : float *synth_subfr_bwe, /* i : synthesized BWE from ACELP core */
2386 : const int16_t output_frame, /* i : output frame length */
2387 : const int16_t bwidth /* i : output bandwidth */
2388 : );
2389 :
2390 : void retro_interp4_5(
2391 : const float *syn,
2392 : float *pst_old_syn );
2393 :
2394 : void retro_interp5_4(
2395 : float *pst_old_syn );
2396 :
2397 : void core_switching_hq_prepare_enc(
2398 : Encoder_State *st, /* i/o: encoder state structure */
2399 : int16_t *num_bits, /* i/o: bit budget update */
2400 : const int16_t input_frame, /* i : input frame length */
2401 : float *wtda_audio,
2402 : const float *audio );
2403 :
2404 : void core_switching_hq_prepare_dec(
2405 : Decoder_State *st, /* i/o: decoder state structure */
2406 : int16_t *num_bits, /* i/o: bit budget update */
2407 : const int16_t input_frame /* i : input frame length */
2408 : );
2409 :
2410 : ivas_error acelp_core_switch_dec(
2411 : Decoder_State *st, /* i/o: decoder structure */
2412 : float *synth_subfr_out, /* o : synthesized ACELP subframe */
2413 : float *tmp_synth_bwe, /* o : synthesized ACELP subframe BWE */
2414 : const int16_t output_frame, /* i : input frame length */
2415 : const int16_t core_switching_flag, /* i : core switching flag */
2416 : float *mem_synth, /* o : synthesis to overlap */
2417 : const int16_t nchan_out /* i : number of output channels */
2418 : );
2419 :
2420 : void space_lsfs(
2421 : float *lsfs,
2422 : const int16_t order );
2423 :
2424 : void lsp2a(
2425 : float *pc_in,
2426 : float *freq,
2427 : const int16_t order );
2428 :
2429 : void lsp_weights(
2430 : const float *lsps,
2431 : float *weight,
2432 : const int16_t order );
2433 :
2434 : void a2lsp_stab(
2435 : const float *a, /* i : LP filter coefficients */
2436 : float *lsp, /* o : Line spectral pairs */
2437 : const float *old_lsp /* i : LSP vector from past frame */
2438 : );
2439 :
2440 : void lsp2a_stab(
2441 : const float *lsp, /* i : LSF vector (in the cosine domain) */
2442 : float *a, /* o : LP filter coefficients */
2443 : const int16_t m /* i : order of LP analysis */
2444 : );
2445 :
2446 : void isf2lsf(
2447 : const float *isf, /* i : ISF vector */
2448 : float *lsf, /* o : LSF vector */
2449 : float *stable_lsp, /* i/o: LSF vector */
2450 : const int16_t m, /* i : order of LP analysis */
2451 : const int32_t Fs );
2452 :
2453 : void lsf2isf(
2454 : const float *lsf, /* i : LSF vector */
2455 : float *isf, /* o : ISF vector */
2456 : float *stable_isp, /* i/o: ISP vector */
2457 : const int16_t m, /* i : order of LP analysis */
2458 : const int32_t Fs );
2459 :
2460 : int16_t a2lsp(
2461 : float *freq, /* o : LSP vector */
2462 : const float *a, /* i : predictor coefficients */
2463 : const int16_t order /* i : order of LP analysis */
2464 : );
2465 :
2466 : void ResetSHBbuffer_Enc(
2467 : TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */
2468 : );
2469 :
2470 : void ResetSHBbuffer_Dec(
2471 : TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
2472 : const int16_t extl /* i : BWE extension layer */
2473 : );
2474 :
2475 : void calc_st_filt(
2476 : const float *apond2, /* i : coefficients of numerator */
2477 : const float *apond1, /* i : coefficients of denominator */
2478 : float *parcor0, /* o : 1st parcor calcul. on composed filter */
2479 : float *sig_ltp_ptr, /* i/o: input of 1/A(gamma1) : scaled by 1/g0 */
2480 : float *mem_zero, /* i/o: All zero memory */
2481 : const int16_t L_subfr, /* i : the length of subframe */
2482 : const int16_t extl /* i : extension layer info */
2483 : );
2484 :
2485 : void scale_st(
2486 : const float *sig_in, /* i : postfilter input signal */
2487 : float *sig_out, /* i/o: postfilter output signal */
2488 : float *gain_prec, /* i/o: last value of gain for subframe */
2489 : const int16_t L_subfr, /* i : the length of subframe */
2490 : const int16_t extl /* i : extension layer info */
2491 : );
2492 :
2493 : void filt_mu(
2494 : const float *sig_in, /* i : signal (beginning at sample -1) */
2495 : float *sig_out, /* o : output signal */
2496 : const float parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */
2497 : const int16_t L_subfr, /* i : the length of subframe */
2498 : const int16_t extl /* i : extension layer info */
2499 : );
2500 :
2501 : void PostShortTerm(
2502 : float *sig_in, /* i : input signal (ptr. to current subframe */
2503 : float *lpccoeff, /* i : LPC coefficients for current subframe */
2504 : float *sig_out, /* o : postfiltered output */
2505 : float *mem_stp, /* i/o: postfilter memory */
2506 : float *ptr_mem_stp, /* i/o: pointer to postfilter memory */
2507 : float *ptr_gain_prec, /* i/o: for gain adjustment */
2508 : float *mem_zero, /* i/o: null memory to compute h_st */
2509 : const float formant_fac /* i : Strength of post-filter [0,1] */
2510 : );
2511 :
2512 : /*! r: Formant filter strength [0,1] */
2513 : float swb_formant_fac(
2514 : const float lpc_shb2, /* i : 2nd HB LPC coefficient */
2515 : float *tilt_mem /* i/o: Tilt smoothing memory */
2516 : );
2517 :
2518 : void GenShapedSHBExcitation(
2519 : float *excSHB, /* o : synthesized shaped shb exctiation */
2520 : const float *lpc_shb, /* i : lpc coefficients */
2521 : float *exc16kWhtnd, /* o : whitened synthesized shb excitation */
2522 : float *mem_csfilt, /* i/o: memory */
2523 : float *mem_genSHBexc_filt_down_shb, /* i/o: memory */
2524 : float *state_lpc_syn, /* i/o: memory */
2525 : const int16_t coder_type, /* i : coding type */
2526 : const float *bwe_exc_extended, /* i : bandwidth extended excitation */
2527 : int16_t bwe_seed[], /* i/o: random number generator seed */
2528 : float voice_factors[], /* i : voicing factor */
2529 : const int16_t extl, /* i : extension layer */
2530 : float *tbe_demph, /* i/o: de-emphasis memory */
2531 : float *tbe_premph, /* i/o: pre-emphasis memory */
2532 : float *lpc_shb_sf, /* i : LP coefficients */
2533 : float *shb_ener_sf, /* i : SHB subframe energies */
2534 : float *shb_res_gshape, /* i : SHB LP residual gain shape */
2535 : float *shb_res, /* i : SHB residual used in encoder only */
2536 : int16_t *vf_ind, /* i/o: Mixing factor index */
2537 : const float formant_fac, /* i : Formant sharpening factor [0..1] */
2538 : float fb_state_lpc_syn[], /* i/o: memory */
2539 : float *fb_tbe_demph, /* i/o: fb de-emphasis memory */
2540 : const int32_t total_brate, /* i : overall bitrate */
2541 : const int16_t prev_bfi, /* i : previous frame was lost flag */
2542 : const int16_t element_mode, /* i : element mode */
2543 : const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */
2544 : float *nlExc16k, /* i/o: NL exc for IC-BWE */
2545 : float *mixExc16k, /* i/o: exc spreading for IC-BWE */
2546 : const int32_t extl_brate, /* i : TD BWE bitrate */
2547 : const int16_t MSFlag, /* i : Multi-source flag */
2548 : float EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */
2549 : float *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */
2550 : float *prev_mix_factor, /* i/o: mixing factor in the previous frame */
2551 : float *Env_error, /* o : error in SHB residual envelope modelling*/
2552 : float Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */
2553 : );
2554 :
2555 : void GenSHBSynth(
2556 : const float *shb_target_speech, /* i : input synthesized speech */
2557 : float *shb_syn_speech_32k, /* o : output highband component */
2558 : float Hilbert_Mem[], /* i/o: memory */
2559 : float state_lsyn_filt_shb_local[], /* i/o: memory */
2560 : const int16_t L_frame, /* i : ACELP Frame length */
2561 : int16_t *syn_dm_phase );
2562 :
2563 : void ScaleShapedSHB(
2564 : const int16_t length, /* i : SHB overlap length */
2565 : float *synSHB, /* i/o: synthesized shb signal */
2566 : float *overlap, /* i/o: buffer for overlap-add */
2567 : const float *subgain, /* i : subframe gain */
2568 : const float frame_gain, /* i : frame gain */
2569 : const float *win, /* i : window */
2570 : const float *subwin /* i : subframes window */
2571 : );
2572 :
2573 : void Interpolate_allpass_steep(
2574 : const float *in, /* i : input array of size N */
2575 : float *mem, /* i/o: memory */
2576 : const int16_t N, /* i : number of input samples */
2577 : float *out /* o : output array of size 2*N */
2578 : );
2579 :
2580 : void Decimate_allpass_steep(
2581 : const float *in, /* i : input array of size N */
2582 : float *mem, /* i/o: memory */
2583 : const int16_t N, /* i : number of input samples */
2584 : float *out /* o : output array of size N/2 */
2585 : );
2586 :
2587 : void interpolate_3_over_2_allpass(
2588 : const float *input, /* i : input signal */
2589 : const int16_t len, /* i : number of input samples */
2590 : float *out, /* o : output signal */
2591 : float *mem /* i/o: memory */
2592 : );
2593 :
2594 : void decimate_2_over_3_allpass(
2595 : const float *input, /* i : input signal */
2596 : const int16_t len, /* i : number of input samples */
2597 : float *out, /* o : output signal */
2598 : float *mem, /* i/o: memory */
2599 : float *lp_mem );
2600 :
2601 : void interpolate_3_over_1_allpass(
2602 : const float *input, /* i : input signal */
2603 : const int16_t len, /* i : number of input samples */
2604 : float *out, /* o : output signal */
2605 : float *mem /* i/o: memory */
2606 : );
2607 :
2608 : void InitSWBencBuffer(
2609 : TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */
2610 : );
2611 :
2612 : void InitSWBencBufferStates(
2613 : TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
2614 : float *shb_speech /* o : SHB target signal (6-14kHz) at 16kHz */
2615 : );
2616 :
2617 : void swb_tbe_enc(
2618 : Encoder_State *st, /* i/o: encoder state structure */
2619 : STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */
2620 : const float *new_speech, /* i : original input signal */
2621 : const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
2622 : const float voice_factors[], /* i : voicing factors */
2623 : float *White_exc16k, /* o : shaped white excitation for the FB TBE */
2624 : const float pitch_buf[] /* i : pitch for each subframe */
2625 : );
2626 :
2627 : void swb_tbe_dec(
2628 : Decoder_State *st, /* i/o: decoder state structure */
2629 : STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */
2630 : const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
2631 : const float voice_factors[], /* i : voicing factors */
2632 : const float old_syn_12k8_16k[], /* i : low band synthesis at 12.8kHz or 16kHz */
2633 : float *White_exc16k, /* o : shaped white excitation for the FB TBE */
2634 : float *synth, /* i/o: ACELP core synthesis/final synthesis */
2635 : float *pitch_buf );
2636 :
2637 : void flip_and_downmix_generic(
2638 : float input[], /* i : input spectrum */
2639 : float output[], /* o : output spectrum */
2640 : const int16_t length, /* i : length of spectra */
2641 : float mem1_ext[HILBERT_ORDER1], /* i/o: Hilbert filter memory */
2642 : float mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory */
2643 : float mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory */
2644 : int16_t *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */
2645 : );
2646 :
2647 : void non_linearity(
2648 : const float input[], /* i : input signal */
2649 : float output[], /* i : output signal */
2650 : float old_bwe_exc_extended[], /* i/o: memory bugffer */
2651 : const int16_t length, /* i : input length */
2652 : float *prev_scale, /* i/o: memory */
2653 : const int16_t coder_type, /* i : Coder Type */
2654 : const float *voice_factors, /* i : Voice Factors */
2655 : const int16_t L_frame /* i : ACELP frame length */
2656 : );
2657 :
2658 : void interp_code_5over2(
2659 : const float inp_code[], /* i : input vector */
2660 : float interp_code[], /* o : output vector */
2661 : const int16_t inp_length /* i : length of the input vector */
2662 : );
2663 :
2664 : void interp_code_4over2(
2665 : const float inp_code[], /* i : input vector */
2666 : float interp_code[], /* o : output vector */
2667 : const int16_t inp_length /* i : length of the input vector */
2668 : );
2669 :
2670 : void flip_spectrum_and_decimby4(
2671 : const float input[], /* i : input spectrum */
2672 : float output[], /* o : output spectrum */
2673 : const int16_t length, /* i : vector length */
2674 : float mem1[], /* i/o: memory */
2675 : float mem2[], /* i/o: memory */
2676 : const int16_t ramp_flag /* i : flag to trigger slow ramp-up of output */
2677 : );
2678 :
2679 : void GenShapedWBExcitation(
2680 : float *excSHB, /* o : synthesized shaped shb exctiation */
2681 : const float *lpc_shb, /* i : lpc coefficients */
2682 : float *exc4kWhtnd, /* o : whitened synthesized shb excitation */
2683 : float *mem_csfilt, /* i/o: memory */
2684 : float *mem_genSHBexc_filt_down1, /* i/o: memory */
2685 : float *mem_genSHBexc_filt_down2, /* i/o: memory */
2686 : float *mem_genSHBexc_filt_down3, /* i/o: memory */
2687 : float *state_lpc_syn, /* i/o: memory */
2688 : const int16_t coder_type, /* i : coding type */
2689 : const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
2690 : int16_t bwe_seed[], /* i/o: random number generator seed */
2691 : const float voice_factors[], /* i : voicing factor */
2692 : const int16_t uv_flag, /* i : unvoiced flag */
2693 : const int16_t igf_flag );
2694 :
2695 : void GenWBSynth(
2696 : const float *input_synspeech, /* i : input synthesized speech */
2697 : float *shb_syn_speech_16k, /* o : output highband compnent */
2698 : float *state_lsyn_filt_shb1, /* i/o: memory */
2699 : float *state_lsyn_filt_shb2 /* i/o: memory */
2700 : );
2701 :
2702 : void wb_tbe_enc(
2703 : Encoder_State *st, /* i/o: encoder state structure */
2704 : const float *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz */
2705 : const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
2706 : const float pitch_buf[], /* i : pitch for each subframe */
2707 : const float voicing[] /* o : OL maximum normalized correlation */
2708 : );
2709 :
2710 : void wb_tbe_dec(
2711 : Decoder_State *st, /* i/o: decoder state structure */
2712 : const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
2713 : const float voice_factors[], /* i : voicing factors */
2714 : float *synth /* i/o: ACELP core synthesis/final synthesis */
2715 : );
2716 :
2717 : void tbe_write_bitstream(
2718 : Encoder_State *st /* i/o: encoder state structure */
2719 : );
2720 :
2721 : void tbe_read_bitstream(
2722 : Decoder_State *st /* i/o: decoder state structure */
2723 : );
2724 :
2725 : void GenTransition(
2726 : TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
2727 : float *outputHB, /* o : synthesized HB transitions signal */
2728 : const int32_t output_Fs, /* i : output sampling rate */
2729 : const int16_t element_mode, /* i : element mode */
2730 : const int16_t L_frame, /* i : ACELP frame length */
2731 : const int16_t rf_flag, /* i : RF flag */
2732 : const int32_t total_brate /* i : total bitrate */
2733 : );
2734 :
2735 : void GenTransition_WB(
2736 : TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
2737 : float *outputHB, /* o : synthesized HB transitions signal */
2738 : const int32_t output_Fs /* i : output sampling rate */
2739 : );
2740 :
2741 : void td_bwe_dec_init(
2742 : TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
2743 : const int16_t extl, /* i : BWE extension layer */
2744 : const int32_t output_Fs /* i : output sampling rate */
2745 : );
2746 :
2747 : void TBEreset_enc(
2748 : TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
2749 : const int16_t last_core, /* i : last core */
2750 : const int16_t bwidth /* i : audio bandwidth */
2751 : );
2752 :
2753 : void TBEreset_dec(
2754 : Decoder_State *st /* i/o: decoder state structure */
2755 : );
2756 :
2757 : /*! r: TBE bit consumption per frame */
2758 : int16_t get_tbe_bits(
2759 : const int32_t total_brate, /* i : overall bitrate */
2760 : const int16_t bwidth, /* i : audio bandwidth */
2761 : const int16_t rf_mode /* i : channel aware mode */
2762 : );
2763 :
2764 : void fb_tbe_enc(
2765 : Encoder_State *st, /* i/o: encoder state structure */
2766 : const float new_input[], /* i : input speech at 48 kHz sample rate */
2767 : const float fb_exc[] /* i : FB excitation from the SWB part */
2768 : );
2769 :
2770 : void fb_tbe_dec(
2771 : Decoder_State *st, /* i/o: decoder state structure */
2772 : const float fb_exc[], /* i : FB excitation from the SWB part */
2773 : float *hb_synth, /* i/o: high-band synthesis */
2774 : float *fb_synth_ref, /* o : high-band synthesis 16-20 kHz */
2775 : const int16_t output_frame /* i : output frame length */
2776 : );
2777 :
2778 : void calc_tilt_bwe(
2779 : const float *sp, /* i : input signal */
2780 : float *tilt, /* o : signal tilt */
2781 : const int16_t N /* i : signal length */
2782 : );
2783 :
2784 : void fd_bwe_enc_init(
2785 : FD_BWE_ENC_HANDLE hBWE_FD /* i/o: FD BWE data handle */
2786 : );
2787 :
2788 : void swb_pre_proc(
2789 : Encoder_State *st, /* i/o: encoder state structure */
2790 : float *new_swb_speech, /* o : original input signal at 32kHz */
2791 : float *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz */
2792 : float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer */
2793 : float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer */
2794 : CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */
2795 : );
2796 :
2797 : void wb_pre_proc(
2798 : Encoder_State *st, /* i/o: encoder state structure */
2799 : const int16_t last_element_mode, /* i : last element mode */
2800 : const float *new_inp_resamp16k, /* i : original input signal */
2801 : float *hb_speech /* o : HB target signal (6-8kHz) at 16kHz */
2802 : );
2803 :
2804 : void wb_bwe_enc(
2805 : Encoder_State *st, /* i/o: encoder state structure */
2806 : const float *new_wb_speech /* i : original input signal at 16kHz */
2807 : );
2808 :
2809 : void wb_bwe_dec(
2810 : Decoder_State *st, /* i/o: decoder state structure */
2811 : const float output[], /* i : synthesis @internal Fs */
2812 : float *synth, /* i/o: ACELP core synthesis/final synthesis */
2813 : float *hb_synth, /* o : SHB synthesis/final synthesis */
2814 : const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
2815 : const int16_t output_frame, /* i : frame length */
2816 : const float voice_factors[], /* i : voicing factors */
2817 : const float pitch_buf[] /* i : pitch buffer */
2818 : );
2819 :
2820 : void swb_bwe_enc(
2821 : Encoder_State *st, /* i/o: encoder state structure */
2822 : const int16_t last_element_mode, /* i : last element mode */
2823 : const float *old_input_12k8, /* i : input signal @12.8kHz for SWB BWE */
2824 : const float *old_input_16k, /* i : input signal @16kHz for SWB BWE */
2825 : const float *old_syn_12k8_16k, /* i : ACELP core synthesis at 12.8kHz or 16kHz*/
2826 : const float *new_swb_speech, /* i : original input signal at 32kHz */
2827 : const float *shb_speech /* i : SHB target signal (6-14kHz) at 16kHz */
2828 : );
2829 :
2830 : void swb_bwe_enc_hr(
2831 : Encoder_State *st, /* i/o: encoder state structure */
2832 : const float *new_input, /* i : input signal */
2833 : const int16_t input_frame, /* i : frame length */
2834 : const int16_t unbits /* i : number of core unused bits */
2835 : );
2836 :
2837 : void fd_bwe_dec_init(
2838 : FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */
2839 : );
2840 :
2841 : void swb_bwe_dec(
2842 : Decoder_State *st, /* i/o: decoder state structure */
2843 : const float output[], /* i : synthesis @internal Fs */
2844 : const float *synth, /* i : ACELP core synthesis/final synthesis */
2845 : float *hb_synth, /* o : SHB synthesis/final synthesis */
2846 : const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
2847 : const int16_t output_frame /* i : frame length */
2848 : );
2849 :
2850 : void hr_bwe_dec_init(
2851 : HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */
2852 : );
2853 :
2854 : void swb_bwe_dec_hr(
2855 : Decoder_State *st, /* i/o: decoder state structure */
2856 : const float *syn_12k8_16k, /* i : ACELP core synthesis @16kHz */
2857 : float *hb_synth, /* o : SHB synthesis */
2858 : const int16_t output_frame, /* i : frame length */
2859 : const int16_t unbits, /* i : number of core unused bits */
2860 : const float pitch_buf[] /* i : pitch buffer */
2861 : );
2862 :
2863 : void swb_hr_noise_fill(
2864 : const int16_t is_transient, /* i : transient flag */
2865 : const int16_t spect_start, /* i : spectrum start point */
2866 : const int16_t spect_end, /* i : spectrum end point */
2867 : const float tilt_wb, /* i : tilt of wideband signal */
2868 : const float pitch, /* i : pitch value */
2869 : const int16_t nq[], /* i : AVQ nq index */
2870 : int16_t Nsv, /* i : number of subband */
2871 : int16_t *bwe_highrate_seed, /* i/o: seed of random noise */
2872 : float *t_audio /* i/o: mdct spectrum */
2873 : );
2874 :
2875 : /*! r: gain */
2876 : float td_postprocess(
2877 : float hb_synth[], /* i/o: high-band synthesis */
2878 : const int16_t input_frame, /* i : frame length */
2879 : const int16_t last_extl /* i : last extension layer */
2880 : );
2881 :
2882 : void calc_normal_length(
2883 : const int16_t core, /* i : core */
2884 : const float *sp, /* i : input signal */
2885 : const int16_t mode, /* i : input mode */
2886 : const int16_t extl, /* i : extension layer */
2887 : int16_t *L_swb_norm, /* o : normalize length */
2888 : int16_t *prev_L_swb_norm /* i/o: last normalize length */
2889 : );
2890 :
2891 : void calc_norm_envelop(
2892 : const float SWB_signal[], /* i : SWB spectrum */
2893 : float *envelope, /* o : normalized envelope */
2894 : const int16_t L_swb_norm, /* i : length of envelope */
2895 : const int16_t SWB_flength, /* i : Length of input/output */
2896 : const int16_t st_offset /* i : offset */
2897 : );
2898 :
2899 : void time_envelop_shaping(
2900 : float werr[], /* i/o: SHB synthesis */
2901 : float SWB_tenv[], /* i/o: frequency envelope */
2902 : const int16_t L /* i : frame length */
2903 : );
2904 :
2905 : void time_reduce_pre_echo(
2906 : const float *synth, /* i : ACELP core synthesis */
2907 : float *error, /* o : SHB BWE synthesis */
2908 : float prev_td_energy, /* o : last td energy */
2909 : const int16_t L /* i : subframe length */
2910 : );
2911 :
2912 : int16_t WB_BWE_gain_pred(
2913 : float *WB_fenv, /* o : WB frequency envelopes */
2914 : const float *core_dec_freq, /* i : Frequency domain core decoded signal */
2915 : const int16_t coder_type, /* i : coding type */
2916 : const int16_t prev_code_type, /* i : coding type of last frame */
2917 : const float prev_WB_fenv, /* i : envelope for last frame */
2918 : const float voice_factors[], /* i : voicing factors */
2919 : const float pitch_buf[], /* i : pitch buffer */
2920 : const int32_t last_core_brate, /* i : previous frame core bitrate */
2921 : const float last_wb_bwe_ener, /* i : previous frame wb bwe signal energy */
2922 : const int16_t last_extl, /* i : extl. layer for last frame */
2923 : const float tilt );
2924 :
2925 : void WB_BWE_decoding(
2926 : const float *core_dec_freq, /* i : Frequency domain core decoded signal */
2927 : float *WB_fenv, /* i : WB frequency envelopes */
2928 : float *WB_signal, /* o : WB signal in MDCT domain */
2929 : const int16_t WB_flength, /* i : Length of input/output */
2930 : const int16_t mode, /* i : classification for WB signal */
2931 : const int16_t last_extl, /* i : extl. layer for last frame */
2932 : float *prev_Energy, /* i/o: energy for last frame */
2933 : float *prev_WB_fenv, /* i/o: envelope for last frame */
2934 : int16_t *prev_L_wb_norm, /* i/o: length for last frame wb norm */
2935 : const int16_t extl, /* i : extension layer */
2936 : const int16_t coder_type, /* i : coding type */
2937 : const int32_t total_brate, /* i : core layer bitrate */
2938 : int16_t *Seed, /* i/o: random generator seed */
2939 : int16_t *prev_flag, /* i/o: attenu flag of last frame */
2940 : int16_t prev_coder_type /* i : coding type of last frame */
2941 : );
2942 :
2943 : void SWB_BWE_decoding(
2944 : const float *core_dec_freq, /* i : Frequency domain core decoded signal */
2945 : float *SWB_fenv, /* i/o: SWB frequency envelopes */
2946 : float *SWB_signal, /* o : SWB signal in MDCT domain */
2947 : const int16_t SWB_flength, /* i : Length of input/output */
2948 : const int16_t mode, /* i : classification for SWB signal */
2949 : int16_t *frica_flag, /* o : fricative signal flag */
2950 : float *prev_Energy, /* i/o: energy for last frame */
2951 : float *prev_SWB_fenv, /* i/o: envelope for last frame */
2952 : int16_t *prev_L_swb_norm, /* i/o: length for last frame wb norm */
2953 : const float tilt_nb, /* i : tilt of synthesis wb signal */
2954 : int16_t *Seed, /* i/o: random generator seed */
2955 : const int16_t st_offset, /* i : offset value due to different core */
2956 : float *prev_weight, /* i/o: excitation weight value of last frame */
2957 : const int16_t extl, /* i : extension layer */
2958 : const int16_t last_extl /* i : extension layer of last frame */
2959 : );
2960 :
2961 : void CNG_reset_enc(
2962 : Encoder_State *st, /* i/o: encoder state structure */
2963 : float *pitch_buf, /* o : floating pitch for each subframe */
2964 : float *voice_factors, /* o : voicing factors */
2965 : int16_t VBR_cng_reset_flag );
2966 :
2967 : void a2isp(
2968 : const float *a, /* i : LP filter coefficients */
2969 : float *isp, /* o : Immittance spectral pairs */
2970 : const float *old_isp /* i : ISP vector from past frame */
2971 : );
2972 :
2973 : void a2isf(
2974 : float *a,
2975 : float *isf,
2976 : const float *old_isf,
2977 : const int16_t lpcOrder );
2978 :
2979 : /*! r: stability flag */
2980 : uint16_t a2rc(
2981 : const float *a, /* i : LPC coefficients */
2982 : float *refl, /* o : Reflection co-efficients */
2983 : const int16_t lpcorder /* i : LPC order */
2984 : );
2985 :
2986 : int16_t lp_filt_exc_enc(
2987 : const int16_t codec_mode, /* i : codec mode */
2988 : const int16_t coder_type, /* i : coding type */
2989 : const int16_t i_subfr, /* i : subframe index */
2990 : float *exc, /* i/o: pointer to excitation signal frame */
2991 : const float *h1, /* i : weighted filter input response */
2992 : const float *xn, /* i : target vector */
2993 : float *y1, /* o : zero-memory filtered adaptive excitation */
2994 : float *xn2, /* o : target vector for innovation search */
2995 : const int16_t L_subfr, /* i : length of vectors for gain quantization */
2996 : const int16_t L_frame, /* i : frame size */
2997 : float *g_corr, /* o : ACELP correlation values */
2998 : const int16_t clip_gain, /* i : adaptive gain clipping flag */
2999 : float *gain_pit, /* o : adaptive excitation gain */
3000 : int16_t *lp_flag /* i/o: mode selection */
3001 : );
3002 :
3003 : void updt_tar(
3004 : const float *x, /* i : old target (for pitch search) */
3005 : float *x2, /* o : new target (for codebook search) */
3006 : const float *y, /* i : filtered adaptive codebook vector */
3007 : const float gain, /* i : adaptive codebook gain */
3008 : const int16_t L /* i : subframe size */
3009 : );
3010 :
3011 : void analy_sp(
3012 : const int16_t element_mode, /* i : element mode */
3013 : CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
3014 : const int32_t input_Fs, /* i : input sampling rate */
3015 : float *speech, /* i : speech buffer */
3016 : float *Bin_E, /* o : per bin log energy spectrum */
3017 : float *Bin_E_old, /* o : per bin log energy spectrum for mid-frame */
3018 : float *fr_bands, /* o : per band energy spectrum (2 analyses) */
3019 : float lf_E[], /* o : per bin E for first VOIC_BINS bins (without DC) */
3020 : float *Etot, /* o : total input energy */
3021 : const int16_t min_band, /* i : minimum critical band */
3022 : const int16_t max_band, /* i : maximum critical band */
3023 : float *band_ener, /* o : energy in critical frequency bands without minimum noise floor E_MIN */
3024 : float *PS, /* o : Per bin energy spectrum */
3025 : float *fft_buff /* o : FFT coefficients */
3026 : );
3027 :
3028 : void CNG_enc(
3029 : Encoder_State *st, /* i/o: State structure */
3030 : float Aq[], /* o : LP coefficients */
3031 : const float *speech, /* i : pointer to current frame input speech buffer */
3032 : float enr, /* i : frame energy output from Levinson recursion */
3033 : const float *lsp_mid, /* i : mid frame LSPs */
3034 : float *lsp_new, /* i/o: current frame LSPs */
3035 : float *lsf_new, /* i/o: current frame LSFs */
3036 : int16_t *allow_cn_step, /* o : allow CN step */
3037 : float *q_env,
3038 : int16_t *sid_bw );
3039 :
3040 : void swb_CNG_enc(
3041 : Encoder_State *st, /* i/o: State structure */
3042 : const float *shb_speech, /* i : SHB target signal (6-14kHz) at 16kHz */
3043 : const float *syn_12k8_16k /* i : ACELP core synthesis at 12.8kHz or 16kHz */
3044 : );
3045 :
3046 : void lsf_enc(
3047 : Encoder_State *st, /* i/o: state structure */
3048 : float *lsf_new, /* o : quantized LSF vector */
3049 : float *lsp_new, /* i/o: LSP vector to quantize/quantized */
3050 : float *lsp_mid, /* i : mid-frame LSP vector */
3051 : float *Aq, /* o : quantized A(z) for 4 subframes */
3052 : const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
3053 : const int16_t GSC_IVAS_mode, /* i : GSC IVAS mode */
3054 : const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
3055 : );
3056 :
3057 : void isf_enc_amr_wb(
3058 : Encoder_State *st, /* i/o: state structure */
3059 : float *isf_new, /* o : quantized ISF vector */
3060 : float *isp_new, /* i/o: ISP vector to quantize/quantized */
3061 : float *Aq /* o : quantized A(z) for 4 subframes */
3062 : );
3063 :
3064 : void find_targets(
3065 : const float *speech, /* i : pointer to the speech frame */
3066 : const float *mem_syn, /* i : memory of the synthesis filter */
3067 : const int16_t i_subfr, /* i : subframe index */
3068 : float *mem_w0, /* i/o: weighting filter denominator memory */
3069 : const float *p_Aq, /* i : interpolated quantized A(z) filter */
3070 : const float *res, /* i : residual signal */
3071 : const int16_t L_subfr, /* i : length of vectors for gain quantization */
3072 : const float *Ap, /* i : unquantized A(z) filter with bandwidth expansion */
3073 : const float tilt_fac, /* i : tilt factor */
3074 : float *xn, /* o : Close-loop Pitch search target vector */
3075 : float *cn, /* o : target vector in residual domain */
3076 : float *h1 /* o : impulse response of weighted synthesis filter */
3077 : );
3078 :
3079 : void inov_encode(
3080 : Encoder_State *st, /* i/o: encoder state structure */
3081 : const int32_t core_brate, /* i : core bitrate */
3082 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
3083 : const int16_t L_frame, /* i : length of the frame */
3084 : const int16_t last_L_frame, /* i : length of the last frame */
3085 : const int16_t coder_type, /* i : coding type */
3086 : const int16_t bwidth, /* i : input signal bandwidth */
3087 : const int16_t sharpFlag, /* i : formant sharpening flag */
3088 : const int16_t i_subfr, /* i : subframe index */
3089 : const int16_t tc_subfr, /* i : TC subframe index */
3090 : const float *p_Aq, /* i : LP filter coefficients */
3091 : const float gain_pit, /* i : adaptive excitation gain */
3092 : float *cn, /* i/o: target vector in residual domain */
3093 : const float *exc, /* i : pointer to excitation signal frame */
3094 : float *h1, /* i/o: weighted filter input response */
3095 : const float tilt_code, /* i : tilt of of the excitation of previous subframe */
3096 : const float pt_pitch, /* i : pointer to current subframe fractional pitch */
3097 : const float *xn2, /* i : target vector for innovation search */
3098 : float *code, /* o : algebraic excitation */
3099 : float *y2, /* o : zero-memory filtered algebraic excitation */
3100 : int16_t *unbits, /* o : number of unused bits for EVS_PI */
3101 : const int16_t L_subfr /* i : subframe length */
3102 : );
3103 :
3104 : void acelp_1t64(
3105 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3106 : const float dn[], /* i : corr. between target and h[]. */
3107 : const float h[], /* i : impulse response of weighted synthesis filter */
3108 : float code[], /* o : algebraic (fixed) codebook excitation */
3109 : float y[], /* o : filtered fixed codebook excitation */
3110 : const int16_t L_subfr /* i : subframe length */
3111 : );
3112 :
3113 : void acelp_2t32(
3114 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3115 : const float dn[], /* i : corr. between target and h[]. */
3116 : const float h[], /* i : impulse response of weighted synthesis filter */
3117 : float code[], /* o : algebraic (fixed) codebook excitation */
3118 : float y[] /* o : filtered fixed codebook excitation */
3119 : );
3120 :
3121 : int16_t acelp_4t64(
3122 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3123 : float dn[], /* i : corr. between target and h[]. */
3124 : const float cn[], /* i : residual after long term prediction */
3125 : const float H[], /* i : impulse response of weighted synthesis filter */
3126 : float R[], /* i : autocorrelation values */
3127 : const int16_t acelpautoc, /* i : autocorrealtion flag */
3128 : float code[], /* o : algebraic (fixed) codebook excitation */
3129 : float y[], /* o : filtered fixed codebook excitation */
3130 : int16_t nbbits, /* i : number of bits per codebook */
3131 : const int16_t cmpl_flag, /* i : coomplexity reduction flag */
3132 : const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
3133 : );
3134 :
3135 : /*! r: return (2*N)+1 bits */
3136 : int16_t quant_2p_2N1(
3137 : const int16_t pos1, /* i : position of the pulse 1 */
3138 : const int16_t pos2, /* i : position of the pulse 2 */
3139 : const int16_t N /* i : number of bits for position */
3140 : );
3141 :
3142 : void corr_xh(
3143 : const float *x, /* i : target signal */
3144 : float *y, /* o : correlation between x[] and h[] */
3145 : const float *h, /* i : impulse response of weighted synthesis filter */
3146 : const int16_t L_subfr /* i : length of the subframe */
3147 : );
3148 :
3149 : void find_tilt(
3150 : const float fr_bands[], /* i : energy in frequency bands */
3151 : const float bckr[], /* i : per band background noise energy estimate */
3152 : float ee[2], /* o : lf/hf E ration for present frame */
3153 : const int16_t pitch[3], /* i : open loop pitch values for 3 half-frames */
3154 : const float voicing[3], /* i : normalized correlation for 3 half-frames */
3155 : const float *lf_E, /* i : per bin energy for low frequencies */
3156 : const float corr_shift, /* i : normalized correlation correction */
3157 : const int16_t bwidth, /* i : input signal bandwidth */
3158 : const int16_t max_band, /* i : maximum critical band */
3159 : float hp_E[], /* o : energy in HF */
3160 : const int16_t codec_mode, /* i : Mode 1 or 2 */
3161 : float *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise */
3162 : int16_t Opt_vbr_mode );
3163 :
3164 : void init_gp_clip(
3165 : float mem[] /* o : memory of gain of pitch clipping algorithm */
3166 : );
3167 :
3168 : int16_t gp_clip(
3169 : const int16_t element_mode, /* i : element mode */
3170 : const int32_t core_brate, /* i : core bitrate */
3171 : const float *voicing, /* i : normalized correlations (from OL pitch) */
3172 : const int16_t i_subfr, /* i : subframe index */
3173 : const int16_t coder_type, /* i : coding type */
3174 : const float xn[], /* i : target vector */
3175 : float mem[] /* i/o: memory of gain of pitch clipping algorithm */
3176 : );
3177 :
3178 : void gp_clip_test_lsf(
3179 : const int16_t element_mode, /* i : element mode */
3180 : const int32_t core_brate, /* i : core bitrate */
3181 : const float lsf[], /* i : LSF vector */
3182 : float mem[], /* i/o: memory of gain of pitch clipping algorithm */
3183 : const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
3184 : );
3185 :
3186 : void gp_clip_test_gain_pit(
3187 : const int16_t element_mode, /* i : element mode */
3188 : const int32_t core_brate, /* i : core bitrate */
3189 : const float gain_pit, /* i : gain of quantized pitch */
3190 : float mem[] /* i/o: memory of gain of pitch clipping algorithm */
3191 : );
3192 :
3193 : void analy_lp(
3194 : const float speech[], /* i : pointer to the denoised speech frame */
3195 : const int16_t L_frame, /* i : length of the frame */
3196 : const int16_t L_look, /* i : look-ahead length */
3197 : float *ener, /* o : residual signal energy */
3198 : float A[], /* o : A(z) filter coefficients */
3199 : float epsP[], /* o : LP analysis residual energies for each iteration */
3200 : float lsp_new[], /* o : current frame ISPs */
3201 : float lsp_mid[], /* o : current mid-frame ISPs */
3202 : float lsp_old[], /* i/o: previous frame unquantized ISPs */
3203 : const int16_t Top[2], /* i : open loop pitch lag */
3204 : const float Tnc[2], /* i : open loop pitch gain */
3205 : const int32_t sr_core, /* i : internal sampling rate */
3206 : const int16_t sec_chan_low_rate /* i : TD secondary channel flag */
3207 : );
3208 :
3209 : void analy_lp_AMR_WB(
3210 : const float speech[], /* i : pointer to the speech frame */
3211 : float *ener, /* o : residual energy from Levinson-Durbin */
3212 : float A[], /* o : A(z) filter coefficients */
3213 : float epsP[], /* o : LP analysis residual energies for each iteration */
3214 : float isp_new[], /* o : current frame ISPs */
3215 : float isp_old[], /* i/o: previous frame unquantized ISPs */
3216 : float isf_new[], /* o : current frame ISFs */
3217 : const int16_t Top, /* i : open loop pitch lag */
3218 : const float Tnc /* i : open loop pitch gain */
3219 : );
3220 :
3221 : void noise_est_init(
3222 : NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */
3223 : );
3224 :
3225 : void speech_music_clas_init(
3226 : SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */
3227 : );
3228 :
3229 : void long_enr(
3230 : Encoder_State *st, /* i/o: encoder state structure */
3231 : const float Etot, /* i : total channel energy */
3232 : const int16_t localVAD_HE_SAD, /* i : HE-SAD flag without hangover */
3233 : const int16_t high_lpn_flag, /* i : sp/mus LPN flag */
3234 : FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */
3235 : const int16_t n_chan, /* i : number of channels */
3236 : const int16_t localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover LR channels */
3237 : const float Etot_LR[] /* i : total channel energy LR channels */
3238 : );
3239 :
3240 : void noise_est_pre(
3241 : const float Etot, /* i : Energy of current frame */
3242 : const int16_t ini_frame, /* i : Frame number (init) */
3243 : NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation data handle */
3244 : const int16_t idchan, /* i : channel ID */
3245 : const int16_t element_mode, /* i : element mode */
3246 : const int16_t last_element_mode /* i : last element mode */
3247 : );
3248 :
3249 : void noise_est_down(
3250 : const float fr_bands[], /* i : per band input energy (contains 2 vectors) */
3251 : float bckr[], /* i/o: per band background noise energy estimate */
3252 : float tmpN[], /* o : temporary noise update */
3253 : float enr[], /* o : averaged energy over both subframes */
3254 : const int16_t min_band, /* i : minimum critical band */
3255 : const int16_t max_band, /* i : maximum critical band */
3256 : float *totalNoise, /* o : noise estimate over all critical bands */
3257 : const float Etot, /* i : Energy of current frame */
3258 : float *Etot_last, /* i/o: Energy of last frame */
3259 : float *Etot_v_h2 /* i/o: Energy variaions of noise frames */
3260 : );
3261 :
3262 : void noise_est(
3263 : Encoder_State *st, /* i/o: encoder state structure */
3264 : const int16_t old_pitch1, /* i : previous frame OL pitch[1] */
3265 : const float tmpN[], /* i : temporary noise update */
3266 : const float *epsP, /* i : LP prediction error energies */
3267 : const float Etot, /* i : total channel E */
3268 : const float relE, /* i : relative frame energy */
3269 : const float corr_shift, /* i : normalized correlation correction */
3270 : const float enr[], /* i : averaged energy over both subframes */
3271 : float fr_bands[], /* i : spectrum per critical bands of the current frame */
3272 : float *cor_map_sum, /* o : sum of correlation map from mult-harm analysis */
3273 : float *ncharX, /* o : noise character for sp/mus classifier */
3274 : float *sp_div, /* o : soectral diversity feature */
3275 : float *non_staX, /* o : non-stationarity for sp/mus classifier */
3276 : int16_t *loc_harm, /* o : multi-harmonicity flag for UV classifier */
3277 : const float *lf_E, /* i : per bin energy for low frequencies */
3278 : int16_t *st_harm_cor_cnt, /* i : 1st harm correlation timer */
3279 : const float Etot_l_lp, /* i : Smoothed low energy */
3280 : float *sp_floor, /* o : noise floor estimate */
3281 : float S_map[], /* o : short-term correlation map */
3282 : STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
3283 : FRONT_VAD_ENC_HANDLE hFrontVad, /* i/o: front-VAD handle */
3284 : const int16_t ini_frame /* i : Frame number (init) */
3285 : );
3286 :
3287 : void vad_param_updt(
3288 : Encoder_State *st, /* i/o: encoder state structure */
3289 : const float corr_shift, /* i : correlation shift */
3290 : const float corr_shiftR, /* i : correlation shift right channel */
3291 : const float A[], /* i : A(z) unquantized for the 4 subframes */
3292 : const int16_t old_pitch1, /* i : previous frame OL pitch[1] */
3293 : FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */
3294 : const int16_t n_channels /* i : number of channels */
3295 : );
3296 :
3297 : /*! r: frame multi-harmonicity (1-harmonic, 0-not) */
3298 : int16_t multi_harm(
3299 : const float Bin_E[], /* i : log energy spectrum of the current frame */
3300 : float old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor */
3301 : float cor_map_LT[], /* i/o: LT correlation map */
3302 : float *multi_harm_limit, /* i/o: multi harminic threshold */
3303 : const int32_t total_brate, /* i : total bitrate */
3304 : const int16_t bwidth, /* i : input signal bandwidth */
3305 : int16_t *cor_strong_limit, /* i/o: HF correlation indicator */
3306 : float *st_mean_avr_dyn, /* i/o: long term average dynamic */
3307 : float *st_last_sw_dyn, /* i/o: last dynamic */
3308 : float *cor_map_sum, /* i : sum of correlation map */
3309 : float *sp_floor, /* o : noise floor estimate */
3310 : float S_map[] /* o : short-term correlation map */
3311 : );
3312 :
3313 : void lp_gain_updt(
3314 : const int16_t i_subfr, /* i : subframe number */
3315 : const float gain_pit, /* i : Decoded gain pitch */
3316 : const float norm_gain_code, /* i : Normalised gain code */
3317 : float *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) */
3318 : float *lp_gainc, /* i/o: LP-filtered code gain (FEC) */
3319 : const int16_t L_frame /* i : length of the frame */
3320 : );
3321 :
3322 : void enc_pit_exc(
3323 : Encoder_State *st, /* i/o: state structure */
3324 : const float *speech, /* i : Input speech */
3325 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
3326 : const float *Aq, /* i : 12k8 Lp coefficient */
3327 : const float Es_pred, /* i : predicted scaled innov. energy */
3328 : const float *res, /* i : residual signal */
3329 : float *synth, /* i/o: core synthesis */
3330 : float *exc, /* i/o: current non-enhanced excitation */
3331 : int16_t *T0, /* i/o: close loop integer pitch */
3332 : int16_t *T0_frac, /* i/o: close-loop pitch period - fractional part */
3333 : float *pitch_buf, /* i/o: Fractionnal per subframe pitch */
3334 : const int16_t nb_subfr, /* i : Number of subframe considered */
3335 : float *gpit, /* o : pitch gain per subframe */
3336 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
3337 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
3338 : );
3339 :
3340 : void GSC_enc_init(
3341 : GSC_ENC_HANDLE hGSCEnc /* i/o: GSC data handle */
3342 : );
3343 :
3344 : void encod_audio(
3345 : Encoder_State *st, /* i/o: state structure */
3346 : const float speech[], /* i : input speech */
3347 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
3348 : const float Aq[], /* i : 12k8 Lp coefficient */
3349 : const float *res, /* i : residual signal */
3350 : float *synth, /* i/o: core synthesis */
3351 : float *exc, /* i/o: current non-enhanced excitation */
3352 : float *pitch_buf, /* i/o: floating pitch values for each subframe */
3353 : float *voice_factors, /* o : voicing factors */
3354 : float *bwe_exc, /* o : excitation for SWB TBE */
3355 : const int16_t attack_flag, /* i : attack flag (GSC or TC) */
3356 : float *lsf_new, /* i : current frame ISF vector */
3357 : float *tmp_noise, /* o : long-term noise energy */
3358 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
3359 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
3360 : );
3361 :
3362 : /*! r: index of the last band where pitch contribution is significant */
3363 : int16_t Pit_exc_contribution_len(
3364 : Encoder_State *st, /* i/o: state structure */
3365 : const float *dct_res, /* i : DCT of residual */
3366 : float *dct_pitex, /* i/o: DCT of pitch contribution */
3367 : float *pitch_buf, /* i/o: Pitch per subframe */
3368 : int16_t *hangover /* i : Hangover for the time contribution switching */
3369 : );
3370 :
3371 : int16_t stab_est(
3372 : float etot, /* i : Total energy of the current frame */
3373 : float *lt_diff_etot, /* i/o: Long term total energy variation */
3374 : float *mem_etot, /* i/o: Total energy memory */
3375 : int16_t *nb_thr_3, /* i/o: Number of consecutives frames of level 3 */
3376 : int16_t *nb_thr_1, /* i/o: Number of consecutives frames of level 1 */
3377 : float *thresh, /* i/o: Detection thresold */
3378 : int16_t *last_music_flag, /* i/o: Previous music detection ouptut */
3379 : const int16_t vad_flag /* i : VAD flag */
3380 : );
3381 :
3382 : float gsc_gainQ(
3383 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3384 : const int16_t element_mode, /* i : element mode */
3385 : const int16_t idchan, /* i : channel ID */
3386 : const float y_gain4[], /* i : gain per band */
3387 : float y_gainQ[], /* o : quantized gain per band */
3388 : const int32_t core_brate, /* i : Core rate */
3389 : const int16_t coder_type, /* i : coding type */
3390 : const int16_t bwidth, /* i : input signal bandwidth */
3391 : const int16_t L_frame, /* i : frame length */
3392 : const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */
3393 : const int32_t core_brate_inp /* i : true core brate */
3394 : );
3395 :
3396 : void Ener_per_band_comp(
3397 : const float exc_diff[], /* i : gain per band */
3398 : float y_gain4[], /* o : gain per band to quantize */
3399 : const int16_t Mband, /* i : Max band */
3400 : const int16_t Eflag, /* i : flag of highest band */
3401 : const int16_t L_frame /* i : frame length */
3402 : );
3403 :
3404 : void Comp_and_apply_gain(
3405 : float exc_diffQ[], /* i/o: gain per band */
3406 : float Ener_per_bd_iQ[], /* o : Quant Ener per band */
3407 : float Ener_per_bd_yQ[], /* o : Ener per band for quantize y */
3408 : int16_t Mbands_gn, /* i : number of bands */
3409 : const int16_t ReUseGain /* i : Reuse the gain in Ener_per_bd_yQ */
3410 : );
3411 :
3412 : void bands_and_bit_alloc(
3413 : const int16_t cor_strong_limit, /* i : HF correlation */
3414 : const int16_t noise_lev, /* i : dwn scaling factor */
3415 : const int32_t core_brate, /* i : core bitrate */
3416 : const int16_t Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/
3417 : const int16_t bits_used, /* i : Number of bit used before frequency Q */
3418 : int16_t *bit, /* i/o: Number of bit allowed for frequency quantization */
3419 : float *ener_vec, /* i/o: Quantized energy vector */
3420 : int16_t *max_ener_band, /* o : Sorted order */
3421 : int16_t *bits_per_bands_s, /* i/o: Number of bit allowed per allowed subband (Q3) */
3422 : int16_t *nb_subbands, /* o : Number of subband allowed */
3423 : const float *exc_diff, /* i : Difference signal to quantize (encoder side only) */
3424 : float *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */
3425 : int16_t *pvq_len, /* o : Number of bin covered with the PVQ */
3426 : const int16_t coder_type, /* i : coding type */
3427 : const int16_t bwidth, /* i : input signal bandwidth */
3428 : const int16_t GSC_noisy_speech, /* i : GSC noisy speech flag */
3429 : const int16_t L_frame, /* i : frame length */
3430 : const int16_t element_mode, /* i : element mode */
3431 : const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */
3432 : );
3433 :
3434 : /*! r: average frequency gain */
3435 : float gsc_gaindec(
3436 : Decoder_State *st, /* i/o: decoder state structure */
3437 : float y_gainQ[], /* o : quantized gain per band */
3438 : const int32_t core_brate, /* i : core used */
3439 : float old_y_gain[], /* i/o: AR gain quantizer for low rate */
3440 : const int16_t coder_type, /* i : coding type */
3441 : const int16_t bwidth /* i : input signal bandwidth */
3442 : );
3443 :
3444 : void freq_dnw_scaling(
3445 : const int16_t cor_strong_limit, /* i : HF correlation */
3446 : const int16_t coder_type, /* i : coder type */
3447 : const int16_t noise_lev, /* i : Noise level */
3448 : const int32_t core_brate, /* i : Core bitrate */
3449 : float fy_norm[], /* i/o: Frequency quantized parameter */
3450 : const int16_t L_frame /* i : frame length */
3451 : );
3452 :
3453 : void GSC_dec_init(
3454 : GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */
3455 : );
3456 :
3457 : void decod_audio(
3458 : Decoder_State *st, /* i/o: decoder static memory */
3459 : float dct_epit[], /* o : GSC excitation in DCT domain */
3460 : const float *Aq, /* i : LP filter coefficient */
3461 : float *tmp_noise, /* o : long term temporary noise energy */
3462 : float *pitch_buf, /* o : floating pitch values for each subframe */
3463 : float *voice_factors, /* o : voicing factors */
3464 : float *exc_dct_in, /* i/o: adapt. excitation exc */
3465 : float *exc2, /* i/o: adapt. excitation/total exc */
3466 : float *bwe_exc, /* o : excitation for SWB TBE */
3467 : float *lsf_new, /* i : current frame ISF vector */
3468 : float *gain_buf, /* o : floating pitch gain for each subframe */
3469 : const int16_t tdm_lp_reuse_flag, /* i : LPC reuse flag */
3470 : const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
3471 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
3472 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
3473 : );
3474 :
3475 : void gsc_dec(
3476 : Decoder_State *st, /* i/o: State structure */
3477 : float exc_dct_in[], /* i/o: dct of pitch-only/total excitation */
3478 : const int16_t pit_band_idx, /* i : pitch band index */
3479 : const int16_t Diff_len, /* i : */
3480 : const int16_t bits_used, /* i : total number of bits used */
3481 : const int16_t nb_subfr, /* i : Number of subframe considered */
3482 : const int16_t coder_type, /* i : coding type */
3483 : int16_t *last_bin, /* i : last bin of bit allocation */
3484 : const float *lsf_new, /* i : ISFs at the end of the frame */
3485 : float *exc_wo_nf, /* o : excitation (in f domain) without noisefill*/
3486 : float *tmp_noise /* o : long-term noise energy */
3487 : );
3488 :
3489 : void dec_pit_exc(
3490 : Decoder_State *st, /* i/o: decoder static memory */
3491 : const int16_t L_frame, /* i : length of the frame */
3492 : const float *Aq, /* i : LP filter coefficient */
3493 : const float Es_pred, /* i : predicted scaled innov. energy */
3494 : float *pitch_buf, /* o : floating pitch values for each subframe */
3495 : float *code, /* o : innovation */
3496 : float *exc, /* i/o: adapt. excitation exc */
3497 : const int16_t nb_subfr, /* i : Number of subframe considered */
3498 : float *gain_buf, /* o : floating pitch gain for each subframe */
3499 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
3500 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
3501 : );
3502 :
3503 : void highband_exc_dct_in(
3504 : const int32_t core_brate, /* i : core bitrate */
3505 : const int16_t *mfreq_bindiv_loc, /* i : bin per bands tables */
3506 : int16_t last_bin, /* i : last bin of bit allocation */
3507 : int16_t Diff_len, /* i : number of bin before cut-off frequency */
3508 : int16_t noise_lev, /* i : pulses dynamic */
3509 : int16_t pit_band_idx, /* i : bin position of the cut-off frequency */
3510 : float *exc_diffQ, /* i : frequency coefficients of per band */
3511 : int16_t *seed_tcx, /* i : Seed for noise */
3512 : float *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */
3513 : int16_t nb_subfr, /* i : Number of subframe considered */
3514 : float *exc_dct_in, /* o : dct of residual signal */
3515 : int16_t last_coder_type, /* i : coding type of last frame */
3516 : int16_t *bitallocation_band, /* i : bit allocation flag of each band */
3517 : const float *lsf_new, /* i : ISFs at the end of the frame */
3518 : float *last_exc_dct_in, /* i : dct of residual signal of last frame */
3519 : float *last_ener, /* i : frequency energy of last frame */
3520 : int16_t *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */
3521 : int16_t *bitallocation_exc, /* i : flag of decoded coefficients */
3522 : const int16_t bfi, /* i : bad frame indicator */
3523 : const int16_t coder_type, /* i : coder type */
3524 : const int16_t bwidth, /* i : audio bandwidth */
3525 : float *exc_wo_nf, /* o : excitation (in f domain) without noisefill */
3526 : const int16_t GSC_noisy_speech, /* i : GSC noisy speech flag */
3527 : float *lt_ener_per_band_fx, /* i/o: Average per band energy */
3528 : const int16_t L_frame, /* i : frame length */
3529 : const int16_t element_mode, /* i : IVAS element moden */
3530 : const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */
3531 : );
3532 :
3533 : void inact_switch_ematch(
3534 : float exc2[], /* i/o: CELP/GSC excitation buffer */
3535 : float dct_exc_tmp[], /* i : GSC excitation in DCT domain */
3536 : float lt_ener_per_band[], /* i/o: long-term energy per band */
3537 : const int16_t coder_type, /* i : coder type */
3538 : const int16_t inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
3539 : const int16_t L_frame, /* i : frame length */
3540 : const int16_t bfi, /* i : frame lost indicator */
3541 : const int16_t last_core, /* i : Last core used */
3542 : const int16_t last_codec_mode, /* i : Last codec mode */
3543 : const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
3544 : const int16_t element_mode /* i : element mode */
3545 : );
3546 :
3547 : void music_postfilt_init(
3548 : MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */
3549 : );
3550 :
3551 : void LD_music_post_filter(
3552 : MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */
3553 : const float dtc_in[], /* i : input synthesis */
3554 : float dtc_out[], /* o : output synthesis */
3555 : const int32_t core_brate, /* i : core bitrate */
3556 : const int16_t coder_type, /* i : Coder type : -1 in case of IO */
3557 : const int16_t Last_coder_type /* i : last Coder type */
3558 : );
3559 :
3560 : void Post_music_postP(
3561 : float dct_buffer_in[], /* i/o: excitation buffer */
3562 : float exc_buffer_out[], /* o : DCT output buffer */
3563 : float *exc2, /* i/o: Current excitation to be overwriten */
3564 : const float *mem_tmp, /* i : previous frame synthesis memory */
3565 : float *st_mem_syn2, /* i/o: current frame synthesis memory */
3566 : const float *Aq, /* i : LPC filter coefficients */
3567 : float *syn /* i/o: 12k8 synthesis */
3568 : );
3569 :
3570 : void Prep_music_postP(
3571 : float exc_buffer_in[], /* i/o: excitation buffer */
3572 : float dct_buffer_out[], /* o : DCT output buffer */
3573 : float filt_lfE[], /* i/o: long term spectrum energy */
3574 : const int16_t last_core, /* i : last core */
3575 : const float *pitch_buf, /* i : current frame pitch information */
3576 : float *LDm_enh_lp_gbin /* o : smoothed suppression gain, per bin FFT */
3577 : );
3578 :
3579 : void speech_music_classif(
3580 : Encoder_State *st, /* i/o: encoder state structure */
3581 : const float *new_inp, /* i : new input signal */
3582 : const float *inp, /* i : input signal to locate attach position */
3583 : const int16_t localVAD_HE_SAD, /* i : HE-SAD flag without hangover */
3584 : const float lsp_new[M], /* i : LSPs in current frame */
3585 : const float cor_map_sum, /* i : correlation map sum (from multi-harmonic anal.) */
3586 : const float epsP[M + 1], /* i : LP prediciton error */
3587 : const float PS[], /* i : energy spectrum */
3588 : const float Etot, /* i : total frame energy */
3589 : const float old_cor, /* i : max correlation from previous frame */
3590 : int16_t *attack_flag, /* o : attack flag (GSC or TC) */
3591 : const float non_staX, /* i : unbound non-stationarity for sp/mus classifier */
3592 : const float relE, /* i : relative frame energy */
3593 : int16_t *high_lpn_flag, /* o : sp/mus LPN flag */
3594 : const int16_t flag_spitch /* i : flag to indicate very short stable pitch */
3595 : );
3596 :
3597 : void find_wsp(
3598 : const int16_t L_frame, /* i : length of the frame */
3599 : const int16_t L_subfr, /* i : length of subframe */
3600 : const int16_t nb_subfr, /* i : number of subframes */
3601 : const float *A, /* i : A(z) filter coefficients */
3602 : float *Aw, /* o : weighted A(z) filter coefficients */
3603 : const float *speech, /* i : pointer to the denoised speech frame */
3604 : const float tilt_fact, /* i : tilt factor */
3605 : float *wsp, /* o : poitnter to the weighted speech frame */
3606 : float *mem_wsp, /* i/o: W(Z) denominator memory */
3607 : const float gamma, /* i : weighting factor */
3608 : const int16_t L_look /* i : look-ahead */
3609 : );
3610 :
3611 : void pitch_ol_init(
3612 : float *old_thres, /* o : threshold for reinforcement of past pitch influence */
3613 : int16_t *old_pitch, /* o : pitch of the 2nd half-frame of previous frame */
3614 : int16_t *delta_pit, /* o : pitch evolution extrapolation */
3615 : float *old_corr /* o : correlation */
3616 : );
3617 :
3618 : void pitch_ol(
3619 : int16_t pitch[3], /* o : open loop pitch lag for each half-frame */
3620 : float voicing[3], /* o : maximum normalized correlation for each half-frame */
3621 : int16_t *old_pitch, /* i/o: OL pitch of the 2nd half-frame of the last frame */
3622 : float *old_corr, /* i/o: correlation */
3623 : float corr_shift, /* i : normalized correlation correction */
3624 : float *old_thres, /* i/o: maximum correlation weighting with respect to past frame pitch */
3625 : int16_t *delta_pit, /* i/o: old pitch extrapolation correction (added to old pitch) */
3626 : float *st_old_wsp2, /* i/o: weighted speech memory */
3627 : const float *wsp, /* i : weighted speech for current frame and look-ahead */
3628 : float mem_decim2[3], /* i/o: wsp decimation filter memory */
3629 : const float relE, /* i : relative frame energy */
3630 : const int16_t L_look, /* i : look-ahead length */
3631 : const int16_t last_class, /* i : frame classification of last frame */
3632 : const int16_t bwidth, /* i : audio bandwidth */
3633 : const int16_t Opt_SC_VBR /* i : SC-VBR flag */
3634 : );
3635 :
3636 : void pitch_ol2(
3637 : const int16_t pit_min, /* i : pit_min value */
3638 : const int16_t pitch_ol, /* i : pitch to be improved */
3639 : float *pitch_fr, /* o : adjusted 1/4 fractional pitch */
3640 : float *voicing_fr, /* o : adjusted 1/4 fractional voicing */
3641 : const int16_t pos, /* i : position in frame where to calculate the improv. */
3642 : const float *wsp, /* i : weighted speech for current frame and look-ahead */
3643 : const int16_t delta /* i : delta for pitch search */
3644 : );
3645 :
3646 : void StableHighPitchDetect(
3647 : int16_t *flag_spitch, /* o : flag to indicate very short stable pitch */
3648 : int16_t pitch[], /* i/o: OL pitch buffer */
3649 : const float voicing[], /* i : OL pitch gains */
3650 : const float Bin_E[], /* i : per bin log energy spectrum */
3651 : const float wsp[], /* i : weighted speech */
3652 : const int16_t localVAD, /* i : local VAD flag */
3653 : float *voicing_sm, /* i/o: smoothed open-loop pitch gains */
3654 : float *voicing0_sm, /* i/o: smoothed high pitch gains */
3655 : float *LF_EnergyRatio_sm, /* i/o: smoothed [0, 300Hz] relative peak energy */
3656 : int16_t *predecision_flag, /* i/o: predecision flag */
3657 : float *diff_sm, /* i/o: smoothed pitch frequency difference */
3658 : float *energy_sm /* i/o: smoothed energy around pitch frequency */
3659 : );
3660 :
3661 : void pitchDoubling_det(
3662 : const float *wspeech,
3663 : int16_t *pitch_ol,
3664 : float *pitch_fr,
3665 : float *voicing_fr );
3666 :
3667 : void gain_enc_amr_wb(
3668 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3669 : const float *xn, /* i : target vector */
3670 : const float *y1, /* i : zero-memory filtered adaptive excitation */
3671 : const float *y2, /* i : zero-memory filtered algebraic codebook excitation */
3672 : const float *code, /* i : algebraic excitation */
3673 : const int32_t core_brate, /* i : core bitrate */
3674 : float *gain_pit, /* i/o: Pitch gain / Quantized pitch gain */
3675 : float *gain_code, /* o : Quantized codebook gain */
3676 : float *gain_inov, /* o : innovation gain */
3677 : float *norm_gain_code, /* o : norm. gain of the codebook excitation */
3678 : float *coeff, /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
3679 : const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
3680 : float *past_qua_en /* i/o: gain quantization memory (4 words) */
3681 : );
3682 :
3683 : void gain_enc_lbr(
3684 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3685 : const int16_t gains_mode[], /* i : gain bits */
3686 : const int16_t coder_type, /* i : coding type */
3687 : const int16_t i_subfr, /* i : subframe index */
3688 : const float *xn, /* i : target vector */
3689 : const float *y1, /* i : zero-memory filtered adaptive excitation */
3690 : const float *y2, /* i : zero-memory filtered algebraic codebook excitation */
3691 : const float *code, /* i : algebraic excitation */
3692 : float *gain_pit, /* o : quantized pitch gain */
3693 : float *gain_code, /* o : quantized codebook gain */
3694 : float *gain_inov, /* o : gain of the innovation (used for normalization) */
3695 : float *norm_gain_code, /* o : norm. gain of the codebook excitation */
3696 : float *g_corr, /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
3697 : float gains_mem[], /* i/o: pitch gain and code gain from previous subframes */
3698 : const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
3699 : const int16_t L_subfr /* i : subfr Lenght */
3700 : );
3701 :
3702 : void gain_enc_mless(
3703 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3704 : const int16_t gains_mode[], /* i : gain bits */
3705 : const int16_t element_mode, /* i : element mode */
3706 : const int16_t L_frame, /* i : length of the frame */
3707 : const int16_t i_subfr, /* i : subframe index */
3708 : const int16_t tc_subfr, /* i : TC subframe index */
3709 : const float *xn, /* i : target vector */
3710 : const float *y1, /* i : zero-memory filtered adaptive excitation */
3711 : const float *y2, /* i : zero-memory filtered algebraic codebook excitation */
3712 : const float *code, /* i : algebraic excitation */
3713 : const float Es_pred, /* i : predicted scaled innovation energy */
3714 : float *gain_pit, /* o : quantized pitch gain */
3715 : float *gain_code, /* o : quantized codebook gain */
3716 : float *gain_inov, /* o : innovation gain */
3717 : float *norm_gain_code, /* o : norm. gain of the codebook excitation */
3718 : float *coeff, /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
3719 : const int16_t clip_gain /* i : gain pitch clipping flag (1 = clipping) */
3720 : );
3721 :
3722 : void gain_enc_SQ(
3723 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3724 : const int16_t gains_mode[], /* i : gain bits */
3725 : const int16_t i_subfr, /* i : subframe index */
3726 : const float *xn, /* i : target vector */
3727 : const float *yy1, /* i : zero-memory filtered adaptive excitation */
3728 : const float *y2, /* i : zero-memory filtered algebraic codebook excitation */
3729 : const float *code, /* i : algebraic excitation */
3730 : const float Es_pred, /* i : predicted scaled innovation energy */
3731 : float *gain_pit, /* o : quantized pitch gain */
3732 : float *gain_code, /* o : quantized codebook gain */
3733 : float *gain_inov, /* o : gain of the innovation (used for normalization) */
3734 : float *norm_gain_code, /* o : norm. gain of the codebook excitation */
3735 : float *g_corr, /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
3736 : const int16_t clip_gain /* i : gain pitch clipping flag (1 = clipping) */
3737 : );
3738 :
3739 : /*! r: Return index of quantization */
3740 : int16_t gain_enc_gaus(
3741 : float *gain, /* i/o: Code gain to quantize */
3742 : const int16_t bits, /* i : number of bits to quantize */
3743 : const float lowBound, /* i : lower bound of quantizer (dB) */
3744 : const float topBound /* i : upper bound of quantizer (dB) */
3745 : );
3746 :
3747 : void E_corr_xy2(
3748 : const float xn[], /* i : target vector */
3749 : const float y1[], /* i : filtered excitation components 1 */
3750 : const float y2[], /* i : filtered excitation components 2 */
3751 : float g_corr[], /* o : correlations between x, y1, y2, y3, y4 */
3752 : const int16_t L_subfr /* i : subframe size */
3753 : );
3754 :
3755 : /*! r: Floating pitch for each subframe */
3756 : float pit_encode(
3757 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3758 : const int16_t pitch_bits[], /* i : pitch bits */
3759 : const int32_t core_brate, /* i : core bitrate */
3760 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
3761 : const int16_t L_frame, /* i : length of the frame */
3762 : const int16_t coder_type, /* i : coding type */
3763 : int16_t *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
3764 : const int16_t i_subfr, /* i : subframe index */
3765 : float *exc, /* i/o: pointer to excitation signal frame */
3766 : const int16_t L_subfr, /* i : subframe length */
3767 : const int16_t *pitch, /* i : open loop pitch estimates in current frame */
3768 : int16_t *T0_min, /* i/o: lower limit for close-loop search */
3769 : int16_t *T0_max, /* i/o: higher limit for close-loop search */
3770 : int16_t *T0, /* i/o: close loop integer pitch */
3771 : int16_t *T0_frac, /* i/o: close loop fractional part of the pitch */
3772 : const float *h1, /* i : weighted filter input response */
3773 : const float *xn, /* i : target vector */
3774 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
3775 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
3776 : );
3777 :
3778 : /*! r: coding type */
3779 : int16_t find_uv(
3780 : Encoder_State *st, /* i/o: encoder state structure */
3781 : const float *pitch_fr, /* i : pointer to adjusted fractional pitch (4 val.) */
3782 : const float *voicing_fr, /* i : refined correlation for each subframes */
3783 : const float *speech, /* i : pointer to speech signal for E computation */
3784 : const float *ee, /* i : lf/hf Energy ratio for present frame */
3785 : float *dE1X, /* o : sudden energy increase for S/M classifier */
3786 : const float corr_shift, /* i : normalized correlation correction in noise */
3787 : const float relE, /* i : relative frame energy */
3788 : const float Etot, /* i : total energy */
3789 : const float hp_E[], /* i : energy in HF */
3790 : int16_t *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */
3791 : const int16_t last_core_orig, /* i : original last core */
3792 : STEREO_CLASSIF_HANDLE hStereoClf /* i/o: stereo classifier structure */
3793 : );
3794 :
3795 : /*! r: classification for current frames */
3796 : int16_t signal_clas(
3797 : Encoder_State *st, /* i/o: encoder state structure */
3798 : const float *speech, /* i : pointer to speech signal for E computation */
3799 : const float *ee, /* i : lf/hf E ration for 2 half-frames */
3800 : const float relE, /* i : frame relative E to the long term average */
3801 : const int16_t L_look, /* i : look-ahead */
3802 : int16_t *clas_mod /* o : class flag for NOOP detection */
3803 : );
3804 :
3805 : void select_TC(
3806 : const int16_t codec_mode, /* i : codec mode */
3807 : const int16_t tc_cnt, /* i : TC frame counter */
3808 : int16_t *coder_type, /* i/o: coder type */
3809 : const int16_t localVAD /* i : VAD without hangover */
3810 : );
3811 :
3812 : void coder_type_modif(
3813 : Encoder_State *st, /* i/o: encoder state structure */
3814 : const float relE /* i : frame relative E to the long term average */
3815 : );
3816 :
3817 : void wb_vad_init(
3818 : VAD_HANDLE hVAD /* i/o: VAD data handle */
3819 : );
3820 :
3821 : int16_t dtx_hangover_addition(
3822 : Encoder_State *st, /* i/o: encoder state structure */
3823 : const int16_t vad_flag, /* i : VAD flag */
3824 : const float snr, /* i : input single SNR estimate */
3825 : const int16_t cldfb_subtraction, /* i : */
3826 : int16_t *vad_hover_flag, /* o : VAD hangover flag */
3827 : VAD_HANDLE hVAD, /* i/o: VAD handle for L or R channel */
3828 : NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */
3829 : int16_t *rem_dtx_ho /* o : Expected remaining hangover frames */
3830 : );
3831 :
3832 : int16_t wb_vad(
3833 : Encoder_State *st, /* i/o: encoder state structure */
3834 : const float fr_bands[], /* i : per band input energy (contains 2 vectors) */
3835 : int16_t *noisy_speech_HO, /* o : SC-VBR noisy speech HO flag */
3836 : int16_t *clean_speech_HO, /* o : SC-VBR clean speech HO flag */
3837 : int16_t *NB_speech_HO, /* o : SC-VBR NB speech HO flag */
3838 : float *snr_sum_he, /* i : voicing metric from SAD */
3839 : int16_t *localVAD_HE_SAD, /* o : HE_SAD decision without hangovers */
3840 : int16_t *flag_noisy_speech_snr, /* o : */
3841 : VAD_HANDLE hVAD, /* i/o: VAD handle */
3842 : NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation handle */
3843 : float lp_speech, /* i : long term active speech energy average */
3844 : float lp_noise /* i : long term noise energy */
3845 : );
3846 :
3847 : void bw_detect(
3848 : Encoder_State *st, /* i/o: Encoder State */
3849 : const float signal_in[], /* i : input signal */
3850 : float *spectrum, /* i : MDCT spectrum */
3851 : const float *enerBuffer, /* i : energy buffer */
3852 : const IVAS_FORMAT ivas_format, /* i : IVAS format */
3853 : const int16_t mct_on /* i : flag MCT mode */
3854 : );
3855 :
3856 : void set_bw(
3857 : const int16_t element_mode, /* i : element mode */
3858 : const int32_t element_brate, /* i : element bitrate */
3859 : Encoder_State *st, /* i/o: Encoder State */
3860 : const int16_t codec_mode /* i : codec mode */
3861 : );
3862 :
3863 : float gaus_encode(
3864 : Encoder_State *st, /* i/o: encoder state structure */
3865 : const int16_t i_subfr, /* i : subframe index */
3866 : const float *h1, /* i : weighted filter input response */
3867 : const float *xn, /* i : target vector */
3868 : float *exc, /* o : pointer to excitation signal frame */
3869 : float *mem_w0, /* o : weighting filter denominator memory */
3870 : float *gp_clip_mem, /* o : memory of gain of pitch clipping algorithm */
3871 : float *tilt_code, /* o : synthesis excitation spectrum tilt */
3872 : float *code, /* o : algebraic excitation */
3873 : float *gain_code, /* o : Code gain. */
3874 : float *y2, /* o : zero-memory filtered adaptive excitation */
3875 : float *gain_inov, /* o : innovation gain */
3876 : float *voice_fac, /* o : voicing factor */
3877 : float *gain_pit, /* o : adaptive excitation gain */
3878 : float *norm_gain_code /* o : normalized innovative cb. gain */
3879 : );
3880 :
3881 : void td_cng_enc_init(
3882 : TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */
3883 : const int16_t Opt_DTX_ON, /* i : flag indicating DTX operation */
3884 : const int16_t max_bwidth /* i : maximum encoded bandwidth */
3885 : );
3886 :
3887 : void dtx(
3888 : Encoder_State *st, /* i/o: encoder state structure */
3889 : const int32_t last_ivas_total_brate, /* i : last IVAS total bitrate */
3890 : const int32_t ivas_total_brate, /* i : IVAS total bitrate */
3891 : const int16_t vad, /* i : VAD flag for DTX */
3892 : const float speech[] /* i : Pointer to the speech frame */
3893 : );
3894 :
3895 : void dtx_hangover_control(
3896 : Encoder_State *st, /* i/o: encoder state structure */
3897 : const float lsp_new[M] /* i : current frame LSPs */
3898 : );
3899 :
3900 : void updt_enc(
3901 : Encoder_State *st, /* i/o: state structure */
3902 : const float *old_exc, /* i : buffer of excitation */
3903 : const float *pitch_buf, /* i : Floating pitch for each subframe */
3904 : const float Es_pred, /* i : predicited scaled innovation energy */
3905 : const float *Aq, /* i : A(z) quantized for all subframes */
3906 : const float *lsf_new, /* i : current frame LSF vector */
3907 : const float *lsp_new, /* i : current frame LSP vector */
3908 : const float *old_bwe_exc /* o : buffer of excitation for SWB TBE */
3909 : );
3910 :
3911 : void updt_enc_common(
3912 : Encoder_State *st /* i/o: encoder state structure */
3913 : );
3914 :
3915 : void updt_IO_switch_enc(
3916 : Encoder_State *st, /* i/o: state structure */
3917 : const int16_t input_frame /* i : input frame length */
3918 : );
3919 :
3920 : void transition_enc(
3921 : Encoder_State *st, /* i/o: encoder state structure */
3922 : const int16_t i_subfr, /* i : subframe index */
3923 : int16_t *tc_subfr, /* i/o: TC subframe index */
3924 : int16_t *Jopt_flag, /* i : joint optimization flag */
3925 : int16_t *position, /* i/o: maximum of residual signal index */
3926 : int16_t *T0, /* i/o: close loop integer pitch */
3927 : int16_t *T0_frac, /* i/o: close loop fractional part of the pitch */
3928 : int16_t *T0_min, /* i/o: lower limit for close-loop search */
3929 : int16_t *T0_max, /* i/o: higher limit for close-loop search */
3930 : float *exc, /* i/o: pointer to excitation signal frame */
3931 : float *y1, /* o : zero-memory filtered adaptive excitation */
3932 : const float *h1, /* i : weighted filter input response */
3933 : const float *xn, /* i : target vector */
3934 : float *xn2, /* o : target vector for innovation search */
3935 : float *gp_cl, /* i/o: memory of gain of pitch clipping algorithm */
3936 : float *gain_pit, /* o : adaptive excitation gain */
3937 : float *g_corr, /* o : ACELP correlation values */
3938 : int16_t *clip_gain, /* i/o: adaptive gain clipping flag */
3939 : float **pt_pitch, /* o : floating pitch values */
3940 : float *bwe_exc, /* i/o: excitation for SWB TBE */
3941 : int16_t *unbits /* i/o: unused bits */
3942 : );
3943 :
3944 : void tc_classif_enc(
3945 : const int16_t L_frame, /* i : length of the frame */
3946 : int16_t *tc_subfr, /* i/o: TC subframe index */
3947 : int16_t *position, /* i/o: maximum of residual signal index */
3948 : const int16_t attack_flag, /* i : attack flag */
3949 : const int16_t pitch, /* i : open loop pitch estimates for first halfframe */
3950 : const float *res /* i : pointer to the LP residual signal frame */
3951 : );
3952 :
3953 : void set_impulse(
3954 : const float xn[], /* i : target signal */
3955 : const float h_orig[], /* i : impulse response of weighted synthesis filter */
3956 : float exc[], /* o : adaptive codebook excitation */
3957 : float y1[], /* o : filtered adaptive codebook excitation */
3958 : int16_t *imp_shape, /* o : adaptive codebook index */
3959 : int16_t *imp_pos, /* o : position of the glottal impulse center index */
3960 : float *gain_trans /* o : transition gain */
3961 : );
3962 :
3963 : void gain_enc_tc(
3964 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3965 : const int16_t gains_mode[], /* i : gain bits */
3966 : const int16_t i_subfr, /* i : subframe index */
3967 : const float xn[], /* i : target vector */
3968 : const float y2[], /* i : zero-memory filtered algebraic codebook excitation */
3969 : const float code[], /* i : algebraic excitation */
3970 : const float Es_pred, /* i : predicted scaled innovation energy */
3971 : float *gain_pit, /* o : pitch gain / Quantized pitch gain */
3972 : float *gain_code, /* o : quantized codebook gain */
3973 : float *gain_inov, /* o : innovation gain */
3974 : float *norm_gain_code /* o : norm. gain of the codebook excitation */
3975 : );
3976 :
3977 : /*! r: pitch gain (0..GAIN_PIT_MAX) */
3978 : float corr_xy1(
3979 : const float xn[], /* i : target signal */
3980 : const float y1[], /* i : filtered adaptive codebook excitation */
3981 : float g_corr[], /* o : correlations <y1,y1> and -2<xn,y1> */
3982 : const int16_t L_subfr, /* i : subframe length */
3983 : const int16_t norm_flag /* i : flag for constraining pitch contribution */
3984 : );
3985 :
3986 : void norm_corr(
3987 : const float exc[], /* i : excitation buffer */
3988 : const float xn[], /* i : target signal */
3989 : const float h[], /* i : weighted synthesis filter impulse response */
3990 : const int16_t t_min, /* i : minimum value of searched range */
3991 : const int16_t t_max, /* i : maximum value of searched range */
3992 : float corr_norm[], /* o : normalized correlation */
3993 : const int16_t L_subfr /* i : subframe size */
3994 : );
3995 :
3996 : /*! r: chosen integer pitch lag */
3997 : int16_t pitch_fr4(
3998 : const float exc[], /* i : excitation buffer */
3999 : const float xn[], /* i : target signal */
4000 : const float h[], /* i : weighted synthesis filter impulse response */
4001 : const int16_t t0_min, /* i : minimum value in the searched range. */
4002 : const int16_t t0_max, /* i : maximum value in the searched range. */
4003 : int16_t *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */
4004 : const int16_t i_subfr, /* i : flag to first subframe */
4005 : const int16_t limit_flag, /* i : flag for limits (0=restrained, 1=extended) */
4006 : const int16_t t0_fr2, /* i : minimum value for resolution 1/2 */
4007 : const int16_t t0_fr1, /* i : minimum value for resolution 1 */
4008 : const int16_t L_frame, /* i : length of the frame */
4009 : const int16_t L_subfr /* i : size of subframe */
4010 : );
4011 :
4012 : void pit_Q_enc(
4013 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
4014 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
4015 : const int16_t nBits, /* i : # of Q bits */
4016 : const int16_t delta, /* i : Half the CL searched interval */
4017 : const int16_t pit_flag, /* i : absolute(0) or delta(1) pitch Q */
4018 : const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */
4019 : const int16_t T0, /* i : integer pitch lag */
4020 : const int16_t T0_frac, /* i : pitch fraction */
4021 : int16_t *T0_min, /* i/o: delta search min */
4022 : int16_t *T0_max /* o : delta search max */
4023 : );
4024 :
4025 : void pit16k_Q_enc(
4026 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
4027 : const int16_t nBits, /* i : # of Q bits */
4028 : const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */
4029 : const int16_t T0, /* i : integer pitch lag */
4030 : const int16_t T0_frac, /* i : pitch fraction */
4031 : int16_t *T0_min, /* i/o: delta search min */
4032 : int16_t *T0_max /* o : delta search max */
4033 : );
4034 :
4035 : /*! r: pitch index */
4036 : int16_t abs_pit_enc(
4037 : const int16_t fr_steps, /* i : fractional resolution step */
4038 : const int16_t limit_flag, /* i : restrained(0) or extended(1) limits */
4039 : const int16_t T0, /* i : integer pitch lag */
4040 : const int16_t T0_frac /* i : pitch fraction */
4041 : );
4042 :
4043 : /*! r: pitch index */
4044 : int16_t delta_pit_enc(
4045 : const int16_t fr_steps, /* i : fractional resolution steps (2 or 4) */
4046 : const int16_t T0, /* i : integer pitch lag */
4047 : const int16_t T0_frac, /* i : pitch fraction */
4048 : const int16_t T0_min /* i : delta search min */
4049 : );
4050 :
4051 : /*! r: comfort noise gain factor */
4052 : float AVQ_cod(
4053 : const float xri[], /* i : vector to quantize */
4054 : int16_t xriq[], /* o : quantized normalized vector (assuming the bit budget is enough) */
4055 : const int16_t nb_bits, /* i : number of allocated bits */
4056 : const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */
4057 : );
4058 :
4059 : void AVQ_encmux(
4060 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
4061 : const int16_t extl, /* i : extension layer */
4062 : int16_t xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */
4063 : int16_t *nb_bits, /* i/o: number of allocated bits */
4064 : const int16_t Nsv, /* i : number of subvectors */
4065 : int16_t nq[], /* o : AVQ nq index */
4066 : int16_t avq_bit_sFlag, /* i : flag indicating AVQ bit savings */
4067 : int16_t trgtSvPos /* i : target SV for AVQ bit savings */
4068 : );
4069 :
4070 : void ordr_esti(
4071 : const int16_t k, /* i : sub-vector index */
4072 : int16_t *Mpos, /* i/o: dominant sub-vector position from ACV */
4073 : int16_t svOrder[], /* i/o: AVQ sub-vector order */
4074 : const int16_t Nsv /* i : total sub-vectors in a sub-frames */
4075 : );
4076 :
4077 : void re8_cod(
4078 : int16_t x[], /* i : point in RE8 (8-dimensional integer vector) */
4079 : int16_t *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */
4080 : uint16_t *I, /* o : index of c (pointer to unsigned 16-bit word) */
4081 : int16_t k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index */
4082 : );
4083 :
4084 : void pre_exc(
4085 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
4086 : const int16_t L_frame, /* i : frame length */
4087 : const float *speech, /* i : input speech */
4088 : const float *p_Aq, /* i : 12k8 Lp coefficient */
4089 : const float *p_A, /* i : unquantized A(q) filter with bandwidth expansion */
4090 : const int16_t coder_type, /* i : coding type */
4091 : const int16_t i_subfr, /* i : current sub frame indicator */
4092 : float *Ap, /* o : weighted LP filter coefficients */
4093 : const float *res, /* i : residual signal */
4094 : float *h1, /* o : impulse response of weighted synthesis filter */
4095 : float *xn, /* o : close-loop Pitch search target vector */
4096 : float *cn, /* o : target vector in residual domain */
4097 : float *mem_syn, /* i/o: memory of the synthesis filter */
4098 : float *mem_w0, /* i/o: weighting filter denominator memory */
4099 : const int16_t L_subfr /* i : subframe length */
4100 : );
4101 :
4102 : void encod_unvoiced(
4103 : Encoder_State *st, /* i/o: state structure */
4104 : const float *speech, /* i : input speech */
4105 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
4106 : const float *Aq, /* i : LP coefficients */
4107 : const float Es_pred, /* i : predicted scaled innov. energy */
4108 : const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */
4109 : const float *res, /* i : residual signal */
4110 : float *syn, /* o : core synthesis */
4111 : float *tmp_noise, /* o : long-term noise energy */
4112 : float *exc, /* i/o: current non-enhanced excitation */
4113 : float *pitch_buf, /* o : floating pitch values for each subframe */
4114 : float *voice_factors, /* o : voicing factors */
4115 : float *bwe_exc /* i/o: excitation for SWB TBE */
4116 : );
4117 :
4118 : void encod_gen_voic(
4119 : Encoder_State *st, /* i/o: state structure */
4120 : const float speech[], /* i : input speech */
4121 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
4122 : const float Aq[], /* i : LP coefficients */
4123 : const float Es_pred, /* i : predicted scaled innov. energy */
4124 : const float *res, /* i : residual signal */
4125 : float *syn, /* o : core synthesis */
4126 : float *exc, /* i/o: current non-enhanced excitation */
4127 : float *exc2, /* i/o: current enhanced excitation */
4128 : float *pitch_buf, /* o : floating pitch values for each subframe */
4129 : float *voice_factors, /* o : voicing factors */
4130 : float *bwe_exc, /* i/o: excitation for SWB TBE */
4131 : int16_t *unbits, /* i/o: number of unused bits */
4132 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
4133 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
4134 : );
4135 :
4136 : int16_t encod_tran(
4137 : Encoder_State *st, /* i/o: state structure */
4138 : const float speech[], /* i : input speech */
4139 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
4140 : const float Aq[], /* i : LP coefficients */
4141 : const float Es_pred, /* i : predicted scaled innov. energy */
4142 : const float *res, /* i : residual signal */
4143 : float *syn, /* o : synthesis */
4144 : float *exc, /* i/o: current non-enhanced excitation */
4145 : float *exc2, /* i/o: current enhanced excitation */
4146 : float *pitch_buf, /* o : floating pitch values for each subframe */
4147 : float *voice_factors, /* o : voicing factors */
4148 : float *bwe_exc, /* i/o: excitation for SWB TBE */
4149 : int16_t tc_subfr, /* i/o: TC subframe classification */
4150 : int16_t position, /* i : maximum of residual signal index */
4151 : int16_t *unbits /* i/o: number of unused bits */
4152 : );
4153 :
4154 : void encod_amr_wb(
4155 : Encoder_State *st, /* i/o: state structure */
4156 : const float speech[], /* i : input speech */
4157 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
4158 : const float Aq[], /* i : 12k8 Lp coefficient */
4159 : const float *res, /* i : residual signal */
4160 : float *syn, /* i/o: core synthesis */
4161 : float *exc, /* i/o: current non-enhanced excitation */
4162 : float *exc2, /* i/o: current enhanced excitation */
4163 : float *pitch_buf, /* i/o: floating pitch values for each subframe */
4164 : int16_t hf_gain[NB_SUBFR], /* o : decoded HF gain */
4165 : const float *speech16k /* i : input speech @16kHz */
4166 : );
4167 :
4168 : void stat_noise_uv_enc(
4169 : Encoder_State *st, /* i/o: state structure */
4170 : const float *epsP, /* i : LP prediction errors */
4171 : const float *isp_new, /* i : immittance spectral pairs at 4th sfr */
4172 : const float *isp_mid, /* i : immittance spectral pairs at 2nd sfr */
4173 : float *Aq, /* i/o: A(z) quantized for the 4 subframes */
4174 : float *exc2, /* i/o: excitation buffer */
4175 : const int16_t uc_two_stage_flag /* o : flag undicating two-stage UC */
4176 : );
4177 :
4178 : void re8_compute_base_index(
4179 : const int16_t *x, /* i : Elemen of Q2, Q3 or Q4 */
4180 : const int16_t ka, /* i : Identifier of the absolute leader related to x */
4181 : uint16_t *I /* o : index */
4182 : );
4183 :
4184 : void transf_cdbk_enc(
4185 : Encoder_State *st, /* i/o: encoder state structure */
4186 : const int16_t harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
4187 : const int16_t i_subfr, /* i : subframe index */
4188 : float cn[], /* i/o: target vector in residual domain */
4189 : float exc[], /* i/o: pointer to excitation signal frame */
4190 : const float *p_Aq, /* i : 12k8 Lp coefficient */
4191 : const float Ap[], /* i : weighted LP filter coefficients */
4192 : const float h1[], /* i : weighted filter input response */
4193 : float xn[], /* i/o: target vector */
4194 : float xn2[], /* i/o: target vector for innovation search */
4195 : float y1[], /* i/o: zero-memory filtered adaptive excitation */
4196 : const float y2[], /* i : zero-memory filtered innovative excitation */
4197 : const float Es_pred, /* i : predicited scaled innovation energy */
4198 : float *gain_pit, /* i/o: adaptive excitation gain */
4199 : const float gain_code, /* i : innovative excitation gain */
4200 : float g_corr[], /* o : ACELP correlation values */
4201 : const int16_t clip_gain, /* i : adaptive gain clipping flag */
4202 : float *gain_preQ, /* o : prequantizer excitation gain */
4203 : float code_preQ[], /* o : prequantizer excitation */
4204 : int16_t *unbits /* i/o: number of AVQ unused bits */
4205 : );
4206 :
4207 : /*! r: quantization index */
4208 : int16_t gain_quant(
4209 : float *gain, /* i/o: quantized gain */
4210 : const float min_val, /* i : value of lower limit */
4211 : const float max_val, /* i : value of upper limit */
4212 : const int16_t bits /* i : number of bits to quantize */
4213 : );
4214 :
4215 : void deemph_lpc(
4216 : float *p_Aq_cuerr, /* i : LP coefficients current frame */
4217 : float *p_Aq_old, /* i : LP coefficients previous frame */
4218 : float *LPC_de_curr, /* o : De-emphasized LP coefficients current frame */
4219 : float *LPC_de_old, /* o : De-emphasized LP coefficients previous frame*/
4220 : const int16_t deemph_old );
4221 :
4222 : void Interpol_delay(
4223 : float *out, /* o : pitch interpolation output */
4224 : float *last, /* i : last frame pitch lag */
4225 : float *current, /* i : current frame pitch lag */
4226 : int16_t SubNum, /* i : subframe number */
4227 : const float *frac /* i : interpolation constant */
4228 : );
4229 :
4230 : void dequantize_uvg(
4231 : int16_t iG1, /* i : gain 1 index */
4232 : int16_t *iG2, /* i : gain 2 index */
4233 : float *G, /* o : quantized gain */
4234 : const int16_t bwidth /* i : audio bandwidth */
4235 : );
4236 :
4237 : void generate_nelp_excitation(
4238 : int16_t *seed, /* i/o: random number seed */
4239 : float *Gains, /* i : excitation gains */
4240 : float *output, /* o : excitation output */
4241 : float gain_fac /* i : gain factor */
4242 : );
4243 :
4244 : void nelp_encoder(
4245 : Encoder_State *st, /* i/o: encoder state */
4246 : float *in, /* i : residual signal */
4247 : float *exc, /* o : NELP quantized excitation signal */
4248 : const int16_t reduce_gains );
4249 :
4250 : void encod_nelp(
4251 : Encoder_State *st, /* i/o: state structure */
4252 : const float *speech, /* i : input speech */
4253 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
4254 : const float *Aq, /* i : 12k8 Lp coefficient */
4255 : float *res, /* o : residual signal */
4256 : float *synth, /* o : core synthesis */
4257 : float *tmp_noise, /* o : long-term noise energy */
4258 : float *exc, /* i/o: current non-enhanced excitation */
4259 : float *exc2, /* i/o: current enhanced excitation */
4260 : float *pitch_buf, /* o : floating pitch values for each subframe */
4261 : float *voice_factors, /* o : voicing factors */
4262 : float *bwe_exc /* o : excitation for SWB TBE */
4263 : );
4264 :
4265 : void realft(
4266 : float *data, /* i/o: data array */
4267 : int16_t n, /* i : length of data array */
4268 : int16_t isign /* i : sign +1 or -1 */
4269 : );
4270 :
4271 : ivas_error DTFS_new(
4272 : DTFS_STRUCTURE **dtfs_out );
4273 :
4274 : void DTFS_copy(
4275 : DTFS_STRUCTURE *Xout, /* o : DTFS */
4276 : DTFS_STRUCTURE Xinp /* i : DTFS */
4277 : );
4278 :
4279 : void DTFS_sub(
4280 : DTFS_STRUCTURE *tmp, /* o : output DFTS */
4281 : DTFS_STRUCTURE X1, /* i : DTFS input 1 */
4282 : DTFS_STRUCTURE X2 /* i : DTFS input 2 */
4283 : );
4284 :
4285 : void DTFS_to_fs(
4286 : const float *x, /* i : Time domain signal */
4287 : const int16_t N, /* i : Length of input vector */
4288 : DTFS_STRUCTURE *X, /* o : DTFS structure with a, b, lag */
4289 : const int32_t sampling_rate,
4290 : const int16_t FR_flag /* i : FR flag */
4291 : );
4292 :
4293 : void DTFS_fs_inv(
4294 : DTFS_STRUCTURE *X, /* i : DTFS */
4295 : float *x, /* o : time domain sig */
4296 : const int16_t N, /* i : Output length */
4297 : float ph0 /* i : Input phase */
4298 : );
4299 :
4300 : void DTFS_car2pol(
4301 : DTFS_STRUCTURE *X /* i/o: DTFS structure a, b, lag */
4302 : /* input in Cartesion, output in Polar */
4303 : );
4304 :
4305 : void DTFS_pol2car(
4306 : DTFS_STRUCTURE *X /* i/o: DTFS structure a, b, lag */
4307 : /* input in Polar, output in Cartesian */
4308 : );
4309 :
4310 : /*! r: Return Input RMS between f1/f2 b4 scaling */
4311 : float DTFS_setEngyHarm(
4312 : float f1, /* i : lower band freq of input to control energy */
4313 : float f2, /* i : upper band freq of input to control energy */
4314 : float g1, /* i : lower band freq of output to control energy */
4315 : float g2, /* i : upper band freq of output to control energy */
4316 : float en2, /* i : Target Energy to set the DTFS to */
4317 : DTFS_STRUCTURE *X /* i/o: DTFS to adjust the energy of */
4318 : );
4319 :
4320 : void DTFS_to_erb(
4321 : DTFS_STRUCTURE X, /* i : DTFS input */
4322 : float *out /* o : ERB output */
4323 : );
4324 :
4325 : void DTFS_zeroPadd(
4326 : const int16_t N, /* i : Target lag */
4327 : DTFS_STRUCTURE *X /* i/o: DTFS */
4328 : );
4329 :
4330 : /*! r: Energy */
4331 : float DTFS_getEngy(
4332 : DTFS_STRUCTURE X /* i : DTFS to compute energy of */
4333 : );
4334 :
4335 : void DTFS_adjustLag(
4336 : DTFS_STRUCTURE *X_DTFS, /* i/o: DTFS to adjust lag for */
4337 : const int16_t N /* i : Target lag */
4338 : );
4339 :
4340 : void DTFS_poleFilter(
4341 : DTFS_STRUCTURE *X, /* i/o: DTFS to poleFilter inplace */
4342 : const float *LPC, /* i : LPCs */
4343 : const int16_t N /* i : LPCORDER */
4344 : );
4345 :
4346 : void DTFS_zeroFilter(
4347 : DTFS_STRUCTURE *X, /* i/o: DTFS to zeroFilter inplace */
4348 : const float *LPC, /* i : LPCs */
4349 : const int16_t N /* i : LPCORDER */
4350 : );
4351 :
4352 : float DTFS_alignment_full(
4353 : DTFS_STRUCTURE X1_DTFS, /* i : reference DTFS */
4354 : DTFS_STRUCTURE X2_DTFS, /* i : DTFS to shift */
4355 : const int16_t num_steps /* i : resolution */
4356 : );
4357 :
4358 : void DTFS_phaseShift(
4359 : DTFS_STRUCTURE *X, /* i : DTFS to shift */
4360 : float ph /* i : phase to shift */
4361 : );
4362 :
4363 : void erb_add(
4364 : float *curr_erb, /* i/o: current ERB */
4365 : const int16_t l, /* i : current lag */
4366 : const float *prev_erb, /* i : previous ERB */
4367 : const int16_t pl, /* i : previous lag */
4368 : const int16_t *index, /* i : ERB index */
4369 : const int16_t num_erb /* i : number of ERBs */
4370 : );
4371 :
4372 : void erb_slot(
4373 : int16_t lag, /* i : input lag */
4374 : int16_t *out, /* o : ERB slots */
4375 : float *mfreq, /* i : ERB frequencies */
4376 : int16_t num_erb /* i : number of ERBs */
4377 : );
4378 :
4379 : void erb_diff(
4380 : const float *prev_erb, /* i : previous ERB */
4381 : const int16_t pl, /* i : previous lag */
4382 : const float *curr_erb, /* i : current ERB */
4383 : const int16_t l, /* i : current lag */
4384 : const float *curr_lsp, /* i : current LSP coefficients */
4385 : float *out, /* o : ERB difference */
4386 : int16_t *index, /* i : ERB index */
4387 : const int16_t num_erb /* i : Number of ERBs */
4388 : );
4389 :
4390 : void DTFS_erb_inv(
4391 : float *in, /* i : ERB inpt */
4392 : int16_t *slot, /* i : ERB slots filled based on lag */
4393 : float *mfreq, /* i : erb frequence edges */
4394 : DTFS_STRUCTURE *X, /* o : DTFS after erb-inv */
4395 : const int16_t num_erb /* i : Number of ERB bands */
4396 : );
4397 :
4398 : ivas_error ppp_quarter_encoder(
4399 : int16_t *returnFlag, /* o : return value */
4400 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
4401 : DTFS_STRUCTURE *CURRCW_Q, /* o : Quantized (amp/phase) DTFS */
4402 : DTFS_STRUCTURE *TARGETCW, /* o : DTFS with quant phase but unquant Amp */
4403 : const int16_t prevCW_lag, /* i : previous lag */
4404 : DTFS_STRUCTURE vCURRCW_NQ, /* i : Unquantized DTFS */
4405 : const float *curr_lpc, /* i : LPCS */
4406 : float *lastLgainE, /* i/o: last low band gain */
4407 : float *lastHgainE, /* i/o: last high band gain */
4408 : float *lasterbE, /* i/o: last ERB vector */
4409 : DTFS_STRUCTURE PREV_CW_E /* i : past DTFS */
4410 : );
4411 :
4412 : ivas_error WIsyn(
4413 : DTFS_STRUCTURE PREVCW, /* i : Prev frame DTFS */
4414 : DTFS_STRUCTURE *CURR_CW_DTFS, /* i/o: Curr frame DTFS */
4415 : const float *curr_lpc, /* i : LPC */
4416 : float *ph_offset, /* i/o: Phase offset to line up at end of frame */
4417 : float *out, /* o : Waveform Interpolated time domain signal */
4418 : const int16_t N, /* i : Number of samples of output to generate */
4419 : const int16_t FR_flag /* i : called for post-smoothing in FR */
4420 : );
4421 :
4422 : void set_ppp_mode(
4423 : Encoder_State *st, /* i/o: encoder state structure */
4424 : const int16_t noisy_speech_HO, /* i : SC-VBR noisy speech HO flag */
4425 : const int16_t clean_speech_HO, /* i : SC-VBR clean speech HO flag */
4426 : const int16_t NB_speech_HO, /* i : SC-VBR NB speech HO flag */
4427 : const int16_t localVAD_he /* i : HE-SAD flag without hangover */
4428 : );
4429 :
4430 : void lsf_syn_mem_backup(
4431 : Encoder_State *st, /* i : state structure */
4432 : float *btilt_code, /* i : tilt code */
4433 : float *bgc_threshold, /* i : */
4434 : float *clip_var_bck, /* o : */
4435 : int16_t *next_force_sf_bck, /* o : */
4436 : float *lsp_new, /* i : LSP vector to quantize */
4437 : float *lsp_mid, /* i : mid-frame LSP vector */
4438 : float *clip_var, /* o : pitch clipping state var */
4439 : float *mem_AR, /* o : quantizer memory for AR model */
4440 : float *mem_MA, /* o : quantizer memory for AR model */
4441 : float *lsp_new_bck, /* o : LSP vector to quantize- backup */
4442 : float *lsp_mid_bck, /* o : mid-frame LSP vector - backup */
4443 : float *Bin_E, /* o : FFT Bin energy 128 *2 sets */
4444 : float *Bin_E_old, /* o : FFT Bin energy 128 sets */
4445 : float *mem_syn_bck, /* o : synthesis filter memory */
4446 : float *mem_w0_bck, /* o : memory of the weighting filter */
4447 : float *streaklimit,
4448 : int16_t *pstreaklen );
4449 :
4450 : void lsf_syn_mem_restore(
4451 : Encoder_State *st, /* o : state structure */
4452 : float btilt_code, /* i : */
4453 : float gc_threshold, /* i : */
4454 : float *clip_var_bck, /* i : */
4455 : int16_t next_force_sf_bck, /* i : */
4456 : float *lsp_new, /* o : LSP vector to quantize */
4457 : float *lsp_mid, /* o : mid-frame LSP vector */
4458 : float clip_var, /* i : pitch clipping state var */
4459 : float *mem_AR, /* i : quantizer memory for AR model */
4460 : float *mem_MA, /* i : quantizer memory for AR model */
4461 : float *lsp_new_bck, /* i : LSP vector to quantize- backup */
4462 : float *lsp_mid_bck, /* i : mid-frame LSP vector - backup */
4463 : float *Bin_E, /* i : FFT Bin energy 128 *2 sets */
4464 : float *Bin_E_old, /* i : FFT Bin energy 128 sets */
4465 : float *mem_syn_bck, /* i : synthesis filter memory */
4466 : float mem_w0_bck, /* i : memory of the weighting filter */
4467 : const float streaklimit,
4468 : const int16_t pstreaklen );
4469 :
4470 : ivas_error ppp_voiced_encoder(
4471 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
4472 : SC_VBR_ENC_HANDLE hSC_VBR, /* i/o: SC-VBR state structure */
4473 : const int16_t bwidth, /* i : audio bandwidth */
4474 : const int16_t last_coder_type_raw, /* i : raw last_coder_type */
4475 : const float old_pitch_buf[], /* i : buffer of old subframe pitch values */
4476 : float *in, /* i : residual signal */
4477 : float *out, /* o : Quantized residual signal */
4478 : const int16_t delay, /* i : open loop pitch */
4479 : float *lpc1, /* i : prev frame de-emphasized LPC */
4480 : float *lpc2, /* i : current frame de-emphasized LPC */
4481 : float *exc, /* i : previous frame quantized excitation */
4482 : float *pitch /* o : floating pitch values for each subframe */
4483 : );
4484 :
4485 : ivas_error encod_ppp(
4486 : Encoder_State *st, /* i/o: state structure */
4487 : const float speech[], /* i : input speech */
4488 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
4489 : const float Aq[], /* i : 12k8 Lp coefficient */
4490 : float *res, /* i/o: residual signal */
4491 : float *synth, /* i/o: core synthesis */
4492 : float *exc, /* i/o: current non-enhanced excitation */
4493 : float *exc2, /* i/o: current enhanced excitation */
4494 : float *pitch_buf, /* i/o: floating pitch values for each subframe */
4495 : float *voice_factors, /* o : voicing factors */
4496 : float *bwe_exc /* o : excitation for SWB TBE */
4497 : );
4498 :
4499 : void reset_rf_indices(
4500 : RF_ENC_HANDLE hRF, /* i/o: RF state structure */
4501 : const int16_t L_frame, /* i : frame length */
4502 : int16_t *rf_target_bits_write );
4503 :
4504 : void signaling_enc_rf(
4505 : Encoder_State *st /* i/o: encoder state structure */
4506 : );
4507 :
4508 : ivas_error acelp_core_dec(
4509 : Decoder_State *st, /* i/o: Decoder state structure */
4510 : float output[], /* o : synthesis @internal Fs */
4511 : float synth[], /* o : synthesis */
4512 : float save_hb_synth[], /* o : HB synthesis */
4513 : float bwe_exc_extended[], /* i/o: bandwidth extended excitation */
4514 : float *voice_factors, /* o : voicing factors */
4515 : float old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
4516 : const int16_t sharpFlag, /* i : formant sharpening flag */
4517 : float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */
4518 : int16_t *unbits, /* o : number of unused bits */
4519 : int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */
4520 : STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */
4521 : const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
4522 : const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
4523 : const int16_t last_element_mode, /* i : last element mode */
4524 : const int32_t last_element_brate, /* i : last element bitrate */
4525 : const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */
4526 : const int16_t nchan_out, /* i : number of output channels */
4527 : STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
4528 : const int16_t read_sid_info /* i : read SID info flag */
4529 : );
4530 :
4531 : void bass_psfilter_init(
4532 : BPF_DEC_HANDLE hBPF /* o : BPF data handle */
4533 : );
4534 :
4535 : void bass_psfilter(
4536 : BPF_DEC_HANDLE hBPF, /* o : BPF data handle */
4537 : const int16_t Opt_AMR_WB, /* i : AMR-WB IO flag */
4538 : const float synth_in[], /* i : synthesis (at 16kHz) */
4539 : const int16_t L_frame, /* i : length of the last frame */
4540 : const float pitch_buf[], /* i : pitch for every subfr [0,1,2,3] */
4541 : const int16_t bpf_off, /* i : do not use BPF when set to 1 */
4542 : float v_stab, /* i : stability factor */
4543 : float *v_stab_smooth, /* i : smoothed stability factor */
4544 : const int16_t coder_type, /* i : coder_type */
4545 : float bpf_noise_buf[] /* o : BPF error signal (at int_fs) */
4546 : );
4547 :
4548 : void CNG_reset_dec(
4549 : Decoder_State *st, /* i/o: decoder state structure */
4550 : float *pitch_buf, /* o : floating pitch for each subframe */
4551 : float *voice_factors /* o : voicing factors */
4552 : );
4553 :
4554 : void updt_dec(
4555 : Decoder_State *st, /* i/o: state structure */
4556 : const float *old_exc, /* i : buffer of excitation */
4557 : const float *pitch_buf, /* i : floating pitch values for each subframe */
4558 : const float Es_pred, /* i : predicited scaled innovation energy */
4559 : const float *Aq, /* i : A(z) quantized for all subframes */
4560 : const float *lsf_new, /* i : current frame LSF vector */
4561 : const float *lsp_new, /* i : current frame LSP vector */
4562 : const float voice_factors[], /* i : voicing factors */
4563 : const float *old_bwe_exc, /* i : buffer of excitation */
4564 : const float *gain_buf /* o : floating pitch gain for each subframe */
4565 : );
4566 :
4567 : void updt_IO_switch_dec(
4568 : const int16_t output_frame, /* i : output frame length */
4569 : Decoder_State *st /* i/o: state structure */
4570 : );
4571 :
4572 : void updt_dec_common(
4573 : Decoder_State *st, /* i/o: decoder state structure */
4574 : const int16_t hq_core_type, /* i : HQ core type */
4575 : const int16_t concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */
4576 : const float *synth /* i : decoded synthesis */
4577 : );
4578 :
4579 : void td_cng_dec_init(
4580 : DEC_CORE_HANDLE st /* i/o: decoder state structure */
4581 : );
4582 :
4583 : void CNG_dec(
4584 : Decoder_State *st, /* i/o: State structure */
4585 : const int16_t last_element_mode, /* i : last element mode */
4586 : float Aq[], /* o : LP coefficients */
4587 : float *lsp_new, /* i/o: current frame LSPs */
4588 : float *lsf_new, /* i/o: current frame LSFs */
4589 : int16_t *allow_cn_step, /* o : allow cn step */
4590 : int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */
4591 : float *q_env );
4592 :
4593 : void swb_CNG_dec(
4594 : Decoder_State *st, /* i/o: State structure */
4595 : const float *synth, /* i : ACELP core synthesis at 32kHz */
4596 : float *shb_synth, /* o : high-band CNG synthesis */
4597 : const int16_t sid_bw /* i : 0-NB/WB, 1-SWB SID */
4598 : );
4599 :
4600 : void lsf_dec(
4601 : Decoder_State *st, /* i/o: State structure */
4602 : const int16_t tc_subfr, /* i : TC subframe index */
4603 : float *Aq, /* o : quantized A(z) for 4 subframes */
4604 : int16_t *LSF_Q_prediction, /* o : LSF prediction mode */
4605 : float *lsf_new, /* o : de-quantized LSF vector */
4606 : float *lsp_new, /* o : de-quantized LSP vector */
4607 : float *lsp_mid, /* o : de-quantized mid-frame LSP vector */
4608 : const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
4609 : const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
4610 : );
4611 :
4612 : void isf_dec_amr_wb(
4613 : Decoder_State *st, /* i/o: State structure */
4614 : float *Aq, /* o : quantized A(z) for 4 subframes */
4615 : float *isf_new, /* o : de-quantized ISF vector */
4616 : float *isp_new /* o : de-quantized ISP vector */
4617 : );
4618 :
4619 : void Es_pred_dec(
4620 : float *Es_pred, /* o : predicted scaled innovation energy */
4621 : const int16_t enr_idx, /* i : indice */
4622 : const int16_t nb_bits, /* i : number of bits */
4623 : const int16_t no_ltp /* i : no LTP flag */
4624 : );
4625 :
4626 : void gaus_dec(
4627 : Decoder_State *st, /* i/o: decoder state structure */
4628 : const int16_t i_subfr, /* i : subframe index */
4629 : float *code, /* o : gaussian excitation */
4630 : float *norm_gain_code, /* o : gain of the normalized gaussian excitation */
4631 : float *lp_gainp, /* i/o: lp filtered pitch gain(FER) */
4632 : float *lp_gainc, /* i/o: lp filtered code gain (FER) */
4633 : float *gain_inov, /* o : unscaled innovation gain */
4634 : float *tilt_code, /* o : synthesis excitation spectrum tilt */
4635 : float *voice_fac, /* o : estimated voicing factor */
4636 : float *gain_pit, /* o : reset pitch gain */
4637 : float *pt_pitch, /* o : reset floating pitch buffer */
4638 : float *exc, /* o : excitation signal frame */
4639 : float *gain_code, /* o : gain of the gaussian excitation */
4640 : float *exc2 /* o : scaled excitation signal frame */
4641 : );
4642 :
4643 : void gain_dec_amr_wb(
4644 : Decoder_State *st, /* i/o: decoder state structure */
4645 : const int32_t core_brate, /* i : core bitrate */
4646 : float *gain_pit, /* o : Quantized pitch gain */
4647 : float *gain_code, /* o : Quantized codeebook gain */
4648 : float *past_qua_en, /* i/o: gain quantization memory (4 words) */
4649 : float *gain_inov, /* o : unscaled innovation gain */
4650 : const float *code, /* i : algebraic code excitation */
4651 : float *norm_gain_code /* o : norm. gain of the codebook excitation */
4652 : );
4653 :
4654 : void gain_dec_lbr(
4655 : Decoder_State *st, /* i/o: decoder state structure */
4656 : const int16_t coder_type, /* i : coding type */
4657 : const int16_t i_subfr, /* i : subframe index */
4658 : const float *code, /* i : algebraic excitation */
4659 : float *gain_pit, /* o : quantized pitch gain */
4660 : float *gain_code, /* o : quantized codebook gain */
4661 : float *gain_inov, /* o : gain of the innovation (used for normalization) */
4662 : float *norm_gain_code, /* o : norm. gain of the codebook excitation */
4663 : float gains_mem[], /* i/o: pitch gain and code gain from previous subframes */
4664 : const int16_t L_subfr /* i : subframe length */
4665 : );
4666 :
4667 : void gain_dec_mless(
4668 : Decoder_State *st, /* i/o: decoder state structure */
4669 : const int16_t L_frame, /* i : length of the frame */
4670 : const int16_t coder_type, /* i : coding type */
4671 : const int16_t i_subfr, /* i : subframe number */
4672 : const int16_t tc_subfr, /* i : TC subframe index */
4673 : const float *code, /* i : algebraic code excitation */
4674 : const float Es_pred, /* i : predicted scaled innov. energy */
4675 : float *gain_pit, /* o : Quantized pitch gain */
4676 : float *gain_code, /* o : Quantized codeebook gain */
4677 : float *gain_inov, /* o : unscaled innovation gain */
4678 : float *norm_gain_code /* o : norm. gain of the codebook excitation */
4679 : );
4680 :
4681 : void gain_dec_SQ(
4682 : Decoder_State *st, /* i/o: decoder state structure */
4683 : const int16_t i_subfr, /* i : subframe number */
4684 : const float *code, /* i : algebraic code excitation */
4685 : const float Es_pred, /* i : predicted scaled innov. energy */
4686 : float *gain_pit, /* o : Quantized pitch gain */
4687 : float *gain_code, /* o : Quantized codeebook gain */
4688 : float *gain_inov, /* o : unscaled innovation gain */
4689 : float *norm_gain_code /* o : norm. gain of the codebook excitation */
4690 : );
4691 :
4692 : /*! r: quantized codebook gain */
4693 : float gain_dec_gaus(
4694 : const int16_t index, /* i : quantization index */
4695 : const int16_t bits, /* i : number of bits to quantize */
4696 : const float lowBound, /* i : lower bound of quantizer (dB) */
4697 : const float topBound, /* i : upper bound of quantizer (dB) */
4698 : const float gain_inov, /* i : unscaled innovation gain */
4699 : float *norm_gain_code /* o : gain of normalized gaus. excit. */
4700 : );
4701 :
4702 : /*! r: floating pitch value */
4703 : float pit_decode(
4704 : Decoder_State *st, /* i/o: decoder state structure */
4705 : const int32_t core_brate, /* i : core bitrate */
4706 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
4707 : const int16_t L_frame, /* i : length of the frame */
4708 : int16_t i_subfr, /* i : subframe index */
4709 : const int16_t coder_type, /* i : coding type */
4710 : int16_t *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
4711 : int16_t *T0, /* o : close loop integer pitch */
4712 : int16_t *T0_frac, /* o : close loop fractional part of the pitch */
4713 : int16_t *T0_min, /* i/o: delta search min for sf 2 & 4 */
4714 : int16_t *T0_max, /* i/o: delta search max for sf 2 & 4 */
4715 : const int16_t L_subfr, /* i : subframe length */
4716 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
4717 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
4718 : );
4719 :
4720 : void abs_pit_dec(
4721 : const int16_t fr_steps, /* i : fractional resolution steps (0, 2, 4) */
4722 : int16_t pitch_index, /* i : pitch index */
4723 : const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */
4724 : int16_t *T0, /* o : integer pitch lag */
4725 : int16_t *T0_frac /* o : pitch fraction */
4726 : );
4727 :
4728 : void delta_pit_dec(
4729 : const int16_t fr_steps, /* i : fractional resolution steps (0, 2, 4) */
4730 : const int16_t pitch_index, /* i : pitch index */
4731 : int16_t *T0, /* o : integer pitch lag */
4732 : int16_t *T0_frac, /* o : pitch fraction */
4733 : const int16_t T0_min /* i : delta search min */
4734 : );
4735 :
4736 : void pit_Q_dec(
4737 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
4738 : const int16_t pitch_index, /* i : pitch index */
4739 : const int16_t nBits, /* i : # of Q bits */
4740 : const int16_t delta, /* i : Half the CL searched interval */
4741 : const int16_t pit_flag, /* i : absolute(0) or delta(1) pitch Q */
4742 : const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */
4743 : int16_t *T0, /* o : integer pitch lag */
4744 : int16_t *T0_frac, /* o : pitch fraction */
4745 : int16_t *T0_min, /* i/o: delta search min */
4746 : int16_t *T0_max, /* i/o: delta search max */
4747 : int16_t *BER_detect /* o : BER detect flag */
4748 : );
4749 :
4750 : void pit16k_Q_dec(
4751 : const int16_t pitch_index, /* i : pitch index */
4752 : const int16_t nBits, /* i : # of Q bits */
4753 : const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */
4754 : int16_t *T0, /* o : integer pitch lag */
4755 : int16_t *T0_frac, /* o : pitch fraction */
4756 : int16_t *T0_min, /* i/o: delta search min */
4757 : int16_t *T0_max, /* i/o: delta search max */
4758 : int16_t *BER_detect /* o : BER detect flag */
4759 : );
4760 :
4761 : void lp_filt_exc_dec(
4762 : Decoder_State *st, /* i/o: decoder state structure */
4763 : const int16_t codec_mode, /* i : codec mode */
4764 : const int16_t i_subfr, /* i : subframe index */
4765 : const int16_t L_subfr, /* i : subframe size */
4766 : const int16_t L_Frame, /* i : frame size */
4767 : int16_t lp_flag, /* i : operation mode signaling */
4768 : float *exc /* i/o: pointer to the excitation signal frame */
4769 : );
4770 :
4771 : void inov_decode(
4772 : Decoder_State *st, /* i/o: decoder state structure */
4773 : const int32_t core_brate, /* i : core bitrate */
4774 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
4775 : const int16_t L_frame, /* i : length of the frame */
4776 : const int16_t sharpFlag, /* i : formant sharpening flag */
4777 : const int16_t i_subfr, /* i : subframe index */
4778 : const float *p_Aq, /* i : LP filter coefficients */
4779 : const float tilt_code, /* i : tilt of of the excitation of previous subframe */
4780 : const float pt_pitch, /* i : pointer to current subframe fractional pitch */
4781 : float *code, /* o : algebraic excitation */
4782 : const int16_t L_subfr /* i : subframe length */
4783 : );
4784 :
4785 : void dec_acelp_1t64(
4786 : Decoder_State *st, /* i/o: decoder state structure */
4787 : float code[], /* o : algebraic (fixed) codebook excitation */
4788 : const int16_t L_subfr /* i : subframe length */
4789 : );
4790 :
4791 : void dec_acelp_2t32(
4792 : Decoder_State *st, /* i/o: decoder state structure */
4793 : float code[] /* o : algebraic (fixed) codebook excitation */
4794 : );
4795 :
4796 : void dec_acelp_4t64(
4797 : Decoder_State *st, /* i/o: decoder state structure */
4798 : int16_t nbbits, /* i : number of bits per codebook */
4799 : float code[], /* o : algebraic (fixed) codebook excitation */
4800 : const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
4801 : );
4802 :
4803 : void FEC_exc_estim(
4804 : Decoder_State *st, /* i/o: Decoder static memory */
4805 : const int16_t L_frame, /* i : length of the frame */
4806 : float *old_exc, /* i/o: excitation buffer */
4807 : float *exc2, /* o : excitation buffer (for synthesis) */
4808 : float *exc_dct_in, /* o : GSC excitation in DCT domain */
4809 : float *pitch_buf, /* o : Floating pitch for each subframe */
4810 : float *tmp_tc, /* o : FEC pitch */
4811 : float *voice_factors, /* o : voicing factors */
4812 : float *bwe_exc, /* i/o: excitation for SWB TBE */
4813 : float *lsf_new, /* i : ISFs at the end of the frame */
4814 : float *tmp_noise /* o : long-term noise energy */
4815 : );
4816 :
4817 : void FEC_lsf2lsp_interp(
4818 : Decoder_State *st, /* i/o: Decoder static memory */
4819 : const int16_t L_frame, /* i : length of the frame */
4820 : float *Aq, /* o : calculated A(z) for 4 subframes */
4821 : float *lsf, /* o : estimated LSF vector */
4822 : float *lsp /* o : estimated LSP vector */
4823 : );
4824 :
4825 : void FEC_lsf_estim_enc(
4826 : Encoder_State *st, /* i : Encoder static memory */
4827 : float *lsf /* o : estimated LSF vector */
4828 : );
4829 :
4830 : float frame_energy(
4831 : const int16_t L_frame, /* i : length of the frame */
4832 : const float *pitch, /* i : pitch values for each subframe */
4833 : const float *speech, /* i : pointer to speech signal for E computation */
4834 : const float lp_speech, /* i : long term active speech energy average */
4835 : float *frame_ener /* o : pitch-synchronous energy at frame end */
4836 : );
4837 :
4838 : void FEC_SinOnset(
4839 : float *exc, /* i/o: exc vector to modify */
4840 : int16_t puls_pos, /* i : Last pulse position desired */
4841 : int16_t T0, /* i : decoded first frame pitch */
4842 : float enr_q, /* i : energy provided by the encoder */
4843 : float *Aq, /* i : Lsp coefficient */
4844 : const int16_t L_frame /* i : Frame length */
4845 : );
4846 :
4847 : int16_t FEC_enhACB(
4848 : const int16_t L_frame, /* i : Frame length */
4849 : const int16_t last_L_frame, /* i : frame length of last frame */
4850 : float *exc_io, /* i/o: Adaptive codebook memory */
4851 : const int16_t new_pit, /* i : decoded first frame pitch */
4852 : const int16_t puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */
4853 : const float bfi_pitch /* i : Pitch used for concealment */
4854 : );
4855 :
4856 : void FEC_scale_syn(
4857 : const int16_t L_frame, /* i : length of the frame */
4858 : int16_t clas, /* i/o: frame classification */
4859 : const int16_t last_good, /* i : last good frame classification */
4860 : float *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */
4861 : const float *pitch, /* i : pitch values for each subframe */
4862 : float enr_old, /* i : energy at the end of prvious frame */
4863 : float enr_q, /* i : transmitted energy for current frame */
4864 : const int16_t coder_type, /* i : coding type */
4865 : const int16_t LSF_Q_prediction, /* i : LSF prediction mode */
4866 : int16_t *scaling_flag, /* i/o: flag to indicate energy control of syn */
4867 : float *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */
4868 : float *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */
4869 : const int16_t bfi, /* i : current frame BFI */
4870 : const int32_t total_brate, /* i : total bitrate */
4871 : const int16_t prev_bfi, /* i : previous frame BFI */
4872 : const int32_t last_core_brate, /* i : previous frame core bitrate */
4873 : float *exc, /* i/o: excitation signal without enhancement */
4874 : float *exc2, /* i/o: excitation signal with enhancement */
4875 : const float Aq[], /* i : LP filter coefs */
4876 : float *old_enr_LP, /* i/o: LP filter E of last good voiced frame */
4877 : const float *mem_tmp, /* i : temp. initial synthesis filter states */
4878 : float *mem_syn, /* o : initial synthesis filter states */
4879 : const int16_t avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */
4880 : const int16_t force_scaling /* i : force scaling */
4881 : );
4882 :
4883 : void FEC_pitch_estim(
4884 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
4885 : const int16_t last_core, /* i : last core */
4886 : const int16_t L_frame, /* i : length of the frame */
4887 : const int16_t clas, /* i : current frame classification */
4888 : const int16_t last_good, /* i : last good clas information */
4889 : const float pitch_buf[], /* i : Floating pitch for each subframe */
4890 : const float old_pitch_buf[], /* i : buffer of old subframe pitch values */
4891 : float *bfi_pitch, /* i/o: update of the estimated pitch for FEC */
4892 : int16_t *bfi_pitch_frame, /* o : frame length when pitch was updated */
4893 : int16_t *upd_cnt, /* i/o: update counter */
4894 : const int16_t coder_type );
4895 :
4896 : void FEC_encode(
4897 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
4898 : const ACELP_config acelp_cfg, /* i : configuration of the ACELP */
4899 : const float *synth, /* i : pointer to synthesized speech for E computation */
4900 : const int16_t coder_type, /* i : type of coder */
4901 : int16_t clas, /* i : signal clas for current frame */
4902 : const float *fpit, /* i : close loop fractional pitch buffer */
4903 : const float *res, /* i : LP residual signal frame */
4904 : int16_t *last_pulse_pos, /* i/o: Position of the last pulse */
4905 : const int16_t L_frame, /* i : Frame length */
4906 : const int32_t total_brate /* i : total codec bitrate */
4907 : );
4908 :
4909 : int16_t FEC_pos_dec(
4910 : Decoder_State *st, /* i/o: decoder state structure */
4911 : int16_t *last_pulse_pos, /* o : Last glottal pulse position in the lost ACB */
4912 : float *enr_q, /* o : Decoded energy */
4913 : const int16_t nBits_es_Pred /* i : number of bits for Es_pred Q */
4914 : );
4915 :
4916 : void improv_amr_wb_gs(
4917 : const int16_t clas, /* i : bitrate allocated to the core */
4918 : const int16_t coder_type, /* i : coder_type */
4919 : const int32_t core_brate, /* i : bitrate allocated to the core */
4920 : int16_t *seed_tcx, /* i/o: Seed used for noise generation */
4921 : float *old_Aq, /* i/o: old LPC filter coefficient */
4922 : float *mem_syn2, /* i/o: synthesis memory */
4923 : const float lt_voice_fac, /* i/o: long term voice factor */
4924 : const int16_t locattack, /* i : Flag for a detected attack */
4925 : float *Aq, /* i/o: Decoded LP filter coefficient */
4926 : float *exc2, /* i/o: Decoded complete excitation */
4927 : float *mem_tmp, /* i/o: synthesis temporary memory */
4928 : float *syn, /* i/o: Decoded synthesis to be updated */
4929 : const float *pitch_buf, /* i : Decoded pitch buffer */
4930 : const float Last_ener, /* i : Last energy */
4931 : const int16_t rate_switching_reset, /* i : rate switching reset flag */
4932 : const int16_t last_coder_type, /* i : Last coder_type */
4933 : const int16_t VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */
4934 : );
4935 :
4936 : int16_t tc_classif(
4937 : Decoder_State *st /* i/o: decoder state structure */
4938 : );
4939 :
4940 : void transition_dec(
4941 : Decoder_State *st, /* i/o: decoder state structure */
4942 : const int16_t L_frame, /* i : length of the frame */
4943 : const int16_t i_subfr, /* i : subframe index */
4944 : const int16_t tc_subfr, /* i : TC subframe index */
4945 : int16_t *Jopt_flag, /* i : joint optimization flag */
4946 : float *exc, /* i/o: current frame excitation signal */
4947 : int16_t *T0, /* o : close loop integer pitch */
4948 : int16_t *T0_frac, /* o : close loop fractional part of the pitch */
4949 : int16_t *T0_min, /* i/o: delta search min for sf 2 & 4 */
4950 : int16_t *T0_max, /* i/o: delta search max for sf 2 & 4 */
4951 : float **pt_pitch, /* o : floating pitch values */
4952 : int16_t *position, /* i/o: first glottal impulse position in frame */
4953 : float *bwe_exc /* i/o: excitation for SWB TBE */
4954 : );
4955 :
4956 : void gain_dec_tc(
4957 : Decoder_State *st, /* i/o: decoder state structure */
4958 : const int16_t i_subfr, /* i : subframe number */
4959 : const float Es_pred, /* i : predicted scaled innov. energy */
4960 : const float *code, /* i : algebraic code excitation */
4961 : float *gain_pit, /* o : pitch gain */
4962 : float *gain_code, /* o : Quantized codeebook gain */
4963 : float *gain_inov, /* o : unscaled innovation gain */
4964 : float *norm_gain_code /* o : norm. gain of the codebook excit. */
4965 : );
4966 :
4967 : void stat_noise_uv_dec(
4968 : Decoder_State *st, /* i/o: decoder static memory */
4969 : const float *lsp_new, /* i : end-frame LSP vector */
4970 : const float *lsp_mid, /* i : mid-frame LSP vector */
4971 : float *Aq, /* o : A(z) quantized for the 4 subframes */
4972 : float *exc2, /* i/o: excitation buffer */
4973 : const int16_t uc_two_stage_flag /* 1 : flag undicating two-stage UC */
4974 : );
4975 :
4976 : void sc_vbr_dec_init(
4977 : SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle */
4978 : );
4979 :
4980 : void decod_nelp(
4981 : Decoder_State *st, /* i/o: decoder static memory */
4982 : float *tmp_noise, /* o : long term temporary noise energy */
4983 : float *pitch_buf, /* o : floating pitch values for each subframe */
4984 : float *exc, /* o : adapt. excitation exc */
4985 : float *exc2, /* o : adapt. excitation/total exc */
4986 : float *voice_factors, /* o : voicing factors */
4987 : float *bwe_exc, /* o : excitation for SWB TBE */
4988 : const int16_t bfi, /* i : bad frame indicator */
4989 : float *gain_buf /* o : floating pitch gain for each subframe */
4990 : );
4991 :
4992 : void nelp_decoder(
4993 : Decoder_State *st, /* i/o: decoder static memory */
4994 : float *exc_nelp, /* o : adapt. excitation/total exc */
4995 : float *exc, /* o : adapt. excitation exc */
4996 : int16_t bfi, /* i : frame error rate */
4997 : const int16_t coder_type, /* i : coding type */
4998 : float *gain_buf /* o : floating pitch gain for each subframe */
4999 : );
5000 :
5001 : ivas_error decod_ppp(
5002 : Decoder_State *st, /* i/o: state structure */
5003 : const float Aq[], /* i : 12k8 Lp coefficient */
5004 : float *pitch_buf, /* i/o: floating pitch values for each subframe */
5005 : float *exc, /* i/o: current non-enhanced excitation */
5006 : float *exc2, /* i/o: current enhanced excitation */
5007 : float *voice_factors, /* o : voicing factors */
5008 : float *bwe_exc, /* o : excitation for SWB TBE */
5009 : float *gain_buf, /* o : floating pitch gain for each subframe */
5010 : const int16_t bfi /* i : BFI flag */
5011 : );
5012 :
5013 : ivas_error ppp_quarter_decoder(
5014 : Decoder_State *st, /* i/o: decoder state structure */
5015 : DTFS_STRUCTURE *CURRCW_Q_DTFS, /* i/o: Current CW DTFS */
5016 : int16_t prevCW_lag, /* i : Previous lag */
5017 : float *lastLgainD, /* i/o: Last gain lowband */
5018 : float *lastHgainD, /* i/o: Last gain highwband */
5019 : float *lasterbD, /* i/o: Last ERB vector */
5020 : int16_t bfi, /* i : FER flag */
5021 : DTFS_STRUCTURE PREV_CW_D /* i : Previous DTFS */
5022 : );
5023 :
5024 : ivas_error ppp_voiced_decoder(
5025 : Decoder_State *st, /* i/o: state structure */
5026 : float *out, /* o : residual signal */
5027 : const float *lpc2, /* i : current frame LPC */
5028 : float *exc, /* i : previous frame excitation */
5029 : float *pitch, /* o : floating pitch values for each subframe */
5030 : const int16_t bfi /* i : BFI flag */
5031 : );
5032 :
5033 : void AVQ_demuxdec(
5034 : Decoder_State *st, /* i/o: decoder state structure */
5035 : int16_t xriq[], /* o : decoded subvectors [0..8*Nsv-1] */
5036 : int16_t *nb_bits, /* i/o: number of allocated bits */
5037 : const int16_t Nsv, /* i : number of subvectors */
5038 : int16_t nq[], /* i/o: AVQ nq index */
5039 : int16_t avq_bit_sFlag, /* i : flag for AVQ bit saving solution*/
5040 : int16_t trgtSvPos /* i : target SV for AVQ bit savings */
5041 : );
5042 :
5043 : void re8_dec(
5044 : int16_t nq, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */
5045 : const uint16_t I, /* i : index of c (pointer to unsigned 16-bit word) */
5046 : const int16_t kv[], /* i : index of v (8-dimensional vector of binary indices) = Voronoi index */
5047 : int16_t y[] /* o : point in RE8 (8-dimensional integer vector) */
5048 : );
5049 :
5050 : void re8_decode_base_index(
5051 : const int16_t n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */
5052 : uint16_t I, /* i : index of c (pointer to unsigned 16-bit word) */
5053 : int16_t *x /* o : point in RE8 (8-dimensional integer vector) */
5054 : );
5055 :
5056 : void Init_post_filter(
5057 : PFSTAT_HANDLE hPFstat /* i : post-filter state memories */
5058 : );
5059 :
5060 : void nb_post_filt(
5061 : const int16_t L_frame, /* i : frame length */
5062 : const int16_t L_subfr, /* i : sub-frame length */
5063 : PFSTAT_HANDLE hPFstat, /* i/o: Post filter related memories */
5064 : float *lp_noise, /* i/o: long term noise energy */
5065 : const float tmp_noise, /* i : noise energy */
5066 : float *synth, /* i/o: synthesis */
5067 : const float *Aq, /* i : LP filter coefficient */
5068 : const float *pitch_buf, /* i : Floating pitch for each subframe */
5069 : const int16_t coder_type, /* i : coder_type -> deactivated in AUDIO */
5070 : const int16_t BER_detect, /* i : BER detect flag */
5071 : const int16_t disable_hpf /* i : flag to diabled HPF */
5072 : );
5073 :
5074 : void decod_unvoiced(
5075 : Decoder_State *st, /* i/o: decoder static memory */
5076 : const float *Aq, /* i : LP filter coefficient */
5077 : const float Es_pred, /* i : predicted scaled innov. energy */
5078 : const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */
5079 : float *tmp_noise, /* o : long term temporary noise energy */
5080 : float *pitch_buf, /* o : floating pitch values for each subframe */
5081 : float *voice_factors, /* o : voicing factors */
5082 : float *exc, /* o : adapt. excitation exc */
5083 : float *exc2, /* o : adapt. excitation/total exc */
5084 : float *bwe_exc, /* i/o: excitation for SWB TBE */
5085 : float *gain_buf /* o : floating pitch gain for each subfram */
5086 : );
5087 :
5088 : void decod_tran(
5089 : Decoder_State *st, /* i/o: decoder static memory */
5090 : const int16_t L_frame, /* i : length of the frame */
5091 : const int16_t tc_subfr, /* i : TC subframe index */
5092 : const float *Aq, /* i : LP filter coefficient */
5093 : const float Es_pred, /* i : predicted scaled innov. energy */
5094 : float *pitch_buf, /* o : floating pitch values for each subframe */
5095 : float *voice_factors, /* o : voicing factors */
5096 : float *exc, /* i/o: adapt. excitation exc */
5097 : float *exc2, /* i/o: adapt. excitation/total exc */
5098 : float *bwe_exc, /* i/o: excitation for SWB TBE */
5099 : int16_t *unbits, /* i/o: number of unused bits */
5100 : const int16_t sharpFlag, /* i : formant sharpening flag */
5101 : float *gain_buf /* o : floating pitch gain for each subframe */
5102 : );
5103 :
5104 : ivas_error decod_gen_voic(
5105 : Decoder_State *st, /* i/o: decoder static memory */
5106 : const int16_t L_frame, /* i : length of the frame */
5107 : const int16_t sharpFlag, /* i : formant sharpening flag */
5108 : const float *Aq, /* i : LP filter coefficient */
5109 : const float Es_pred, /* i : predicted scaled innov. energy */
5110 : const int16_t do_WI, /* i : FEC fast recovery flag */
5111 : float *pitch_buf, /* o : floating pitch for each subframe */
5112 : float *voice_factors, /* o : voicing factors */
5113 : float *exc, /* i/o: adapt. excitation exc */
5114 : float *exc2, /* i/o: adapt. excitation/total exc */
5115 : float *bwe_exc, /* i/o: excitation for SWB TBE */
5116 : int16_t *unbits, /* i/o: number of unused bits */
5117 : float *gain_buf, /* o : floating pitch gain for each subframe */
5118 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
5119 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
5120 : );
5121 :
5122 : void decod_amr_wb(
5123 : Decoder_State *st, /* i/o: decoder static memory */
5124 : const float *Aq, /* i : LP filter coefficients */
5125 : float *pitch_buf, /* o : floating pitch values for each subframe */
5126 : float *exc, /* i/o: adapt. excitation exc */
5127 : float *exc2, /* i/o: adapt. excitation/total exc */
5128 : int16_t hf_gain[NB_SUBFR], /* o : decoded HF gain */
5129 : float *voice_factors, /* o : voicing factors */
5130 : float *gain_buf /* o : floating pitch gain for each subframe */
5131 : );
5132 :
5133 : ivas_error init_decoder(
5134 : Decoder_State *st, /* o : Decoder static variables structure */
5135 : const int16_t idchan, /* i : channel ID */
5136 : const MC_MODE mc_mode /* i : MC mode */
5137 : );
5138 :
5139 : void destroy_cldfb_decoder(
5140 : Decoder_State *st /* o : Decoder static variables structure */
5141 : );
5142 :
5143 : void HQ_core_dec_init(
5144 : HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */
5145 : );
5146 :
5147 : void HQ_nbfec_init(
5148 : HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */
5149 : );
5150 :
5151 : ivas_error evs_dec(
5152 : Decoder_State *st, /* i/o: Decoder state structure */
5153 : float mem_hp20_out[L_HP20_MEM], /* i/o: HP filter memory for synthesis */
5154 : float *output, /* o : output synthesis signal */
5155 : FRAME_MODE frameMode /* i : Decoder frame mode */
5156 : );
5157 :
5158 : void get_next_frame_parameters(
5159 : Decoder_State *st /* i/o: Decoder state structure */
5160 : );
5161 :
5162 : ivas_error amr_wb_dec(
5163 : Decoder_State *st, /* i/o: decoder state structure */
5164 : float mem_hp20_out[L_HP20_MEM], /* i/o: HP filter memory for synthesis */
5165 : float *output /* o : synthesis output */
5166 : );
5167 :
5168 : void transf_cdbk_dec(
5169 : Decoder_State *st, /* i/o: decoder state structure */
5170 : const int16_t harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
5171 : const int16_t i_subfr, /* i : subframe index */
5172 : const float Es_pred, /* i : predicited scaled innovation energy */
5173 : const float gain_code, /* i : innovative excitation gain */
5174 : float *gain_preQ, /* o : prequantizer excitation gain */
5175 : float *norm_gain_preQ, /* o : normalized prequantizer excitation gain */
5176 : float code_preQ[], /* o : prequantizer excitation */
5177 : int16_t *unbits /* o : number of AVQ unused bits */
5178 : );
5179 :
5180 : /*! r: decoded gain */
5181 : float gain_dequant(
5182 : int16_t index, /* i : quantization index */
5183 : const float min_val, /* i : value of lower limit */
5184 : const float max_val, /* i : value of upper limit */
5185 : const int16_t bits /* i : number of bits to dequantize */
5186 : );
5187 :
5188 : void HQ_core_enc_init(
5189 : HQ_ENC_HANDLE hHQ_core /* i/o: HQ core data handle */
5190 : );
5191 :
5192 : void hq_core_enc(
5193 : Encoder_State *st, /* i/o: encoder state structure */
5194 : const float *audio, /* i : input audio signal */
5195 : const int16_t input_frame, /* i : frame length */
5196 : const int16_t hq_core_type, /* i : HQ core type */
5197 : const int16_t Voicing_flag, /* i : Voicing flag for FER method selection */
5198 : const int16_t vad_hover_flag /* i : VAD hangover flag */
5199 : );
5200 :
5201 : int16_t detect_transient(
5202 : Encoder_State *st, /* i/o: encoder state structure */
5203 : const float *in, /* i : input signal */
5204 : const int16_t L /* i : length */
5205 : );
5206 :
5207 : void wtda(
5208 : const float *new_audio, /* i : input audio */
5209 : float *wtda_audio, /* o : windowed audio */
5210 : float *old_wtda, /* i/o: windowed audio from previous frame */
5211 : const int16_t left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */
5212 : const int16_t right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
5213 : const int16_t L /* i : length */
5214 : );
5215 :
5216 : void wtda_ext(
5217 : const float *new_audio, /* i : input audio */
5218 : float *wtda_audio, /* o : windowed audio */
5219 : const int16_t left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */
5220 : const int16_t right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
5221 : const int16_t L, /* i : length */
5222 : const uint16_t kernel_type /* i : transform kernel type (0 - 3) */
5223 : );
5224 :
5225 : void tcx_get_windows_mode1(
5226 : const int16_t left_mode, /* i : overlap mode of left window half */
5227 : const int16_t right_mode, /* i : overlap mode of right window half */
5228 : float *left_win, /* o : left overlap window */
5229 : float *right_win, /* o : right overlap window */
5230 : float *left_win_int, /* o : left overlap window */
5231 : float *right_win_int, /* o : right overlap window */
5232 : const int16_t L /* i : length */
5233 : );
5234 :
5235 : void direct_transform(
5236 : const float *in32, /* i : input signal */
5237 : float *out32, /* o : output transformation */
5238 : const int16_t is_transient, /* i : transient flag */
5239 : const int16_t L, /* i : length */
5240 : const int16_t element_mode /* i : IVAS element mode */
5241 : );
5242 :
5243 : /*! r: index of noise attenuation */
5244 : int16_t noise_adjust(
5245 : const float *coeffs_norm, /* i : normalized coefficients */
5246 : const int16_t *bitalloc, /* i : bit allocation */
5247 : const int16_t *sfm_start, /* i : Start of bands */
5248 : const int16_t *sfm_end, /* i : End of bands */
5249 : const int16_t core_sfm /* i : index of the end band for core */
5250 : );
5251 :
5252 : void interleave_spectrum(
5253 : float *coefs, /* i/o: input and output coefficients */
5254 : const int16_t length /* i : length of spectrum */
5255 : );
5256 :
5257 : void hq_hr_enc(
5258 : Encoder_State *st, /* i/o: encoder state structure */
5259 : float *coefs, /* i/o: transform-domain coefficients */
5260 : const int16_t length, /* i : length of spectrum */
5261 : int16_t *num_bits, /* i/o: number of available bits */
5262 : const int16_t is_transient, /* i : transient flag */
5263 : const int16_t vad_hover_flag /* i : VAD hangover flag */
5264 : );
5265 :
5266 : void logqnorm(
5267 : const float *x, /* i : coefficient vector */
5268 : int16_t *k, /* o : index */
5269 : const int16_t L, /* i : codebook length */
5270 : const int16_t N, /* i : sub-vector size */
5271 : const float *thren );
5272 :
5273 : void huff_dec(
5274 : Decoder_State *st, /* i/o: decoder state structure */
5275 : const int16_t N, /* i : Number of codewords to decode */
5276 : const int16_t buffer_len, /* i : Number of bits to read */
5277 : const int16_t num_lengths, /* i : Number of different huffman codeword lengths */
5278 : const int16_t *thres, /* i : Threshold of first codeword of each length */
5279 : const int16_t *offset, /* i : Offset for first codeword */
5280 : const int16_t *huff_tab, /* i : Huffman table order by codeword lengths */
5281 : int16_t *index /* o : Decoded index */
5282 : );
5283 :
5284 : void calc_norm(
5285 : const float *x, /* i : Input vector. */
5286 : int16_t *norm, /* o : Quantization indices for norms */
5287 : int16_t *normlg, /* o : Quantized norms in log2 */
5288 : const int16_t start_band, /* i : Indice of band to start coding */
5289 : const int16_t num_bands, /* i : Number of bands */
5290 : const int16_t *band_len, /* i : Length of bands */
5291 : const int16_t *band_start /* i : Start of bands */
5292 : );
5293 :
5294 : void reordernorm(
5295 : const int16_t *ynrm, /* i : quantization indices for norms */
5296 : const int16_t *normqlg2, /* i : quantized norms */
5297 : int16_t *idxbuf, /* o : reordered quantization indices */
5298 : int16_t *normbuf, /* o : reordered quantized norms */
5299 : const int16_t nb_sfm /* i : number of bands */
5300 : );
5301 :
5302 : void diffcod(
5303 : const int16_t N, /* i : number of sub-vectors */
5304 : int16_t *y, /* i/o: indices of quantized norms */
5305 : int16_t *difidx /* o : differential code */
5306 : );
5307 :
5308 : void diffcod_lrmdct(
5309 : const int16_t N, /* i : number of sub-vectors */
5310 : const int16_t be_ref, /* i : band energy reference */
5311 : int16_t *y, /* i/o: indices of quantized norms */
5312 : int16_t *difidx, /* o : differential code */
5313 : const int16_t is_transient /* i : transient flag */
5314 : );
5315 :
5316 : void normalizecoefs(
5317 : float *coefs, /* i/o: MDCT coefficients */
5318 : const int16_t *ynrm, /* i : quantization indices for norms */
5319 : const int16_t num_bands, /* i : Number of bands */
5320 : const int16_t *band_start, /* i : Start of bands */
5321 : const int16_t *band_end /* i : End of bands */
5322 : );
5323 :
5324 : void bitallocsum(
5325 : int16_t *R, /* i : bit-allocation vector */
5326 : const int16_t nb_sfm, /* i : number of sub-vectors */
5327 : int16_t *sum, /* o : total number of bits allocated */
5328 : int16_t *Rsubband, /* o : rate per subband (Q3) */
5329 : const int16_t num_bits, /* i : number of bits */
5330 : const int16_t length, /* i : length of spectrum */
5331 : const int16_t *sfmsize /* i : Length of bands */
5332 : );
5333 :
5334 : void hq_generic_hf_encoding(
5335 : const float *coefs, /* i : MDCT coefficients of weighted original */
5336 : float *hq_generic_fenv, /* i/o: energy of SWB envelope */
5337 : const int16_t hq_generic_offset, /* i : frequency offset for extracting energy */
5338 : Encoder_State *st, /* i/o: encoder state structure */
5339 : int16_t *hq_generic_exc_clas, /* o : HF excitation class */
5340 : const int16_t length /* i : Length of spectrum */
5341 : );
5342 :
5343 : /*! r: BWE class */
5344 : int16_t swb_bwe_gain_deq(
5345 : Decoder_State *st, /* i/o: decoder state structure */
5346 : const int16_t core, /* i : core */
5347 : float *SWB_tenv, /* o : time-domain BWE envelope */
5348 : float *SWB_fenv, /* o : frequency-domain BWE envelope */
5349 : const int16_t hr_flag, /* i : high rate flag */
5350 : const int16_t hqswb_clas /* i : HQ BWE class */
5351 : );
5352 :
5353 : void save_old_syn(
5354 : const int16_t L_frame, /* i : frame length */
5355 : const float syn[], /* i : ACELP synthesis */
5356 : float old_syn[], /* o : old synthesis buffer */
5357 : float old_syn_12k8_16k[], /* i/o: old synthesis buffer */
5358 : const float preemph_fac, /* i : preemphasis factor */
5359 : float *mem_deemph /* i/o: deemphasis filter memory */
5360 : );
5361 :
5362 : void hq_generic_hf_decoding(
5363 : const int16_t HQ_mode, /* i : HQ mode */
5364 : float *coeff_out1, /* i/o: BWE input & temporary buffer */
5365 : const float *hq_generic_fenv, /* i : SWB frequency envelopes */
5366 : float *coeff_out, /* o : SWB signal in MDCT domain */
5367 : const int16_t hq_generic_offset, /* i : frequency offset for representing hq swb bwe*/
5368 : int16_t *prev_L_swb_norm, /* i/o: last normalize length */
5369 : const int16_t hq_swb_bwe_exc_clas, /* i : bwe excitation class */
5370 : const int16_t *R );
5371 :
5372 : void hq_core_dec(
5373 : Decoder_State *st, /* i/o: decoder state structure */
5374 : float out[], /* o : output synthesis */
5375 : const int16_t output_frame, /* i : output frame length */
5376 : const int16_t hq_core_type, /* i : HQ core type */
5377 : const int16_t core_switching_flag, /* i : ACELP->HQ switching frame flag */
5378 : float *output /* o : LB synthesis in case of ACELP-HQ switch */
5379 : );
5380 :
5381 : void IMDCT(
5382 : float *x,
5383 : float *old_syn_overl,
5384 : float *syn_Overl_TDAC,
5385 : float *xn_buf,
5386 : const float *tcx_aldo_window_1_trunc,
5387 : const float *tcx_aldo_window_2,
5388 : const float *tcx_mdct_window_half,
5389 : const float *tcx_mdct_window_minimum,
5390 : const float *tcx_mdct_window_trans,
5391 : const int16_t tcx_mdct_window_half_length,
5392 : const int16_t tcx_mdct_window_min_length,
5393 : int16_t index,
5394 : const uint16_t kernel_type, /* i : TCX transform kernel type */
5395 : const int16_t left_rect,
5396 : const int16_t tcx_offset,
5397 : const int16_t overlap,
5398 : const int16_t L_frame,
5399 : const int16_t L_frameTCX,
5400 : const int16_t L_spec_TCX5,
5401 : const int16_t L_frame_glob,
5402 : const int16_t frame_cnt,
5403 : const int16_t bfi,
5404 : float *old_out,
5405 : const int16_t FB_flag,
5406 : Decoder_State *st,
5407 : const int16_t fullband,
5408 : float *acelp_zir );
5409 :
5410 : void hq_hr_dec(
5411 : Decoder_State *st, /* i/o: decoder state structure */
5412 : float *t_audio_q, /* o : transform-domain coefficients */
5413 : const int16_t length, /* i : frame length */
5414 : const int16_t num_bits, /* i : number of available bits */
5415 : int16_t *ynrm, /* o : norm quantization index vector */
5416 : int16_t *is_transient, /* o : transient flag */
5417 : int16_t *hqswb_clas, /* o : HQ SWB class */
5418 : float *SWB_fenv, /* o : SWB frequency envelopes */
5419 : const int16_t core_switching_flag /* i : Core switching flag */
5420 :
5421 : );
5422 :
5423 : void hdecnrm_context(
5424 : Decoder_State *st, /* i/o: decoder state structure */
5425 : const int16_t N, /* i : number of norms */
5426 : int16_t *index, /* o : indices of quantized norms */
5427 : int16_t *n_length /* o : decoded stream length */
5428 : );
5429 :
5430 : void hdecnrm_tran(
5431 : Decoder_State *st, /* i/o: decoder state structure */
5432 : const int16_t N, /* i : number of norms */
5433 : int16_t *index /* o : indices of quantized norms */
5434 : );
5435 :
5436 : void hdecnrm_resize(
5437 : Decoder_State *st, /* i/o: decoder state structure */
5438 : const int16_t N, /* i : number of SFMs */
5439 : int16_t *index /* o : norm quantization index vector */
5440 : );
5441 :
5442 : void hdecnrm(
5443 : Decoder_State *st, /* i/o: decoder state structure */
5444 : const int16_t N, /* i : number of norms */
5445 : int16_t *index /* o : indices of quantized norms */
5446 : );
5447 :
5448 : /*! r: index of last band */
5449 : int16_t find_last_band(
5450 : const int16_t *bitalloc, /* i : bit allocation */
5451 : const int16_t nb_sfm /* i : number of possibly coded bands */
5452 : );
5453 :
5454 : void fill_spectrum(
5455 : float *coeff, /* i/o: normalized MLT spectrum / nf spectrum */
5456 : int16_t *R, /* i : number of pulses per band */
5457 : const int16_t is_transient, /* i : transient flag */
5458 : int16_t norm[], /* i : quantization indices for norms */
5459 : const float *hq_generic_fenv, /* i : HQ GENERIC envelope */
5460 : const int16_t hq_generic_offset, /* i : HQ GENERIC offset */
5461 : const int16_t nf_idx, /* i : noise fill index */
5462 : const int16_t length, /* i : Length of spectrum (32 or 48 kHz) */
5463 : const float env_stab, /* i : Envelope stability measure [0..1] */
5464 : int16_t *no_att_hangover, /* i/o: Frame counter for attenuation hangover */
5465 : float *energy_lt, /* i/o: Long-term energy measure for transient detection */
5466 : int16_t *bwe_seed, /* i/o: random seed for generating BWE input */
5467 : const int16_t hq_generic_exc_clas, /* i : HF excitation class */
5468 : const int16_t core_sfm, /* i : index of the end band for core */
5469 : int16_t HQ_mode, /* i : HQ mode */
5470 : float noise_level[], /* i : noise level for harmonic modes */
5471 : int32_t core_brate, /* i : target bitrate */
5472 : float prev_noise_level[], /* i/o: noise factor in previous frame */
5473 : int16_t *prev_R, /* i/o: bit allocation info. in previous frame */
5474 : float *prev_coeff_out, /* i/o: decoded spectrum in previous frame */
5475 : const int16_t *peak_idx, /* i : peak positions */
5476 : const int16_t Npeaks, /* i : number of peaks */
5477 : const int16_t *npulses, /* i : Number of assigned pulses per band */
5478 : int16_t prev_is_transient, /* i : previous transient flag */
5479 : float *prev_normq, /* i : previous norms */
5480 : float *prev_env, /* i : previous noise envelopes */
5481 : int16_t prev_bfi, /* i : previous bad frame indicator */
5482 : const int16_t *sfmsize, /* i : Length of bands */
5483 : const int16_t *sfm_start, /* i : Start of bands */
5484 : const int16_t *sfm_end, /* i : End of bands */
5485 : int16_t *prev_L_swb_norm, /* i/o: last normalize length for harmonic mode */
5486 : int16_t prev_hq_mode, /* i : previous HQ mode */
5487 : const int16_t num_sfm, /* i : Number of bands */
5488 : const int16_t num_env_bands, /* i : Number of envelope bands */
5489 : const int16_t element_mode /* i : element mode */
5490 : );
5491 :
5492 : void env_stab_transient_detect(
5493 : const int16_t is_transient, /* i : Transient flag */
5494 : const int16_t length, /* i : Length of spectrum (32 or 48 kHz) */
5495 : const int16_t norm[], /* i : quantization indices for norms */
5496 : int16_t *no_att_hangover, /* i/o: Frame counter for attenuation hangover */
5497 : float *energy_lt, /* i/o: Long-term energy measure for transient detection */
5498 : const int16_t HQ_mode, /* i : HQ coding mode */
5499 : const int16_t bin_th, /* i : HVQ cross-over frequency bin */
5500 : const float *coeff /* i : Coded spectral coefficients */
5501 : );
5502 :
5503 : void de_interleave_spectrum(
5504 : float *coefs, /* i/o: input and output coefficients */
5505 : int16_t length /* i : length of spectrum */
5506 : );
5507 :
5508 : void inverse_transform(
5509 : const float *InMDCT, /* i : input MDCT vector */
5510 : float *Out, /* o : output vector */
5511 : const int16_t IsTransient, /* i : transient flag */
5512 : const int16_t L, /* i : output frame length */
5513 : const int16_t L_inner, /* i : length of the transform */
5514 : const int16_t element_mode /* i : IVAS element mode */
5515 : );
5516 :
5517 : void window_ola(
5518 : const float *ImdctOut, /* i : input */
5519 : float *auOut, /* o : output audio */
5520 : float *OldauOut, /* i/o: audio from previous frame */
5521 : const int16_t L, /* i : length */
5522 : const int16_t right_mode,
5523 : const int16_t left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
5524 : const int16_t use_bfi_win, /* i : use BFI windowing */
5525 : const int16_t oldHqVoicing, /* i : previous HqVoicing */
5526 : float *oldgapsynth /* i : previous gapsynth */
5527 : );
5528 :
5529 : void window_ola_ext(
5530 : const float *ImdstOut, /* i : input */
5531 : float *auOut, /* o : output audio */
5532 : float *OldauOut, /* i/o: audio from previous frame */
5533 : const int16_t L, /* i : length */
5534 : const int16_t right_mode,
5535 : const int16_t left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
5536 : const uint16_t kernel_type /* i : transform kernel type */
5537 : );
5538 :
5539 : void map_quant_weight(
5540 : const int16_t normqlg2[], /* i : quantized norms */
5541 : int16_t wnorm[], /* o : weighted norm */
5542 : const int16_t is_transient /* i : transient flag */
5543 : );
5544 :
5545 : void recovernorm(
5546 : const int16_t *const idxbuf, /* i : reordered quantization indices */
5547 : int16_t *ynrm, /* o : recovered quantization indices */
5548 : int16_t *normqlg2, /* o : recovered quantized norms */
5549 : const int16_t nb_sfm /* i : number of subbands */
5550 : );
5551 :
5552 : void reordvct(
5553 : int16_t *y, /* i/o: vector to rearrange */
5554 : const int16_t N, /* i : dimensions */
5555 : int16_t *idx /* o : reordered vector index */
5556 : );
5557 :
5558 : void bitalloc(
5559 : int16_t *y, /* i : reordered norm of sub-vectors */
5560 : int16_t *idx, /* i : reordered sub-vector indices */
5561 : int16_t sum, /* i : number of available bits */
5562 : int16_t N, /* i : number of norms */
5563 : int16_t K, /* i : maximum number of bits per dimension */
5564 : int16_t *r, /* o : bit-allacation vector */
5565 : const int16_t *sfmsize, /* i : Length of bands */
5566 : const int16_t hqswb_clas /* i : signal classification flag */
5567 : );
5568 :
5569 : /*! r: Integer (truncated) number of allocated bits */
5570 : int16_t BitAllocF(
5571 : int16_t *y, /* i : norm of sub-vectors */
5572 : int32_t bit_rate, /* i : bitrate */
5573 : int16_t B, /* i : number of available bits */
5574 : int16_t N, /* i : number of sub-vectors */
5575 : int16_t *R, /* o : bit-allocation indicator */
5576 : int16_t *Rsubband, /* o : sub-band bit-allocation vector (Q3) */
5577 : const int16_t hqswb_clas, /* i : hq swb class */
5578 : const int16_t num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */
5579 : );
5580 :
5581 : /*! r: Integer (truncated) number of allocated bits */
5582 : int16_t BitAllocWB(
5583 : int16_t *y, /* i : norm of sub-vectors */
5584 : int16_t B, /* i : number of available bits */
5585 : int16_t N, /* i : number of sub-vectors */
5586 : int16_t *R, /* o : bit-allocation indicator */
5587 : int16_t *Rsubband ); /* o : sub-band bit-allocation vector (Q3) */
5588 :
5589 : /*! r: Number of low frequency bands */
5590 : int16_t hvq_pvq_bitalloc(
5591 : int16_t num_bits, /* i/o: Number of available bits (including gain bits) */
5592 : const int32_t core_brate, /* i : bitrate */
5593 : const int16_t bwidth, /* i : Encoded bandwidth */
5594 : const int16_t *ynrm, /* i : Envelope coefficients */
5595 : const int32_t manE_peak, /* i : Peak energy mantissa */
5596 : const int16_t expE_peak, /* i : Peak energy exponent */
5597 : int16_t *Rk, /* o : bit allocation for concatenated vector */
5598 : int16_t *R, /* i/o: Global bit allocation */
5599 : int16_t *sel_bands, /* o : Selected bands for encoding */
5600 : int16_t *n_sel_bands /* o : No. of selected bands for encoding */
5601 : );
5602 :
5603 : void floating_point_add(
5604 : int32_t *mx, /* i/o: mantissa of the addend Q31 */
5605 : int16_t *ex, /* i/o: exponent of the addend Q0 */
5606 : const int32_t my, /* i : mantissa of the adder Q31 */
5607 : const int16_t ey /* i : exponent of the adder Q0 */
5608 : );
5609 :
5610 : /*! r: Number of bits needed */
5611 : int16_t rc_get_bits2(
5612 : const int16_t N, /* i : Number of bits currently used */
5613 : const uint32_t range /* i : Range of range coder */
5614 : );
5615 :
5616 : void rc_enc_init(
5617 : PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
5618 : int16_t tot_bits /* i : Total bit budget */
5619 : );
5620 :
5621 : void rc_encode(
5622 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
5623 : PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
5624 : const uint32_t cum_freq, /* i : Cumulative frequency up to symbol */
5625 : const uint32_t sym_freq, /* i : Symbol probability */
5626 : const uint32_t tot /* i : Total cumulative frequency */
5627 : );
5628 :
5629 : void rc_enc_finish(
5630 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
5631 : PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */
5632 : );
5633 :
5634 : void rc_enc_bits(
5635 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
5636 : PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
5637 : const uint32_t value, /* i : Value to encode */
5638 : const int16_t bits /* i : Number of bits used */
5639 : );
5640 :
5641 : void rc_enc_uniform(
5642 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
5643 : PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
5644 : uint32_t value, /* i : Value to encode */
5645 : uint32_t tot /* i : Maximum value */
5646 : );
5647 :
5648 : void rc_dec_init(
5649 : Decoder_State *st, /* i/o: Decoder State */
5650 : PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
5651 : int16_t tot_bits /* i : Total bit budget */
5652 : );
5653 :
5654 : /*! r: Decoded value */
5655 : uint32_t rc_decode(
5656 : int16_t *BER_detect, /* o : Bit error detection flag */
5657 : PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
5658 : uint32_t tot /* i : Total cumulative frequency */
5659 : );
5660 :
5661 : void rc_dec_update(
5662 : Decoder_State *st, /* i/o: Decoder State */
5663 : PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
5664 : const uint32_t cum_freq, /* i : Cumulative frequency */
5665 : const uint32_t sym_freq /* i : Symbol frequency */
5666 : );
5667 :
5668 : /*! r: Decoded value */
5669 : uint32_t rc_dec_bits(
5670 : Decoder_State *st, /* i/o: Decoder State */
5671 : PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
5672 : const int16_t bits /* i : Number of bits */
5673 : );
5674 :
5675 : /*! r: Decoded value */
5676 : uint32_t rc_dec_uniform(
5677 : Decoder_State *st, /* i/o: Decoder State */
5678 : PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
5679 : const uint32_t tot /* i : Maximum value */
5680 : );
5681 :
5682 : void rc_dec_finish(
5683 : Decoder_State *st, /* i/o: decoder state structure */
5684 : PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle */
5685 : );
5686 :
5687 : /*! r: number of bits encoded */
5688 : int16_t pvq_core_enc(
5689 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
5690 : float coefs_norm[], /* i/o: normalized coefficients to encode */
5691 : float coefs_quant[], /* o : quantized coefficients */
5692 : const int16_t bits_tot, /* i : total number of bits */
5693 : const int16_t nb_sfm, /* i : number of bands */
5694 : const int16_t *sfm_start, /* i : Subband start coefficient */
5695 : const int16_t *sfm_end, /* i : Subband end coefficient */
5696 : const int16_t *sfmsize, /* i : subband width */
5697 : int16_t *R, /* i/o: Bit allocation/Adjusted bit alloc. (Q3) */
5698 : int16_t *Rs, /* i/o: Integer bit allocation */
5699 : int16_t *npulses, /* o : number of pulses */
5700 : int16_t *maxpulse, /* i : maximum pulse per band */
5701 : const int16_t core /* i : number of bands */
5702 : );
5703 :
5704 : /*! r: number of bits decoded */
5705 : int16_t pvq_core_dec(
5706 : Decoder_State *st, /* i/o: Decoder state */
5707 : const int16_t *sfm_start, /* i : indices of first coeffs in the bands */
5708 : const int16_t *sfm_end, /* i : indices of last coeffs in the bands */
5709 : const int16_t *sfmsize, /* i : band sizes */
5710 : float coefs_quant[], /* o : output MDCT */
5711 : const int16_t bits_tot, /* i : bit budget */
5712 : const int16_t nb_sfm, /* i : number of bands */
5713 : int16_t *R, /* i/o: Bit allocation/Adjusted bit alloc.(Q3) */
5714 : int16_t *Rs, /* i/o: Integer bit allocation */
5715 : int16_t *npulses, /* o : number of pulses per band */
5716 : int16_t *maxpulse, /* o : maximum pulse per band */
5717 : const int16_t core /* i : core */
5718 : );
5719 :
5720 : void pvq_encode(
5721 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
5722 : PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
5723 : const float *x, /* i : vector to quantize */
5724 : int16_t *y, /* o : quantized vector (non-scaled integer)*/
5725 : float *xq, /* o : quantized vector (scaled float) */
5726 : const int16_t pulses, /* i : number of allocated pulses */
5727 : const int16_t N, /* i : Length of vector */
5728 : const float gain /* i : Gain */
5729 : );
5730 :
5731 : void pvq_decode(
5732 : Decoder_State *st, /* i/o: Decoder State */
5733 : PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
5734 : float *xq, /* o : decoded vector (scaled float) */
5735 : int16_t *y, /* o : decoded vector (non-scaled short)*/
5736 : const int16_t K, /* i : number of allocated pulses */
5737 : const int16_t N, /* i : Length of vector */
5738 : const float gain /* i : Gain */
5739 : );
5740 :
5741 : void rangeCoderFinalizationFBits(
5742 : const int16_t Brc, /* i : Current number of decoded bits */
5743 : const uint32_t INTrc, /* i : Range coder state */
5744 : int16_t *FBits /* i : Fractional finalization bits */
5745 : );
5746 :
5747 : void bandBitsAdjustment(
5748 : const int16_t Brc, /* i : Current number of read quanta in range coder */
5749 : const uint32_t INTrc, /* i : Range coder state */
5750 : const int16_t Bavail, /* i : Available number of quanta */
5751 : const int16_t Nbands, /* i : Number of bands */
5752 : const int16_t D, /* i : Remaining number of bands to encode */
5753 : const int16_t L, /* i : Size of current band */
5754 : const int16_t Bband, /* i : Quanta allocation for current band */
5755 : const int16_t Breserv, /* i : Quanta reservoir */
5756 : int16_t *Bband_adj, /* o : Actual used number of quanta */
5757 : int16_t *Brem, /* o : Quanta remaining */
5758 : int16_t *Breservplus /* o : Quanta pool size */
5759 : );
5760 :
5761 : void conservativeL1Norm(
5762 : const int16_t L, /* i : Length of vector segment */
5763 : const int16_t Qvec, /* i : Assigned number of quanta */
5764 : const int16_t Fcons, /* i : Conservative rounding flag */
5765 : const int16_t Qavail, /* i : Input quanta remaining */
5766 : const int16_t Qreserv, /* i : Input quanta in reservoir */
5767 : const int16_t Dspec, /* i : assigned diracs from bitalloc */
5768 : int16_t *Dvec, /* o : actual number of diracs */
5769 : int16_t *Qspare, /* o : Output quanta remaining */
5770 : int16_t *Qreservplus, /* o : Output quanta in reservoir */
5771 : int16_t *Dspecplus /* o : Output number of diracs */
5772 : );
5773 :
5774 : void NearOppSplitAdjustment(
5775 : const int16_t qband, /* i : quanta for current band */
5776 : const int16_t qzero, /* i : range coder finalization quanta */
5777 : const int16_t Qac, /* i : range coder current quanta */
5778 : const uint32_t INTac, /* i : range coder state */
5779 : const int16_t qglobal, /* i : quanta input */
5780 : const int16_t FlagCons, /* i : conservative rounding flag */
5781 : const int16_t Np, /* i : number of parts */
5782 : const int16_t Nhead, /* i : first part */
5783 : const int16_t Ntail, /* i : remaining parts */
5784 : const int16_t Nnear, /* i : length of near component */
5785 : const int16_t Nopp, /* i : length of opposite component */
5786 : int16_t oppRQ3, /* i : ratio */
5787 : int16_t *qnear, /* o : quantized near */
5788 : int16_t *qopp, /* o : quantized opposite */
5789 : int16_t *qglobalupd /* o : quanta remaining */
5790 : );
5791 :
5792 : /*! r: Approximate integer division for positive input */
5793 : int32_t intLimCDivPos(
5794 : const int32_t NUM, /* i : numerator */
5795 : const int16_t DEN /* i : denominator */
5796 : );
5797 :
5798 : /*! r: Approximate integer division */
5799 : int16_t shrtCDivSignedApprox(
5800 : const int16_t num, /* i : numerator */
5801 : const int16_t den /* i : denominator */
5802 : );
5803 :
5804 : void QuantaPerDsDirac(
5805 : const int16_t td, /* i : Length of vector segment */
5806 : const int16_t dsDiracIndex, /* i : Quanta table index */
5807 : const uint8_t *const *dimFrQuanta, /* i : Quanta lookup table */
5808 : int16_t *Quanta /* i : Quanta */
5809 : );
5810 :
5811 : void obtainEnergyQuantizerDensity(
5812 : const int16_t L_in, /* i : left vector energy */
5813 : const int16_t R_in, /* i : right vector energy */
5814 : int16_t *Density /* o : quantizer density */
5815 : );
5816 :
5817 : void densityAngle2RmsProjDec(
5818 : const int16_t D, /* i : density */
5819 : const int16_t indexphi, /* i : decoded index from AR dec */
5820 : int16_t *oppQ15, /* o : opposite */
5821 : int16_t *nearQ15, /* o : near */
5822 : int16_t *oppRatioQ3 /* o : ratio */
5823 : );
5824 :
5825 : void densityAngle2RmsProjEnc(
5826 : const int16_t D, /* i : density */
5827 : const int16_t phiQ14uq, /* i : angle */
5828 : int16_t *indexphi, /* o : index */
5829 : int16_t *oppQ15, /* o : opposite */
5830 : int16_t *nearQ15, /* o : near */
5831 : int16_t *oppRatioQ3 /* o : ratio */
5832 : );
5833 :
5834 : void env_adj(
5835 : const int16_t *pulses, /* i : number of pulses per band */
5836 : const int16_t length, /* i : length of spectrum */
5837 : const int16_t last_sfm, /* i : Index of last band */
5838 : float *adj, /* o : Adjustment factors for the envelope */
5839 : const float env_stab, /* i : Envelope stability parameter */
5840 : const int16_t *sfmsize /* i : Length of bands */
5841 : );
5842 :
5843 : float env_stability(
5844 : const int16_t *ynrm, /* i : Norm vector for current frame */
5845 : const int16_t nb_sfm, /* i : Number of sub-bands */
5846 : int16_t *mem_norm, /* i/o: Norm vector memory from past frame */
5847 : int16_t *mem_env_delta, /* i/o: Envelope stability memory for smoothing*/
5848 : const int16_t core_switching_flag /* i : Core switching flag */
5849 : );
5850 :
5851 : /*! r: New speech/music state */
5852 : float env_stab_smo(
5853 : float env_stab, /* i : env_stab value */
5854 : float *env_stab_state_p, /* i/o: env_stab state probabilities */
5855 : int16_t *ho_cnt /* i/o: hangover counter for speech state */
5856 : );
5857 :
5858 : void core_switching_pre_enc(
5859 : Encoder_State *st, /* i/o: encoder state structure */
5860 : const float *old_inp_12k8, /* i : old input signal @12.8kHz */
5861 : const float *old_inp_16k, /* i : old input signal @16kHz */
5862 : const int16_t active_cnt, /* i : Active frame counter */
5863 : const int16_t last_element_mode /* i : last_element_mode */
5864 : );
5865 :
5866 : void core_switching_post_enc(
5867 : Encoder_State *st, /* i/o: encoder state structure */
5868 : const float *old_inp_12k8, /* i : old input signal @12.8kHz */
5869 : const float *old_inp_16k, /* i : old input signal @16kHz */
5870 : const float A[] /* i : unquant LP filter coefs. */
5871 : );
5872 :
5873 : ivas_error core_switching_post_dec(
5874 : Decoder_State *st, /* i/o: decoder state structure */
5875 : float *synth, /* i/o: output synthesis */
5876 : float *output, /* i/o: LB synth/upsampled LB synth */
5877 : float output_mem[], /* i : OLA memory from last TCX/HQ frame */
5878 : const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
5879 : const int16_t output_frame, /* i : frame length */
5880 : const int16_t core_switching_flag, /* i : ACELP->HQ switching frame flag */
5881 : const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */
5882 : const int16_t nchan_out, /* i : number of output channels */
5883 : const int16_t last_element_mode /* i : element mode of previous frame */
5884 : );
5885 :
5886 : ivas_error core_switching_pre_dec(
5887 : Decoder_State *st, /* i/o: decoder state structure */
5888 : const int16_t output_frame, /* i : frame length */
5889 : const int32_t last_core_brate_st0, /* i : channel 0 last core bitrate */
5890 : const int16_t nchan_out, /* i : number of output channels */
5891 : const int16_t last_element_mode, /* i : last_element_mode */
5892 : const int32_t last_element_brate /* i : last element bitrate */
5893 : );
5894 :
5895 : void bandwidth_switching_detect(
5896 : Decoder_State *st /* i/o: decoder state structure */
5897 : );
5898 :
5899 : void bw_switching_pre_proc(
5900 : Decoder_State *st, /* i/o: decoder state structure */
5901 : const float *old_syn_12k8_16k, /* i : ACELP core synthesis @ 12.8kHz or 16kHz */
5902 : const int32_t last_element_brate, /* i : last element bitrate */
5903 : const int16_t nchan_out /* i : number of output channels */
5904 : );
5905 :
5906 : void updt_bw_switching(
5907 : Decoder_State *st, /* i/o: decoder state structure */
5908 : const float *synth /* i : float synthesis signal */
5909 : );
5910 :
5911 : void swb_tbe_reset(
5912 : float mem_csfilt[],
5913 : float mem_genSHBexc_filt_down_shb[],
5914 : float state_lpc_syn[],
5915 : float syn_overlap[],
5916 : float state_syn_shbexc[],
5917 : float *tbe_demph,
5918 : float *tbe_premph,
5919 : float mem_stp_swb[],
5920 : float *gain_prec_swb );
5921 :
5922 : void swb_tbe_reset_synth(
5923 : float genSHBsynth_Hilbert_Mem[],
5924 : float genSHBsynth_state_lsyn_filt_shb_local[] );
5925 :
5926 : void find_td_envelope(
5927 : const float inp[],
5928 : const int16_t len,
5929 : const int16_t len_h,
5930 : float mem_h[],
5931 : float out[] );
5932 :
5933 : void fb_tbe_reset_enc(
5934 : float elliptic_bpf_2_48k_mem[][4],
5935 : float *prev_fb_energy );
5936 :
5937 : void fb_tbe_reset_synth(
5938 : float fbbwe_hpf_mem[][4],
5939 : float *prev_fbbwe_ratio );
5940 :
5941 : void wb_tbe_extras_reset(
5942 : float mem_genSHBexc_filt_down_wb2[],
5943 : float mem_genSHBexc_filt_down_wb3[] );
5944 :
5945 : void wb_tbe_extras_reset_synth(
5946 : float state_lsyn_filt_shb[],
5947 : float state_lsyn_filt_dwn_shb[],
5948 : float mem_resamp_HB[] );
5949 :
5950 : void tbe_celp_exc(
5951 : const int16_t element_mode, /* i : element mode */
5952 : const int16_t idchan, /* i : channel ID */
5953 : float *bwe_exc, /* i/o: BWE excitation */
5954 : const int16_t L_frame, /* i : frame length */
5955 : const int16_t L_subfr, /* i : subframe length */
5956 : const int16_t i_subfr, /* i : subframe index */
5957 : const int16_t T0, /* i : integer pitch lag */
5958 : const int16_t T0_frac, /* i : fraction of lag */
5959 : float *error, /* i/o: error */
5960 : const int16_t tdm_LRTD_flag /* i : LRTD stereo mode flag */
5961 : );
5962 :
5963 : void prep_tbe_exc(
5964 : const int16_t L_frame, /* i : length of the frame */
5965 : const int16_t L_subfr, /* i : subframe length */
5966 : const int16_t i_subfr, /* i : subframe index */
5967 : const float gain_pit, /* i : Pitch gain */
5968 : const float gain_code, /* i : algebraic codebook gain */
5969 : const float code[], /* i : algebraic excitation */
5970 : const float voice_fac, /* i : voicing factor */
5971 : float *voice_factors, /* o : TBE voicing factor */
5972 : float bwe_exc[], /* i/o: excitation for TBE */
5973 : const float gain_preQ, /* i : prequantizer excitation gain */
5974 : const float code_preQ[], /* i : prequantizer excitation */
5975 : const int16_t T0, /* i : integer pitch variables */
5976 : const int16_t coder_type, /* i : coding type */
5977 : const int32_t core_brate, /* i : core bitrate */
5978 : const int16_t element_mode, /* i : element mode */
5979 : const int16_t idchan, /* i : channel ID */
5980 : const int16_t flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */
5981 : const int16_t tdm_LRTD_flag /* i : LRTD stereo mode flag */
5982 : );
5983 :
5984 : void synthesise_fb_high_band(
5985 : const float excitation_in[], /* i : full band excitation */
5986 : float output[], /* o : high band speech - 14.0 to 20 kHz */
5987 : const float fb_exc_energy, /* i : full band excitation energy */
5988 : const float ratio, /* i : energy ratio */
5989 : const int16_t L_frame, /* i : ACELP frame length */
5990 : const int16_t bfi, /* i : BFI flag */
5991 : float *prev_fbbwe_ratio, /* o : previous frame energy for FEC */
5992 : float bpf_memory[][4] /* i/o: memory for elliptic bpf 48k */
5993 : );
5994 :
5995 : void elliptic_bpf_48k_generic(
5996 : const float input[], /* i : input signal */
5997 : float output[], /* o : output signal */
5998 : float memory[][4], /* i/o: 4 arrays for memory */
5999 : const float full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 */
6000 : );
6001 :
6002 : void HQ_FEC_processing(
6003 : Decoder_State *st, /* i/o: decoder state structure */
6004 : float *t_audio_q, /* o : MDCT coeffs. (for synthesis) */
6005 : int16_t is_transient, /* i : Old flag for transient */
6006 : float ynrm_values[][MAX_PGF], /* i : Old average Norm values for each group of bands */
6007 : float r_p_values[][MAX_ROW], /* i : Computed y-intercept and slope by Regression */
6008 : int16_t num_Sb, /* i : Number of sub-band group */
6009 : int16_t nb_sfm, /* i : Number of sub-band */
6010 : int16_t *Num_bands_p, /* i : Number of coeffs. for each sub-band */
6011 : int16_t output_frame, /* i : Frame size */
6012 : const int16_t *sfm_start, /* i : Start of bands */
6013 : const int16_t *sfm_end /* i : End of bands */
6014 : );
6015 :
6016 : void HQ_FEC_Mem_update(
6017 : Decoder_State *st, /* i/o: decoder state structure */
6018 : const float *t_audio_q,
6019 : float *normq,
6020 : int16_t *ynrm,
6021 : const int16_t *Num_bands_p,
6022 : const int16_t is_transient,
6023 : const int16_t hqswb_clas,
6024 : const int16_t c_switching_flag,
6025 : const int16_t nb_sfm,
6026 : const int16_t num_Sb,
6027 : float *mean_en_high,
6028 : const int16_t hq_core_type, /* i : normal or low-rate MDCT(HQ) core */
6029 : const int16_t output_frame /* i : Frame size */
6030 : );
6031 :
6032 : void time_domain_FEC_HQ(
6033 : Decoder_State *st, /* i : Decoder State */
6034 : float *wtda_audio, /* i : input */
6035 : float *out, /* o : output audio */
6036 : const float mean_en_high, /* i : transient flag */
6037 : const int16_t output_frame /* i : Frame size */
6038 : );
6039 :
6040 : void save_synthesis_hq_fec(
6041 : Decoder_State *st, /* i/o: decoder state structure */
6042 : const float *output, /* i : decoded synthesis */
6043 : const int16_t output_frame, /* i : decoded synthesis */
6044 : CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */
6045 : );
6046 :
6047 : void Next_good_after_burst_erasures(
6048 : const float *ImdctOut, /* i : input */
6049 : float *auOut, /* o : output audio */
6050 : float *OldauOut, /* i/o: audio from previous frame */
6051 : const int16_t ol_size /* i : overlap size */
6052 : );
6053 :
6054 : void update_average_rate(
6055 : SC_VBR_ENC_HANDLE hSC_VBR, /* i/o: SC-VBR state structure */
6056 : const int32_t core_brate /* i : core bitrate */
6057 : );
6058 :
6059 : void reset_preecho_dec(
6060 : HQ_DEC_HANDLE hHQ_core /* i/o: HQ decoder handle */
6061 : );
6062 :
6063 : void preecho_sb(
6064 : const int32_t core_brate, /* i : core bitrate */
6065 : const float wtda_audio[], /* i : imdct signal */
6066 : float *rec_sig, /* i : reconstructed signal, output of the imdct transform */
6067 : const int16_t framelength, /* i : frame length */
6068 : float *memfilt_lb, /* i/o: memory */
6069 : float *mean_prev_hb, /* i/o: memory */
6070 : float *smoothmem, /* i/o: memory */
6071 : float *mean_prev, /* i/o: memory */
6072 : float *mean_prev_nc, /* i/o: memory */
6073 : float *wmold_hb, /* i/o: memory */
6074 : int16_t *prevflag, /* i/o: flag */
6075 : int16_t *pastpre, /* i/o: flag */
6076 : const int16_t bwidth /* i : audio bandwidth */
6077 : );
6078 :
6079 : void hq2_core_configure(
6080 : const int16_t frame_length, /* i : frame length */
6081 : const int16_t num_bits, /* i : number of bits */
6082 : const int16_t is_transient, /* i : transient flag */
6083 : int16_t *bands,
6084 : int16_t *length,
6085 : int16_t band_width[],
6086 : int16_t band_start[],
6087 : int16_t band_end[],
6088 : Word32 *L_qint, /* o : Q29 */
6089 : Word16 *eref_fx, /* o : Q10 */
6090 : Word16 *bit_alloc_weight_fx, /* o : Q13 */
6091 : int16_t *gqlevs,
6092 : int16_t *Ngq,
6093 : int16_t *p2a_bands,
6094 : float *p2a_th,
6095 : float *pd_thresh,
6096 : float *ld_slope,
6097 : float *ni_coef,
6098 : float *ni_pd_th,
6099 : int32_t bwe_br );
6100 :
6101 : void hq_lr_enc(
6102 : Encoder_State *st, /* i/o: encoder state structure */
6103 : float t_audio[], /* i/o: transform-domain coefs. */
6104 : const int16_t inner_frame, /* i : inner frame length */
6105 : int16_t *num_bits, /* i/o: number of available bits */
6106 : const int16_t is_transient /* i : transient flag */
6107 : );
6108 :
6109 : void hq_lr_dec(
6110 : Decoder_State *st, /* i/o: decoder state structure */
6111 : float yout[], /* o : transform-domain output coefs. */
6112 : const int16_t inner_frame, /* i : inner frame length */
6113 : int16_t num_bits, /* i : number of available bits */
6114 : int16_t *is_transient /* o : transient flag */
6115 : );
6116 :
6117 : void hq2_bit_alloc(
6118 : const float band_energy[], /* i : band energy of each subband */
6119 : const int16_t bands, /* i : total number of subbands in a frame */
6120 : Word32 L_Rk[], /* i/o: Bit allocation/Adjusted bit alloc. */
6121 : int16_t *bit_budget, /* i/o: bit bugdet */
6122 : int16_t *p2a_flags, /* i : HF tonal indicator */
6123 : const Word16 weight_fx, /* i : weight (Q13) */
6124 : const int16_t band_width[], /* i : Sub band bandwidth */
6125 : const int16_t num_bits, /* i : available bits */
6126 : const int16_t hqswb_clas, /* i : HQ2 class information */
6127 : const int16_t bwidth, /* i : input bandwidth */
6128 : const int16_t is_transient /* i : indicator HQ_TRANSIENT or not */
6129 : );
6130 :
6131 : void hq2_noise_inject(
6132 : float y2hat[],
6133 : const int16_t band_start[],
6134 : const int16_t band_end[],
6135 : const int16_t band_width[],
6136 : float Ep[],
6137 : float Rk[],
6138 : const int16_t npulses[],
6139 : int16_t ni_seed,
6140 : const int16_t bands,
6141 : const int16_t ni_start_band,
6142 : const int16_t bw_low,
6143 : const int16_t bw_high,
6144 : const float enerL,
6145 : const float enerH,
6146 : float last_ni_gain[],
6147 : float last_env[],
6148 : int16_t *last_max_pos_pulse,
6149 : int16_t *p2a_flags,
6150 : int16_t p2a_bands,
6151 : const int16_t hqswb_clas,
6152 : const int16_t bwidth,
6153 : const int32_t bwe_br );
6154 :
6155 : void mdct_spectrum_denorm(
6156 : const int32_t inp_vector[],
6157 : float y2[],
6158 : const int16_t band_start[],
6159 : const int16_t band_end[],
6160 : const int16_t band_width[],
6161 : const float band_energy[],
6162 : const int16_t npulses[],
6163 : const int16_t bands,
6164 : const float ld_slope,
6165 : const float pd_thresh );
6166 :
6167 : void reverse_transient_frame_energies(
6168 : float band_energy[], /* o : band energies */
6169 : const int16_t bands /* i : number of bands */
6170 : );
6171 :
6172 : int16_t peak_vq_enc(
6173 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
6174 : const int16_t bwidth, /* i : audio bandwidth */
6175 : #ifdef DEBUGGING
6176 : const int16_t idchan, /* i : channel ID */
6177 : #endif
6178 : const float *coefs, /* i : Input coefficient vector */
6179 : float *coefs_out, /* o : Quantized output vector */
6180 : const int32_t core_brate, /* i : Core bitrate */
6181 : const int16_t num_bits, /* i : Number of bits for HVQ */
6182 : const int16_t vq_peaks, /* i : Number of identified peaks */
6183 : const int16_t *ynrm, /* i : Envelope coefficients */
6184 : int16_t *R, /* i/o: Bit allocation/updated bit allocation */
6185 : int16_t *vq_peak_idx, /* i : Peak index vector */
6186 : float *nf_gains /* i : Estimated noise floor gains */
6187 : );
6188 :
6189 : void hvq_dec(
6190 : Decoder_State *st, /* i/o: decoder state structure */
6191 : const int16_t num_bits, /* i : Number of available bits */
6192 : const int32_t core_brate, /* i : Core bitrate */
6193 : const int16_t *ynrm, /* i : Envelope coefficients */
6194 : int16_t *R, /* i/o: Bit allocation/updated bit allocation */
6195 : float *noise_level, /* o : Noise level */
6196 : int16_t *peak_idx, /* o : Peak position vector */
6197 : int16_t *Npeaks, /* o : Total number of peaks */
6198 : float *coefsq_norm, /* o : Output vector */
6199 : const int16_t core /* i : Core */
6200 : );
6201 :
6202 : void hq_configure_bfi(
6203 : int16_t *nb_sfm, /* o : Number of sub bands */
6204 : int16_t *num_Sb, /* o : Number of FEC sub bands ? */
6205 : int16_t *num_bands_p, /* o : FEC sub bands */
6206 : const int16_t **sfmsize, /* o : Subband bandwidths */
6207 : const int16_t **sfm_start, /* o : Subband start coefficients */
6208 : const int16_t **sfm_end /* o : Subband end coefficients */
6209 : );
6210 :
6211 : void swb_bwe_enc_lr(
6212 : Encoder_State *st, /* i/o: encoder state structure */
6213 : const float m_core[], /* i : core synthesis (MDCT) */
6214 : const float m_orig[], /* i/o: scaled orig signal (MDCT) */
6215 : float m[], /* o : output, SWB part (MDCT) */
6216 : const int32_t total_brate, /* i : total bitrate for selecting subband pattern */
6217 : int16_t BANDS,
6218 : int16_t *band_start,
6219 : int16_t *band_end,
6220 : float *band_energy,
6221 : int16_t *p2a_flags,
6222 : const int16_t hqswb_clas,
6223 : int16_t lowlength,
6224 : int16_t highlength,
6225 : int16_t *prev_frm_index,
6226 : const int16_t har_bands,
6227 : int16_t *prev_frm_hfe2,
6228 : int16_t *prev_stab_hfe2,
6229 : int16_t band_width[],
6230 : const float y2_ni[],
6231 : int16_t *ni_seed );
6232 :
6233 : void swb_bwe_dec_lr(
6234 : Decoder_State *st, /* i/o: decoder state structure */
6235 : const float m_core[], /* i : lowband synthesis */
6236 : float m[], /* o : highband synthesis with lowband zeroed */
6237 : const int32_t total_brate, /* i : total bitrate for selecting subband pattern */
6238 : int16_t BANDS,
6239 : int16_t *band_start,
6240 : int16_t *band_end,
6241 : float *band_energy,
6242 : int16_t *p2a_flags,
6243 : const int16_t hqswb_clas,
6244 : int16_t lowlength,
6245 : int16_t highlength,
6246 : const int16_t har_bands,
6247 : int16_t *prev_frm_hfe2,
6248 : int16_t *prev_stab_hfe2,
6249 : int16_t band_width[],
6250 : const float y2_ni[],
6251 : int16_t *ni_seed );
6252 :
6253 : int16_t get_usebit_npswb(
6254 : const int16_t hqswb_clas );
6255 :
6256 : void GetPredictedSignal(
6257 : const float *predBuf, /* i : prediction buffer */
6258 : float *outBuf, /* o : output buffer */
6259 : const int16_t lag, /* i : prediction buffer offset */
6260 : const int16_t fLen, /* i : length of loop (output) */
6261 : const float gain /* i : gain to be applied */
6262 : );
6263 :
6264 : void convert_lagIndices_pls2smp(
6265 : int16_t lagIndices_in[],
6266 : int16_t nBands_search,
6267 : int16_t lagIndices_out[],
6268 : const float sspectra[],
6269 : const int16_t sbWidth[],
6270 : const int16_t fLenLow );
6271 :
6272 : void FindNBiggest2_simple(
6273 : const float *inBuf, /* i : input buffer (searched) */
6274 : GainItem *g, /* o : N biggest components found */
6275 : const int16_t nIdx, /* i : search length */
6276 : int16_t *n, /* i : number of components searched (N biggest) */
6277 : const int16_t N_NBIGGESTSEARCH );
6278 :
6279 : void updat_prev_frm(
6280 : float y2[],
6281 : float t_audio[],
6282 : const int32_t bwe_br,
6283 : const int16_t length,
6284 : const int16_t inner_frame,
6285 : const int16_t bands,
6286 : const int16_t bwidth,
6287 : const int16_t is_transient,
6288 : const int16_t hqswb_clas,
6289 : int16_t *prev_hqswb_clas,
6290 : int16_t *prev_SWB_peak_pos,
6291 : int16_t prev_SWB_peak_pos_tmp[],
6292 : int16_t *prev_frm_hfe2,
6293 : int16_t *prev_stab_hfe2,
6294 : const int16_t bws_cnt );
6295 :
6296 : void hf_parinitiz(
6297 : const int32_t total_brate,
6298 : const int16_t hqswb_clas,
6299 : int16_t lowlength,
6300 : int16_t highlength,
6301 : int16_t wBands[],
6302 : const int16_t **subband_search_offset,
6303 : const int16_t **subband_offsets,
6304 : int16_t *nBands,
6305 : int16_t *nBands_search,
6306 : int16_t *swb_lowband,
6307 : int16_t *swb_highband );
6308 :
6309 : float spectrumsmooth_noiseton(
6310 : float spectra[],
6311 : const float spectra_ni[],
6312 : float sspectra[],
6313 : float sspectra_diff[],
6314 : float sspectra_ni[],
6315 : const int16_t fLenLow,
6316 : int16_t *ni_seed );
6317 :
6318 : void noiseinj_hf(
6319 : float xSynth_har[],
6320 : const float th_g[],
6321 : const float band_energy[],
6322 : float *prev_En_sb,
6323 : const int16_t p2a_flags[],
6324 : const int16_t BANDS,
6325 : const int16_t band_start[],
6326 : const int16_t band_end[],
6327 : const int16_t fLenLow );
6328 :
6329 : void noise_extr_corcod(
6330 : float spectra[],
6331 : const float spectra_ni[],
6332 : float sspectra[],
6333 : float sspectra_diff[],
6334 : float sspectra_ni[],
6335 : const int16_t fLenLow,
6336 : int16_t prev_hqswb_clas,
6337 : float *prev_ni_ratio );
6338 :
6339 : void genhf_noise(
6340 : float noise_flr[],
6341 : float xSynth_har[],
6342 : float *predBuf,
6343 : int16_t bands, /* i : total number of subbands in a frame */
6344 : int16_t harmonic_band, /* i : Number of LF harmonic frames */
6345 : int16_t har_freq_est2,
6346 : int16_t pos_max_hfe2,
6347 : int16_t *pul_res,
6348 : GainItem pk_sf[],
6349 : const int16_t fLenLow,
6350 : const int16_t fLenHigh,
6351 : const int16_t sbWidth[],
6352 : const int16_t lagIndices[],
6353 : const int16_t subband_offsets[],
6354 : const int16_t subband_search_offset[] );
6355 :
6356 : void ton_ene_est(
6357 : float xSynth_har[],
6358 : float be_tonal[],
6359 : float band_energy[],
6360 : int16_t band_start[],
6361 : int16_t band_end[],
6362 : int16_t band_width[],
6363 : const int16_t fLenLow,
6364 : const int16_t fLenHigh,
6365 : int16_t bands,
6366 : int16_t har_bands,
6367 : float ni_lvl,
6368 : GainItem pk_sf[],
6369 : int16_t *pul_res );
6370 :
6371 : void Gettonl_scalfact(
6372 : float *outBuf, /* o : synthesized spectrum */
6373 : const float *codbuf, /* i : core coder */
6374 : const int16_t fLenLow, /* i : lowband length */
6375 : const int16_t fLenHigh, /* i : highband length */
6376 : int16_t harmonic_band, /* i : Number of LF harmonic frames */
6377 : int16_t bands, /* i : total number of subbands in a frame */
6378 : float *band_energy, /* i : band energy of each subband */
6379 : int16_t *band_start, /* i : subband start indices */
6380 : int16_t *band_end, /* i : subband end indices */
6381 : const int16_t p2aflags[],
6382 : float be_tonal[],
6383 : GainItem *pk_sf,
6384 : int16_t *pul_res );
6385 :
6386 : void SpectrumSmoothing(
6387 : float *inBuf,
6388 : float *outBuf,
6389 : const int16_t fLen,
6390 : const float th_cut );
6391 :
6392 : void hq2_bit_alloc_har(
6393 : float *y, /* i : band energy of sub-vectors */
6394 : int16_t B, /* i : number of available bits */
6395 : int16_t N, /* i : number of sub-vectors */
6396 : Word32 *L_Rsubband,
6397 : int16_t p2a_bands,
6398 : int32_t core_brate, /* i : core bitrate */
6399 : int16_t p2a_flags[],
6400 : int16_t band_width[] );
6401 :
6402 : void GetSynthesizedSpecThinOut(
6403 : const float *predBuf,
6404 : float *outBuf,
6405 : const int16_t nBands,
6406 : const int16_t *sbWidth,
6407 : const int16_t *lagIndices,
6408 : const float *lagGains,
6409 : const int16_t predBufLen );
6410 :
6411 : void return_bits_normal2(
6412 : int16_t *bit_budget,
6413 : const int16_t p2a_flags[],
6414 : const int16_t bands,
6415 : const int16_t bits_lagIndices[] );
6416 :
6417 : void GetlagGains(
6418 : const float *predBuf,
6419 : const float *band_energy,
6420 : const int16_t nBands,
6421 : const int16_t *sbWidth,
6422 : const int16_t *lagIndices,
6423 : const int16_t predBufLen,
6424 : float *lagGains );
6425 :
6426 : void preset_hq2_swb(
6427 : const int16_t hqswb_clas,
6428 : const int16_t band_end[],
6429 : int16_t *har_bands,
6430 : int16_t p2a_bands,
6431 : const int16_t length,
6432 : const int16_t bands,
6433 : int16_t *lowlength,
6434 : int16_t *highlength,
6435 : float m[] );
6436 :
6437 : void post_hq2_swb(
6438 : const float m[],
6439 : const int16_t lowlength,
6440 : const int16_t highlength,
6441 : const int16_t hqswb_clas,
6442 : const int16_t har_bands,
6443 : const int16_t bands,
6444 : const int16_t p2a_flags[],
6445 : const int16_t band_start[],
6446 : const int16_t band_end[],
6447 : float y2[],
6448 : int16_t npulses[] );
6449 :
6450 : void har_denorm_pulcnt(
6451 : float spectra[], /* i/o: MDCT domain spectrum */
6452 : const int16_t band_start[], /* i : Number subbands/Frame */
6453 : const int16_t band_end[], /* i : Band Start of each SB */
6454 : const float band_energy[], /* i : Band end of each SB */
6455 : const int16_t band_width[],
6456 : const int16_t npulses[],
6457 : const int16_t har_bands /* i : No. of harmonic bands */
6458 : );
6459 :
6460 : int16_t har_est(
6461 : float spectra[],
6462 : const int16_t N,
6463 : int16_t *har_freq_est1,
6464 : int16_t *har_freq_est2,
6465 : int16_t *flag_dis,
6466 : int16_t *prev_frm_hfe2,
6467 : const int16_t subband_search_offset[],
6468 : const int16_t sbWidth[],
6469 : int16_t *prev_stab_hfe2 );
6470 :
6471 : void spt_shorten_domain_pre(
6472 : const int16_t band_start[],
6473 : const int16_t band_end[],
6474 : const int16_t prev_SWB_peak_pos[],
6475 : const int16_t BANDS,
6476 : const int32_t bwe_br,
6477 : int16_t new_band_start[],
6478 : int16_t new_band_end[],
6479 : int16_t new_band_width[] );
6480 :
6481 : void spt_shorten_domain_band_save(
6482 : const int16_t bands,
6483 : const int16_t band_start[],
6484 : const int16_t band_end[],
6485 : const int16_t band_width[],
6486 : int16_t org_band_start[],
6487 : int16_t org_band_end[],
6488 : int16_t org_band_width[] );
6489 :
6490 : void spt_shorten_domain_band_restore(
6491 : const int16_t bands,
6492 : int16_t band_start[],
6493 : int16_t band_end[],
6494 : int16_t band_width[],
6495 : const int16_t org_band_start[],
6496 : const int16_t org_band_end[],
6497 : const int16_t org_band_width[] );
6498 :
6499 : void spt_swb_peakpos_tmp_save(
6500 : const float y2[],
6501 : const int16_t bands,
6502 : const int16_t band_start[],
6503 : const int16_t band_end[],
6504 : int16_t prev_SWB_peak_pos_tmp[] );
6505 :
6506 : void hq_ecu(
6507 : const float *prevsynth, /* i : buffer of previously synthesized signal */
6508 : float *ecu_rec, /* o : reconstructed frame in tda domain */
6509 : int16_t *time_offs, /* i/o: Sample offset for consecutive frame losses*/
6510 : float *X_sav, /* i/o: Stored spectrum of prototype frame */
6511 : int16_t *num_p, /* i/o: Number of identified peaks */
6512 : int16_t *plocs, /* i/o: Peak locations */
6513 : float *plocsi, /* i/o: Interpolated peak locations */
6514 : const float env_stab, /* i : Envelope stability parameter */
6515 : int16_t *last_fec, /* i/o: Flag for usage of pitch dependent ECU */
6516 : const int16_t ph_ecu_HqVoicing, /* i : HQ Voicing flag */
6517 : int16_t *ph_ecu_active, /* i : Phase ECU active flag */
6518 : float *gapsynth, /* o : Gap synthesis */
6519 : const int16_t prev_bfi, /* i : indicating burst frame error */
6520 : const int16_t old_is_transient[2], /* i : flags indicating previous transient frames*/
6521 : float *mag_chg_1st, /* i/o: per band magnitude modifier for transients*/
6522 : float Xavg[LGW_MAX], /* i/o: Frequency group average gain to fade to */
6523 : float *beta_mute, /* o : Factor for long-term mute */
6524 : const int16_t output_frame, /* i : frame length */
6525 : Decoder_State *st /* i/o: decoder state structure */
6526 : );
6527 :
6528 : void peakfinder(
6529 : const float *x0, /* i : vector from which the maxima will be found */
6530 : const int16_t len0, /* i : length of input vector */
6531 : int16_t *plocs, /* o : the indicies of the identified peaks in x0 */
6532 : int16_t *cInd, /* o : number of identified peaks */
6533 : const float sel, /* i : The amount above surrounding data for a peak to be identified */
6534 : const int16_t endpoints /* i : Flag to include endpoints in peak search */
6535 : );
6536 :
6537 : /*! r: interpolated maximum position */
6538 : float imax_pos(
6539 : const float *y /* i : Input vector for peak interpolation */
6540 : );
6541 :
6542 :
6543 : void fft3(
6544 : const float X[], /* i : input frame */
6545 : float Y[], /* o : DFT of input frame */
6546 : const int16_t n /* i : block length (must be radix 3) */
6547 : );
6548 :
6549 : void ifft3(
6550 : const float X[], /* i : input frame */
6551 : float Y[], /* o : iDFT of input frame */
6552 : const int16_t n /* i : block length (must be radix 3) */
6553 : );
6554 :
6555 : /*! r: updated estimate of background noise */
6556 : void minimumStatistics(
6557 : float *noiseLevelMemory, /* i/o: internal state */
6558 : int16_t *noiseLevelIndex, /* i/o: internal state */
6559 : int16_t *currLevelIndex, /* i/o: internal state (circular buffer) */
6560 : float *noiseEstimate, /* i/o: previous estimate of background noise */
6561 : float *lastFrameLevel, /* i/o: level of the last frame */
6562 : float currentFrameLevel, /* i : level of the current frame */
6563 : const float minLev, /* i : minimum level */
6564 : const int16_t buffSize /* i : buffer size */
6565 : );
6566 :
6567 : void E_LPC_int_lpc_tcx(
6568 : const float lsf_old[], /* i : LSFs from past frame */
6569 : const float lsf_new[], /* i : LSFs from present frame */
6570 : float a[] /* o : interpolated LP coefficients */
6571 : );
6572 :
6573 : int16_t E_GAIN_closed_loop_search(
6574 : float exc[],
6575 : float xn[],
6576 : float h[],
6577 : int16_t t0_min,
6578 : int16_t t0_min_frac,
6579 : int16_t t0_max,
6580 : int16_t t0_max_frac,
6581 : const int16_t t0_min_max_res,
6582 : int16_t *pit_frac,
6583 : int16_t *pit_res,
6584 : const int16_t pit_res_max,
6585 : const int16_t i_subfr,
6586 : const int16_t pit_min,
6587 : const int16_t pit_fr2,
6588 : const int16_t pit_fr1,
6589 : const int16_t L_subfr );
6590 :
6591 : void E_ACELP_toeplitz_mul(
6592 : const float R[],
6593 : const float c[],
6594 : float d[] );
6595 :
6596 : void acelp_pulsesign(
6597 : const float cn[],
6598 : float dn[],
6599 : float dn2[],
6600 : float sign[],
6601 : float vec[],
6602 : const float alp );
6603 :
6604 : void E_ACELP_4t(
6605 : float dn[],
6606 : float cn[],
6607 : float H[],
6608 : float R[],
6609 : const int16_t acelpautoc,
6610 : float code[],
6611 : const int16_t cdk_index,
6612 : int16_t _index[],
6613 : const int16_t L_frame,
6614 : const int16_t last_L_frame,
6615 : const int32_t total_brate,
6616 : const int16_t i_subfr,
6617 : const int16_t cmpl_flag );
6618 :
6619 : void E_ACELP_4tsearch(
6620 : float dn[],
6621 : const float cn[],
6622 : const float H[],
6623 : float code[],
6624 : PulseConfig *config,
6625 : int16_t ind[],
6626 : float y[] );
6627 :
6628 : void E_ACELP_4tsearchx(
6629 : float dn[],
6630 : const float cn[],
6631 : float Rw[],
6632 : float code[],
6633 : PulseConfig *config,
6634 : int16_t ind[] );
6635 :
6636 : int16_t E_ACELP_indexing(
6637 : float code[],
6638 : PulseConfig config,
6639 : const int16_t num_tracks,
6640 : int16_t prm[] );
6641 :
6642 : void acelp_findcandidates(
6643 : float dn2[],
6644 : int16_t dn2_pos[],
6645 : int16_t pos_max[],
6646 : const int16_t L_subfr,
6647 : const int16_t tracks );
6648 :
6649 : void E_ACELP_innovative_codebook(
6650 : const float *exc, /* i : pointer to the excitation frame */
6651 : const int16_t T0, /* i : integer pitch lag */
6652 : const int16_t T0_frac, /* i : fraction of lag */
6653 : const int16_t T0_res, /* i : pitch resolution */
6654 : const float pitch_gain, /* i : adaptive codebook gain */
6655 : const float tilt_code, /* i : tilt factor */
6656 : ACELP_config *acelp_cfg, /* i/o: configuration of the ACELP */
6657 : const int16_t i_subfr, /* i : subframe index */
6658 : const float *Aq, /* i : quantized LPC coefficients */
6659 : const float *h1, /* i : impulse response of weighted synthesis filter */
6660 : const float *xn, /* i : Close-loop Pitch search target vector */
6661 : const float *cn, /* i : Innovative codebook search target vector */
6662 : const float *y1, /* i : zero-memory filtered adaptive excitation */
6663 : float *y2, /* o : zero-memory filtered algebraic excitation */
6664 : const int16_t acelpautoc, /* i : autocorrelation mode enabled */
6665 : int16_t **pt_indice, /* i/o: quantization indices pointer */
6666 : float *code, /* o : innovative codebook */
6667 : const int16_t L_frame, /* i : length of the frame */
6668 : const int16_t last_L_frame, /* i : length of the last frame */
6669 : const int32_t total_brate /* i : total bitrate */
6670 : );
6671 :
6672 : int16_t E_ACELP_code43bit(
6673 : const float code[],
6674 : uint32_t *ps,
6675 : int16_t *p,
6676 : uint16_t idxs[] );
6677 :
6678 : void fcb_pulse_track_joint(
6679 : uint16_t *idxs,
6680 : const int16_t wordcnt,
6681 : uint32_t *index_n,
6682 : const int16_t *pulse_num,
6683 : const int16_t track_num );
6684 :
6685 : void D_ACELP_indexing(
6686 : float code[],
6687 : PulseConfig config,
6688 : const int16_t num_tracks,
6689 : int16_t prm[],
6690 : int16_t *BER_detect );
6691 :
6692 : void D_ACELP_decode_43bit(
6693 : uint16_t idxs[],
6694 : float code[],
6695 : int16_t *pulsestrack );
6696 :
6697 : void fcb_pulse_track_joint_decode(
6698 : uint16_t *idxs,
6699 : const int16_t wordcnt,
6700 : uint32_t *index_n,
6701 : const int16_t *pulse_num,
6702 : const int16_t track_num );
6703 :
6704 : void lag_wind(
6705 : float r[], /* i/o: autocorrelations */
6706 : const int16_t m, /* i : order of LP filter */
6707 : const int32_t sr_core, /* i : sampling rate */
6708 : const int16_t strength /* i : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG */
6709 : );
6710 :
6711 : void adapt_lag_wind(
6712 : float r[], /* i/o: autocorrelations */
6713 : const int16_t m, /* i : order of LP filter */
6714 : const int16_t Top, /* i : open loop pitch lags from curr. frame (or NULL if n/a) */
6715 : const float Tnc, /* i : open loop pitch gains from curr. frame (NULL if n/a) */
6716 : const int32_t sr_core /* i : core sampling rate */
6717 : );
6718 :
6719 : void hp20(
6720 : Float32 signal[],
6721 : const Word16 lg,
6722 : Float32 mem[],
6723 : const Word32 Fs );
6724 :
6725 : void ham_cos_window(
6726 : float *fh,
6727 : const int16_t n1,
6728 : const int16_t n2 );
6729 :
6730 : /*! r: noise dependent voicing correction */
6731 : float correlation_shift(
6732 : const float totalNoise /* i : noise estimate over all critical bands */
6733 : );
6734 :
6735 : void init_coder_ace_plus(
6736 : Encoder_State *st, /* i : Encoder state handle */
6737 : const int32_t last_total_brate, /* i : last total bitrate */
6738 : const int32_t igf_brate, /* i : IGF configuration bitrate */
6739 : const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
6740 : );
6741 :
6742 : void core_coder_reconfig(
6743 : Encoder_State *st, /* i/o: encoder state structure */
6744 : const int32_t last_total_brate /* i : last total bitrate */
6745 : );
6746 :
6747 : void core_coder_mode_switch(
6748 : Encoder_State *st, /* i/o: encoder state structure */
6749 : const int32_t last_total_brate, /* i : last bitrate */
6750 : const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
6751 : );
6752 :
6753 : void enc_acelp_tcx_main(
6754 : Encoder_State *st, /* i/o: encoder state structure */
6755 : const float new_samples[], /* i : new samples */
6756 : float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
6757 : const float lsp_new[M], /* i : LSPs at the end of the frame */
6758 : const float lsp_mid[M], /* i : LSPs at the middle of the frame */
6759 : float bwe_exc_extended[], /* i/o: bandwidth extended excitation */
6760 : float *voice_factors, /* o : voicing factors */
6761 : float pitch_buf[], /* o : floating pitch for each subframe */
6762 : const int16_t vad_hover_flag /* i : VAD hangover flag */
6763 : );
6764 :
6765 : void getTCXMode(
6766 : Decoder_State *st, /* i/o: decoder memory state */
6767 : Decoder_State *st0, /* i : bitstream */
6768 : const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
6769 : );
6770 :
6771 : void getTCXWindowing(
6772 : const int16_t core, /* i : current frame mode */
6773 : const int16_t last_core, /* i : last frame mode */
6774 : const int16_t element_mode, /* i : element mode */
6775 : TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */
6776 : Decoder_State *st0 /* i : bitstream */
6777 : );
6778 :
6779 : void getLPCparam(
6780 : Decoder_State *st, /* i/o: decoder memory state */
6781 : int16_t param_lpc[], /* o : LTP parameters */
6782 : Decoder_State *st0, /* i : bitstream */
6783 : const int16_t ch, /* i : channel */
6784 : const int16_t sns_low_br_mode /* i : SNS low-bitrate mode */
6785 : );
6786 :
6787 : void getTCXparam(
6788 : Decoder_State *st, /* i/o: Decoder State handle */
6789 : Decoder_State *st0, /* i : bitstream */
6790 : CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */
6791 : int16_t param[], /* o : decoded parameters */
6792 : const int16_t bits_common, /* i : number of common bits */
6793 : const int16_t start_bit_pos, /* i : position of the start bit */
6794 : const int16_t *no_param_tns, /* i : number of TNS parameters per subframe */
6795 : int16_t p_param[2], /* o : pointer to parameters for next round of bs reading*/
6796 : int16_t nTnsBitsTCX10[2],
6797 : const int16_t pre_past_flag );
6798 :
6799 : void pitch_pred_linear_fit(
6800 : const int16_t nbLostCmpt, /* i : bfi counter */
6801 : const int16_t last_good, /* i : last classification type */
6802 : float *old_pitch_buf, /* i : pitch lag buffer */
6803 : float *old_fpitch, /* i/o: pitch used for initial ACB generation */
6804 : float *T0_out, /* o : estimated close loop pitch */
6805 : const int16_t pit_min, /* i : Minimum pitch lag */
6806 : const int16_t pit_max, /* i : Maximum pitch lag */
6807 : float *mem_pitch_gain, /* i : lag pitch gain [0] is the most recent subfr lag */
6808 : const int16_t limitation,
6809 : const int16_t plc_use_future_lag, /* i : number of subframes to predict */
6810 : int16_t *extrapolationFailed, /* o : flag if extrap decides not to change the pitch */
6811 : const int16_t nb_subfr /* i : number of ACELP subframes */
6812 : );
6813 :
6814 : void get_subframe_pitch(
6815 : const int16_t nSubframes, /* i : number of subframes */
6816 : float pitchStart, /* i : starting pitch lag (in subframe -1) */
6817 : float pitchEnd, /* i : ending pitch lag (in subframe nSubframes-1) */
6818 : float *pitchBuf /* o : interpolated pitch lag per subframe */
6819 : );
6820 :
6821 : void core_encode_openloop(
6822 : Encoder_State *st, /* i/o: encoder state structure */
6823 : const float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
6824 : const float lsp_new[M], /* i : LSPs at the end of the frame */
6825 : const float lsp_mid[M], /* i : LSPs at the middle of the frame */
6826 : float *pitch_buf, /* i/o: floating pitch values for each subfr*/
6827 : float *voice_factors, /* o : voicing factors */
6828 : float *ptr_bwe_exc, /* o : excitation for SWB TBE */
6829 : const int16_t vad_hover_flag /* i : VAD hangover flag */
6830 : );
6831 :
6832 : void core_acelp_tcx20_switching(
6833 : Encoder_State *st, /* i/o: encoder state structure */
6834 : float non_staX, /* i : unbound non-stationarity for sp/mu clas */
6835 : float *pitch_fr, /* i/o: fraction pitch values */
6836 : float *voicing_fr, /* i/o: fractional voicing values */
6837 : const float currTempFlatness, /* i : flatness */
6838 : const float lsp_mid[M], /* i : LSPs at the middle of the frame */
6839 : const float stab_fac /* i : LP filter stability */
6840 : );
6841 :
6842 : void core_encode_twodiv(
6843 : Encoder_State *st, /* i/o: coder memory state */
6844 : const float new_samples[], /* i : new samples */
6845 : float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
6846 : const int16_t vad_hover_flag /* i : VAD hangover flag */
6847 : );
6848 :
6849 : void core_encode_update(
6850 : Encoder_State *st /* i/o: encoder state structure */
6851 : );
6852 :
6853 : void core_encode_update_cng(
6854 : Encoder_State *st, /* i/o: encoder state structure */
6855 : float *timeDomainBuffer,
6856 : float *A,
6857 : const float Aw[] /* i : weighted A(z) unquant. for subframes*/
6858 : );
6859 :
6860 : void core_signal_analysis_high_bitrate(
6861 : const float *new_samples,
6862 : const int16_t T_op[3], /* i : open-loop pitch values for quantiz. */
6863 : float lsp_new[],
6864 : float lsp_mid[],
6865 : Encoder_State *st,
6866 : float *mdst_spectrum[2],
6867 : int16_t pTnsSize[],
6868 : int16_t pTnsBits[],
6869 : int16_t param_core[],
6870 : int16_t *ltpBits,
6871 : float *windowed_samples, /* i/o: backup of windowed time signal */
6872 : const int16_t L_frame,
6873 : const int16_t L_frameTCX,
6874 : const int16_t last_element_mode,
6875 : const int16_t vad_hover_flag /* i : VAD hangover flag */
6876 : );
6877 :
6878 : /*! r: codebook gain (adaptive or fixed) */
6879 : float get_gain(
6880 : const float x[], /* i : target signal */
6881 : const float y[], /* i : filtered codebook excitation */
6882 : const int16_t n, /* i : segment length */
6883 : float *en_y /* o : energy of y (sum of y[]^2, optional) */
6884 : );
6885 :
6886 : void encode_acelp_gains(
6887 : const float *code,
6888 : const int16_t gains_mode,
6889 : const float mean_ener_code,
6890 : const int16_t clip_gain,
6891 : ACELP_CbkCorr *g_corr,
6892 : float *gain_pit,
6893 : float *gain_code,
6894 : int16_t **pt_indice,
6895 : float *past_gcode,
6896 : float *gain_inov,
6897 : const int16_t L_subfr,
6898 : float *code2,
6899 : float *gain_code2,
6900 : const int16_t noisy_speech_flag );
6901 :
6902 : int16_t gain_enc_gacelp_uv(
6903 : const float *code, /* i : algebraic excitation */
6904 : const float *code2, /* i : gaussian excitation */
6905 : const int16_t lcode, /* i : Subframe size */
6906 : const float mean_ener, /* i : quantized mean energy of the frame */
6907 : float *gain_pit, /* o : quantized pitch gain */
6908 : float *gain_code, /* o : quantized codebook gain */
6909 : float *gain_code2, /* o : quantized codebook gain */
6910 : ACELP_CbkCorr *coeff, /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
6911 : float *past_gcode, /* i/o: past gain of code */
6912 : float *gain_inov, /* o : unscaled innovation gain */
6913 : const int16_t noisy_speech_flag /* i : noisy speech flag */
6914 : );
6915 :
6916 : int16_t Mode2_gain_enc_mless(
6917 : const float *code, /* i : algebraic excitation */
6918 : const int16_t lcode, /* i : Subframe size */
6919 : float *gain_pit, /* o : quantized pitch gain */
6920 : float *gain_code, /* o : quantized codebook gain */
6921 : ACELP_CbkCorr *coeff, /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
6922 : const float mean_ener, /* i : mean_ener defined in open-loop (3 bits) */
6923 : const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
6924 : float *past_gcode, /* i/o: past gain of code */
6925 : float *gain_inov, /* o : unscaled innovation gain */
6926 : const int16_t coder_type /* i : type of coder */
6927 : );
6928 :
6929 : void decode_acelp_gains(
6930 : const float *code,
6931 : const int16_t gains_mode,
6932 : const float mean_ener_code,
6933 : float *gain_pit,
6934 : float *gain_code,
6935 : int16_t **pt_indice,
6936 : float *past_gpit,
6937 : float *past_gcode,
6938 : float *gain_inov,
6939 : const int16_t L_subfr,
6940 : float *code2,
6941 : float *gain_code2 );
6942 :
6943 : void gain_dec_gacelp_uv(
6944 : int16_t index, /* i/o: Quantization index vector */
6945 : const float *code, /* i : algebraic code excitation */
6946 : const float *code2, /* i : algebraic code excitation */
6947 : const float mean_ener, /* i : mean energy */
6948 : const int16_t lcode, /* i : Subframe size */
6949 : float *gain_pit, /* o : Quantized pitch gain */
6950 : float *gain_code, /* o : Quantized codebook gain */
6951 : float *gain_code2, /* o : Quantized codebook gain */
6952 : float *past_gpit, /* i/o: past gain of pitch */
6953 : float *past_gcode, /* i/o: past energy of code */
6954 : float *gain_inov /* o : unscaled innovation gain */
6955 : );
6956 :
6957 : void Mode2_pit_encode(
6958 : const int16_t coder_type, /* i : coding model */
6959 : const int16_t i_subfr, /* i : subframe index */
6960 : int16_t **pt_indice, /* i/o: quantization indices pointer */
6961 : float *exc, /* i/o: pointer to excitation signal frame */
6962 : const int16_t *T_op, /* i : open loop pitch estimates in current frame */
6963 : int16_t *T0_min, /* i/o: lower limit for close-loop search */
6964 : int16_t *T0_min_frac, /* i/o: lower limit for close-loop search */
6965 : int16_t *T0_max, /* i/o: higher limit for close-loop search */
6966 : int16_t *T0_max_frac, /* i/o: higher limit for close-loop search */
6967 : int16_t *T0, /* i/o: close loop integer pitch */
6968 : int16_t *T0_frac, /* i/o: close loop fractional part of the pitch */
6969 : int16_t *T0_res, /* i/o: close loop pitch resolution */
6970 : float *h1, /* i : weighted filter impulse response */
6971 : float *xn, /* i : target vector */
6972 : const int16_t pit_min,
6973 : const int16_t pit_fr1,
6974 : const int16_t pit_fr1b,
6975 : const int16_t pit_fr2,
6976 : const int16_t pit_max,
6977 : const int16_t pit_res_max );
6978 :
6979 : void limit_T0_voiced(
6980 : const int16_t nbits,
6981 : const int16_t res,
6982 : const int16_t T0, /* i : rough pitch estimate around which the search is done */
6983 : const int16_t T0_frac, /* i : pitch estimate fractional part */
6984 : const int16_t T0_res, /* i : pitch resolution */
6985 : int16_t *T0_min, /* o : lower pitch limit */
6986 : int16_t *T0_min_frac, /* o : lower pitch limit */
6987 : int16_t *T0_max, /* o : higher pitch limit */
6988 : int16_t *T0_max_frac, /* o : higher pitch limit */
6989 : const int16_t pit_min, /* i : Minimum pitch lag */
6990 : const int16_t pit_max /* i : Maximum pitch lag */
6991 : );
6992 :
6993 : void Mode2_abs_pit_enc(
6994 : const int16_t T0, /* i : integer pitch lag */
6995 : const int16_t T0_frac, /* i : pitch fraction */
6996 : int16_t **pt_indice, /* i/o: pointer to Vector of Q indexes */
6997 : const int16_t pit_min,
6998 : const int16_t pit_fr1,
6999 : const int16_t pit_fr2,
7000 : const int16_t pit_res_max );
7001 :
7002 : void Mode2_delta_pit_enc(
7003 : const int16_t T0, /* i : integer pitch lag */
7004 : const int16_t T0_frac, /* i : pitch fraction */
7005 : const int16_t T0_res, /* i : pitch resolution */
7006 : const int16_t T0_min, /* i : delta search min */
7007 : const int16_t T0_min_frac, /* i : delta search min */
7008 : int16_t **pt_indice /* o : pointer to Vector of Q indexes */
7009 : );
7010 :
7011 : /*! r: floating pitch value */
7012 : float Mode2_pit_decode(
7013 : const int16_t coder_type, /* i : coding model */
7014 : const int16_t i_subfr, /* i : subframe index */
7015 : const int16_t L_subfr, /* i : sub-frame length */
7016 : int16_t **pt_indice, /* i/o: quantization indices pointer */
7017 : int16_t *T0, /* o : close loop integer pitch */
7018 : int16_t *T0_frac, /* o : close loop fractional part of the pitch */
7019 : int16_t *T0_res, /* i/o: pitch resolution */
7020 : int16_t *T0_min, /* i/o: lower limit for close-loop search */
7021 : int16_t *T0_min_frac, /* i/o: lower limit for close-loop search */
7022 : int16_t *T0_max, /* i/o: higher limit for close-loop search */
7023 : int16_t *T0_max_frac, /* i/o: higher limit for close-loop search */
7024 : const int16_t pit_min,
7025 : const int16_t pit_fr1,
7026 : const int16_t pit_fr1b,
7027 : const int16_t pit_fr2,
7028 : const int16_t pit_max,
7029 : const int16_t pit_res_max );
7030 :
7031 : void Mode2_abs_pit_dec(
7032 : int16_t *T0, /* o : integer pitch lag */
7033 : int16_t *T0_frac, /* o : pitch fraction */
7034 : int16_t *T0_res, /* o : pitch resolution */
7035 : int16_t **pt_indice, /* i/o: pointer to Vector of Q indexes */
7036 : const int16_t pit_min,
7037 : const int16_t pit_fr1,
7038 : const int16_t pit_fr2,
7039 : const int16_t pit_res_max );
7040 :
7041 : void Mode2_delta_pit_dec(
7042 : int16_t *T0, /* o : integer pitch lag */
7043 : int16_t *T0_frac, /* o : pitch fraction */
7044 : int16_t T0_res, /* i : pitch resolution */
7045 : int16_t *T0_min, /* i : delta search min */
7046 : int16_t *T0_min_frac, /* i : delta search min */
7047 : int16_t **pt_indice /* i/o: pointer to Vector of Q indexes */
7048 : );
7049 :
7050 : void formant_post_filt(
7051 : PFSTAT_HANDLE hPFstat, /* i/o: Post filter related memories */
7052 : float *synth_in, /* i : 12k8 synthesis */
7053 : const float *Aq, /* i : LP filter coefficient */
7054 : float *synth_out, /* i/o: input signal */
7055 : const int16_t L_frame, /* i : frame length */
7056 : const int16_t L_subfr, /* i : sub-frame length */
7057 : const float lp_noise, /* i : background noise energy */
7058 : const int32_t brate, /* i : bitrate */
7059 : const int16_t off_flag /* i : Off flag */
7060 : );
7061 :
7062 : void qlpc_avq(
7063 : const float *lsp, /* i : Input LSF vectors */
7064 : const float *lspmid, /* i : Input mid-LSF vectors */
7065 : float *lsf_q, /* o : Quantized LFS vectors */
7066 : float *lsfmid_q, /* o : Quantized mid-LFS vectors */
7067 : int16_t *index, /* o : Quantization indices */
7068 : int16_t *nb_indices, /* o : Number of quantization indices */
7069 : int16_t *nbbits, /* o : Number of quantization bits */
7070 : const int16_t core, /* i : core */
7071 : const int32_t sr_core /* i : internal sampling rate */
7072 : );
7073 :
7074 : int16_t encode_lpc_avq(
7075 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
7076 : const int16_t numlpc, /* i : Number of sets of lpc */
7077 : const int16_t *param_lpc, /* i : lpc parameters */
7078 : const int16_t core, /* i : core */
7079 : const int16_t element_mode /* i : element mode */
7080 : );
7081 :
7082 : int16_t dlpc_avq(
7083 : int16_t *index, /* i : Quantization indices */
7084 : float *LSF_Q, /* o : Quantized LSF vectors */
7085 : const int16_t numlpc, /* i : Number of sets of lpc */
7086 : const int32_t sr_core /* i : internal sampling rate */
7087 : );
7088 :
7089 : int16_t decode_lpc_avq(
7090 : Decoder_State *st, /* i/o: decoder state structure */
7091 : const int16_t numlpc, /* i : Number of sets of lpc */
7092 : int16_t *param_lpc, /* o : lpc parameters */
7093 : const int16_t ch, /* i : channel */
7094 : const int16_t element_mode, /* i : element mode */
7095 : const int16_t sns_low_br_mode /* i : SNS low-bitrate mode */
7096 : );
7097 :
7098 : /*! r: codebook index */
7099 : int16_t vlpc_1st_cod(
7100 : const float *lsf, /* i : vector to quantize */
7101 : float *lsfq, /* i/o: i:prediction o:quantized lsf */
7102 : const int32_t sr_core, /* i : internal sampling rate */
7103 : float *w /* o : lsf weights */
7104 : );
7105 :
7106 : /*! r: number of allocated bits */
7107 : int16_t vlpc_2st_cod(
7108 : const float *lsf, /* i : normalized vector to quantize */
7109 : float *lsfq, /* i/o: i:1st stage o:1st+2nd stage */
7110 : int16_t *indx, /* o : index[] (4 bits per words) */
7111 : const int16_t mode, /* i : 0=abs, >0=rel */
7112 : const int32_t sr_core /* i : internal sampling rate */
7113 : );
7114 :
7115 : void vlpc_2st_dec(
7116 : float *lsfq, /* i/o: i:1st stage o:1st+2nd stage */
7117 : int16_t *indx, /* i : index[] (4 bits per words) */
7118 : const int16_t mode, /* i : 0=abs, >0=rel */
7119 : const int32_t sr_core /* i : internal sampling rate */
7120 : );
7121 :
7122 : void lsf_weight_2st(
7123 : const float *lsfq,
7124 : float *w,
7125 : const int16_t mode,
7126 : const int32_t sr_core );
7127 :
7128 : void mdct_window_sine(
7129 : float *window,
7130 : const int32_t Fs,
7131 : const int16_t n,
7132 : const int16_t window_type,
7133 : const int16_t element_mode );
7134 :
7135 : void mdct_window_aldo(
7136 : float *window1,
7137 : float *window2,
7138 : const int16_t n );
7139 :
7140 : void AVQ_cod_lpc(
7141 : const float nvec[], /* i : vector to quantize */
7142 : int16_t nvecq[], /* o : quantized normalized vector (assuming the bit budget is enough) */
7143 : int16_t *indx, /* o : index[] (4 bits per words) */
7144 : const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */
7145 : );
7146 :
7147 : void AVQ_dec_lpc(
7148 : const int16_t indx[], /* i : index[] (4 bits per words) */
7149 : int16_t nvecq[], /* o : vector quantized */
7150 : const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */
7151 : );
7152 :
7153 : void vlpc_1st_dec(
7154 : const int16_t index, /* i : codebook index */
7155 : float *lsfq, /* i/o: i:prediction o:quantized lsf */
7156 : const int32_t sr_core );
7157 :
7158 : void WindowSignal(
7159 : TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
7160 : int16_t offset, /* i : left folding point offset relative to the input signal pointer */
7161 : const int16_t left_overlap_mode, /* i : overlap mode of left window half */
7162 : const int16_t right_overlap_mode, /* i : overlap mode of right window half */
7163 : int16_t *left_overlap_length, /* o : TCX window left overlap length */
7164 : int16_t *right_overlap_length, /* o : TCX window right overlap length */
7165 : const float in[], /* i : input signal */
7166 : int16_t *L_frame, /* i/o: frame length */
7167 : float out[], /* o : output windowed signal */
7168 : const int16_t truncate_aldo, /* i : nonzero to truncate long ALDO slope */
7169 : const int16_t fullband /* i : fullband flag */
7170 : );
7171 :
7172 : void HBAutocorrelation(
7173 : TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
7174 : const int16_t left_mode, /* i : overlap mode of left window half */
7175 : const int16_t right_mode, /* i : overlap mode of right window half */
7176 : float speech[], /* i : speech */
7177 : int16_t L_frame_glob, /* i/o: frame length */
7178 : float *r /* o : autocorrelations vector */
7179 : );
7180 :
7181 : void TNSAnalysis(
7182 : TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
7183 : const int16_t L_frame, /* i : frame length */
7184 : int16_t L_spec, /* i : length of the spectrum */
7185 : const int16_t transform_type, /* i : transform type for the frame/subframe - TCX20 | TCX10 | TCX 5 (meaning 2 x TCX 5) */
7186 : const int16_t isAfterACELP, /* i : Flag indicating if the last frame was ACELP. For the second TCX subframe it should be 0 */
7187 : float spectrum[], /* i : MDCT spectrum of the subframe */
7188 : TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */
7189 : const float ltp_gain, /* i : ltp gain */
7190 : STnsData *pTnsData, /* o : TNS data */
7191 : int16_t *pfUseTns, /* o : Flag indicating if TNS is used */
7192 : float *predictionGain /* o : TNS prediction gain */
7193 : );
7194 :
7195 : void CalculateTnsFilt(
7196 : STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */
7197 : const float pSpectrum[], /* i : MDCT spectrum */
7198 : STnsData *pTnsData, /* o : TNS data struct */
7199 : float *predictionGain /* o : TNS prediction gain */
7200 : );
7201 :
7202 : void ShapeSpectrum(
7203 : TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
7204 : const float A[], /* i : quantized coefficients NxAz_q[M+1] */
7205 : float gainlpc[], /* o : MDCT gains for the previous frame */
7206 : const int16_t L_frame_glob, /* i : frame length */
7207 : int16_t L_spec, /* i : length of the spectrum */
7208 : float spectrum[], /* i/o: MDCT spectrum */
7209 : const int16_t fUseTns, /* i : Flag indicating if TNS is used */
7210 : Encoder_State *st, /* i/o: encoder state structure */
7211 : float *scf /* i : scale factors */
7212 : );
7213 :
7214 : void QuantizeSpectrum(
7215 : Encoder_State *st, /* i/o: encoder state structure */
7216 : const float A[], /* i : quantized coefficients NxAz_q[M+1] */
7217 : const Word16 Aqind[], /* i : frame-independent quantized coeffs (M+1) */
7218 : float gainlpc[], /* i : MDCT gains of the previous frame */
7219 : float synth[], /* o : synthesis buffer */
7220 : const int16_t nb_bits, /* i : bit budget */
7221 : const int16_t tnsSize, /* i : number of tns parameters put into prm */
7222 : int16_t prm[], /* o : tcx parameters */
7223 : const int16_t frame_cnt, /* i : frame counter in the super_frame */
7224 : CONTEXT_HM_CONFIG *hm_cfg, /* i : HM configuration */
7225 : const int16_t vad_hover_flag /* i : VAD hangover flag */
7226 : );
7227 :
7228 : /*! r: index of next coefficient */
7229 : int16_t get_next_coeff_mapped(
7230 : int16_t ii[2], /* i/o: coefficient indexes */
7231 : int32_t *pp, /* o : peak(1)/hole(0) indicator */
7232 : int16_t *idx, /* o : index in unmapped domain */
7233 : CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */
7234 : );
7235 :
7236 : /*! r: index of next coefficient */
7237 : int16_t get_next_coeff_unmapped(
7238 : int16_t *ii, /* i/o: coefficient index */
7239 : int16_t *idx /* o : index in unmapped domain */
7240 : );
7241 :
7242 : int32_t update_mixed_context(
7243 : int32_t ctx,
7244 : int16_t a );
7245 :
7246 : void ACcontextMapping_encode2_no_mem_s17_LC(
7247 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
7248 : int16_t *x,
7249 : int16_t nt,
7250 : int16_t lastnz,
7251 : int16_t nbbits,
7252 : int16_t resQMaxBits,
7253 : CONTEXT_HM_CONFIG *hm_cfg );
7254 :
7255 : int16_t ACcontextMapping_decode2_no_mem_s17_LC(
7256 : Decoder_State *st, /* i/o: decoder state */
7257 : int16_t *x, /* o : decoded spectrum */
7258 : int16_t nt, /* i : size of spectrum */
7259 : int16_t nbbits, /* i : bit budget */
7260 : int16_t resQMaxBits, /* i : residual coding maximum bits */
7261 : CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration */
7262 : );
7263 :
7264 : int16_t ACcontextMapping_encode2_estimate_no_mem_s17_LC(
7265 : const int16_t *x,
7266 : const int16_t nt,
7267 : int16_t *lastnz,
7268 : int16_t *nEncoded,
7269 : const int16_t target,
7270 : int16_t *stop,
7271 : CONTEXT_HM_CONFIG *hm_cfg );
7272 :
7273 : void RCcontextMapping_encode2_no_mem_s17_LCS(
7274 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
7275 : int16_t *x,
7276 : const int16_t nt,
7277 : int16_t lastnz,
7278 : const int16_t nbbits,
7279 : const int16_t resQMaxBits,
7280 : CONTEXT_HM_CONFIG *hm_cfg );
7281 :
7282 : int16_t RCcontextMapping_decode2_no_mem_s17_LCS(
7283 : Decoder_State *st, /* i/o: decoder state */
7284 : int16_t *x, /* o : decoded spectrum */
7285 : const int16_t nt, /* i : size of spectrum */
7286 : const int16_t nbbits, /* i : bit budget */
7287 : const int16_t resQMaxBits, /* i : residual coding maximum bits */
7288 : CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration */
7289 : );
7290 :
7291 : int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
7292 : int16_t *x, /* Spectral coefficients */
7293 : const int16_t nt, /* L - size of spectrum (no. of spectral coefficients) */
7294 : int16_t *lastnz_out,
7295 : int16_t *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring */
7296 : const int16_t target, /* Target bits */
7297 : int16_t *stop,
7298 : int16_t mode,
7299 : CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
7300 : );
7301 :
7302 : int16_t RCcontextMapping_encode2_estimate_bandWise_start(
7303 : int16_t *x,
7304 : const int16_t nt,
7305 : const int16_t target,
7306 : HANDLE_RC_CONTEXT_MEM hContextMem );
7307 :
7308 : int16_t RCcontextMapping_encode2_estimate_bandWise(
7309 : int16_t *x,
7310 : const int16_t start_line,
7311 : const int16_t end_line,
7312 : HANDLE_RC_CONTEXT_MEM hContextMem );
7313 :
7314 : void tcx_get_windows(
7315 : TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */
7316 : const int16_t left_mode, /* i : overlap mode of left window half */
7317 : const int16_t right_mode, /* i : overlap mode of right window half */
7318 : int16_t *left_overlap, /* o : left overlap length */
7319 : const float **left_win, /* o : left overlap window */
7320 : int16_t *right_overlap, /* o : right overlap length */
7321 : const float **right_win, /* o : right overlap window */
7322 : const int16_t fullband /* i : fullband flag */
7323 : );
7324 :
7325 : void tcx_windowing_analysis(
7326 : const float *signal, /* i : signal vector */
7327 : const int16_t L_frame, /* i : frame length */
7328 : const int16_t left_overlap, /* i : left overlap length */
7329 : const float *left_win, /* i : left overlap window */
7330 : const int16_t right_overlap, /* i : right overlap length */
7331 : const float *right_win, /* i : right overlap window */
7332 : float *output /* o : windowed signal vector */
7333 : );
7334 :
7335 : void tcx_windowing_synthesis_current_frame(
7336 : float *signal, /* i/o: signal vector */
7337 : const float *window, /* i : TCX window vector */
7338 : const float *window_half, /* i : TCX window vector for half-overlap window */
7339 : const float *window_min, /* i : TCX minimum overlap window */
7340 : const int16_t window_length, /* i : TCX window length */
7341 : const int16_t window_half_length, /* i : TCX half window length */
7342 : const int16_t window_min_length, /* i : TCX minimum overlap length */
7343 : const int16_t left_rect, /* i : left part is rectangular */
7344 : const int16_t left_mode, /* i : overlap mode of left window half */
7345 : float *acelp_zir, /* i/o: acelp ZIR */
7346 : const float *old_syn, /* i : old synthesis */
7347 : const float *syn_overl, /* i : overlap synthesis */
7348 : const float *A_zir,
7349 : const float *window_trans, /* i : window for transition from ACELP */
7350 : int16_t acelp_zir_len,
7351 : const int16_t acelp_mem_len,
7352 : const int16_t last_core_bfi, /* i : last mode */
7353 : const int16_t last_is_cng,
7354 : const int16_t fullbandScale );
7355 :
7356 : void tcx_windowing_synthesis_past_frame(
7357 : float *signal, /* i/o: signal vector */
7358 : const float *window, /* i : TCX window vector */
7359 : const float *window_half, /* i : TCX window vector for half-overlap window */
7360 : const float *window_min, /* i : TCX minimum overlap window */
7361 : const int16_t window_length, /* i : TCX window length */
7362 : const int16_t window_half_length, /* i : TCX half window length */
7363 : const int16_t window_min_length, /* i : TCX minimum overlap length */
7364 : const int16_t right_mode /* i : overlap mode (left_mode of current frame) */
7365 : );
7366 :
7367 : void ProcessIGF(
7368 : Encoder_State *st, /* i : Encoder state */
7369 : float *pMDCTSpectrum, /* i : MDCT spectrum */
7370 : const float *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */
7371 : float *pPowerSpectrum, /* i : MDCT^2 + MDST^2 spectrum, or estimate */
7372 : const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
7373 : const int16_t frameno, /* i : flag indicating index of current subframe */
7374 : const int16_t sp_aud_decision0, /* i : first stage switching decision */
7375 : const int16_t vad_hover_flag /* i : VAD hangover flag */
7376 : );
7377 :
7378 : void ProcessStereoIGF(
7379 : STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct,
7380 : Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
7381 : int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
7382 : float *pITFMDCTSpectrum[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */
7383 : float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
7384 : float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */
7385 : float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
7386 : const int16_t frameno, /* i : flag indicating index of current subframe*/
7387 : const int16_t sp_aud_decision0, /* i : sp_aud_decision0 */
7388 : const int32_t element_brate, /* i : element bitrate */
7389 : const int16_t mct_on /* i : flag mct block (1) or stereo (0) */
7390 : );
7391 :
7392 : void AnalyzePowerSpectrum(
7393 : Encoder_State *st, /* i/o: encoder states */
7394 : const int16_t L_frame, /* i : frame length */
7395 : const int16_t L_frameTCX, /* i : full band frame length */
7396 : const int16_t left_overlap, /* i : left overlap length */
7397 : const int16_t right_overlap, /* i : right overlap length */
7398 : const float mdctSpectrum[], /* i : MDCT spectrum */
7399 : const float signal[], /* i : windowed signal corresponding to mdctSpectrum */
7400 : float powerSpec[] /* o : Power spectrum */
7401 : );
7402 :
7403 : void lpc2mdct(
7404 : float *lpcCoeffs,
7405 : const int16_t lpcOrder,
7406 : float mdct_gains[],
7407 : const int16_t length,
7408 : const int16_t noInverse );
7409 :
7410 : void mdct_preShaping(
7411 : float x[],
7412 : const int16_t lg,
7413 : const float gains[] );
7414 :
7415 : void mdct_noiseShaping(
7416 : float x[],
7417 : const int16_t lg,
7418 : const float gains[],
7419 : const int16_t nBands );
7420 :
7421 : void AdaptLowFreqEmph(
7422 : float x[],
7423 : int16_t xq[],
7424 : float invGain,
7425 : const int16_t tcx_lpc_shaped_ari,
7426 : const float lpcGains[],
7427 : const int16_t lg );
7428 :
7429 : void PsychAdaptLowFreqEmph(
7430 : float x[],
7431 : const float lpcGains[] );
7432 :
7433 : void PsychAdaptLowFreqDeemph(
7434 : float x[],
7435 : const float lpcGains[],
7436 : float lf_deemph_factors[] );
7437 :
7438 : void AdaptLowFreqDeemph(
7439 : float x[],
7440 : int16_t tcx_lpc_shaped_ari,
7441 : const float lpcGains[],
7442 : const int16_t lg,
7443 : float lf_deemph_factors[] );
7444 :
7445 : /*! r: SQ gain */
7446 : float SQ_gain(
7447 : const float x[], /* i : vector to quantize */
7448 : const int16_t nbitsSQ, /* i : number of bits targeted */
7449 : const int16_t lg /* i : vector size (2048 max) */
7450 : );
7451 :
7452 : /*! r: SQ gain */
7453 : float SQ_gain_estimate(
7454 : const float x[], /* i : vector to quantize */
7455 : const int16_t nbitsSQ, /* i : number of bits targeted */
7456 : const int16_t lg /* i : vector size (2048 max) */
7457 : );
7458 :
7459 :
7460 : void tcx_scalar_quantization(
7461 : float *x, /* i : input coefficients */
7462 : int16_t *xq, /* o : quantized coefficients */
7463 : const int16_t L_frame, /* i : frame length */
7464 : const float gain, /* i : quantization gain */
7465 : const float offset, /* i : rounding offset (deadzone) */
7466 : int16_t *memQuantZeros, /* o : coefficients set to 0 */
7467 : const int16_t tcxonly );
7468 :
7469 : int16_t tcx_scalar_quantization_rateloop(
7470 : float *x, /* i : input coefficients */
7471 : int16_t *xq, /* o : quantized coefficients */
7472 : const int16_t L_frame, /* i : frame length */
7473 : float *gain, /* i/o: quantization gain */
7474 : float offset, /* i : rounding offset (deadzone) */
7475 : int16_t *memQuantZeros, /* o : coefficients set to 0 */
7476 : int16_t *lastnz_out, /* i/o: last nonzero coeff index */
7477 : const int16_t target, /* i : target number of bits */
7478 : int16_t *nEncoded, /* o : number of encoded coeff */
7479 : int16_t *stop, /* i/o: stop param */
7480 : const int16_t sqBits_in_noStop, /* i : number of sqBits as determined in prev. quant. stage, w/o using stop mechanism (ie might exceed target bits) */
7481 : const int16_t sqBits_in, /* i : number of sqBits as determined in prev. quant. stage, using stop mechanism (ie always <= target bits) */
7482 : const int16_t tcxRateLoopOpt, /* i : turns on/off rateloop optimization */
7483 : const int16_t tcxonly,
7484 : CONTEXT_HM_CONFIG *hm_cfg,
7485 : const int16_t iter_max,
7486 : const int16_t element_mode );
7487 :
7488 : void tcx_QuantizeGain(
7489 : const int16_t n,
7490 : float *pGain,
7491 : int16_t *pQuantizedGain );
7492 :
7493 : void tcx_noise_factor(
7494 : const float *x_orig, /* i : unquantized mdct coefficients */
7495 : float *sqQ, /* i/o: quantized mdct coefficients */
7496 : const int16_t iFirstLine, /* i : first coefficient to be considered */
7497 : const int16_t lowpassLine, /* i : last nonzero coefficients after low-pass */
7498 : const int16_t nMinHoleSize, /* i : minimum size of hole to be checked */
7499 : const int16_t L_frame, /* i : frame length */
7500 : const float gain_tcx, /* i : tcx gain */
7501 : const float tiltCompFactor, /* i : LPC tilt compensation factor */
7502 : float *fac_ns, /* o : noise factor */
7503 : int16_t *quantized_fac_ns, /* o : quantized noise factor */
7504 : const int16_t element_mode /* i : IVAS element mode */
7505 : );
7506 :
7507 : void tcx_noise_filling(
7508 : float *Q,
7509 : const int16_t noiseFillSeed,
7510 : const int16_t iFirstLine,
7511 : const int16_t lowpassLine,
7512 : const int16_t nTransWidth,
7513 : const int16_t L_frame,
7514 : const float tiltCompFactor,
7515 : float fac_ns,
7516 : uint8_t *infoTCXNoise,
7517 : const int16_t element_mode /* i : IVAS element mode */
7518 : );
7519 :
7520 : void tcx_encoder_memory_update(
7521 : Encoder_State *st, /* i/o: encoder memory state */
7522 : float *xn_buf, /* i/o: mdct output buffer/TD weigthed synthesis */
7523 : const float *Ai, /* i : Unquantized (interpolated) LPC coefficients */
7524 : const float *A /* i : Quantized LPC coefficients */
7525 : );
7526 :
7527 : void tcx_decoder_memory_update(
7528 : Decoder_State *st, /* i/o: decoder memory state */
7529 : const float *xn_buf, /* i : mdct output buffer */
7530 : float *synth, /* i/o: synth */
7531 : const float *A /* i : Quantized LPC coefficients */
7532 : );
7533 :
7534 : /*! r: number of bits used (including "bits") */
7535 : int16_t tcx_ari_res_Q_spec(
7536 : const float x_orig[], /* i : original spectrum */
7537 : const int16_t signs[], /* i : signs (x_orig[.]<0) */
7538 : float x_Q[], /* i/o: quantized spectrum */
7539 : const int16_t L_frame, /* i : number of lines */
7540 : const float gain, /* i : TCX gain */
7541 : int16_t prm[], /* o : bitstream */
7542 : int16_t target_bits, /* i : number of bits available */
7543 : int16_t bits, /* i : number of bits used so far */
7544 : const float deadzone, /* i : quantizer deadzone */
7545 : const float x_fac[] /* i : spectrum post-quantization factors */
7546 : );
7547 :
7548 : /*! r: number of bits used (including "bits") */
7549 : int16_t tcx_ari_res_invQ_spec(
7550 : float x_Q[], /* i/o: quantized spectrum */
7551 : const int16_t L_frame, /* i : number of lines */
7552 : const int16_t prm[], /* i : bitstream */
7553 : int16_t target_bits, /* i : number of bits available */
7554 : int16_t bits, /* i : number of bits used so far */
7555 : const float deadzone, /* i : quantizer deadzone */
7556 : const float x_fac[] /* i : spectrum post-quantization factors */
7557 : );
7558 :
7559 : int16_t tcx_res_Q_gain(
7560 : float sqGain,
7561 : float *gain_tcx,
7562 : int16_t *prm,
7563 : int16_t sqTargetBits );
7564 :
7565 : int16_t tcx_res_Q_spec(
7566 : const float *x_orig,
7567 : float *x_Q,
7568 : const int16_t L_frame,
7569 : const float sqGain,
7570 : int16_t *prm,
7571 : int16_t sqTargetBits,
7572 : int16_t bits,
7573 : const float sq_round,
7574 : const float lf_deemph_factors[] );
7575 :
7576 : int16_t tcx_res_invQ_gain(
7577 : float *gain_tcx,
7578 : const int16_t *prm,
7579 : const int16_t resQBits );
7580 :
7581 : int16_t tcx_res_invQ_spec(
7582 : float *x,
7583 : const int16_t L_frame,
7584 : const int16_t *prm,
7585 : int16_t resQBits,
7586 : int16_t bits,
7587 : const float sq_round,
7588 : const float lf_deemph_factors[] );
7589 :
7590 : void InitTnsConfigs(
7591 : const int16_t bwidth,
7592 : const int16_t L_frame,
7593 : STnsConfig tnsConfig[2][2],
7594 : const int16_t igfStopFreq,
7595 : const int32_t total_brate,
7596 : const int16_t element_mode,
7597 : const int16_t MCT_flag );
7598 :
7599 : void SetAllowTnsOnWhite(
7600 : STnsConfig tnsConfig[2][2],
7601 : const int8_t allowTnsOnWhite );
7602 :
7603 : void SetTnsConfig(
7604 : TCX_CONFIG_HANDLE hTcxCfg,
7605 : const int16_t isTCX20,
7606 : const int16_t isAfterACELP );
7607 :
7608 : void ari_copy_states(
7609 : Tastat *source,
7610 : Tastat *dest );
7611 :
7612 : int32_t mul_sbc_14bits(
7613 : int32_t r,
7614 : int32_t c );
7615 :
7616 : void ari_start_encoding_14bits(
7617 : Tastat *s );
7618 :
7619 : int16_t ari_encode_14bits_ext(
7620 : int16_t *ptr,
7621 : int16_t bp,
7622 : Tastat *s,
7623 : int32_t symbol,
7624 : const uint16_t *cum_freq );
7625 :
7626 : int16_t ari_done_encoding_14bits(
7627 : int16_t *ptr,
7628 : int16_t bp,
7629 : Tastat *s );
7630 :
7631 : void ari_start_decoding_14bits(
7632 : Decoder_State *st,
7633 : Tastat *s );
7634 :
7635 : int16_t ari_start_decoding_14bits_prm(
7636 : const int16_t *ptr,
7637 : int16_t bp,
7638 : Tastat *s );
7639 :
7640 : void ari_decode_14bits_s17_ext(
7641 : Decoder_State *st,
7642 : uint16_t *res,
7643 : Tastat *s,
7644 : const uint16_t *cum_freq );
7645 :
7646 : void ari_decode_14bits_s27_ext(
7647 : Decoder_State *st,
7648 : uint16_t *res,
7649 : Tastat *s,
7650 : const uint16_t *cum_freq );
7651 :
7652 : void ari_decode_14bits_bit_ext(
7653 : Decoder_State *st,
7654 : uint16_t *res,
7655 : Tastat *s );
7656 :
7657 : /*! r: Q15 */
7658 : Word16 expfp(
7659 : const Word16 x, /* i : mantissa Q15-e */
7660 : const Word16 x_e /* i : exponent Q0 */
7661 : );
7662 :
7663 : void powfp_odd2(
7664 : const Word16 base, /* Q15 */
7665 : const Word16 exp, /* Q0 */
7666 : Word16 *pout1, /* Q15 */
7667 : Word16 *pout2 /* Q15 */
7668 : );
7669 :
7670 : void tcx_arith_scale_envelope(
7671 : const Word16 L_spec_core, /* i : number of lines to scale Q0 */
7672 : Word16 L_frame, /* i : number of lines Q0 */
7673 : const Word32 env[], /* i : unscaled envelope Q16 */
7674 : Word16 target_bits, /* i : number of available bits Q0 */
7675 : const Word16 low_complexity, /* i : low-complexity flag Q0 */
7676 : Word16 s_env[], /* o : scaled envelope Q15-e */
7677 : Word16 *s_env_e /* o : scaled envelope exponent Q0 */
7678 : );
7679 :
7680 : void tcx_arith_render_envelope(
7681 : const Word16 A_ind[], /* i : LPC coefficients of signal envelope */
7682 : const Word16 L_frame, /* i : number of spectral lines */
7683 : const Word16 L_spec, /* i : length of the coded spectrum */
7684 : const Word16 preemph_fac, /* i : pre-emphasis factor */
7685 : const Word16 gamma_w, /* i : A_ind -> weighted envelope factor */
7686 : const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor */
7687 : Word32 env[] /* o : shaped signal envelope */
7688 : );
7689 :
7690 : int16_t ari_encode_14bits_range(
7691 : int16_t *ptr,
7692 : int16_t bp,
7693 : int32_t bits,
7694 : Tastat *s,
7695 : uint16_t cum_freq_low,
7696 : uint16_t cum_freq_high );
7697 :
7698 : int16_t ari_encode_14bits_sign(
7699 : int16_t *ptr,
7700 : int16_t bp,
7701 : int32_t bits,
7702 : Tastat *s,
7703 : int32_t sign );
7704 :
7705 : int16_t ari_done_cbr_encoding_14bits(
7706 : int16_t *ptr,
7707 : int16_t bp,
7708 : int32_t bits,
7709 : Tastat *s );
7710 :
7711 : int16_t ari_decode_14bits_pow(
7712 : const int16_t *ptr,
7713 : int16_t bp,
7714 : int16_t bits,
7715 : int16_t *res,
7716 : Tastat *s,
7717 : uint16_t base );
7718 :
7719 : int16_t ari_decode_14bits_sign(
7720 : const int16_t *ptr,
7721 : int16_t bp,
7722 : int16_t bits,
7723 : uint16_t *res,
7724 : Tastat *s );
7725 :
7726 : void tcx_arith_encode_envelope(
7727 : float spectrum[], /* i/o: MDCT coefficients */
7728 : int16_t signs[], /* o : signs (spectrum[.]<0) */
7729 : const int16_t L_frame, /* i : frame or MDCT length */
7730 : const int16_t L_spec, /* i : length w/o BW limitation */
7731 : Encoder_State *st, /* i/o: coder state */
7732 : const Word16 A_ind[], /* i : quantised LPC coefficients */
7733 : int16_t target_bits, /* i : number of available bits */
7734 : int16_t prm[], /* o : bitstream parameters */
7735 : const int16_t use_hm, /* i : use HM in current frame? */
7736 : int16_t prm_hm[], /* o : HM parameter area */
7737 : const int16_t tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/
7738 : int16_t *arith_bits, /* o : bits used for ari. coding */
7739 : int16_t *signaling_bits, /* o : bits used for signaling */
7740 : const int16_t low_complexity /* i : low-complexity flag */
7741 : );
7742 :
7743 : void tcx_arith_decode_envelope(
7744 : Decoder_State *st, /* i/o: coder state */
7745 : float q_spectrum[], /* o : quantised MDCT coefficients */
7746 : const int16_t L_frame, /* i : frame or MDCT length */
7747 : int16_t L_spec, /* i : length w/o BW limitation */
7748 : const Word16 A_ind[], /* i : quantised LPC coefficients */
7749 : const int16_t target_bits, /* i : number of available bits */
7750 : const int16_t prm[], /* i : bitstream parameters */
7751 : const int16_t use_hm, /* i : use HM in current frame? */
7752 : const int16_t prm_hm[], /* i : HM parameter area */
7753 : int16_t tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/
7754 : int16_t *arith_bits, /* o : bits used for ari. coding */
7755 : int16_t *signaling_bits, /* o : bits used for signaling */
7756 : const int16_t low_complexity /* i : low-complexity flag */
7757 : );
7758 :
7759 : void UnmapIndex(
7760 : const int16_t PeriodicityIndex,
7761 : const int16_t Bandwidth,
7762 : const int16_t LtpPitchLag,
7763 : const int16_t SmallerLags,
7764 : int16_t *FractionalResolution,
7765 : int32_t *Lag );
7766 :
7767 : /*! r: PeriodicityIndex */
7768 : int16_t SearchPeriodicityIndex(
7769 : const float Mdct[], /* i : Coefficients, Mdct[0..NumCoeffs-1] */
7770 : const float UnfilteredMdct[], /* i : Unfiltered coefficients, UnfilteredMdct[0..NumCoeffs-1] */
7771 : const int16_t NumCoeffs, /* i : Number of coefficients */
7772 : const int16_t shortTargetBits, /* i : Target bit budget (excl. Done flag) */
7773 : const int16_t LtpPitchLag, /* i : TCX-LTP pitch */
7774 : const float LtpGain, /* i : LTP gain */
7775 : float *RelativeScore /* o : Energy concentration factor */
7776 : );
7777 :
7778 : void ConfigureContextHm(
7779 : const int16_t NumCoeffs, /* i : Number of coefficients */
7780 : const int16_t TargetBits, /* i : Target bit budget (excl. Done flag) */
7781 : const int16_t PeriodicityIndex, /* i : Pitch related index */
7782 : const int16_t LtpPitchLag, /* i : TCX-LTP pitch in F.D. */
7783 : CONTEXT_HM_CONFIG *hm_cfg /* o : Context-based harmonic model configuration */
7784 : );
7785 :
7786 : int16_t EncodeIndex(
7787 : const int16_t Bandwidth, /* o : NB, 1: (S)WB */
7788 : int16_t PeriodicityIndex,
7789 : BSTR_ENC_HANDLE hBstr );
7790 :
7791 : int16_t CountIndexBits(
7792 : const int16_t Bandwidth, /* o : NB, 1: (S)WB */
7793 : const int16_t PeriodicityIndex );
7794 :
7795 : int16_t DecodeIndex(
7796 : Decoder_State *st,
7797 : const int16_t Bandwidth, /* o : NB, 1: (S)WB */
7798 : int16_t *PeriodicityIndex );
7799 :
7800 : #define GET_ADJ( T, L ) GET_ADJ2( T, L, *FractionalResolution )
7801 : #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) )
7802 :
7803 : int16_t tcx_hm_render(
7804 : const int32_t lag, /* i : pitch lag */
7805 : const int16_t fract_res, /* i : fractional resolution of the lag */
7806 : Word16 p[] /* o : harmonic model (Q13) */
7807 : );
7808 :
7809 : void tcx_hm_modify_envelope(
7810 : const Word16 gain, /* i : HM gain (Q11) */
7811 : const int32_t lag,
7812 : const int16_t fract_res,
7813 : const Word16 p[], /* i : harmonic model (Q13) */
7814 : Word32 env[], /* i/o: envelope (Q16) */
7815 : const int16_t L_frame /* i : number of spectral lines */
7816 : );
7817 :
7818 : void tcx_hm_analyse(
7819 : const float abs_spectrum[], /* i : absolute spectrum */
7820 : const int16_t L_frame, /* i : number of spectral lines */
7821 : Word32 env[], /* i/o: envelope shape (Q16) */
7822 : const int16_t targetBits, /* i : target bit budget */
7823 : const int16_t coder_type, /* i : GC/VC coder type */
7824 : int16_t prm_hm[], /* o : HM parameters */
7825 : int16_t LtpPitchLag, /* i : LTP pitch lag or -1 if none */
7826 : const float LtpGain, /* i : LTP gain */
7827 : int16_t *hm_bits /* o : bit consumption */
7828 : );
7829 :
7830 : void tcx_hm_decode(
7831 : const int16_t L_frame, /* i : number of spectral lines */
7832 : Word32 env[], /* i/o: envelope shape (Q16) */
7833 : const int16_t targetBits, /* i : target bit budget */
7834 : const int16_t coder_type, /* i : GC/VC coder type */
7835 : const int16_t prm_hm[], /* i : HM parameters */
7836 : const int16_t LtpPitchLag, /* i : LTP pitch lag or -1 if none */
7837 : int16_t *hm_bits /* o : bit consumption */
7838 : );
7839 :
7840 : void coder_tcx(
7841 : Encoder_State *st, /* i/o: encoder state structure */
7842 : TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
7843 : const float A[], /* i : quantized coefficients NxAz_q[M+1] */
7844 : const Word16 Aqind[], /* i : frame-independent quantized coefficients (M+1) */
7845 : float synth[], /* o : decoded synthesis */
7846 : const int16_t L_frame_glob, /* i : frame length */
7847 : const int16_t L_frameTCX_glob,
7848 : const int16_t L_spec,
7849 : int16_t nb_bits, /* i : bit budget */
7850 : float spectrum[], /* i/o: MDCT spectrum */
7851 : int16_t prm[], /* o : tcx parameters */
7852 : CONTEXT_HM_CONFIG *hm_cfg,
7853 : const int16_t vad_hover_flag /* i : VAD hangover flag */
7854 : );
7855 :
7856 : void coder_tcx_post(
7857 : Encoder_State *st, /* i/o: encoder memory state */
7858 : float *A, /* o : Quantized LPC coefficients */
7859 : const float *Ai /* i : Unquantized (interpolated) LPC coefficients */
7860 : );
7861 :
7862 : void decoder_tcx(
7863 : Decoder_State *st, /* i/o: coder memory state */
7864 : int16_t prm[], /* i : parameters */
7865 : float A[], /* i : coefficients NxAz[M+1] */
7866 : Word16 Aind[], /* i : frame-independent coefficients Az[M+1]*/
7867 : float synth[], /* i/o: synth[-M..lg] */
7868 : float synthFB[], /* i/o: encoder memory state */
7869 : const int16_t bfi, /* i : Bad frame indicator */
7870 : const int16_t frame_cnt, /* i : frame counter in the super_frame */
7871 : const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */
7872 : );
7873 :
7874 : void decoder_tcx_post(
7875 : Decoder_State *st, /* i/o: decoder memory state */
7876 : float *synth,
7877 : float *synthFB,
7878 : float *A, /* i : A(z) filter coefficients */
7879 : const int16_t bfi,
7880 : const int16_t isMCT );
7881 :
7882 : void coder_acelp(
7883 : Encoder_State *st, /* i/o: coder memory state */
7884 : const float A[], /* i : coefficients 4xAz[M+1] */
7885 : const float Aq[], /* i : coefficients 4xAz_q[M+1] */
7886 : const float speech[], /* i : speech[-M..lg] */
7887 : LPD_state *LPDmem, /* i/o: ACELP memories */
7888 : int16_t *prm, /* o : acelp parameters */
7889 : const float stab_fac,
7890 : const int16_t target_bits,
7891 : float *gain_pitch_buf, /* o : gain pitch values */
7892 : float *gain_code_buf, /* o : gain code values */
7893 : float *pitch_buf, /* o : pitch values for each subfr.*/
7894 : float *voice_factors, /* o : voicing factors */
7895 : float *bwe_exc /* o : excitation for SWB TBE */
7896 : );
7897 :
7898 : void coder_acelp_rf(
7899 : const int16_t target_bits, /* i : target bits */
7900 : const float speech[], /* i : speech[-M..lg] */
7901 : const int16_t coder_type, /* i : coding type */
7902 : const int16_t rf_frame_type, /* i : rf_frame_type */
7903 : const float A[], /* i : coefficients 4xAz[M+1] */
7904 : const float Aq[], /* i : coefficients 4xAz_q[M+1] */
7905 : const float voicing[], /* i : open-loop LTP gain */
7906 : const int16_t T_op[], /* i : open-loop LTP lag */
7907 : const float stab_fac, /* i : LP stability factor */
7908 : Encoder_State *st, /* i/o: coder memory state */
7909 : ACELP_config *acelp_cfg, /* i/o: configuration of the ACELP */
7910 : float *exc_rf, /* i/o: pointer to RF excitation */
7911 : float *syn_rf /* i/o: pointer to RF synthesis */
7912 : );
7913 :
7914 : void decoder_acelp(
7915 : Decoder_State *st, /* i/o: coder memory state */
7916 : int16_t prm[], /* i : parameters */
7917 : const float A[], /* i : coefficients NxAz[M+1] */
7918 : ACELP_config acelp_cfg, /* i : ACELP config */
7919 : float synth[], /* i/o: synthesis */
7920 : int16_t *pT, /* o : pitch for all subframe */
7921 : float *pgainT, /* o : pitch gain for all subfr */
7922 : const float stab_fac, /* i : stability of isf */
7923 : float *pitch_buffer, /* o : pitch values for each subfr.*/
7924 : float *voice_factors, /* o : voicing factors */
7925 : const int16_t LSF_Q_prediction, /* i : LSF prediction mode */
7926 : float *bwe_exc /* o : excitation for SWB TBE */
7927 : );
7928 :
7929 : void writeTCXMode(
7930 : Encoder_State *st, /* i/o: encoder state structure */
7931 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
7932 : const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/
7933 : int16_t *nbits_start /* o : nbits start */
7934 : );
7935 :
7936 : void writeTCXWindowing(
7937 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
7938 : const int16_t overlap_mode /* i : overlap mode */
7939 : );
7940 :
7941 : void writeLPCparam(
7942 : Encoder_State *st, /* i/o: encoder state structure */
7943 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
7944 : const int16_t param_lpc[], /* i : LPC parameters to write */
7945 : const int16_t bits_param_lpc[], /* i : bits per LPC parameter */
7946 : const int16_t no_param_lpc, /* i : number of LPC parameters */
7947 : int16_t *nbits_lpc /* o : LPC bits written */
7948 : );
7949 :
7950 : void enc_prm(
7951 : Encoder_State *st, /* i/o: encoder state structure */
7952 : int16_t param[], /* i : parameters */
7953 : int16_t param_lpc[], /* i : LPC parameters */
7954 : CONTEXT_HM_CONFIG hm_cfg[],
7955 : const int16_t bits_param_lpc[],
7956 : const int16_t no_param_lpc );
7957 :
7958 : void writeTCXparam(
7959 : Encoder_State *st, /* i/o: Encoder State handle */
7960 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
7961 : CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */
7962 : int16_t param[], /* i : parameters */
7963 : const int16_t nbits_header,
7964 : const int16_t nbits_start,
7965 : const int16_t nbits_lpc,
7966 : const int16_t *no_param_tns, /* i : number of TNS parameters per subframe */
7967 : int16_t p_param[2], /* i/o: pointer to parameters from previous bs writing */
7968 : const int16_t target_bitsTCX10[2],
7969 : const int16_t pre_past_flag );
7970 :
7971 : void enc_prm_rf(
7972 : Encoder_State *st, /* i/o: encoder memory state */
7973 : const int16_t rf_frame_type,
7974 : const int16_t fec_offset );
7975 :
7976 : void dec_prm_hm(
7977 : Decoder_State *st, /* i/o: decoder memory state */
7978 : int16_t *prm_hm,
7979 : const int16_t hm_size );
7980 :
7981 : void dec_prm(
7982 : Decoder_State *st, /* i/o: decoder memory state */
7983 : int16_t param[], /* o : decoded parameters */
7984 : int16_t param_lpc[], /* i : LPC parameters */
7985 : int16_t *total_nbbits, /* i/o: number of bits / decoded bits */
7986 : int16_t *bitsRead );
7987 :
7988 : void gauss_L2(
7989 : const float h[], /* i : weighted LP filter impulse response */
7990 : float code[], /* o : gaussian excitation */
7991 : float y2[], /* i : zero-memory filtered code. excitation */
7992 : float y11[], /* o : zero-memory filtered gauss. excitation */
7993 : float *gain, /* o : excitation gain */
7994 : float g_corr[], /* i/o: correlation structure for gain coding */
7995 : float tilt_code, /* i : tilt of code */
7996 : const float *Aq, /* i : quantized LPCs */
7997 : float formant_enh_num, /* i : formant enhancement factor */
7998 : int16_t *seed_acelp /* i/o: random seed */
7999 : );
8000 :
8001 : void gaus_L2_dec(
8002 : float *code, /* o : decoded gaussian codevector */
8003 : float tilt_code,
8004 : const float *A,
8005 : float formant_enh_num,
8006 : int16_t *seed_acelp /* i/o: random seed */
8007 : );
8008 :
8009 : /*! r: interpolated value */
8010 : float interpolation(
8011 : const float *x, /* i : input vector */
8012 : const float *win, /* i : interpolation window */
8013 : const int16_t frac, /* i : fraction */
8014 : const int16_t up_samp, /* i : upsampling factor */
8015 : const int16_t nb_coef /* i : nb of filter coef */
8016 : );
8017 :
8018 : void predict_signal(
8019 : const float excI[], /* i : input excitation buffer */
8020 : float excO[], /* o : output excitation buffer */
8021 : const int16_t T0, /* i : integer pitch lag */
8022 : int16_t frac, /* i : fraction of lag */
8023 : const int16_t frac_max, /* i : max fraction */
8024 : const int16_t L_subfr /* i : subframe size */
8025 : );
8026 :
8027 : void tcx_ltp_encode(
8028 : Encoder_State *st,
8029 : const int16_t tcxMode,
8030 : const int16_t L_frame,
8031 : const float *speech,
8032 : float *speech_ltp,
8033 : const float *wsp,
8034 : const int16_t Top[],
8035 : int16_t *ltp_param,
8036 : int16_t *ltp_bits,
8037 : float *A,
8038 : const int16_t disable_ltp,
8039 : const int16_t element_mode );
8040 :
8041 : void tcx_ltp_post(
8042 : Decoder_State *st,
8043 : TCX_LTP_DEC_HANDLE hTcxLtpDec,
8044 : const int16_t core,
8045 : const int16_t output_frame,
8046 : const int16_t L_frame,
8047 : float sig[],
8048 : const float tcx_buf[] );
8049 :
8050 : int16_t tcx_ltp_decode_params(
8051 : int16_t *ltp_param,
8052 : int16_t *pitch_int,
8053 : int16_t *pitch_fr,
8054 : float *gain,
8055 : const int16_t pitmin,
8056 : const int16_t pitfr1,
8057 : const int16_t pitfr2,
8058 : const int16_t pitmax,
8059 : const int16_t pitres );
8060 :
8061 : int16_t enc_lsf_tcxlpc(
8062 : const int16_t **indices, /* i : Ptr to VQ indices */
8063 : BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
8064 : );
8065 :
8066 : void msvq_enc(
8067 : const float *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */
8068 : const int16_t dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */
8069 : const int16_t offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */
8070 : const float u[], /* i : Vector to be encoded (prediction and mean removed) */
8071 : const int16_t *levels, /* i : Number of levels in each stage */
8072 : const int16_t maxC, /* i : Tree search size (number of candidates kept from one stage to the next == M-best) */
8073 : const int16_t stages, /* i : Number of stages */
8074 : const float w[], /* i : Weights */
8075 : const int16_t N, /* i : Vector dimension */
8076 : const int16_t maxN, /* i : Codebook dimension */
8077 : const int16_t applyDCT_flag, /* i : applyDCT flag */
8078 : float *invTrfMatrix, /* i/o: expanded synthesis matrix */
8079 : int16_t Idx[] /* o : Indices */
8080 : );
8081 :
8082 : void msvq_dec(
8083 : const float *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */
8084 : const int16_t dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */
8085 : const int16_t offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */
8086 : const int16_t stages, /* i : Number of stages */
8087 : const int16_t N, /* i : Vector dimension */
8088 : const int16_t maxN, /* i : Codebook dimension */
8089 : const int16_t Idx[], /* i : Indices */
8090 : const int16_t applyIDCT_flag, /* i : applyIDCT flag */
8091 : const float *invTrfMatrix, /* i : synthesis matrix */
8092 : float *uq, /* o : quantized vector */
8093 : Word16 *uq_ind /* o : quantized vector (fixed point) */
8094 : );
8095 :
8096 :
8097 : void dec_FDCNG_MSVQ_stage1(
8098 : int16_t j_full, /* i : index full range */
8099 : int16_t n, /* i : dimension to generate */
8100 : const float *invTrfMatrix, /* i : IDCT matrix for synthesis */
8101 : const DCTTYPE idcttype, /* i : specify which IDCT */
8102 : float *uq, /* o : synthesized stage1 vector */
8103 : Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */
8104 : );
8105 :
8106 : void create_IDCT_N_Matrix(
8107 : float *inv_matrixFloatQ, /* i/o: RAM buffer */
8108 : const int16_t N, /* i : DCT length, number of time samples */
8109 : const int16_t n_cols, /* i : number of dct coeffs (as DCT may be truncated) */
8110 : const int16_t alloc_size /* i : RAM buffer size in elements */
8111 : );
8112 :
8113 : void dctT2_N_apply_matrix(
8114 : const float *input, /* i : input in fdcng or DCT(fdcng) domain */
8115 : float *output, /* o : output in DCT(fdcng) or fdcng ordomain */
8116 : const int16_t dct_dim, /* i : dct processing dim possibly truncated */
8117 : const int16_t fdcngvq_dim, /* i : fdcng domain length */
8118 : const float *matrix, /* i : IDCT matrix */
8119 : const int16_t matrix_row_dim, /* i : */
8120 : const DCTTYPE dcttype /* i : matrix operation type */
8121 : );
8122 :
8123 : void extend_dctN_input(
8124 : const float *input, /* i : input in fdcng domain */
8125 : const float *dct_input, /* i : input in dctN(fdcng) domain */
8126 : const int16_t in_dim, /* i : in_dim == N */
8127 : float *ext_sig, /* o : extended output in fdcng domain */
8128 : const int16_t out_dim, /* i : output total dim */
8129 : float *matrix, /* i : idct synthesis matrix N rows, n_cols columns */
8130 : const int16_t n_cols, /* i : number of columns == DCT truncation length */
8131 : const DCTTYPE dcttype /* i : matrix operation type */
8132 : );
8133 :
8134 : /*! r: (p_max , best candidate sofar ) */
8135 : int16_t msvq_stage1_dct_search(
8136 : const float *u, /* i : target */
8137 : const int16_t N, /* i : target length and IDCT synthesis length */
8138 : const int16_t maxC_st1, /* i : number of final stage 1 candidates to provide */
8139 : const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */
8140 : const int16_t max_dct_trunc, /* i : maximum of truncation lenghts */
8141 : float *invTrfMatrix, /* i : IDCT synthesis matrix for dim N */
8142 : const float *midQ_truncQ, /* i : midQ vector */
8143 : const float *dct_invScaleF, /* i : global inv scale factors */
8144 : const float *dct_scaleF, /* i : global scale factors */
8145 : const Word16 n_segm, /* i : number of segments */
8146 : const Word16 *cols_per_segment, /* i : remaining length per segment */
8147 : const Word16 *trunc_dct_cols_per_segment, /* i : trunc length per segment */
8148 : const Word16 *entries_per_segment, /* i : number of rows per segment */
8149 : const Word16 *cum_entries_per_segment, /* i : number of cumulative entries */
8150 : const Word8 *const W8Qx_dct_sections[], /* i : Word8(byte) segment table ptrs */
8151 : const Word16 *col_syn_shift[], /* i : columnwise syn shift tables */
8152 : const Word8 *segm_neighbour_fwd, /* i : circular neighbour list fwd */
8153 : const Word8 *segm_neighbour_rev, /* i : circular neighbour list reverse */
8154 : const Word16 npost_check, /* i : number of neigbours to check , should be even */
8155 : float *st1_mse_ptr, /* i : dynRAM buffer for MSEs */
8156 : int16_t *indices_st1_local, /* o : selected cand indices */
8157 : float *st1_syn_vec_ptr, /* i/o: buffer for IDCT24 synthesis */
8158 : float *dist1_ptr /* o : resulting stage 1 MSEs in DCT-N domain */
8159 : );
8160 :
8161 : /*! r: (updated p_max) */
8162 : int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb(
8163 : const float *st1_syn_vec_ptr, /* i : IDCT24 synthesis vectors */
8164 : const float *u, /* i : target signal */
8165 : const int16_t maxC_st1, /* i : number of candidates in stage1 */
8166 : float *dist_ptr /* i/o: updated MSE vector for stage1 */
8167 : );
8168 :
8169 : void PulseResynchronization(
8170 : const float *src_exc, /* i : Input excitation buffer */
8171 : float *dst_exc, /* o : output excitation buffer */
8172 : const int16_t nFrameLength, /* i : frame length */
8173 : const int16_t nSubframes, /* i : Number of subframes */
8174 : const float pitchStart, /* i : Pitch at the end of the last frame */
8175 : const float pitchEnd /* i : Pitch at the end of the current frame */
8176 : );
8177 :
8178 : void con_acelp(
8179 : float A[], /* i : coefficients NxAz[M+1] */
8180 : const int16_t coder_type, /* i : ACELP coder type */
8181 : float synth[], /* i/o: synthesis */
8182 : int16_t *pT, /* o : pitch for all subframe */
8183 : float *pgainT, /* o : pitch gain for all subfr */
8184 : float stab_fac, /* i : stability of isf */
8185 : Decoder_State *st, /* i/o: coder memory state */
8186 : float pitch_buffer[], /* i/o: floating pitch values for each subframe */
8187 : float *voice_factors, /* o : voicing factors */
8188 : float *bwe_exc /* o : excitation for SWB TBE */
8189 : );
8190 :
8191 : void con_tcx(
8192 : Decoder_State *st, /* i/o: coder memory state */
8193 : float synth[], /* i/o: synth[] */
8194 : const float coh, /* i : coherence of stereo signal */
8195 : int16_t *noise_seed, /* i/o: noise seed for stereo */
8196 : const int16_t only_left, /* i : TD-PLC only in left channel */
8197 : const float A_cng[] /* i : CNG LP filter coefficients */
8198 : );
8199 :
8200 : /*! r: codebook index */
8201 : int16_t tcxlpc_get_cdk(
8202 : const int16_t coder_type /* i : GC/VC indicator */
8203 : );
8204 :
8205 : int16_t lsf_msvq_ma_encprm(
8206 : BSTR_ENC_HANDLE hBstr,
8207 : const int16_t *param_lpc,
8208 : const int16_t core,
8209 : const int16_t acelp_mode,
8210 : const int16_t acelp_midLpc,
8211 : const int16_t bits_param_lpc[],
8212 : const int16_t no_indices );
8213 :
8214 : int16_t lsf_msvq_ma_decprm(
8215 : Decoder_State *st,
8216 : int16_t *param_lpc );
8217 :
8218 : int16_t dec_lsf_tcxlpc(
8219 : Decoder_State *st, /* i : Decoder state */
8220 : int16_t **indices, /* o : Ptr to VQ indices */
8221 : const int16_t narrowband, /* i : narrowband flag */
8222 : const int16_t cdk /* i : codebook selector */
8223 : );
8224 :
8225 : int16_t D_lsf_tcxlpc(
8226 : const int16_t indices[], /* i : VQ indices */
8227 : float lsf_q[], /* o : quantized lsf */
8228 : Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */
8229 : const int16_t narrowband, /* i : narrowband flag */
8230 : const int16_t cdk, /* i : codebook selector */
8231 : const float mem_MA[] /* i : MA memory */
8232 : );
8233 :
8234 : void lsf_update_memory(
8235 : const int16_t narrowband, /* i : narrowband flag */
8236 : const float qlsf[], /* i : quantized lsf coefficients */
8237 : float old_mem_MA[], /* i : MA memory */
8238 : float mem_MA[] /* o : updated MA memory */
8239 : );
8240 :
8241 : int16_t Q_lsf_tcxlpc(
8242 : /* const */ float lsf[], /* i : original lsf */
8243 : float lsf_q[], /* o : quantized lsf */
8244 : Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */
8245 : int16_t indices[], /* o : VQ indices */
8246 : const int16_t narrowband, /* i : narrowband flag */
8247 : const int16_t cdk, /* i : codebook selector */
8248 : const float mem_MA[], /* i : MA memory */
8249 : const int16_t coder_type, /* i : acelp extended mode */
8250 : const float *Bin_Ener /* i : Spectrum energy */
8251 : );
8252 :
8253 : int16_t E_LPC_lsp_unweight(
8254 : const float lsp_w[], /* i : weighted lsp */
8255 : float lsp_uw[], /* o : unweighted lsp */
8256 : float lsf_uw[], /* o : unweighted lsf */
8257 : const float inv_gamma /* i : inverse weighting factor */
8258 : );
8259 :
8260 : int16_t lsf_ind_is_active(
8261 : const Word16 lsf_q_ind[],
8262 : const float means[],
8263 : const int16_t narrowband,
8264 : const int16_t cdk );
8265 :
8266 : void midlsf_enc(
8267 : const float qlsf0[],
8268 : const float qlsf1[],
8269 : const float lsf[],
8270 : int16_t *idx,
8271 : const int16_t N,
8272 : const float *Bin_Ener,
8273 : const int16_t narrowBand,
8274 : const int32_t sr_core,
8275 : const int16_t coder_type );
8276 :
8277 : void midlsf_dec(
8278 : const float qlsf0[],
8279 : const float qlsf1[],
8280 : const int16_t idx,
8281 : float qlsf[],
8282 : const int16_t N,
8283 : const int16_t coder_type,
8284 : int16_t *mid_lsf_int,
8285 : const int16_t prev_bfi,
8286 : const int16_t safety_net );
8287 :
8288 : void lsf_end_enc(
8289 : Encoder_State *st,
8290 : const float *lsf,
8291 : float *qlsf,
8292 : const int16_t nBits,
8293 : const int16_t coder_type_org,
8294 : const int16_t force_sf,
8295 : int16_t *lpc_param,
8296 : int16_t *no_stages,
8297 : int16_t *bits_param_lpc,
8298 : const int16_t coder_type_raw,
8299 : const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
8300 : );
8301 :
8302 : void lsf_end_dec(
8303 : Decoder_State *st, /* i/o: decoder state structure */
8304 : const int16_t coder_type_org, /* i : coding type */
8305 : const int16_t bwidth, /* i : input signal bandwidth */
8306 : const int16_t nBits, /* i : number of bits used for ISF quantization*/
8307 : float *qlsf, /* o : quantized LSFs in the cosine domain */
8308 : int16_t *lpc_param, /* i : LPC parameters */
8309 : int16_t *LSF_Q_prediction, /* o : LSF prediction mode */
8310 : int16_t *nb_indices, /* o : number of indices */
8311 : const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
8312 : );
8313 :
8314 : ivas_error find_pred_mode(
8315 : int16_t *predmode,
8316 : const int16_t coder_type,
8317 : const int16_t bwidth,
8318 : const int32_t int_fs,
8319 : int16_t *p_mode_lvq,
8320 : int16_t *p_mode_lvq_p,
8321 : const int32_t core_brate );
8322 :
8323 : void lpc_quantization(
8324 : Encoder_State *st,
8325 : const float lsp[],
8326 : const float lspmid[],
8327 : float lsp_q[],
8328 : float lsf_q[],
8329 : float lspmid_q[],
8330 : const int16_t coder_type,
8331 : const int16_t acelp_midLpc,
8332 : int16_t param_lpc[],
8333 : int16_t nbits_lpc[],
8334 : int16_t *bits_param_lpc,
8335 : int16_t *no_param_lpc );
8336 :
8337 : void lpc_unquantize(
8338 : Decoder_State *st,
8339 : float *lsf,
8340 : float *lsp,
8341 : int16_t *param_lpc,
8342 : float *lspmid,
8343 : float *lsfmid,
8344 : const int16_t coder_type,
8345 : int16_t *LSF_Q_prediction /* o : LSF prediction mode */
8346 : );
8347 :
8348 : void dlpc_bfi(
8349 : const int16_t L_frame,
8350 : float *lsf_q, /* o : quantized lsfs */
8351 : const float *lsfold, /* i : past quantized lsf */
8352 : const int16_t last_good, /* i : last good received frame */
8353 : const int16_t nbLostCmpt, /* i : counter of consecutive bad frames */
8354 : float mem_MA[], /* i/o: quantizer memory for MA model */
8355 : float mem_AR[], /* i/o: quantizer memory for MA model */
8356 : float *stab_fac, /* i : lsf stability factor */
8357 : float *lsf_adaptive_mean, /* i : lsf adaptive mean, updated when BFI==0 */
8358 : const int16_t numlpc, /* i : Number of division per superframe */
8359 : float lsf_cng[],
8360 : const int16_t plcBackgroundNoiseUpdated,
8361 : float *lsf_q_cng, /* o : quantized lsfs of background noise */
8362 : float *old_lsf_q_cng, /* o : old quantized lsfs for background noise */
8363 : const float lsfBase[] /* i : base for differential lsf coding */
8364 : );
8365 :
8366 : void lsf_dec_bfi(
8367 : const int16_t codec_mode, /* i : codec_mode: MODE1 | MODE2 */
8368 : float *lsf, /* o : estimated LSF vector */
8369 : const float *lsfold, /* i : past quantized lsf */
8370 : float *lsf_adaptive_mean, /* i : lsf adaptive mean, updated when BFI==0 */
8371 : const float lsfBase[], /* i : base for differential lsf coding */
8372 : float *mem_MA, /* i/o: quantizer memory for MA model */
8373 : float *mem_AR, /* o : quantizer memory for AR model */
8374 : const float stab_fac, /* i : lsf stability factor */
8375 : const int16_t last_coder_type, /* i : last coder type */
8376 : const int16_t L_frame, /* i : frame length */
8377 : const int16_t last_good, /* i : last good received frame */
8378 : const int16_t nbLostCmpt, /* i : counter of consecutive bad frames */
8379 : const int16_t plcBackgroundNoiseUpdated, /* i : background noise already updated? */
8380 : float *lsf_q_cng, /* o : quantized lsfs of background noise */
8381 : float *lsf_cng, /* i : long term target for fading to bg noise*/
8382 : float *old_lsf_q_cng, /* o : old quantized lsfs for background noise*/
8383 : const int16_t Last_GSC_pit_band_idx, /* i : AC mode (GSC) - Last pitch band index */
8384 : const int16_t Opt_AMR_WB, /* i : IO flag */
8385 : const int16_t bwidth /* i : coded bandwidth */
8386 : );
8387 :
8388 : const float *PlcGetlsfBase(
8389 : const int16_t pcQuantization,
8390 : const int16_t narrowBand,
8391 : const int32_t sr_core );
8392 :
8393 : void Unified_weighting(
8394 : const float Bin_Ener_128[], /* i : FFT Bin energy 128 bins in two sets */
8395 : const float lsf[], /* i : LSF vector */
8396 : float w[], /* o : LP weighting filter (numerator) */
8397 : const int16_t narrowBand, /* i : flag for Narrowband */
8398 : const int16_t unvoiced, /* i : flag for Unvoiced frame */
8399 : const int32_t sr_core, /* i : sampling rate of core-coder */
8400 : const int16_t order /* i : LP order */
8401 : );
8402 :
8403 : int16_t vad_init(
8404 : VAD_CLDFB_HANDLE hVAD_CLDFB /* i/o: CLDFB VAD state */
8405 : );
8406 :
8407 : int16_t vad_proc(
8408 : float realValues[16][60], /* i : CLDFB real values */
8409 : float imagValues[16][60], /* i : CLDFB imag values */
8410 : float *sb_power, /* i/o: Energy of CLDFB data */
8411 : const int16_t numBands, /* i : number of input bands */
8412 : VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
8413 : int16_t *cldfb_addition,
8414 : const int16_t vada_flag /* i : VAD flag */
8415 : );
8416 :
8417 : void subband_FFT(
8418 : float Sr[16][60], /* i : real part */
8419 : float Si[16][60], /* i : imag part */
8420 : float *spec_amp /* o : spectral amplitude */
8421 : );
8422 :
8423 : int16_t update_decision(
8424 : VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
8425 : const float snr, /* i : frequency domain SNR */
8426 : const float tsnr, /* i : time domain SNR */
8427 : const float frame_energy, /* i : current frame energy */
8428 : const float high_eng, /* i : current frame high frequency energy */
8429 : const int16_t vad_flag, /* i : VAD flag */
8430 : const int16_t music_backgound_f /* i : background music flag */
8431 : );
8432 :
8433 : void frame_spec_dif_cor_rate(
8434 : float spec_amp[], /* i : spectral amplitude */
8435 : float pre_spec_low_dif[], /* i/o: low spectrum different */
8436 : float f_tonality_rate[] /* o : tonality rate */
8437 : );
8438 :
8439 : void ltd_stable(
8440 : float frames_power[], /* i/o: energy of several frames */
8441 : float ltd_stable_rate[], /* o : time-domain stable rate */
8442 : const float frame_energy, /* i : current frame energy */
8443 : const int16_t frameloop /* i : number of frames */
8444 : );
8445 :
8446 : void SNR_calc(
8447 : const float frame_sb_energy[], /* i : energy of sub-band divided non-uniformly*/
8448 : const float sb_bg_energy[], /* i : sub-band background energy */
8449 : const float t_bg_energy, /* i : time background energy of several frames*/
8450 : float *snr, /* o : frequency domain SNR */
8451 : float *tsnr, /* o : time domain SNR */
8452 : const float frame_energy, /* i : current frame energy */
8453 : const int16_t bwidth /* i : audio bandwidth */
8454 : );
8455 :
8456 : void background_update(
8457 : VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
8458 : float frame_energy, /* i : current frame energy 2 */
8459 : const int16_t update_flag, /* i : current frame update flag */
8460 : const int16_t music_backgound_f, /* i : background music flag */
8461 : const float snr );
8462 :
8463 : void bg_music_decision(
8464 : VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
8465 : int16_t *music_backgound_f, /* i : background music flag */
8466 : const float frame_energy /* i : current frame energy 1 */
8467 : );
8468 :
8469 : void est_energy(
8470 : float sb_power[], /* o : energy of sub-band divided uniformly */
8471 : float frame_sb_energy[], /* o : energy of sub-band divided non-uniformly*/
8472 : float *p_frame_energy, /* o : frame energy 1 */
8473 : float *p_frame_energy2, /* o : frame energy 2 */
8474 : float *p_high_energy, /* o : high frequency energy */
8475 : const int16_t bw /* i : bandwidth */
8476 : );
8477 :
8478 : void spec_center(
8479 : float spec_power[], /* i : energy of sub-band divided uniformly */
8480 : float sp_center[], /* o : spectral center */
8481 : const int16_t bw_index /* i : bandwidth */
8482 : );
8483 :
8484 : void spec_flatness(
8485 : float spec_amp[], /* i : spectral amplitude */
8486 : float smooth_spec_amp[], /* i : smoothed spectral amplitude */
8487 : float sSFM[] /* o : spectral flatness rate */
8488 : );
8489 :
8490 : int16_t comvad_decision(
8491 : VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
8492 : const float snr, /* i : frequency domain SNR */
8493 : const float tsnr, /* i : time domain SNR */
8494 : const float snr_flux, /* i : average tsnr of several frames */
8495 : const float lt_snr, /* i : long time SNR calculated by fg_energy and bg_energy*/
8496 : const float lt_snr_org, /* i : original long time SNR */
8497 : const float lf_snr, /* i : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/
8498 : const float frame_energy, /* i : current frame energy */
8499 : const int16_t music_backgound_f, /* i : background music flag */
8500 : int16_t *cldfb_addition,
8501 : const int16_t vada_flag /* i : VAD flag */
8502 : );
8503 :
8504 : void calc_snr_flux(
8505 : float tsnr, /* i : time-domain SNR */
8506 : float pre_snr[], /* i/o: time-domain SNR storage */
8507 : float *snr_flux /* o : average tsnr */
8508 : );
8509 :
8510 : void calc_lt_snr(
8511 : float *lt_snr_org, /* o : original long time SNR */
8512 : float *lt_snr, /* o : long time SNR calculated by fg_energy and bg_energy*/
8513 : const float fg_energy, /* i : foreground energy sum */
8514 : const int16_t fg_energy_count, /* i : number of the foreground energy frame */
8515 : const float bg_energy, /* i : background energy sum */
8516 : const int16_t bg_energy_count, /* i : number of the background energy frame */
8517 : const int16_t bw_index, /* i : band width index */
8518 : const float lt_noise_sp_center0 /* i : long time noise spectral center by 0 */
8519 : );
8520 :
8521 : void calc_lf_snr(
8522 : float *lf_snr_smooth, /* o : smoothed lf_snr */
8523 : float *lf_snr, /* o : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/
8524 : const float l_speech_snr, /* i : sum of active frames snr */
8525 : const int16_t l_speech_snr_count, /* i : number of the active frame */
8526 : const float l_silence_snr, /* i : sum of the nonactive frames snr */
8527 : const int16_t l_silence_snr_count, /* i : number of the nonactive frame */
8528 : const int16_t fg_energy_count, /* i : number of the foreground energy frame */
8529 : const int16_t bg_energy_count, /* i : number of the background energy frame */
8530 : const int16_t bw_index /* i : band width index */
8531 : );
8532 :
8533 : float construct_snr_thresh(
8534 : const float sp_center[], /* i : spectral center */
8535 : const float snr_flux, /* i : snr flux */
8536 : const float lt_snr, /* i : long time time domain snr */
8537 : const float lf_snr, /* i : long time frequency domain snr */
8538 : const int16_t continuous_speech_num, /* i : continuous speech number */
8539 : const int16_t continuous_noise_num, /* i : continuous noise number */
8540 : const int16_t fg_energy_est_start, /* i : whether if estimated energy */
8541 : const int16_t bw_index /* i : band width index */
8542 : );
8543 :
8544 : ivas_error createFdCngCom(
8545 : HANDLE_FD_CNG_COM *hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
8546 : );
8547 :
8548 : void deleteFdCngCom(
8549 : HANDLE_FD_CNG_COM *hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
8550 : );
8551 :
8552 : void initFdCngCom(
8553 : HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
8554 : const float scale );
8555 :
8556 : void initPartitions(
8557 : const int16_t *part_in,
8558 : const int16_t npart_in,
8559 : const int16_t startBand,
8560 : const int16_t stopBand,
8561 : int16_t *part_out,
8562 : int16_t *npart_out,
8563 : int16_t *midband,
8564 : float *psize,
8565 : float *psize_inv,
8566 : const int16_t stopBandFR );
8567 :
8568 : void minimum_statistics(
8569 : const int16_t len, /* i : Vector length */
8570 : const int16_t lenFFT, /* i : Length of the FFT part of the vectors */
8571 : float *psize,
8572 : float *msPeriodog, /* i : Periodograms */
8573 : float *msNoiseFloor,
8574 : float *msNoiseEst, /* o : Noise estimates */
8575 : float *msAlpha,
8576 : float *msPsd,
8577 : float *msPsdFirstMoment,
8578 : float *msPsdSecondMoment,
8579 : float *msMinBuf,
8580 : float *msBminWin,
8581 : float *msBminSubWin,
8582 : float *msCurrentMin,
8583 : float *msCurrentMinOut,
8584 : float *msCurrentMinSubWindow,
8585 : int16_t *msLocalMinFlag,
8586 : int16_t *msNewMinFlag,
8587 : float *msPeriodogBuf,
8588 : int16_t *msPeriodogBufPtr,
8589 : HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
8590 : const int16_t enc_dec, /* i : encoder/decoder indicator */
8591 : const int16_t element_mode /* i : IVAS element mode */
8592 : );
8593 :
8594 : void generate_comfort_noise_enc(
8595 : Encoder_State *st /* i/o: encoder state structure */
8596 : );
8597 :
8598 : void generate_comfort_noise_dec(
8599 : float **bufferReal, /* o : Real part of input bands */
8600 : float **bufferImag, /* o : Imaginary part of input bands */
8601 : Decoder_State *st, /* i/o: decoder state structure */
8602 : const int16_t nchan_out /* i : number of output channels */
8603 : );
8604 :
8605 : void generate_comfort_noise_dec_hf(
8606 : float **bufferReal, /* o : Real part of input bands */
8607 : float **bufferImag, /* o : Imaginary part of input bands */
8608 : HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
8609 : const int16_t cng_flag /* i : CNG Flag */
8610 : );
8611 :
8612 : void generate_masking_noise(
8613 : float *timeDomainBuffer, /* i/o: time-domain signal */
8614 : HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
8615 : const int16_t length, /* i : frame size */
8616 : const int16_t core, /* i : core */
8617 : const int16_t return_noise, /* i : noise is returned instead of added */
8618 : const int16_t secondary, /* i : indicator for secondary channel */
8619 : const int16_t element_mode, /* i : element mode */
8620 : STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
8621 : const int16_t nchan_out /* i : number of output channels */
8622 : );
8623 :
8624 : void generate_masking_noise_update_seed(
8625 : HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
8626 : );
8627 :
8628 : void generate_masking_noise_mdct(
8629 : float *mdctBuffer, /* i/o: time-domain signal */
8630 : HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
8631 : );
8632 :
8633 : void SynthesisSTFT_dirac(
8634 : float *fftBuffer, /* i : FFT bins */
8635 : float *timeDomainOutput,
8636 : float *olapBuffer,
8637 : const float *olapWin,
8638 : const int16_t samples_out,
8639 : HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
8640 : );
8641 :
8642 : void generate_masking_noise_dirac(
8643 : HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
8644 : HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */
8645 : float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */
8646 : float *Cldfb_RealBuffer, /* o : CLDFD real buffer */
8647 : float *Cldfb_ImagBuffer, /* o : CLDFD imaginary buffer */
8648 : const int16_t slot_index, /* i : CLDFB slot index */
8649 : const int16_t cna_flag, /* i : CNA flag for LB and HB */
8650 : const int16_t fd_cng_flag /* i : FD-CNG flag for HB */
8651 : );
8652 :
8653 : void generate_stereo_masking_noise(
8654 : float *syn, /* i/o: time-domain signal */
8655 : Decoder_State *st, /* i/o: decoder state structure */
8656 : STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */
8657 : const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */
8658 : const int16_t fadeOut, /* i : only fade out of previous state */
8659 : STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
8660 : const int16_t nchan_out /* i : number of output channels */
8661 : );
8662 :
8663 : void apply_scale(
8664 : float *scale, /* i : scale factor */
8665 : const int16_t bwidth, /* i : audio bandwidth */
8666 : const int32_t brate, /* i : Bit rate */
8667 : const SCALE_SETUP *scaleTable, /* i : Scale table */
8668 : const int16_t scaleTableSize /* i : Size of scale table */
8669 : );
8670 :
8671 : void compress_range(
8672 : float *in,
8673 : float *out,
8674 : const int16_t len );
8675 :
8676 : void expand_range(
8677 : float *in,
8678 : float *out,
8679 : const int16_t len );
8680 :
8681 : void bandcombinepow(
8682 : const float *bandpow, /* i : Power for each band */
8683 : const int16_t nband, /* i : Number of bands */
8684 : int16_t *part, /* i : Partition upper boundaries (band indices starting from 0) */
8685 : const int16_t npart, /* i : Number of partitions */
8686 : const float *psize_inv, /* i : Inverse partition sizes */
8687 : float *partpow /* o : Power for each partition */
8688 : );
8689 :
8690 : void scalebands(
8691 : const float *partpow, /* i : Power for each partition */
8692 : int16_t *part, /* i : Partition upper boundaries (band indices starting from 0) */
8693 : const int16_t npart, /* i : Number of partitions */
8694 : int16_t *midband, /* i : Central band of each partition */
8695 : const int16_t nFFTpart, /* i : Number of FFT partitions */
8696 : const int16_t nband, /* i : Number of bands */
8697 : float *bandpow, /* o : Power for each band */
8698 : const int16_t flag_fft_en );
8699 :
8700 : void AnalysisSTFT(
8701 : const float *timeDomainInput,
8702 : float *fftBuffer, /* o : FFT bins */
8703 : HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */
8704 : );
8705 :
8706 : void SynthesisSTFT(
8707 : float *fftBuffer,
8708 : float *timeDomainOutput,
8709 : float *olapBuffer,
8710 : const float *olapWin,
8711 : const int16_t tcx_transition,
8712 : HANDLE_FD_CNG_COM hFdCngCom,
8713 : const int16_t element_mode, /* i : element mode */
8714 : const int16_t nchan_out /* i : number of output channels */
8715 : );
8716 :
8717 : float rand_gauss(
8718 : float *x,
8719 : int16_t *seed );
8720 :
8721 : void lpc_from_spectrum(
8722 : HANDLE_FD_CNG_COM hFdCngCom,
8723 : const int16_t start,
8724 : const int16_t stop,
8725 : const float preemph_fac );
8726 :
8727 : ivas_error createFdCngDec(
8728 : HANDLE_FD_CNG_DEC *hFdCngDec );
8729 :
8730 : void deleteFdCngDec(
8731 : HANDLE_FD_CNG_DEC *hFdCngDec );
8732 :
8733 : void initFdCngDec(
8734 : DEC_CORE_HANDLE st /* i/o: decoder state structure */
8735 : );
8736 :
8737 : void configureFdCngDec(
8738 : HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */
8739 : const int16_t bwidth,
8740 : const int32_t total_brate,
8741 : const int16_t L_frame,
8742 : const int16_t last_L_frame,
8743 : const int16_t element_mode );
8744 :
8745 : void ApplyFdCng(
8746 : float *timeDomainInput,
8747 : float *powerSpectrum,
8748 : float **realBuffer, /* i/o: Real part of the buffer */
8749 : float **imagBuffer, /* i/o: Imaginary part of the buffer */
8750 : Decoder_State *st,
8751 : const int16_t concealWholeFrame, /* i : binary flag indicating frame loss */
8752 : const int16_t is_music );
8753 :
8754 : void generate_comfort_noise_dec(
8755 : float **bufferReal, /* o : Real part of input bands */
8756 : float **bufferImag, /* o : Imaginary part of input bands */
8757 : Decoder_State *st, /* i/o: decoder state structure */
8758 : const int16_t nchan_out /* i : number of output channels */
8759 : );
8760 :
8761 : /*! r: CNG energy */
8762 : float cng_energy(
8763 : const int16_t element_mode, /* i : element mode */
8764 : const int16_t bwidth, /* i : audio bandwidh */
8765 : const int16_t CNG_mode, /* i : mode for DTX configuration */
8766 : const float CNG_att, /* i : attenuation factor for CNG */
8767 : const float *inputBuffer, /* i : input signal */
8768 : const int16_t len /* i : vector length */
8769 : );
8770 :
8771 : void FdCng_decodeSID(
8772 : Decoder_State *st /* i/o: decoder state structure */
8773 : );
8774 :
8775 : void FdCng_exc(
8776 : HANDLE_FD_CNG_COM hFdCngCom,
8777 : int16_t *CNG_mode,
8778 : const int16_t L_frame,
8779 : const float *lsp_old,
8780 : const int16_t first_CNG,
8781 : float *lsp_CNG,
8782 : float *Aq, /* o : LPC coeffs */
8783 : float *lsp_new, /* o : lsp */
8784 : float *lsf_new, /* o : lsf */
8785 : float *exc, /* o : LP excitation */
8786 : float *exc2, /* o : LP excitation */
8787 : float *bwe_exc /* o : LP excitation for BWE */
8788 : );
8789 :
8790 : void noisy_speech_detection(
8791 : HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */
8792 : const int16_t vad, /* i : VAD flag */
8793 : const float syn[] /* i : input time-domain frame */
8794 : );
8795 :
8796 : ivas_error createFdCngEnc(
8797 : HANDLE_FD_CNG_ENC *hFdCngEnc /* i/o: FD_CNG structure */
8798 : );
8799 :
8800 : void deleteFdCngEnc(
8801 : HANDLE_FD_CNG_ENC *hFdCngEnc /* i/o: FD_CNG structure */
8802 : );
8803 :
8804 : void configureFdCngEnc(
8805 : HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */
8806 : const int16_t bwidth,
8807 : const int32_t total_brate );
8808 :
8809 : void initFdCngEnc(
8810 : HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */
8811 : const int32_t input_Fs, /* i : input signal sampling frequency in Hz */
8812 : const float scale /* i : scaling factor */
8813 : );
8814 :
8815 : void resetFdCngEnc(
8816 : Encoder_State *st /* i/o: encoder state structure */
8817 : );
8818 :
8819 : void perform_noise_estimation_enc(
8820 : float *band_energies, /* i : energy in critical bands without minimum noise floor E_MIN */
8821 : float *enerBuffer, /* i : energy buffer */
8822 : HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */
8823 : const int32_t input_Fs, /* i : input sampling rate */
8824 : CPE_ENC_HANDLE hCPE );
8825 :
8826 : void AdjustFirstSID(
8827 : Encoder_State *st /* i/o: encoder state structure */
8828 : );
8829 :
8830 : void FdCng_encodeSID(
8831 : Encoder_State *st /* i/o: encoder state structure */
8832 : );
8833 :
8834 : void GetParameters(
8835 : ParamsBitMap const *paramsBitMap,
8836 : const int16_t nParams,
8837 : void const *pParameter,
8838 : int16_t **pStream,
8839 : int16_t *pnSize,
8840 : int16_t *pnBits );
8841 :
8842 : void SetParameters(
8843 : ParamsBitMap const *paramsBitMap,
8844 : const int16_t nParams,
8845 : void *pParameter,
8846 : const int16_t **pStream,
8847 : int16_t *pnSize );
8848 :
8849 : void WriteToBitstream(
8850 : ParamsBitMap const *paramsBitMap,
8851 : const int16_t nParams,
8852 : const int16_t **pStream,
8853 : int16_t *pnSize,
8854 : BSTR_ENC_HANDLE hBstr,
8855 : int16_t *pnBits );
8856 :
8857 : void ReadFromBitstream(
8858 : ParamsBitMap const *paramsBitMap,
8859 : const int16_t nArrayLength,
8860 : Decoder_State *st,
8861 : int16_t **pStream,
8862 : int16_t *pnSize );
8863 :
8864 : void const *GetTnsFilterOrder( void const *p, const int16_t index, int16_t *pValue );
8865 : void *SetTnsFilterOrder( void *p, const int16_t index, const int16_t value );
8866 : void const *GetNumOfTnsFilters( void const *p, const int16_t index, int16_t *pValue );
8867 : void *SetNumOfTnsFilters( void *p, const int16_t index, const int16_t value );
8868 : void const *GetTnsEnabled( void const *p, const int16_t index, int16_t *pValue );
8869 : void *SetTnsEnabled( void *p, const int16_t index, const int16_t value );
8870 : void const *GetTnsEnabledSingleFilter( void const *p, const int16_t index, int16_t *pValue );
8871 : void *SetTnsEnabledSingleFilter( void *p, const int16_t index, const int16_t value );
8872 : void const *GetTnsFilterCoeff( void const *p, const int16_t index, int16_t *pValue );
8873 : void *SetTnsFilterCoeff( void *p, const int16_t index, const int16_t value );
8874 :
8875 : void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue );
8876 : void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value );
8877 :
8878 : int16_t GetSWBTCX10TnsFilterCoeffBits( const int16_t value, const int16_t index );
8879 : int16_t EncodeSWBTCX10TnsFilterCoeff( const int16_t value, const int16_t index );
8880 : int16_t DecodeSWBTCX10TnsFilterCoeff( Decoder_State *st, const int16_t index, int16_t *pValue );
8881 : int16_t GetSWBTCX20TnsFilterCoeffBits( const int16_t value, const int16_t index );
8882 : int16_t EncodeSWBTCX20TnsFilterCoeff( const int16_t value, const int16_t index );
8883 : int16_t DecodeSWBTCX20TnsFilterCoeff( Decoder_State *st, const int16_t index, int16_t *pValue );
8884 :
8885 : int16_t GetWBTCX20TnsFilterCoeffBits( const int16_t value, const int16_t index );
8886 : int16_t EncodeWBTCX20TnsFilterCoeff( const int16_t, const int16_t index );
8887 : int16_t DecodeWBTCX20TnsFilterCoeff( Decoder_State *st, const int16_t index, int16_t *pValue );
8888 :
8889 : int16_t GetTnsFilterOrderBitsSWBTCX10( const int16_t value, const int16_t index );
8890 : int16_t EncodeTnsFilterOrderSWBTCX10( const int16_t value, const int16_t index );
8891 : int16_t DecodeTnsFilterOrderSWBTCX10( Decoder_State *st, const int16_t index, int16_t *pValue );
8892 : int16_t GetTnsFilterOrderBitsSWBTCX20( const int16_t value, const int16_t index );
8893 : int16_t EncodeTnsFilterOrderSWBTCX20( const int16_t value, const int16_t index );
8894 : int16_t DecodeTnsFilterOrderSWBTCX20( Decoder_State *st, const int16_t index, int16_t *pValue );
8895 : int16_t GetTnsFilterOrderBits( const int16_t value, const int16_t index );
8896 : int16_t EncodeTnsFilterOrder( const int16_t value, const int16_t index );
8897 : int16_t DecodeTnsFilterOrder( Decoder_State *st, const int16_t index, int16_t *pValue );
8898 :
8899 : void ResetTnsData(
8900 : STnsData *pTnsData );
8901 :
8902 : void ClearTnsFilterCoefficients(
8903 : STnsFilter *pTnsFilter );
8904 :
8905 : void InitTnsConfiguration(
8906 : const int16_t bwidth,
8907 : const int16_t frameLength,
8908 : STnsConfig *pTnsConfig,
8909 : const int16_t igfStopFreq,
8910 : const int32_t total_brate,
8911 : const int16_t element_mode,
8912 : const int16_t MCT_flag );
8913 :
8914 : int16_t DetectTnsFilt(
8915 : const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */
8916 : const float pSpectrum[], /* i : MDCT spectrum */
8917 : TRAN_DET_HANDLE hTranDet, /* i : transient detection handle */
8918 : const int16_t isTCX10, /* i : TCX10 or TCX20? */
8919 : const float ltp_gain, /* i : LTP gain */
8920 : STnsData *pTnsData, /* o : TNS data struct */
8921 : float *predictionGain /* o : TNS prediction gain */
8922 : );
8923 :
8924 : void ApplyTnsFilter(
8925 : STnsConfig const *pTnsConfig,
8926 : STnsData const *pTnsData,
8927 : float spectrum[],
8928 : const int16_t fIsAnalysis );
8929 :
8930 : int16_t ITF_Detect(
8931 : const float pSpectrum[],
8932 : const int16_t startLine,
8933 : const int16_t stopLine,
8934 : const int16_t maxOrder,
8935 : float *A,
8936 : float *predictionGain,
8937 : int16_t *curr_order );
8938 :
8939 : void ITF_Apply(
8940 : float spectrum[],
8941 : const int16_t startLine,
8942 : const int16_t stopLine,
8943 : const float *A,
8944 : const int16_t curr_order );
8945 :
8946 : void EncodeTnsData(
8947 : STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */
8948 : STnsData const *pTnsData, /* i : TNS data struct (quantized param) */
8949 : int16_t *stream, /* o : internal data stream */
8950 : int16_t *pnSize, /* o : number of written parameters */
8951 : int16_t *pnBits /* o : number of written bits */
8952 : );
8953 :
8954 : int16_t DecodeTnsData(
8955 : STnsConfig const *pTnsConfig,
8956 : const int16_t *stream,
8957 : int16_t *pnSize,
8958 : STnsData *pTnsData );
8959 :
8960 : void WriteTnsData(
8961 : const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */
8962 : const int16_t *stream, /* i : internal data stream */
8963 : int16_t *pnSize, /* o : number of written parameters */
8964 : BSTR_ENC_HANDLE hBstr, /* o : bitstream */
8965 : int16_t *pnBits /* o : number of written bits */
8966 : );
8967 :
8968 : void ReadTnsData(
8969 : STnsConfig const *pTnsConfig,
8970 : Decoder_State *st,
8971 : int16_t *pnBits,
8972 : int16_t *stream,
8973 : int16_t *pnSize );
8974 :
8975 : void cldfbAnalysis(
8976 : const float *timeIn, /* i : time buffer */
8977 : float **realBuffer, /* o : real value buffer */
8978 : float **imagBuffer, /* o : imag value buffer */
8979 : const int16_t samplesToProcess, /* i : number of input samples */
8980 : HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */
8981 : );
8982 :
8983 : void cldfbAnalysis_ts(
8984 : const float *timeIn, /* i : time buffer */
8985 : float realBuffer[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */
8986 : float imagBuffer[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */
8987 : const int16_t samplesToProcess, /* i : samples to process */
8988 : HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */
8989 : );
8990 :
8991 : void cldfbSynthesis(
8992 : float **realBuffer, /* i : real values */
8993 : float **imagBuffer, /* i : imag values */
8994 : float *timeOut, /* o : synthesized output */
8995 : const int16_t samplesToProcess, /* i : number of samples */
8996 : HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */
8997 : );
8998 :
8999 : void configureCldfb(
9000 : HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */
9001 : const int32_t sampling_rate /* i : sampling rate */
9002 : );
9003 :
9004 : void analysisCldfbEncoder(
9005 : Encoder_State *st, /* i/o: encoder state structure */
9006 : const float *timeIn,
9007 : const int16_t samplesToProcess,
9008 : float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
9009 : float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
9010 : float *ppBuf_Ener );
9011 :
9012 : ivas_error openCldfb(
9013 : HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */
9014 : CLDFB_TYPE type, /* i : analysis or synthesis */
9015 : const int32_t sampling_rate, /* i : sampling rate */
9016 : CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */
9017 : );
9018 :
9019 : void resampleCldfb(
9020 : HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */
9021 : const int32_t newSamplerate /* i : new samplerate to operate */
9022 : );
9023 :
9024 : ivas_error cldfb_save_memory(
9025 : HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
9026 : );
9027 :
9028 : void cldfb_restore_memory(
9029 : HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
9030 : );
9031 :
9032 : void cldfb_reset_memory(
9033 : HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
9034 : );
9035 :
9036 : void deleteCldfb(
9037 : HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */
9038 : );
9039 :
9040 : void fft_cldfb(
9041 : float *data, /* i/o: input/output vector */
9042 : const int16_t size /* i : size of fft operation */
9043 : );
9044 :
9045 : void BITS_ALLOC_init_config_acelp(
9046 : const int32_t bit_rate,
9047 : const int16_t narrowBand,
9048 : const int16_t nb_subfr,
9049 : ACELP_config *acelp_cfg /* o : configuration structure of ACELP */
9050 : );
9051 :
9052 : int16_t BITS_ALLOC_config_acelp(
9053 : const int16_t bits_frame, /* i : remaining bit budget for the frame */
9054 : const int16_t coder_type, /* i : acelp coder type */
9055 : ACELP_config *acelp_cfg, /* i/o: configuration structure of ACELP */
9056 : const int16_t narrowband, /* i : narrowband flag */
9057 : const int16_t nb_subfr /* i : number of subframes */
9058 : );
9059 :
9060 : ivas_error config_acelp1(
9061 : const int16_t enc_dec, /* i : encoder/decoder flag */
9062 : const int32_t total_brate, /* i : total bitrate */
9063 : const int32_t core_brate_inp, /* i : core bitrate */
9064 : const int16_t core, /* i : core */
9065 : const int16_t extl, /* i : extension layer */
9066 : const int32_t extl_brate, /* i : extension layer bitrate */
9067 : const int16_t L_frame, /* i : frame length at internal Fs */
9068 : const int16_t GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
9069 : ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
9070 : const int16_t signaling_bits, /* i : number of signaling bits */
9071 : const int16_t coder_type, /* i : coder type */
9072 : const int16_t inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
9073 : const int16_t tc_subfr, /* i : TC subfr ID */
9074 : const int16_t tc_call, /* i : TC call number (0,1,2) */
9075 : int16_t *nBits_es_Pred, /* o : number of bits for Es_pred Q */
9076 : int16_t *unbits, /* o : number of unused bits */
9077 : const int16_t element_mode, /* i : element mode */
9078 : int16_t *uc_two_stage_flag, /* o : flag undicating two-stage UC */
9079 : const int16_t tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel*/
9080 : const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/
9081 : const int16_t idchan, /* i : channel id */
9082 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
9083 : const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */
9084 : const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */
9085 : );
9086 :
9087 : /*! r: ACELP16k flag */
9088 : int16_t set_ACELP_flag(
9089 : const int16_t element_mode, /* i : element mode */
9090 : const int32_t element_brate, /* i : element bitrate */
9091 : const int32_t total_brate, /* i : total bitrate per channel */
9092 : const int16_t idchan, /* i : Channel id */
9093 : const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */
9094 : const int16_t bwidth, /* i : audio bandwidth */
9095 : const int16_t cng_type /* i : CNG type */
9096 : );
9097 :
9098 : void FEC_clas_estim(
9099 : const float *syn,
9100 : const float *pitch, /* i : pitch values for each subframe */
9101 : const int16_t L_frame, /* i : length of the frame */
9102 : const int16_t coder_type, /* i : coder type */
9103 : const int16_t codec_mode, /* i : codec mode */
9104 : float *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */
9105 : int16_t *clas, /* i/o: frame classification */
9106 : float *lp_speech, /* i/o: long term active speech energy average */
9107 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
9108 : int16_t *decision_hyst, /* i/o: hysteresis of the music/speech decision */
9109 : int16_t *locattack, /* i/o: detection of attack (mainly to localized speech burst) */
9110 : int16_t *UV_cnt, /* i/o: number of consecutives frames classified as UV */
9111 : float *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV */
9112 : float *Last_ener, /* i/o: last_energy frame */
9113 : int16_t *amr_io_class, /* i/o: classification for AMR-WB IO mode */
9114 : float *lt_diff_etot, /* i/o: long-term total energy variation */
9115 : float *class_para, /* o : classification para. fmerit1 */
9116 : const float LTP_Gain, /* i : */
9117 : const int16_t narrowBand, /* i : */
9118 : const SIGNAL_CLASSIFIER_MODE mode, /* i : */
9119 : const int16_t bfi, /* i : */
9120 : const float preemph_fac, /* i : */
9121 : const int16_t tcxonly, /* i : */
9122 : const int32_t last_core_brate, /* i : last core bitrate */
9123 : const int16_t FEC_mode /* i : ACELP FEC mode */
9124 : );
9125 :
9126 : void InitTransientDetection(
9127 : const int16_t nFrameLength,
9128 : const int16_t nTCXDelay,
9129 : TRAN_DET_HANDLE hTranDet,
9130 : const int16_t ext_mem_flag );
9131 :
9132 : void RunTransientDetection(
9133 : const float *input, /* i : input signal */
9134 : const int16_t length, /* i : frame length */
9135 : TRAN_DET_HANDLE hTranDet /* i/o: transient detection handle */
9136 : );
9137 :
9138 : float GetTCXAvgTemporalFlatnessMeasure(
9139 : TRAN_DET_HANDLE hTranDet,
9140 : const int16_t nCurrentSubblocks,
9141 : const int16_t nPrevSubblocks );
9142 :
9143 : float GetTCXMaxenergyChange(
9144 : TRAN_DET_HANDLE hTranDet,
9145 : const int16_t isTCX10,
9146 : const int16_t nCurrentSubblocks,
9147 : const int16_t nPrevSubblocks );
9148 :
9149 : void SetTCXModeInfo(
9150 : Encoder_State *st, /* i/o: encoder state structure */
9151 : TRAN_DET_HANDLE hTranDet, /* i/o: transient detection handle */
9152 : int16_t *tcxModeOverlap /* o : window overlap of current frame */
9153 : );
9154 :
9155 : void TCX_MDCT(
9156 : const float *x,
9157 : float *y,
9158 : const int16_t l,
9159 : const int16_t m,
9160 : const int16_t r,
9161 : const int16_t element_mode );
9162 :
9163 : void TCX_MDST(
9164 : const float *x,
9165 : float *y,
9166 : const int16_t l,
9167 : const int16_t m,
9168 : const int16_t r,
9169 : const int16_t element_mode );
9170 :
9171 : void TCX_MDCT_Inverse(
9172 : const float *x,
9173 : float *y,
9174 : const int16_t l,
9175 : const int16_t m,
9176 : const int16_t r,
9177 : const int16_t element_mode );
9178 :
9179 : void TCX_MDST_Inverse(
9180 : const float *x,
9181 : float *y,
9182 : const int16_t l,
9183 : const int16_t m,
9184 : const int16_t r,
9185 : const int16_t element_mode );
9186 :
9187 : void TCX_MDXT_Inverse(
9188 : const float *x,
9189 : float *y,
9190 : const int16_t l,
9191 : const int16_t m,
9192 : const int16_t r,
9193 : const uint16_t kernel_type );
9194 :
9195 : void post_decoder(
9196 : Decoder_State *st,
9197 : float synth_buf[],
9198 : const float pit_gain[],
9199 : const int16_t pitch[],
9200 : float signal_out[],
9201 : float bpf_noise_buf[] );
9202 :
9203 : float bass_pf_enc(
9204 : const float *orig, /* i : 12.8kHz original signal */
9205 : const float *syn, /* i : 12.8kHz synthesis to postfilter */
9206 : const float pitch_buf[], /* i : Pitch gain for all subframes (gainT_sf[16]) */
9207 : const float gainT_sf[], /* i : Pitch gain for all subframes (gainT_sf[16]) */
9208 : const int16_t l_frame, /* i : frame length (should be multiple of l_subfr)*/
9209 : const int16_t l_subfr_in, /* i : sub-frame length (60/64) */
9210 : float mem_bpf[], /* i/o: memory state [2*L_FILT] */
9211 : float mem_error_bpf[], /* i/o: memory state [2*L_FILT] */
9212 : int16_t *gain_factor_param, /* o : quantized gain factor */
9213 : const int16_t mode, /* i : coding mode of adapt bpf */
9214 : float *mem_deemph_err, /* i/o: Error deemphasis memory */
9215 : float *lp_ener /* i/o: long_term error signal energy */
9216 : );
9217 :
9218 : void cldfb_synth_set_bandsToZero(
9219 : Decoder_State *st, /* i/o: decoder state structure */
9220 : float **rAnalysis,
9221 : float **iAnalysis,
9222 : const int16_t nTimeSlots );
9223 :
9224 : void longadd(
9225 : uint16_t a[], /* i/o: vector of the length lena */
9226 : const uint16_t b[], /* i/o: vector of the length lenb */
9227 : const int16_t lena, /* i/o: length of vector a[] */
9228 : const int16_t lenb /* i/o: length of vector b[] */
9229 : );
9230 :
9231 : void longshiftright(
9232 : uint16_t a[], /* i : vector of the length lena */
9233 : const int16_t b, /* i : number of bit positions to shift right */
9234 : uint16_t d[], /* o : vector of the length lend */
9235 : int16_t lena, /* i : length of vector a[] */
9236 : const int16_t lend /* i : length of vector d[] */
9237 : );
9238 :
9239 : void longshiftleft(
9240 : const uint16_t a[], /* i : vector of the length len */
9241 : const int16_t b, /* i : number of bit positions to shift left */
9242 : uint16_t d[], /* o : vector of the length len */
9243 : const int16_t len /* i : length of vector a[] and d[] */
9244 : );
9245 :
9246 : void open_decoder_LPD(
9247 : Decoder_State *st, /* i/o: decoder state structure */
9248 : const int32_t total_brate, /* i : total bitrate */
9249 : const int32_t last_total_brate, /* i : last total bitrate */
9250 : const int16_t bwidth, /* i : audio bandwidth */
9251 : const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
9252 : const int16_t last_element_mode, /* i : last element mode */
9253 : const int16_t is_init /* i : indicate call during initialization */
9254 : );
9255 :
9256 : void acelp_plc_mdct_transition(
9257 : Decoder_State *st /* i/o: Decoder state */
9258 : );
9259 :
9260 : void tcxltp_dec_init(
9261 : TCX_LTP_DEC_HANDLE hTcxLtpDec,
9262 : const int16_t ini_frame,
9263 : const int16_t last_codec_mode,
9264 : const int16_t element_mode,
9265 : const int16_t pit_max,
9266 : const int32_t sr_core );
9267 :
9268 : void reset_tcx_overl_buf(
9269 : TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */
9270 : );
9271 :
9272 : void update_decoder_LPD_cng(
9273 : Decoder_State *st, /* i/o: decoder state structure */
9274 : float *timeDomainBuffer,
9275 : float *A,
9276 : float *bpf_noise_buf );
9277 :
9278 : void reconfig_decoder_LPD(
9279 : Decoder_State *st, /* i/o: decoder state structure */
9280 : const int16_t bits_frame, /* i : bit budget */
9281 : const int16_t bwidth, /* i : audio bandwidth */
9282 : const int32_t total_brate, /* i : total bitrate */
9283 : const int16_t L_frame_old /* i : frame length */
9284 : );
9285 :
9286 : void mode_switch_decoder_LPD(
9287 : Decoder_State *st, /* i/o: decoder state structure */
9288 : const int16_t bwidth, /* i : audio bandwidth */
9289 : const int32_t total_brate, /* i : total bitrate */
9290 : const int32_t last_total_brate, /* i : last frame total bitrate */
9291 : const int16_t frame_size_index, /* i : index determining the frame size */
9292 : const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/
9293 : const int16_t last_element_mode /* i : last element mode */
9294 : );
9295 :
9296 : void dec_acelp_tcx_frame(
9297 : Decoder_State *st, /* i/o: decoder state structure */
9298 : int16_t *concealWholeFrame, /* i/o: concealment flag */
9299 : float *output, /* o : synthesis */
9300 : float *bpf_noise_buf, /* i/o: BPF noise buffer */
9301 : float *pcmbufFB, /* o : synthesis @output_FS */
9302 : float bwe_exc_extended[], /* i/o: bandwidth extended excitation */
9303 : float *voice_factors, /* o : voicing factors */
9304 : float pitch_buf[], /* o : floating pitch for each subframe */
9305 : STEREO_CNG_DEC_HANDLE hStereoCng /* i : stereo CNG handle */
9306 : );
9307 :
9308 : void decoder_LPD(
9309 : Decoder_State *st, /* i/o: decoder memory state pointer */
9310 : float signal_out[], /* o : signal with LPD delay (7 subfrs) */
9311 : float signal_outFB[], /* o : synthesis @output_FS */
9312 : int16_t *total_nbbits, /* i/o: number of bits / decoded bits */
9313 : float *bpf_noise_buf, /* i/o: BPF noise buffer */
9314 : int16_t bfi, /* i : BFI flag */
9315 : int16_t *bitsRead, /* o : number of read bits */
9316 : int16_t param[], /* o : buffer of parameters */
9317 : float *pitch_buf, /* i/o: floating pitch values for each subfr*/
9318 : float *voice_factors, /* o : voicing factors */
9319 : float *ptr_bwe_exc /* o : excitation for SWB TBE */
9320 : );
9321 :
9322 : int16_t tcxGetNoiseFillingTilt(
9323 : const float A[],
9324 : const int16_t L_frame,
9325 : const int16_t mode,
9326 : float *noiseTiltFactor );
9327 :
9328 : void tcxFormantEnhancement(
9329 : float xn_buf[],
9330 : const float *gainlpc,
9331 : float spectrum[],
9332 : const int16_t L_frame );
9333 :
9334 : void tcxInvertWindowGrouping(
9335 : TCX_CONFIG_HANDLE hTcxCfg,
9336 : float xn_buf[],
9337 : float spectrum[],
9338 : const int16_t L_frame,
9339 : const int16_t fUseTns,
9340 : const int16_t last_core,
9341 : const int16_t index,
9342 : const int16_t frame_cnt,
9343 : const int16_t bfi );
9344 :
9345 : void tcx5SpectrumInterleaving(
9346 : const int16_t tcx5Size,
9347 : float *spectrum );
9348 :
9349 : void tcx5SpectrumDeinterleaving(
9350 : const int16_t tcx5Size,
9351 : float *spectrum );
9352 :
9353 : void tcx5TnsGrouping(
9354 : const int16_t L_frame,
9355 : const int16_t L_spec,
9356 : float *spectrum );
9357 :
9358 : void tcx5TnsUngrouping(
9359 : const int16_t L_frame,
9360 : const int16_t L_spec,
9361 : float *spectrum,
9362 : const int16_t enc_dec );
9363 :
9364 : void lerp(
9365 : const float *f,
9366 : float *f_out,
9367 : const int16_t bufferNewSize,
9368 : const int16_t bufferOldSize );
9369 :
9370 : void encoderSideLossSimulation(
9371 : Encoder_State *st,
9372 : PLC_ENC_EVS_HANDLE hPlc_Ext,
9373 : float *isf_q,
9374 : const float stab_fac,
9375 : const int16_t calcOnlyISF,
9376 : const int16_t L_frame );
9377 :
9378 : void enc_prm_side_Info(
9379 : PLC_ENC_EVS_HANDLE hPlc_Ext,
9380 : Encoder_State *st );
9381 :
9382 : void GplcTcxEncSetup(
9383 : const int16_t tcxltp_pitch_int,
9384 : PLC_ENC_EVS_HANDLE hPlc_Ext );
9385 :
9386 : int16_t encSideSpecPowDiffuseDetector(
9387 : float *isf_ref,
9388 : float *isf_con,
9389 : const int32_t sr_core,
9390 : float *prev_isf4_mean,
9391 : const int16_t sw,
9392 : const int16_t coder_type );
9393 :
9394 : void updateSpecPowDiffuseIdx(
9395 : const float gain_pitch_buf[], /* i : gain pitch values */
9396 : const float gain_code_buf[], /* i : gain pitch values */
9397 : int16_t glr_idx[2], /* o : */
9398 : float mean_gc[2] /* o : */
9399 : );
9400 :
9401 : void getLookAheadResSig(
9402 : float *speechLookAhead,
9403 : const float *A,
9404 : float *res,
9405 : const int16_t L_frame,
9406 : const int16_t L_subfr,
9407 : const int16_t m,
9408 : const int16_t numSubFrame );
9409 :
9410 : void updatelsfForConcealment(
9411 : PLC_ENC_EVS_HANDLE decState,
9412 : float *lsf );
9413 :
9414 : void getConcealedLP(
9415 : PLC_ENC_EVS_HANDLE memDecState,
9416 : float *AqCon,
9417 : const float xsfBase[],
9418 : const int32_t sr_core,
9419 : const int16_t last_good,
9420 : const int16_t L_frame );
9421 :
9422 : void RecLpcSpecPowDiffuseLc(
9423 : float *ispq,
9424 : float *isp_old,
9425 : float *isfq,
9426 : Decoder_State *st,
9427 : const int16_t reset_q );
9428 :
9429 : void modify_lsf(
9430 : float *lsf,
9431 : const int16_t n,
9432 : const int32_t sr_core,
9433 : const int16_t reset_q );
9434 :
9435 : void init_PLC_enc(
9436 : PLC_ENC_EVS_HANDLE hPlcExt,
9437 : const int32_t sr_core );
9438 :
9439 : void gPLC_encInfo(
9440 : PLC_ENC_EVS_HANDLE hPlcExt,
9441 : const int32_t total_brate,
9442 : const int16_t bwidth,
9443 : const int16_t last_clas,
9444 : const int16_t coder_type );
9445 :
9446 : void resetTecDec(
9447 : TEC_DEC_HANDLE hTecDec );
9448 :
9449 : void calcGainTemp_TBE(
9450 : float **pCldfbRealSrc,
9451 : float **pCldfbImagSrc,
9452 : float *loBuffer,
9453 : const int16_t startPos, /*!< Start position of the current envelope. */
9454 : const int16_t stopPos, /*!< Stop position of the current envelope. */
9455 : const int16_t lowSubband, /* lowSubband */
9456 : float *pGainTemp,
9457 : const int16_t code );
9458 :
9459 : void procTecTfa_TBE(
9460 : float *hb_synth,
9461 : float *gain,
9462 : const int16_t flat_flag,
9463 : const int16_t last_core,
9464 : const int16_t L_subfr,
9465 : const int16_t code );
9466 :
9467 : void resetTecEnc(
9468 : TEC_ENC_HANDLE hTecEnc,
9469 : const int16_t flag );
9470 :
9471 : void calcHiEnvLoBuff(
9472 : const int16_t noCols,
9473 : const int16_t *pFreqBandTable, /* i : freqbandTable */
9474 : const int16_t nSfb, /* i : Number of scalefactors */
9475 : float **pYBuf,
9476 : float *loBuf,
9477 : float *hiTempEnv );
9478 :
9479 : void calcLoEnvCheckCorrHiLo(
9480 : const int16_t noCols,
9481 : const int16_t *pFreqBandTable, /* i : freqbandTable */
9482 : float *loBuf,
9483 : float *loTempEnv,
9484 : float *loTempEnv_ns,
9485 : float *hiTempEnv,
9486 : int16_t *corr_flag /* o : 0 for original, 1 for TEC */
9487 : );
9488 :
9489 : void tfaCalcEnv(
9490 : const float *shb_speech,
9491 : float *enr );
9492 :
9493 : int16_t tfaEnc_TBE(
9494 : const float *enr,
9495 : const int16_t last_core,
9496 : const float *voicing,
9497 : const float *pitch_buf );
9498 :
9499 : void tecEnc_TBE(
9500 : int16_t *corrFlag,
9501 : const float *voicing,
9502 : const int16_t coder_type );
9503 :
9504 : void set_TEC_TFA_code(
9505 : const int16_t corrFlag,
9506 : int16_t *tec_flag,
9507 : int16_t *tfa_flag );
9508 :
9509 : float Damping_fact(
9510 : const int16_t coder_type, /* i : ACELP core coder type */
9511 : const int16_t nbLostCmpt, /* i : compt for number of consecutive lost frame */
9512 : int16_t last_good, /* i : class of last good received frame */
9513 : float stab_fac, /* i : LSF stability factor */
9514 : float *lp_gainp, /* i/o: low passed pitch gain used for concealment */
9515 : const int16_t core /* i : current core: ACELP = 0, TCX20 = 1, TCX10 = 2 */
9516 : );
9517 :
9518 : void fer_energy(
9519 : const int16_t L_frame, /* i : frame length */
9520 : const int16_t clas, /* i : frame classification */
9521 : const float synth[], /* i : synthesized speech at Fs = 12k8 Hz */
9522 : const float pitch, /* i : pitch period */
9523 : float *enr, /* o : pitch-synchronous or half_frame energy */
9524 : const int16_t useOffset /* i : speech pointer offset (0 or L_FRAME) */
9525 : );
9526 :
9527 : float getLevelSynDeemph(
9528 : const float h1Init[], /* i : input value or vector to be processed */
9529 : const float A[], /* i : LPC coefficients */
9530 : const int16_t lenLpcExc, /* i : length of the LPC excitation buffer */
9531 : const float preemph_fac, /* i : preemphasis factor */
9532 : const int16_t numLoops /* i : number of loops */
9533 : );
9534 :
9535 : void genPlcFiltBWAdap(
9536 : const int32_t sr_core, /* i : core sampling rate */
9537 : float *lpFiltAdapt, /* o : filter coefficients for filtering codebooks in case of flc */
9538 : const int16_t type, /* i : type of filter, either 0 : lowpass or 1 : highpass */
9539 : const float alpha /* i : fade out factor [0 1) used decrease filter tilt */
9540 : );
9541 :
9542 : void highPassFiltering(
9543 : const int16_t last_good, /* i : last classification type */
9544 : const int16_t L_buffer, /* i : buffer length */
9545 : float exc2[], /* i/o: unvoiced excitation before the high pass filtering */
9546 : const float hp_filt[], /* i : high pass filter coefficients */
9547 : const int16_t l_fir_fer /* i : high pass filter length */
9548 : );
9549 :
9550 : int16_t GetPLCModeDecision(
9551 : Decoder_State *st /* i/o: decoder memory state pointer */
9552 : );
9553 :
9554 : void addBassPostFilter(
9555 : const float *harm_timeIn,
9556 : const int16_t samplesToProcess,
9557 : float **rAnalysis,
9558 : float **iAnalysis,
9559 : HANDLE_CLDFB_FILTER_BANK cldfb );
9560 :
9561 : ivas_error TonalMDCTConceal_Init(
9562 : TonalMDCTConcealPtr hTonalMDCTConc,
9563 : const uint16_t samplesPerBlock,
9564 : const uint16_t nSamplesCore,
9565 : const uint16_t nScaleFactors,
9566 : TCX_CONFIG_HANDLE hTcxCfg );
9567 :
9568 : void TonalMDCTConceal_SaveFreqSignal(
9569 : TonalMDCTConcealPtr hTonalMDCTConc,
9570 : const float *mdctSpectrum,
9571 : const uint16_t numSamples,
9572 : const uint16_t nNewSamplesCore,
9573 : const float *scaleFactors,
9574 : const int16_t infoIGFStartLine );
9575 :
9576 : void TonalMDCTConceal_UpdateState(
9577 : TonalMDCTConcealPtr hTonalMDCTConc,
9578 : const int16_t numSamples,
9579 : const float pitchLag,
9580 : const int16_t badBlock,
9581 : const int16_t tonalConcealmentActive );
9582 :
9583 : void TonalMDCTConceal_SaveTimeSignal(
9584 : TonalMDCTConcealPtr hTonalMDCTConc,
9585 : float *timeSignal,
9586 : const int16_t numSamples );
9587 :
9588 : void TonalMDCTConceal_Detect(
9589 : const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
9590 : const float pitchLag, /*IN */
9591 : int16_t *umIndices, /*OUT*/
9592 : const PsychoacousticParameters *psychParamsCurrent /*IN*/
9593 : );
9594 :
9595 : void TonalMDCTConceal_Apply(
9596 : TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
9597 : float *mdctSpectrum, /*OUT*/
9598 : const PsychoacousticParameters *psychParamsCurrent /*IN*/
9599 : );
9600 :
9601 : void TonalMDCTConceal_InsertNoise(
9602 : const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
9603 : float *mdctSpectrum, /*OUT*/
9604 : const int16_t tonalConcealmentActive,
9605 : int16_t *pSeed, /*IN/OUT*/
9606 : const float tiltCompFactor,
9607 : const float crossfadeGain,
9608 : const float concealment_noise[L_FRAME48k],
9609 : const float cngLevelBackgroundTrace_bfi,
9610 : const int16_t crossOverFreq );
9611 :
9612 : void DetectTonalComponents(
9613 : uint16_t indexOfTonalPeak[],
9614 : uint16_t lowerIndex[],
9615 : uint16_t upperIndex[],
9616 : uint16_t *pNumIndexes,
9617 : const float lastPitchLag,
9618 : const float currentPitchLag,
9619 : const float lastMDCTSpectrum[],
9620 : const float scaleFactors[],
9621 : const float secondLastPowerSpectrum[],
9622 : const uint16_t nSamples,
9623 : const uint16_t nSamplesCore,
9624 : float floorPowerSpectrum,
9625 : const PsychoacousticParameters *psychParamsCurrent );
9626 :
9627 : void RefineTonalComponents(
9628 : uint16_t indexOfTonalPeak[],
9629 : uint16_t lowerIndex[],
9630 : uint16_t upperIndex[],
9631 : float phaseDiff[],
9632 : float phases[],
9633 : uint16_t *pNumIndexes,
9634 : const float lastPitchLag,
9635 : const float currentPitchLag,
9636 : const float lastMDCTSpectrum[],
9637 : const float scaleFactors[],
9638 : const float secondLastPowerSpectrum[],
9639 : const uint16_t nSamples,
9640 : const uint16_t nSamplesCore,
9641 : float floorPowerSpectrum,
9642 : const PsychoacousticParameters *psychParamsCurrent );
9643 :
9644 : ivas_error PsychoacousticParameters_Init(
9645 : const int32_t sr_core, /* i : sampling rate of core-coder */
9646 : const int16_t nBins, /* i : Number of bins (spectral lines) */
9647 : const int8_t nBands, /* i : Number of spectrum subbands */
9648 : const int16_t isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */
9649 : const int16_t isWarped, /* i : Flag indicating if the scale is linear or warped */
9650 : PsychoacousticParameters *pPsychParams );
9651 :
9652 : void concealment_init(
9653 : const int16_t L_frameTCX,
9654 : T_PLCInfo_HANDLE hPlcInfo );
9655 :
9656 : void concealment_decode(
9657 : const int16_t core,
9658 : float *invkoef,
9659 : T_PLCInfo_HANDLE hPlcInfo );
9660 :
9661 : void concealment_update(
9662 : const int16_t bfi,
9663 : const int16_t core,
9664 : const int16_t harmonic,
9665 : float *invkoef,
9666 : T_PLCInfo_HANDLE hPlcInfo );
9667 :
9668 : void concealment_update2(
9669 : const float *outx_new,
9670 : T_PLCInfo_HANDLE hPlcInfo,
9671 : const int16_t L_frameTCX );
9672 :
9673 : void concealment_signal_tuning(
9674 : Decoder_State *st,
9675 : const int16_t bfi,
9676 : float *outx_new,
9677 : const int16_t past_core_mode );
9678 :
9679 : void waveform_adj2(
9680 : T_PLCInfo_HANDLE hPlcInfo,
9681 : float *overlapbuf,
9682 : float *outx_new,
9683 : const int16_t delay,
9684 : const int16_t bfi_cnt,
9685 : const int16_t bfi );
9686 :
9687 : float SFM_Cal(
9688 : const float fcoef[],
9689 : const int16_t n );
9690 :
9691 : void set_state(
9692 : int16_t *state,
9693 : const int16_t num,
9694 : const int16_t N );
9695 :
9696 : int16_t RFFTN(
9697 : float *afftData,
9698 : const float *trigPtr,
9699 : const int16_t len,
9700 : const int16_t isign );
9701 :
9702 : void DoFFT(
9703 : float *re2,
9704 : float *im2,
9705 : const int16_t length );
9706 :
9707 : /*! r: flag indicating a valid bitrate */
9708 : int16_t is_EVS_bitrate(
9709 : const int32_t ivas_total_brate, /* i : EVS total bitrate */
9710 : int16_t *Opt_AMR_WB /* i : AMR-WB IO flag */
9711 : );
9712 :
9713 : /*! r: codec mode */
9714 : int16_t get_codec_mode(
9715 : const int32_t total_brate /* i : total bitrate */
9716 : );
9717 :
9718 : int16_t getTcxonly(
9719 : const int16_t element_mode, /* i : IVAS element mode */
9720 : const int32_t total_brate, /* i : total bitrate */
9721 : const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/
9722 : const int16_t is_ism_format /* i : flag indicating ISM format */
9723 : );
9724 :
9725 : int16_t getTnsAllowed(
9726 : const int32_t total_brate, /* i : total bitrate */
9727 : const int16_t igf, /* i : flag indicating IGF activity*/
9728 : const int16_t element_mode /* i : IVAS element mode */
9729 : );
9730 :
9731 : int16_t getCtxHm(
9732 : const int16_t element_mode, /* i : IVAS element mode */
9733 : const int32_t total_brate, /* i : total bitrate */
9734 : const int16_t rf_flag /* i : flag to signal the RF mode */
9735 : );
9736 :
9737 : int16_t getResq(
9738 : const int32_t total_brate /* i : total bitrate */
9739 : );
9740 :
9741 : int16_t getRestrictedMode(
9742 : const int16_t element_mode, /* i : IVAS element mode */
9743 : const int32_t total_brate, /* i : total bitrate */
9744 : const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
9745 : );
9746 :
9747 : int16_t getMdctWindowLength(
9748 : const int16_t fscale );
9749 :
9750 : int16_t sr2fscale(
9751 : const int32_t sr_core /* i : internal sampling rate */
9752 : );
9753 :
9754 : int32_t getCoreSamplerateMode2(
9755 : const int16_t element_mode, /* i : IVAS element mode */
9756 : const int32_t total_brate, /* i : total bitrate */
9757 : const int16_t bwidth, /* i : audio bandwidth */
9758 : const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */
9759 : const int16_t rf_mode, /* i : flag to signal the RF mode */
9760 : const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */
9761 : );
9762 :
9763 : float getTcxBandwidth(
9764 : const int16_t bwidth /* i : audio bandwidth */
9765 : );
9766 :
9767 : int16_t getIgfPresent(
9768 : const int16_t element_mode, /* i : IVAS element mode */
9769 : const int32_t total_brate, /* i : total bitrate */
9770 : const int16_t bwidth, /* i : audio bandwidth */
9771 : const int16_t rf_mode /* i : flag to signal the RF mode */
9772 : );
9773 :
9774 : int16_t getCnaPresent(
9775 : const int16_t element_mode, /* i : element mode */
9776 : const int32_t element_brate, /* i : element bitrate */
9777 : const int32_t total_brate, /* i : total bitrate */
9778 : const int16_t bwidth /* i : audio bandwidth */
9779 : );
9780 :
9781 : int16_t getTcxLtp(
9782 : const int32_t sr_core /* i : internal sampling rate */
9783 : );
9784 :
9785 : int16_t initPitchLagParameters(
9786 : const int32_t sr_core, /* i : internal sampling rate */
9787 : int16_t *pit_min,
9788 : int16_t *pit_fr1,
9789 : int16_t *pit_fr1b,
9790 : int16_t *pit_fr2,
9791 : int16_t *pit_max );
9792 :
9793 : void attenuateNbSpectrum(
9794 : const int16_t L_frame,
9795 : float *spectrum );
9796 :
9797 : void SetModeIndex(
9798 : Encoder_State *st, /* i : Encoder state */
9799 : const int32_t last_total_brate, /* i : last total bitrate */
9800 : const int16_t last_element_mode, /* i : last IVAS element mode */
9801 : const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
9802 : );
9803 :
9804 : int16_t getNumTcxCodedLines(
9805 : const int16_t bwidth /* i : audio bandwidth */
9806 : );
9807 :
9808 : int16_t getTcxLpcShapedAri(
9809 : const int32_t total_brate, /* i : total bitrate */
9810 : const int16_t rf_mode, /* i : flag to signal the RF mode */
9811 : const int16_t element_mode /* i : IVAS element mode */
9812 : );
9813 :
9814 : void IGFEncApplyMono(
9815 : Encoder_State *st, /* i : Encoder state */
9816 : const int16_t igfGridIdx, /* i : IGF grid index */
9817 : float *pMDCTSpectrum, /* i/o: MDCT spectrum */
9818 : float *pPowerSpectrum, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
9819 : const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
9820 : const int16_t isTNSActive, /* i : flag indicating if the TNS is active */
9821 : const int16_t sp_aud_decision0, /* i : first stage switching decision */
9822 : const int16_t vad_hover_flag /* i : VAD hangover flag */
9823 : );
9824 :
9825 : void IGFEncApplyStereo(
9826 : STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */
9827 : int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
9828 : const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */
9829 : const int16_t igfGridIdx, /* i : IGF grid index */
9830 : Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
9831 : float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
9832 : float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */
9833 : float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
9834 : const int16_t frameno, /* i : flag indicating index of current subframe */
9835 : const int16_t sp_aud_decision0, /* i : sp_aud_decision0 */
9836 : const int32_t element_brate, /* i : element bitrate */
9837 : const int16_t mct_on /* i : flag mct block (1) or stereo (0) */
9838 : );
9839 :
9840 : void IGFEncConcatenateBitstream(
9841 : const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
9842 : const int16_t bsBits, /* i : number of IGF bits written to list of indices */
9843 : BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */
9844 : );
9845 :
9846 : void IGFEncResetTCX10BitCounter(
9847 : const IGF_ENC_INSTANCE_HANDLE hIGFEnc /* i : instance handle of IGF Encoder */
9848 : );
9849 :
9850 : ivas_error IGF_Reconfig(
9851 : IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */
9852 : const int16_t igf, /* i : IGF on/off */
9853 : const int16_t reset, /* i : reset flag */
9854 : const int32_t brate, /* i : bitrate for configuration */
9855 : const int16_t bwidth, /* i : signal bandwidth */
9856 : const int16_t element_mode, /* i : IVAS element mode */
9857 : const int16_t rf_mode /* i : flag to signal the RF mode */
9858 : );
9859 :
9860 : void IGFEncSetMode(
9861 : const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
9862 : const int32_t total_brate, /* i : encoder total bitrate */
9863 : const int16_t bwidth, /* i : encoder audio bandwidth */
9864 : const int16_t element_mode, /* i : IVAS element mode */
9865 : const int16_t rf_mode /* i : flag to signal the RF mode */
9866 : );
9867 :
9868 : /*! r: number of bits written per frame */
9869 : int16_t IGFEncWriteBitstream(
9870 : const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
9871 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
9872 : int16_t *pBitOffset, /* i : ptr to bitOffset counter */
9873 : const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */
9874 : const int16_t isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */
9875 : );
9876 :
9877 : /*! r: total number of bits written */
9878 : int16_t IGFEncWriteConcatenatedBitstream(
9879 : const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
9880 : BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
9881 : );
9882 :
9883 : void IGFDecApplyMono(
9884 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */
9885 : float *spectrum, /* i/o: MDCT spectrum */
9886 : const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */
9887 : const int16_t bfi, /* i : frame loss == 1, frame good == 0 */
9888 : const int16_t element_mode /* i : IVAS element mode */
9889 : );
9890 :
9891 : void IGFDecCopyLPCFlatSpectrum(
9892 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */
9893 : const float *pSpectrumFlat, /* i : LPC flattend spectrum from TCX dec */
9894 : const int16_t igfGridIdx /* i : IGF grid index */
9895 : );
9896 :
9897 : void IGFDecReadData(
9898 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder */
9899 : Decoder_State *st, /* i : decoder state */
9900 : const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */
9901 : const int16_t isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */
9902 : );
9903 :
9904 : /*! r: return igfAllZero flag indicating if no envelope is transmitted */
9905 : int16_t IGFDecReadLevel(
9906 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder */
9907 : Decoder_State *st, /* i : decoder state */
9908 : const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */
9909 : const int16_t isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */
9910 : );
9911 :
9912 : void IGFDecRestoreTCX10SubFrameData(
9913 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */
9914 : const int16_t subFrameIdx /* i : index of subframe */
9915 : );
9916 :
9917 : void init_igf_dec(
9918 : IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */
9919 : );
9920 :
9921 : void IGFDecSetMode(
9922 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */
9923 : const int32_t total_brate, /* i : bitrate */
9924 : const int16_t bwidth, /* i : audio bandwidth */
9925 : const int16_t element_mode, /* i : IVAS element mode */
9926 : const int16_t defaultStartLine, /* i : default start subband index */
9927 : const int16_t defaultStopLine, /* i : default stop subband index */
9928 : const int16_t rf_mode /* i : flag to signal the RF mode */
9929 : );
9930 :
9931 : void IGFDecStoreTCX10SubFrameData(
9932 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */
9933 : const int16_t subFrameIdx /* i : index of subframe */
9934 : );
9935 :
9936 : void IGFDecUpdateInfo(
9937 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */
9938 : const int16_t subFrameIdx, /* i : subframe index */
9939 : const int16_t igfGridIdx /* i : IGF grid index */
9940 : );
9941 :
9942 : /*! r: error value: 0 -> error, 1 -> ok */
9943 : int16_t IGFCommonFuncsIGFConfiguration(
9944 : const int32_t total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */
9945 : const int16_t bwidth, /* i : audio bandwidth */
9946 : const int16_t element_mode, /* i : IVAS element mode */
9947 : H_IGF_INFO hIGFInfo, /* o : IGF info handle */
9948 : const int16_t rf_mode /* i : flag to signal the RF mode */
9949 : );
9950 :
9951 : /*! r: error value: 0 -> error, 1 -> ok */
9952 : int16_t IGFCommonFuncsIGFGetCFTables(
9953 : const int32_t total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */
9954 : const int16_t bwidth, /* i : audio bandwidth */
9955 : const int16_t element_mode, /* i : element mode */
9956 : const int16_t rf_mode, /* i : flag to signal the RF mode */
9957 : const uint16_t **cf_se00, /* i : CF table for t == 0 and f == 0 */
9958 : const uint16_t **cf_se01, /* i : CF table for t == 0 and f == 1 */
9959 : int16_t *cf_off_se01, /* o : offset for CF table above */
9960 : const uint16_t **cf_se02, /* i : CF tables for t == 0 and f >= 2 */
9961 : const int16_t **cf_off_se02, /* o : offsets for CF tables above */
9962 : const uint16_t **cf_se10, /* i : CF table for t == 1 and f == 0 */
9963 : int16_t *cf_off_se10, /* o : offset for CF table above */
9964 : const uint16_t **cf_se11, /* i : CF tables for t == 1 and f >= 1 */
9965 : const int16_t **cf_off_se11 /* o : offsets for CF tables above */
9966 : );
9967 :
9968 : /*! r: multiplication factor */
9969 : int16_t IGF_ApplyTransFac(
9970 : const int16_t val, /* i : input value for multiplication, Q15 */
9971 : const float transFac /* i : multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000 */
9972 : );
9973 :
9974 : /*! r: return bitrate index */
9975 : int16_t IGF_MapBitRateToIndex(
9976 : const int32_t brate, /* i : bitrate */
9977 : const int16_t bwidth, /* i : audio bandwidth */
9978 : const int16_t element_mode, /* i : IVAS element mode */
9979 : const int16_t rf_mode /* i : flag to signal the RF mode */
9980 : );
9981 :
9982 : void IGFSCFEncoderOpen(
9983 : IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */
9984 : H_IGF_INFO hIgfInfo, /* i : IGF info handle */
9985 : const int32_t total_brate, /* i : total bitrate */
9986 : const int16_t bwidth, /* i : audio bandwidth */
9987 : const int16_t element_mode, /* i : IVAS element mode */
9988 : const int16_t rf_mode /* i : flag to signal the RF mode */
9989 : );
9990 :
9991 : void IGFSCFEncoderReset(
9992 : IGFSCFENC_INSTANCE_HANDLE hPublicData /* i : handle to public data or NULL in case there was no instance created */
9993 : );
9994 :
9995 : int16_t IGFSCFEncoderEncode(
9996 : IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */
9997 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
9998 : const int16_t bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */
9999 : int16_t *sfe, /* i : ptr to an array which contain quantized scalefactor energies */
10000 : const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */
10001 : const int16_t indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */
10002 : );
10003 :
10004 : void IGFSCFEncoderSaveContextState(
10005 : IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */
10006 : const int16_t igfGridIdx /* i : igf grid index see declaration of IGF_GRID_IDX for details */
10007 : );
10008 :
10009 : void IGFSCFEncoderRestoreContextState(
10010 : IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */
10011 : const int16_t igfGridIdx /* i : igf grid index see declaration of IGF_GRID_IDX for details */
10012 : );
10013 :
10014 : void IGFSCFDecoderOpen(
10015 : IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */
10016 : H_IGF_INFO hIgfInfo, /* i : IGF info handle */
10017 : const int32_t total_brate,
10018 : const int16_t bwidth,
10019 : const int16_t element_mode,
10020 : const int16_t rf_mode );
10021 :
10022 : void IGFSCFDecoderReset(
10023 : IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i : handle to public data or NULL in case there was no instance created */
10024 : );
10025 :
10026 : void IGFSCFDecoderDecode(
10027 : IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */
10028 : Decoder_State *st, /* i/o: pointer to decoder state */
10029 : int16_t *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */
10030 : const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */
10031 : const int16_t indepFlag /* i : if 1 on input the decoder will be forced to reset,
10032 : if 0 on input the decoder will be forced to encode without a reset */
10033 : );
10034 :
10035 : /*! r: offset value */
10036 : int16_t tbe_celp_exc_offset(
10037 : const int16_t T0, /* i : Integer pitch */
10038 : const int16_t T0_frac /* i : Fractional part of the pitch */
10039 : );
10040 :
10041 : void blend_subfr2(
10042 : float *sigIn1, /* i : input signal for fade-out */
10043 : float *sigIn2, /* i : input signal for fade-in */
10044 : float *sigOut /* o : output signal */
10045 : );
10046 :
10047 : void init_tcx_window_cfg(
10048 : TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX Config handle */
10049 : const int32_t sr_core, /* i : SR core */
10050 : const int32_t input_Fs, /* i : input/output SR */
10051 : const int16_t L_frame, /* i : L_frame at sr_core */
10052 : const int16_t L_frameTCX, /* i : L_frame at i/o SR */
10053 : const int16_t encoderLookahead_enc, /* i : encoder LA at sr_core */
10054 : const int16_t encoderLookahead_FB, /* i : encoder LA at i/o SR */
10055 : const int16_t mdctWindowLength, /* i : window length at sr_core */
10056 : const int16_t mdctWindowLengthFB, /* i : window length at i/o SR */
10057 : const int16_t element_mode /* i : mode of CPE/SCE */
10058 : );
10059 :
10060 : void init_tcx_cfg(
10061 : TCX_CONFIG_HANDLE hTcxCfg,
10062 : const int32_t total_brate,
10063 : const int32_t sr_core,
10064 : const int32_t input_Fs,
10065 : const int16_t L_frame,
10066 : const int16_t bwidth,
10067 : const int16_t L_frameTCX,
10068 : const int16_t fscale,
10069 : const int16_t encoderLookahead_enc,
10070 : const int16_t encoderLookahead_FB,
10071 : const float preemph_fac,
10072 : const int16_t tcxonly,
10073 : const int16_t rf_mode,
10074 : const int16_t igf,
10075 : const int16_t infoIGFStopFreq,
10076 : const int16_t element_mode,
10077 : const int16_t ini_frame,
10078 : const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
10079 : );
|