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 1513271 : static __inline Word16 L_Extract_lc( const Word32 L_32, Word16 *p_hi )
121 : {
122 1513271 : *p_hi = extract_h( L_32 );
123 1513271 : 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 vad_only_flag, /* i : flag to indicate front-VAD structure */
2254 : const ISM_MODE ism_mode, /* i : ISM mode */
2255 : const int32_t element_brate /* element bitrate */
2256 : );
2257 :
2258 : void LPDmem_enc_init(
2259 : LPD_state_HANDLE hLPDmem /* i/o: LP memories */
2260 : );
2261 :
2262 : void destroy_cldfb_encoder(
2263 : Encoder_State *st /* i/o: state structure */
2264 : );
2265 : ivas_error evs_enc(
2266 : Encoder_State *st, /* i/o: state structure */
2267 : const int16_t *data, /* i : input signal */
2268 : float *mem_hp20_in, /* i/o: hp20 filter memory */
2269 : const int16_t n_samples /* i : number of input samples */
2270 : );
2271 : void amr_wb_enc(
2272 : Encoder_State *st, /* i/o: encoder state structure */
2273 : const int16_t *data, /* i : input signal */
2274 : float *mem_hp20_in, /* i/o: hp20 filter memory */
2275 : const int16_t n_samples /* i : number of input samples */
2276 : );
2277 :
2278 : void sc_vbr_enc_init(
2279 : SC_VBR_ENC_HANDLE hSC_VBR /* i/o: SC-VBR encoder handle */
2280 : );
2281 :
2282 : void amr_wb_enc_init(
2283 : AMRWB_IO_ENC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO encoder handle */
2284 : );
2285 :
2286 : void pre_proc(
2287 : Encoder_State *st, /* i/o: encoder state structure */
2288 : const int16_t input_frame, /* i : frame length */
2289 : float old_inp_12k8[], /* i/o: buffer of old input signal */
2290 : float old_inp_16k[], /* i/o: buffer of old input signal @ 16kHz */
2291 : float **inp, /* o : ptr. to inp. signal in the current frame*/
2292 : float fr_bands[2 * NB_BANDS], /* i : energy in frequency bands */
2293 : float *ener, /* o : residual energy from Levinson-Durbin */
2294 : #ifndef FIX_I4_OL_PITCH
2295 : int16_t pitch_orig[3], /* o : open-loop pitch values for quantization */
2296 : #endif
2297 : float A[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */
2298 : float Aw[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */
2299 : float epsP[M + 1], /* i/o: LP prediction errors */
2300 : float lsp_new[M], /* i/o: LSPs at the end of the frame */
2301 : float lsp_mid[M], /* i/o: LSPs in the middle of the frame */
2302 : int16_t *vad_hover_flag, /* i : VAD hangover flag */
2303 : int16_t *attack_flag, /* o : attack flag */
2304 : float *new_inp_resamp16k, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
2305 : int16_t *Voicing_flag, /* o : voicing flag for HQ FEC */
2306 : float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */
2307 : float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */
2308 : int16_t *hq_core_type /* o : HQ core type */
2309 : );
2310 : #endif
2311 :
2312 : /*! r: HQ_CORE/TCX_20_CORE decision */
2313 : int16_t mdct_classifier(
2314 : Encoder_State *st, /* i/o: Encoder state variable */
2315 : const float *fft_buff, /* i : FFT spectrum from fft_rel */
2316 : const float enerBuffer[], /* i : energy buffer */
2317 : const int32_t brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */
2318 : );
2319 :
2320 : void MDCT_selector(
2321 : Encoder_State *st, /* i/o: Encoder State */
2322 : const float sp_floor, /* i : Noise floor estimate */
2323 : const float Etot, /* i : Total energy */
2324 : const float cor_map_sum, /* i : sum of correlation map */
2325 : const float enerBuffer[] /* i : energy buffer */
2326 : );
2327 :
2328 : void MDCT_selector_reset(
2329 : TCX_ENC_HANDLE hTcxEnc /* i/o: TCX Encoder Handle */
2330 : );
2331 :
2332 : void MDCT_classifier_reset(
2333 : TCX_ENC_HANDLE hTcxEnc /* i/o: TCX Encoder Handle */
2334 : );
2335 :
2336 : ivas_error acelp_core_enc(
2337 : Encoder_State *st, /* i/o: encoder state structure */
2338 : const float inp[], /* i : input signal of the current frame */
2339 : const float ener, /* i : residual energy from Levinson-Durbin */
2340 : float A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes */
2341 : float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes */
2342 : const float epsP[M + 1], /* i : LP prediction errors */
2343 : float lsp_new[M], /* i : LSPs at the end of the frame */
2344 : float lsp_mid[M], /* i : LSPs in the middle of the frame */
2345 : const int16_t vad_hover_flag, /* i : VAD hangover flag */
2346 : const int16_t attack_flag, /* i : attack flag (GSC or TC) */
2347 : float bwe_exc_extended[], /* i/o: bandwidth extended excitation */
2348 : float *voice_factors, /* o : voicing factors */
2349 : float old_syn_12k8_16k[], /* o : ACELP core synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
2350 : float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */
2351 : int16_t *unbits, /* o : number of unused bits */
2352 : STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
2353 : const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
2354 : );
2355 :
2356 : ivas_error acelp_core_switch_dec_bfi(
2357 : Decoder_State *st /* i/o: decoder state structure */
2358 : );
2359 :
2360 : void acelp_core_switch_enc(
2361 : Encoder_State *st, /* i/o: encoder state structure */
2362 : const float inp12k8[], /* i : input signal @12.8 kHz */
2363 : const float inp16k[], /* i : input signal @16 kHz */
2364 : const float A[NB_SUBFR16k * ( M + 1 )] /* i : A(z) unquantized for the 4 subframes */
2365 : );
2366 :
2367 : /*! r: length of output */
2368 : int16_t modify_Fs_intcub3m_sup(
2369 : const float sigIn[], /* i : signal to decimate with memory of 2 samples (indexes -2 & -1) */
2370 : const int16_t lg, /* i : length of input */
2371 : const int32_t fin, /* i : frequency of input */
2372 : float sigOut[], /* o : decimated signal */
2373 : const int32_t fout, /* i : frequency of output */
2374 : int16_t *delayout /* o : delay of output */
2375 : );
2376 :
2377 : void core_switching_OLA(
2378 : const float *mem_over_hp, /* i : upsampling filter memory */
2379 : const int16_t last_L_frame, /* i : last L_frame lengthture */
2380 : const int32_t output_Fs, /* i : output sampling rate */
2381 : float *synth, /* i/o: synthesized signal from HQ core */
2382 : const float *synth_subfr_out, /* i : synthesized signal from ACELP core */
2383 : float *synth_subfr_bwe, /* i : synthesized BWE from ACELP core */
2384 : const int16_t output_frame, /* i : output frame length */
2385 : const int16_t bwidth /* i : output bandwidth */
2386 : );
2387 :
2388 : void retro_interp4_5(
2389 : const float *syn,
2390 : float *pst_old_syn );
2391 :
2392 : void retro_interp5_4(
2393 : float *pst_old_syn );
2394 :
2395 : void core_switching_hq_prepare_enc(
2396 : Encoder_State *st, /* i/o: encoder state structure */
2397 : int16_t *num_bits, /* i/o: bit budget update */
2398 : const int16_t input_frame, /* i : input frame length */
2399 : float *wtda_audio,
2400 : const float *audio );
2401 :
2402 : void core_switching_hq_prepare_dec(
2403 : Decoder_State *st, /* i/o: decoder state structure */
2404 : int16_t *num_bits, /* i/o: bit budget update */
2405 : const int16_t input_frame /* i : input frame length */
2406 : );
2407 :
2408 : ivas_error acelp_core_switch_dec(
2409 : Decoder_State *st, /* i/o: decoder structure */
2410 : float *synth_subfr_out, /* o : synthesized ACELP subframe */
2411 : float *tmp_synth_bwe, /* o : synthesized ACELP subframe BWE */
2412 : const int16_t output_frame, /* i : input frame length */
2413 : const int16_t core_switching_flag, /* i : core switching flag */
2414 : float *mem_synth, /* o : synthesis to overlap */
2415 : const int16_t nchan_out /* i : number of output channels */
2416 : );
2417 :
2418 : void space_lsfs(
2419 : float *lsfs,
2420 : const int16_t order );
2421 :
2422 : void lsp2a(
2423 : float *pc_in,
2424 : float *freq,
2425 : const int16_t order );
2426 :
2427 : void lsp_weights(
2428 : const float *lsps,
2429 : float *weight,
2430 : const int16_t order );
2431 :
2432 : void a2lsp_stab(
2433 : const float *a, /* i : LP filter coefficients */
2434 : float *lsp, /* o : Line spectral pairs */
2435 : const float *old_lsp /* i : LSP vector from past frame */
2436 : );
2437 :
2438 : void lsp2a_stab(
2439 : const float *lsp, /* i : LSF vector (in the cosine domain) */
2440 : float *a, /* o : LP filter coefficients */
2441 : const int16_t m /* i : order of LP analysis */
2442 : );
2443 :
2444 : void isf2lsf(
2445 : const float *isf, /* i : ISF vector */
2446 : float *lsf, /* o : LSF vector */
2447 : float *stable_lsp, /* i/o: LSF vector */
2448 : const int16_t m, /* i : order of LP analysis */
2449 : const int32_t Fs );
2450 :
2451 : void lsf2isf(
2452 : const float *lsf, /* i : LSF vector */
2453 : float *isf, /* o : ISF vector */
2454 : float *stable_isp, /* i/o: ISP vector */
2455 : const int16_t m, /* i : order of LP analysis */
2456 : const int32_t Fs );
2457 :
2458 : int16_t a2lsp(
2459 : float *freq, /* o : LSP vector */
2460 : const float *a, /* i : predictor coefficients */
2461 : const int16_t order /* i : order of LP analysis */
2462 : );
2463 :
2464 : void ResetSHBbuffer_Enc(
2465 : TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */
2466 : );
2467 :
2468 : void ResetSHBbuffer_Dec(
2469 : TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
2470 : const int16_t extl /* i : BWE extension layer */
2471 : );
2472 :
2473 : void calc_st_filt(
2474 : const float *apond2, /* i : coefficients of numerator */
2475 : const float *apond1, /* i : coefficients of denominator */
2476 : float *parcor0, /* o : 1st parcor calcul. on composed filter */
2477 : float *sig_ltp_ptr, /* i/o: input of 1/A(gamma1) : scaled by 1/g0 */
2478 : float *mem_zero, /* i/o: All zero memory */
2479 : const int16_t L_subfr, /* i : the length of subframe */
2480 : const int16_t extl /* i : extension layer info */
2481 : );
2482 :
2483 : void scale_st(
2484 : const float *sig_in, /* i : postfilter input signal */
2485 : float *sig_out, /* i/o: postfilter output signal */
2486 : float *gain_prec, /* i/o: last value of gain for subframe */
2487 : const int16_t L_subfr, /* i : the length of subframe */
2488 : const int16_t extl /* i : extension layer info */
2489 : );
2490 :
2491 : void filt_mu(
2492 : const float *sig_in, /* i : signal (beginning at sample -1) */
2493 : float *sig_out, /* o : output signal */
2494 : const float parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */
2495 : const int16_t L_subfr, /* i : the length of subframe */
2496 : const int16_t extl /* i : extension layer info */
2497 : );
2498 :
2499 : void PostShortTerm(
2500 : float *sig_in, /* i : input signal (ptr. to current subframe */
2501 : float *lpccoeff, /* i : LPC coefficients for current subframe */
2502 : float *sig_out, /* o : postfiltered output */
2503 : float *mem_stp, /* i/o: postfilter memory */
2504 : float *ptr_mem_stp, /* i/o: pointer to postfilter memory */
2505 : float *ptr_gain_prec, /* i/o: for gain adjustment */
2506 : float *mem_zero, /* i/o: null memory to compute h_st */
2507 : const float formant_fac /* i : Strength of post-filter [0,1] */
2508 : );
2509 :
2510 : /*! r: Formant filter strength [0,1] */
2511 : float swb_formant_fac(
2512 : const float lpc_shb2, /* i : 2nd HB LPC coefficient */
2513 : float *tilt_mem /* i/o: Tilt smoothing memory */
2514 : );
2515 :
2516 : void GenShapedSHBExcitation(
2517 : float *excSHB, /* o : synthesized shaped shb exctiation */
2518 : const float *lpc_shb, /* i : lpc coefficients */
2519 : float *exc16kWhtnd, /* o : whitened synthesized shb excitation */
2520 : float *mem_csfilt, /* i/o: memory */
2521 : float *mem_genSHBexc_filt_down_shb, /* i/o: memory */
2522 : float *state_lpc_syn, /* i/o: memory */
2523 : const int16_t coder_type, /* i : coding type */
2524 : const float *bwe_exc_extended, /* i : bandwidth extended excitation */
2525 : int16_t bwe_seed[], /* i/o: random number generator seed */
2526 : float voice_factors[], /* i : voicing factor */
2527 : const int16_t extl, /* i : extension layer */
2528 : float *tbe_demph, /* i/o: de-emphasis memory */
2529 : float *tbe_premph, /* i/o: pre-emphasis memory */
2530 : float *lpc_shb_sf, /* i : LP coefficients */
2531 : float *shb_ener_sf, /* i : SHB subframe energies */
2532 : float *shb_res_gshape, /* i : SHB LP residual gain shape */
2533 : float *shb_res, /* i : SHB residual used in encoder only */
2534 : int16_t *vf_ind, /* i/o: Mixing factor index */
2535 : const float formant_fac, /* i : Formant sharpening factor [0..1] */
2536 : float fb_state_lpc_syn[], /* i/o: memory */
2537 : float *fb_tbe_demph, /* i/o: fb de-emphasis memory */
2538 : const int32_t total_brate, /* i : overall bitrate */
2539 : const int16_t prev_bfi, /* i : previous frame was lost flag */
2540 : const int16_t element_mode, /* i : element mode */
2541 : const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */
2542 : float *nlExc16k, /* i/o: NL exc for IC-BWE */
2543 : float *mixExc16k, /* i/o: exc spreading for IC-BWE */
2544 : const int32_t extl_brate, /* i : TD BWE bitrate */
2545 : const int16_t MSFlag, /* i : Multi-source flag */
2546 : float EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */
2547 : float *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */
2548 : float *prev_mix_factor, /* i/o: mixing factor in the previous frame */
2549 : float *Env_error, /* o : error in SHB residual envelope modelling*/
2550 : float Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */
2551 : );
2552 :
2553 : void GenSHBSynth(
2554 : const float *shb_target_speech, /* i : input synthesized speech */
2555 : float *shb_syn_speech_32k, /* o : output highband component */
2556 : float Hilbert_Mem[], /* i/o: memory */
2557 : float state_lsyn_filt_shb_local[], /* i/o: memory */
2558 : const int16_t L_frame, /* i : ACELP Frame length */
2559 : int16_t *syn_dm_phase );
2560 :
2561 : void ScaleShapedSHB(
2562 : const int16_t length, /* i : SHB overlap length */
2563 : float *synSHB, /* i/o: synthesized shb signal */
2564 : float *overlap, /* i/o: buffer for overlap-add */
2565 : const float *subgain, /* i : subframe gain */
2566 : const float frame_gain, /* i : frame gain */
2567 : const float *win, /* i : window */
2568 : const float *subwin /* i : subframes window */
2569 : );
2570 :
2571 : void Interpolate_allpass_steep(
2572 : const float *in, /* i : input array of size N */
2573 : float *mem, /* i/o: memory */
2574 : const int16_t N, /* i : number of input samples */
2575 : float *out /* o : output array of size 2*N */
2576 : );
2577 :
2578 : void Decimate_allpass_steep(
2579 : const float *in, /* i : input array of size N */
2580 : float *mem, /* i/o: memory */
2581 : const int16_t N, /* i : number of input samples */
2582 : float *out /* o : output array of size N/2 */
2583 : );
2584 :
2585 : void interpolate_3_over_2_allpass(
2586 : const float *input, /* i : input signal */
2587 : const int16_t len, /* i : number of input samples */
2588 : float *out, /* o : output signal */
2589 : float *mem /* i/o: memory */
2590 : );
2591 :
2592 : void decimate_2_over_3_allpass(
2593 : const float *input, /* i : input signal */
2594 : const int16_t len, /* i : number of input samples */
2595 : float *out, /* o : output signal */
2596 : float *mem, /* i/o: memory */
2597 : float *lp_mem );
2598 :
2599 : void interpolate_3_over_1_allpass(
2600 : const float *input, /* i : input signal */
2601 : const int16_t len, /* i : number of input samples */
2602 : float *out, /* o : output signal */
2603 : float *mem /* i/o: memory */
2604 : );
2605 :
2606 : void InitSWBencBuffer(
2607 : TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */
2608 : );
2609 :
2610 : void InitSWBencBufferStates(
2611 : TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
2612 : float *shb_speech /* o : SHB target signal (6-14kHz) at 16kHz */
2613 : );
2614 :
2615 : void swb_tbe_enc(
2616 : Encoder_State *st, /* i/o: encoder state structure */
2617 : STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */
2618 : const float *new_speech, /* i : original input signal */
2619 : const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
2620 : const float voice_factors[], /* i : voicing factors */
2621 : float *White_exc16k, /* o : shaped white excitation for the FB TBE */
2622 : const float pitch_buf[] /* i : pitch for each subframe */
2623 : );
2624 :
2625 : void swb_tbe_dec(
2626 : Decoder_State *st, /* i/o: decoder state structure */
2627 : STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */
2628 : const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
2629 : const float voice_factors[], /* i : voicing factors */
2630 : const float old_syn_12k8_16k[], /* i : low band synthesis at 12.8kHz or 16kHz */
2631 : float *White_exc16k, /* o : shaped white excitation for the FB TBE */
2632 : float *synth, /* i/o: ACELP core synthesis/final synthesis */
2633 : float *pitch_buf );
2634 :
2635 : void flip_and_downmix_generic(
2636 : float input[], /* i : input spectrum */
2637 : float output[], /* o : output spectrum */
2638 : const int16_t length, /* i : length of spectra */
2639 : float mem1_ext[HILBERT_ORDER1], /* i/o: Hilbert filter memory */
2640 : float mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory */
2641 : float mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory */
2642 : int16_t *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */
2643 : );
2644 :
2645 : void non_linearity(
2646 : const float input[], /* i : input signal */
2647 : float output[], /* i : output signal */
2648 : float old_bwe_exc_extended[], /* i/o: memory bugffer */
2649 : const int16_t length, /* i : input length */
2650 : float *prev_scale, /* i/o: memory */
2651 : const int16_t coder_type, /* i : Coder Type */
2652 : const float *voice_factors, /* i : Voice Factors */
2653 : const int16_t L_frame, /* i : ACELP frame length */
2654 : const int16_t element_mode /* i : element_mode to differentiate EVS and IVAS*/
2655 : );
2656 :
2657 : void interp_code_5over2(
2658 : const float inp_code[], /* i : input vector */
2659 : float interp_code[], /* o : output vector */
2660 : const int16_t inp_length /* i : length of the input vector */
2661 : );
2662 :
2663 : void interp_code_4over2(
2664 : const float inp_code[], /* i : input vector */
2665 : float interp_code[], /* o : output vector */
2666 : const int16_t inp_length /* i : length of the input vector */
2667 : );
2668 :
2669 : void flip_spectrum_and_decimby4(
2670 : const float input[], /* i : input spectrum */
2671 : float output[], /* o : output spectrum */
2672 : const int16_t length, /* i : vector length */
2673 : float mem1[], /* i/o: memory */
2674 : float mem2[], /* i/o: memory */
2675 : const int16_t ramp_flag /* i : flag to trigger slow ramp-up of output */
2676 : );
2677 :
2678 : void GenShapedWBExcitation(
2679 : float *excSHB, /* o : synthesized shaped shb exctiation */
2680 : const float *lpc_shb, /* i : lpc coefficients */
2681 : float *exc4kWhtnd, /* o : whitened synthesized shb excitation */
2682 : float *mem_csfilt, /* i/o: memory */
2683 : float *mem_genSHBexc_filt_down1, /* i/o: memory */
2684 : float *mem_genSHBexc_filt_down2, /* i/o: memory */
2685 : float *mem_genSHBexc_filt_down3, /* i/o: memory */
2686 : float *state_lpc_syn, /* i/o: memory */
2687 : const int16_t coder_type, /* i : coding type */
2688 : const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
2689 : int16_t bwe_seed[], /* i/o: random number generator seed */
2690 : const float voice_factors[], /* i : voicing factor */
2691 : const int16_t uv_flag, /* i : unvoiced flag */
2692 : const int16_t igf_flag );
2693 :
2694 : void GenWBSynth(
2695 : const float *input_synspeech, /* i : input synthesized speech */
2696 : float *shb_syn_speech_16k, /* o : output highband compnent */
2697 : float *state_lsyn_filt_shb1, /* i/o: memory */
2698 : float *state_lsyn_filt_shb2 /* i/o: memory */
2699 : );
2700 :
2701 : void wb_tbe_enc(
2702 : Encoder_State *st, /* i/o: encoder state structure */
2703 : const float *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz */
2704 : const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
2705 : const float pitch_buf[], /* i : pitch for each subframe */
2706 : const float voicing[] /* o : OL maximum normalized correlation */
2707 : );
2708 :
2709 : void wb_tbe_dec(
2710 : Decoder_State *st, /* i/o: decoder state structure */
2711 : const float *bwe_exc_extended, /* i : bandwidth extended exciatation */
2712 : const float voice_factors[], /* i : voicing factors */
2713 : float *synth /* i/o: ACELP core synthesis/final synthesis */
2714 : );
2715 :
2716 : void tbe_write_bitstream(
2717 : Encoder_State *st /* i/o: encoder state structure */
2718 : );
2719 :
2720 : void tbe_read_bitstream(
2721 : Decoder_State *st /* i/o: decoder state structure */
2722 : );
2723 :
2724 : void GenTransition(
2725 : TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
2726 : float *outputHB, /* o : synthesized HB transitions signal */
2727 : const int32_t output_Fs, /* i : output sampling rate */
2728 : const int16_t element_mode, /* i : element mode */
2729 : const int16_t L_frame, /* i : ACELP frame length */
2730 : const int16_t rf_flag, /* i : RF flag */
2731 : const int32_t total_brate /* i : total bitrate */
2732 : );
2733 :
2734 : void GenTransition_WB(
2735 : TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
2736 : float *outputHB, /* o : synthesized HB transitions signal */
2737 : const int32_t output_Fs /* i : output sampling rate */
2738 : );
2739 :
2740 : void td_bwe_dec_init(
2741 : TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
2742 : const int16_t extl, /* i : BWE extension layer */
2743 : const int32_t output_Fs /* i : output sampling rate */
2744 : );
2745 :
2746 : void TBEreset_enc(
2747 : TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
2748 : const int16_t last_core, /* i : last core */
2749 : const int16_t bwidth /* i : audio bandwidth */
2750 : );
2751 :
2752 : void TBEreset_dec(
2753 : Decoder_State *st /* i/o: decoder state structure */
2754 : );
2755 :
2756 : /*! r: TBE bit consumption per frame */
2757 : int16_t get_tbe_bits(
2758 : const int32_t total_brate, /* i : overall bitrate */
2759 : const int16_t bwidth, /* i : audio bandwidth */
2760 : const int16_t rf_mode /* i : channel aware mode */
2761 : );
2762 :
2763 : void fb_tbe_enc(
2764 : Encoder_State *st, /* i/o: encoder state structure */
2765 : const float new_input[], /* i : input speech at 48 kHz sample rate */
2766 : const float fb_exc[] /* i : FB excitation from the SWB part */
2767 : );
2768 :
2769 : void fb_tbe_dec(
2770 : Decoder_State *st, /* i/o: decoder state structure */
2771 : const float fb_exc[], /* i : FB excitation from the SWB part */
2772 : float *hb_synth, /* i/o: high-band synthesis */
2773 : float *fb_synth_ref, /* o : high-band synthesis 16-20 kHz */
2774 : const int16_t output_frame /* i : output frame length */
2775 : );
2776 :
2777 : void calc_tilt_bwe(
2778 : const float *sp, /* i : input signal */
2779 : float *tilt, /* o : signal tilt */
2780 : const int16_t N /* i : signal length */
2781 : );
2782 :
2783 : void fd_bwe_enc_init(
2784 : FD_BWE_ENC_HANDLE hBWE_FD /* i/o: FD BWE data handle */
2785 : );
2786 :
2787 : void swb_pre_proc(
2788 : Encoder_State *st, /* i/o: encoder state structure */
2789 : float *new_swb_speech, /* o : original input signal at 32kHz */
2790 : float *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz */
2791 : float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer */
2792 : float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer */
2793 : CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */
2794 : );
2795 :
2796 : void wb_pre_proc(
2797 : Encoder_State *st, /* i/o: encoder state structure */
2798 : const int16_t last_element_mode, /* i : last element mode */
2799 : const float *new_inp_resamp16k, /* i : original input signal */
2800 : float *hb_speech /* o : HB target signal (6-8kHz) at 16kHz */
2801 : );
2802 :
2803 : void wb_bwe_enc(
2804 : Encoder_State *st, /* i/o: encoder state structure */
2805 : const float *new_wb_speech /* i : original input signal at 16kHz */
2806 : );
2807 :
2808 : void wb_bwe_dec(
2809 : Decoder_State *st, /* i/o: decoder state structure */
2810 : const float output[], /* i : synthesis @internal Fs */
2811 : float *synth, /* i/o: ACELP core synthesis/final synthesis */
2812 : float *hb_synth, /* o : SHB synthesis/final synthesis */
2813 : const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
2814 : const int16_t output_frame, /* i : frame length */
2815 : const float voice_factors[], /* i : voicing factors */
2816 : const float pitch_buf[] /* i : pitch buffer */
2817 : );
2818 :
2819 : void swb_bwe_enc(
2820 : Encoder_State *st, /* i/o: encoder state structure */
2821 : const int16_t last_element_mode, /* i : last element mode */
2822 : const float *old_input_12k8, /* i : input signal @12.8kHz for SWB BWE */
2823 : const float *old_input_16k, /* i : input signal @16kHz for SWB BWE */
2824 : const float *old_syn_12k8_16k, /* i : ACELP core synthesis at 12.8kHz or 16kHz*/
2825 : const float *new_swb_speech, /* i : original input signal at 32kHz */
2826 : const float *shb_speech /* i : SHB target signal (6-14kHz) at 16kHz */
2827 : );
2828 :
2829 : void swb_bwe_enc_hr(
2830 : Encoder_State *st, /* i/o: encoder state structure */
2831 : const float *new_input, /* i : input signal */
2832 : const int16_t input_frame, /* i : frame length */
2833 : const int16_t unbits /* i : number of core unused bits */
2834 : );
2835 :
2836 : void fd_bwe_dec_init(
2837 : FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */
2838 : );
2839 :
2840 : void swb_bwe_dec(
2841 : Decoder_State *st, /* i/o: decoder state structure */
2842 : const float output[], /* i : synthesis @internal Fs */
2843 : const float *synth, /* i : ACELP core synthesis/final synthesis */
2844 : float *hb_synth, /* o : SHB synthesis/final synthesis */
2845 : const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
2846 : const int16_t output_frame /* i : frame length */
2847 : );
2848 :
2849 : void hr_bwe_dec_init(
2850 : HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */
2851 : );
2852 :
2853 : void swb_bwe_dec_hr(
2854 : Decoder_State *st, /* i/o: decoder state structure */
2855 : const float *syn_12k8_16k, /* i : ACELP core synthesis @16kHz */
2856 : float *hb_synth, /* o : SHB synthesis */
2857 : const int16_t output_frame, /* i : frame length */
2858 : const int16_t unbits, /* i : number of core unused bits */
2859 : const float pitch_buf[] /* i : pitch buffer */
2860 : );
2861 :
2862 : void swb_hr_noise_fill(
2863 : const int16_t is_transient, /* i : transient flag */
2864 : const int16_t spect_start, /* i : spectrum start point */
2865 : const int16_t spect_end, /* i : spectrum end point */
2866 : const float tilt_wb, /* i : tilt of wideband signal */
2867 : const float pitch, /* i : pitch value */
2868 : const int16_t nq[], /* i : AVQ nq index */
2869 : int16_t Nsv, /* i : number of subband */
2870 : int16_t *bwe_highrate_seed, /* i/o: seed of random noise */
2871 : float *t_audio /* i/o: mdct spectrum */
2872 : );
2873 :
2874 : /*! r: gain */
2875 : float td_postprocess(
2876 : float hb_synth[], /* i/o: high-band synthesis */
2877 : const int16_t input_frame, /* i : frame length */
2878 : const int16_t last_extl /* i : last extension layer */
2879 : );
2880 :
2881 : void calc_normal_length(
2882 : const int16_t core, /* i : core */
2883 : const float *sp, /* i : input signal */
2884 : const int16_t mode, /* i : input mode */
2885 : const int16_t extl, /* i : extension layer */
2886 : int16_t *L_swb_norm, /* o : normalize length */
2887 : int16_t *prev_L_swb_norm /* i/o: last normalize length */
2888 : );
2889 :
2890 : void calc_norm_envelop(
2891 : const float SWB_signal[], /* i : SWB spectrum */
2892 : float *envelope, /* o : normalized envelope */
2893 : const int16_t L_swb_norm, /* i : length of envelope */
2894 : const int16_t SWB_flength, /* i : Length of input/output */
2895 : const int16_t st_offset /* i : offset */
2896 : );
2897 :
2898 : void time_envelop_shaping(
2899 : float werr[], /* i/o: SHB synthesis */
2900 : float SWB_tenv[], /* i/o: frequency envelope */
2901 : const int16_t L /* i : frame length */
2902 : );
2903 :
2904 : void time_reduce_pre_echo(
2905 : const float *synth, /* i : ACELP core synthesis */
2906 : float *error, /* o : SHB BWE synthesis */
2907 : float prev_td_energy, /* o : last td energy */
2908 : const int16_t L /* i : subframe length */
2909 : );
2910 :
2911 : int16_t WB_BWE_gain_pred(
2912 : float *WB_fenv, /* o : WB frequency envelopes */
2913 : const float *core_dec_freq, /* i : Frequency domain core decoded signal */
2914 : const int16_t coder_type, /* i : coding type */
2915 : const int16_t prev_code_type, /* i : coding type of last frame */
2916 : const float prev_WB_fenv, /* i : envelope for last frame */
2917 : const float voice_factors[], /* i : voicing factors */
2918 : const float pitch_buf[], /* i : pitch buffer */
2919 : const int32_t last_core_brate, /* i : previous frame core bitrate */
2920 : const float last_wb_bwe_ener, /* i : previous frame wb bwe signal energy */
2921 : const int16_t last_extl, /* i : extl. layer for last frame */
2922 : const float tilt );
2923 :
2924 : void WB_BWE_decoding(
2925 : const float *core_dec_freq, /* i : Frequency domain core decoded signal */
2926 : float *WB_fenv, /* i : WB frequency envelopes */
2927 : float *WB_signal, /* o : WB signal in MDCT domain */
2928 : const int16_t WB_flength, /* i : Length of input/output */
2929 : const int16_t mode, /* i : classification for WB signal */
2930 : const int16_t last_extl, /* i : extl. layer for last frame */
2931 : float *prev_Energy, /* i/o: energy for last frame */
2932 : float *prev_WB_fenv, /* i/o: envelope for last frame */
2933 : int16_t *prev_L_wb_norm, /* i/o: length for last frame wb norm */
2934 : const int16_t extl, /* i : extension layer */
2935 : const int16_t coder_type, /* i : coding type */
2936 : const int32_t total_brate, /* i : core layer bitrate */
2937 : int16_t *Seed, /* i/o: random generator seed */
2938 : int16_t *prev_flag, /* i/o: attenu flag of last frame */
2939 : int16_t prev_coder_type /* i : coding type of last frame */
2940 : );
2941 :
2942 : void SWB_BWE_decoding(
2943 : const float *core_dec_freq, /* i : Frequency domain core decoded signal */
2944 : float *SWB_fenv, /* i/o: SWB frequency envelopes */
2945 : float *SWB_signal, /* o : SWB signal in MDCT domain */
2946 : const int16_t SWB_flength, /* i : Length of input/output */
2947 : const int16_t mode, /* i : classification for SWB signal */
2948 : int16_t *frica_flag, /* o : fricative signal flag */
2949 : float *prev_Energy, /* i/o: energy for last frame */
2950 : float *prev_SWB_fenv, /* i/o: envelope for last frame */
2951 : int16_t *prev_L_swb_norm, /* i/o: length for last frame wb norm */
2952 : const float tilt_nb, /* i : tilt of synthesis wb signal */
2953 : int16_t *Seed, /* i/o: random generator seed */
2954 : const int16_t st_offset, /* i : offset value due to different core */
2955 : float *prev_weight, /* i/o: excitation weight value of last frame */
2956 : const int16_t extl, /* i : extension layer */
2957 : const int16_t last_extl /* i : extension layer of last frame */
2958 : );
2959 :
2960 : void CNG_reset_enc(
2961 : Encoder_State *st, /* i/o: encoder state structure */
2962 : float *pitch_buf, /* o : floating pitch for each subframe */
2963 : float *voice_factors, /* o : voicing factors */
2964 : int16_t VBR_cng_reset_flag );
2965 :
2966 : void a2isp(
2967 : const float *a, /* i : LP filter coefficients */
2968 : float *isp, /* o : Immittance spectral pairs */
2969 : const float *old_isp /* i : ISP vector from past frame */
2970 : );
2971 :
2972 : void a2isf(
2973 : float *a,
2974 : float *isf,
2975 : const float *old_isf,
2976 : const int16_t lpcOrder );
2977 :
2978 : /*! r: stability flag */
2979 : uint16_t a2rc(
2980 : const float *a, /* i : LPC coefficients */
2981 : float *refl, /* o : Reflection co-efficients */
2982 : const int16_t lpcorder /* i : LPC order */
2983 : );
2984 :
2985 : int16_t lp_filt_exc_enc(
2986 : const int16_t codec_mode, /* i : codec mode */
2987 : const int16_t coder_type, /* i : coding type */
2988 : const int16_t i_subfr, /* i : subframe index */
2989 : float *exc, /* i/o: pointer to excitation signal frame */
2990 : const float *h1, /* i : weighted filter input response */
2991 : const float *xn, /* i : target vector */
2992 : float *y1, /* o : zero-memory filtered adaptive excitation */
2993 : float *xn2, /* o : target vector for innovation search */
2994 : const int16_t L_subfr, /* i : length of vectors for gain quantization */
2995 : const int16_t L_frame, /* i : frame size */
2996 : float *g_corr, /* o : ACELP correlation values */
2997 : const int16_t clip_gain, /* i : adaptive gain clipping flag */
2998 : float *gain_pit, /* o : adaptive excitation gain */
2999 : int16_t *lp_flag /* i/o: mode selection */
3000 : );
3001 :
3002 : void updt_tar(
3003 : const float *x, /* i : old target (for pitch search) */
3004 : float *x2, /* o : new target (for codebook search) */
3005 : const float *y, /* i : filtered adaptive codebook vector */
3006 : const float gain, /* i : adaptive codebook gain */
3007 : const int16_t L /* i : subframe size */
3008 : );
3009 :
3010 : void analy_sp(
3011 : const int16_t element_mode, /* i : element mode */
3012 : CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
3013 : const int32_t input_Fs, /* i : input sampling rate */
3014 : float *speech, /* i : speech buffer */
3015 : float *Bin_E, /* o : per bin log energy spectrum */
3016 : float *Bin_E_old, /* o : per bin log energy spectrum for mid-frame */
3017 : float *fr_bands, /* o : per band energy spectrum (2 analyses) */
3018 : float lf_E[], /* o : per bin E for first VOIC_BINS bins (without DC) */
3019 : float *Etot, /* o : total input energy */
3020 : const int16_t min_band, /* i : minimum critical band */
3021 : const int16_t max_band, /* i : maximum critical band */
3022 : float *band_ener, /* o : energy in critical frequency bands without minimum noise floor E_MIN */
3023 : float *PS, /* o : Per bin energy spectrum */
3024 : float *fft_buff /* o : FFT coefficients */
3025 : );
3026 :
3027 : void CNG_enc(
3028 : Encoder_State *st, /* i/o: State structure */
3029 : float Aq[], /* o : LP coefficients */
3030 : const float *speech, /* i : pointer to current frame input speech buffer */
3031 : float enr, /* i : frame energy output from Levinson recursion */
3032 : const float *lsp_mid, /* i : mid frame LSPs */
3033 : float *lsp_new, /* i/o: current frame LSPs */
3034 : float *lsf_new, /* i/o: current frame LSFs */
3035 : int16_t *allow_cn_step, /* o : allow CN step */
3036 : float *q_env,
3037 : int16_t *sid_bw );
3038 :
3039 : void swb_CNG_enc(
3040 : Encoder_State *st, /* i/o: State structure */
3041 : const float *shb_speech, /* i : SHB target signal (6-14kHz) at 16kHz */
3042 : const float *syn_12k8_16k /* i : ACELP core synthesis at 12.8kHz or 16kHz */
3043 : );
3044 :
3045 : void lsf_enc(
3046 : Encoder_State *st, /* i/o: state structure */
3047 : float *lsf_new, /* o : quantized LSF vector */
3048 : float *lsp_new, /* i/o: LSP vector to quantize/quantized */
3049 : float *lsp_mid, /* i : mid-frame LSP vector */
3050 : float *Aq, /* o : quantized A(z) for 4 subframes */
3051 : const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
3052 : const int16_t GSC_IVAS_mode, /* i : GSC IVAS mode */
3053 : const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
3054 : );
3055 :
3056 : void isf_enc_amr_wb(
3057 : Encoder_State *st, /* i/o: state structure */
3058 : float *isf_new, /* o : quantized ISF vector */
3059 : float *isp_new, /* i/o: ISP vector to quantize/quantized */
3060 : float *Aq /* o : quantized A(z) for 4 subframes */
3061 : );
3062 :
3063 : void find_targets(
3064 : const float *speech, /* i : pointer to the speech frame */
3065 : const float *mem_syn, /* i : memory of the synthesis filter */
3066 : const int16_t i_subfr, /* i : subframe index */
3067 : float *mem_w0, /* i/o: weighting filter denominator memory */
3068 : const float *p_Aq, /* i : interpolated quantized A(z) filter */
3069 : const float *res, /* i : residual signal */
3070 : const int16_t L_subfr, /* i : length of vectors for gain quantization */
3071 : const float *Ap, /* i : unquantized A(z) filter with bandwidth expansion */
3072 : const float tilt_fac, /* i : tilt factor */
3073 : float *xn, /* o : Close-loop Pitch search target vector */
3074 : float *cn, /* o : target vector in residual domain */
3075 : float *h1 /* o : impulse response of weighted synthesis filter */
3076 : );
3077 :
3078 : void inov_encode(
3079 : Encoder_State *st, /* i/o: encoder state structure */
3080 : const int32_t core_brate, /* i : core bitrate */
3081 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
3082 : const int16_t L_frame, /* i : length of the frame */
3083 : const int16_t last_L_frame, /* i : length of the last frame */
3084 : const int16_t coder_type, /* i : coding type */
3085 : const int16_t bwidth, /* i : input signal bandwidth */
3086 : const int16_t sharpFlag, /* i : formant sharpening flag */
3087 : const int16_t i_subfr, /* i : subframe index */
3088 : const int16_t tc_subfr, /* i : TC subframe index */
3089 : const float *p_Aq, /* i : LP filter coefficients */
3090 : const float gain_pit, /* i : adaptive excitation gain */
3091 : float *cn, /* i/o: target vector in residual domain */
3092 : const float *exc, /* i : pointer to excitation signal frame */
3093 : float *h1, /* i/o: weighted filter input response */
3094 : const float tilt_code, /* i : tilt of of the excitation of previous subframe */
3095 : const float pt_pitch, /* i : pointer to current subframe fractional pitch */
3096 : const float *xn2, /* i : target vector for innovation search */
3097 : float *code, /* o : algebraic excitation */
3098 : float *y2, /* o : zero-memory filtered algebraic excitation */
3099 : int16_t *unbits, /* o : number of unused bits for EVS_PI */
3100 : const int16_t L_subfr /* i : subframe length */
3101 : );
3102 :
3103 : void acelp_1t64(
3104 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3105 : const float dn[], /* i : corr. between target and h[]. */
3106 : const float h[], /* i : impulse response of weighted synthesis filter */
3107 : float code[], /* o : algebraic (fixed) codebook excitation */
3108 : float y[], /* o : filtered fixed codebook excitation */
3109 : const int16_t L_subfr /* i : subframe length */
3110 : );
3111 :
3112 : void acelp_2t32(
3113 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3114 : const float dn[], /* i : corr. between target and h[]. */
3115 : const float h[], /* i : impulse response of weighted synthesis filter */
3116 : float code[], /* o : algebraic (fixed) codebook excitation */
3117 : float y[] /* o : filtered fixed codebook excitation */
3118 : );
3119 :
3120 : int16_t acelp_4t64(
3121 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3122 : float dn[], /* i : corr. between target and h[]. */
3123 : const float cn[], /* i : residual after long term prediction */
3124 : const float H[], /* i : impulse response of weighted synthesis filter */
3125 : float R[], /* i : autocorrelation values */
3126 : const int16_t acelpautoc, /* i : autocorrealtion flag */
3127 : float code[], /* o : algebraic (fixed) codebook excitation */
3128 : float y[], /* o : filtered fixed codebook excitation */
3129 : int16_t nbbits, /* i : number of bits per codebook */
3130 : const int16_t cmpl_flag, /* i : coomplexity reduction flag */
3131 : const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
3132 : );
3133 :
3134 : /*! r: return (2*N)+1 bits */
3135 : int16_t quant_2p_2N1(
3136 : const int16_t pos1, /* i : position of the pulse 1 */
3137 : const int16_t pos2, /* i : position of the pulse 2 */
3138 : const int16_t N /* i : number of bits for position */
3139 : );
3140 :
3141 : void corr_xh(
3142 : const float *x, /* i : target signal */
3143 : float *y, /* o : correlation between x[] and h[] */
3144 : const float *h, /* i : impulse response of weighted synthesis filter */
3145 : const int16_t L_subfr /* i : length of the subframe */
3146 : );
3147 :
3148 : void find_tilt(
3149 : const float fr_bands[], /* i : energy in frequency bands */
3150 : const float bckr[], /* i : per band background noise energy estimate */
3151 : float ee[2], /* o : lf/hf E ration for present frame */
3152 : const int16_t pitch[3], /* i : open loop pitch values for 3 half-frames */
3153 : const float voicing[3], /* i : normalized correlation for 3 half-frames */
3154 : const float *lf_E, /* i : per bin energy for low frequencies */
3155 : const float corr_shift, /* i : normalized correlation correction */
3156 : const int16_t bwidth, /* i : input signal bandwidth */
3157 : const int16_t max_band, /* i : maximum critical band */
3158 : float hp_E[], /* o : energy in HF */
3159 : const int16_t codec_mode, /* i : Mode 1 or 2 */
3160 : float *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise */
3161 : int16_t Opt_vbr_mode );
3162 :
3163 : void init_gp_clip(
3164 : float mem[] /* o : memory of gain of pitch clipping algorithm */
3165 : );
3166 :
3167 : int16_t gp_clip(
3168 : const int16_t element_mode, /* i : element mode */
3169 : const int32_t core_brate, /* i : core bitrate */
3170 : const float *voicing, /* i : normalized correlations (from OL pitch) */
3171 : const int16_t i_subfr, /* i : subframe index */
3172 : const int16_t coder_type, /* i : coding type */
3173 : const float xn[], /* i : target vector */
3174 : float mem[] /* i/o: memory of gain of pitch clipping algorithm */
3175 : );
3176 :
3177 : void gp_clip_test_lsf(
3178 : const int16_t element_mode, /* i : element mode */
3179 : const int32_t core_brate, /* i : core bitrate */
3180 : const float lsf[], /* i : LSF vector */
3181 : float mem[], /* i/o: memory of gain of pitch clipping algorithm */
3182 : const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
3183 : );
3184 :
3185 : void gp_clip_test_gain_pit(
3186 : const int16_t element_mode, /* i : element mode */
3187 : const int32_t core_brate, /* i : core bitrate */
3188 : const float gain_pit, /* i : gain of quantized pitch */
3189 : float mem[] /* i/o: memory of gain of pitch clipping algorithm */
3190 : );
3191 :
3192 : void analy_lp(
3193 : const float speech[], /* i : pointer to the denoised speech frame */
3194 : const int16_t L_frame, /* i : length of the frame */
3195 : const int16_t L_look, /* i : look-ahead length */
3196 : float *ener, /* o : residual signal energy */
3197 : float A[], /* o : A(z) filter coefficients */
3198 : float epsP[], /* o : LP analysis residual energies for each iteration */
3199 : float lsp_new[], /* o : current frame ISPs */
3200 : float lsp_mid[], /* o : current mid-frame ISPs */
3201 : float lsp_old[], /* i/o: previous frame unquantized ISPs */
3202 : const int16_t Top[2], /* i : open loop pitch lag */
3203 : const float Tnc[2], /* i : open loop pitch gain */
3204 : const int32_t sr_core, /* i : internal sampling rate */
3205 : const int16_t sec_chan_low_rate /* i : TD secondary channel flag */
3206 : );
3207 :
3208 : void analy_lp_AMR_WB(
3209 : const float speech[], /* i : pointer to the speech frame */
3210 : float *ener, /* o : residual energy from Levinson-Durbin */
3211 : float A[], /* o : A(z) filter coefficients */
3212 : float epsP[], /* o : LP analysis residual energies for each iteration */
3213 : float isp_new[], /* o : current frame ISPs */
3214 : float isp_old[], /* i/o: previous frame unquantized ISPs */
3215 : float isf_new[], /* o : current frame ISFs */
3216 : const int16_t Top, /* i : open loop pitch lag */
3217 : const float Tnc /* i : open loop pitch gain */
3218 : );
3219 :
3220 : void noise_est_init(
3221 : NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */
3222 : );
3223 :
3224 : void speech_music_clas_init(
3225 : SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */
3226 : );
3227 :
3228 : void long_enr(
3229 : Encoder_State *st, /* i/o: encoder state structure */
3230 : const float Etot, /* i : total channel energy */
3231 : const int16_t localVAD_HE_SAD, /* i : HE-SAD flag without hangover */
3232 : const int16_t high_lpn_flag, /* i : sp/mus LPN flag */
3233 : FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */
3234 : const int16_t n_chan, /* i : number of channels */
3235 : const int16_t localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover LR channels */
3236 : const float Etot_LR[] /* i : total channel energy LR channels */
3237 : );
3238 :
3239 : void noise_est_pre(
3240 : const float Etot, /* i : Energy of current frame */
3241 : const int16_t ini_frame, /* i : Frame number (init) */
3242 : NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation data handle */
3243 : const int16_t idchan, /* i : channel ID */
3244 : const int16_t element_mode, /* i : element mode */
3245 : const int16_t last_element_mode /* i : last element mode */
3246 : );
3247 :
3248 : void noise_est_down(
3249 : const float fr_bands[], /* i : per band input energy (contains 2 vectors) */
3250 : float bckr[], /* i/o: per band background noise energy estimate */
3251 : float tmpN[], /* o : temporary noise update */
3252 : float enr[], /* o : averaged energy over both subframes */
3253 : const int16_t min_band, /* i : minimum critical band */
3254 : const int16_t max_band, /* i : maximum critical band */
3255 : float *totalNoise, /* o : noise estimate over all critical bands */
3256 : const float Etot, /* i : Energy of current frame */
3257 : float *Etot_last, /* i/o: Energy of last frame */
3258 : float *Etot_v_h2 /* i/o: Energy variaions of noise frames */
3259 : );
3260 :
3261 : void noise_est(
3262 : Encoder_State *st, /* i/o: encoder state structure */
3263 : const int16_t old_pitch1, /* i : previous frame OL pitch[1] */
3264 : const float tmpN[], /* i : temporary noise update */
3265 : const float *epsP, /* i : LP prediction error energies */
3266 : const float Etot, /* i : total channel E */
3267 : const float relE, /* i : relative frame energy */
3268 : const float corr_shift, /* i : normalized correlation correction */
3269 : const float enr[], /* i : averaged energy over both subframes */
3270 : float fr_bands[], /* i : spectrum per critical bands of the current frame */
3271 : float *cor_map_sum, /* o : sum of correlation map from mult-harm analysis */
3272 : float *ncharX, /* o : noise character for sp/mus classifier */
3273 : float *sp_div, /* o : soectral diversity feature */
3274 : float *non_staX, /* o : non-stationarity for sp/mus classifier */
3275 : int16_t *loc_harm, /* o : multi-harmonicity flag for UV classifier */
3276 : const float *lf_E, /* i : per bin energy for low frequencies */
3277 : int16_t *st_harm_cor_cnt, /* i : 1st harm correlation timer */
3278 : const float Etot_l_lp, /* i : Smoothed low energy */
3279 : float *sp_floor, /* o : noise floor estimate */
3280 : float S_map[], /* o : short-term correlation map */
3281 : STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
3282 : FRONT_VAD_ENC_HANDLE hFrontVad, /* i/o: front-VAD handle */
3283 : const int16_t ini_frame /* i : Frame number (init) */
3284 : );
3285 :
3286 : void vad_param_updt(
3287 : Encoder_State *st, /* i/o: encoder state structure */
3288 : const float corr_shift, /* i : correlation shift */
3289 : const float corr_shiftR, /* i : correlation shift right channel */
3290 : const float A[], /* i : A(z) unquantized for the 4 subframes */
3291 : const int16_t old_pitch1, /* i : previous frame OL pitch[1] */
3292 : FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */
3293 : const int16_t n_channels /* i : number of channels */
3294 : );
3295 :
3296 : /*! r: frame multi-harmonicity (1-harmonic, 0-not) */
3297 : int16_t multi_harm(
3298 : const float Bin_E[], /* i : log energy spectrum of the current frame */
3299 : float old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor */
3300 : float cor_map_LT[], /* i/o: LT correlation map */
3301 : float *multi_harm_limit, /* i/o: multi harminic threshold */
3302 : const int32_t total_brate, /* i : total bitrate */
3303 : const int16_t bwidth, /* i : input signal bandwidth */
3304 : int16_t *cor_strong_limit, /* i/o: HF correlation indicator */
3305 : float *st_mean_avr_dyn, /* i/o: long term average dynamic */
3306 : float *st_last_sw_dyn, /* i/o: last dynamic */
3307 : float *cor_map_sum, /* i : sum of correlation map */
3308 : float *sp_floor, /* o : noise floor estimate */
3309 : float S_map[] /* o : short-term correlation map */
3310 : );
3311 :
3312 : void lp_gain_updt(
3313 : const int16_t i_subfr, /* i : subframe number */
3314 : const float gain_pit, /* i : Decoded gain pitch */
3315 : const float norm_gain_code, /* i : Normalised gain code */
3316 : float *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) */
3317 : float *lp_gainc, /* i/o: LP-filtered code gain (FEC) */
3318 : const int16_t L_frame /* i : length of the frame */
3319 : );
3320 :
3321 : void enc_pit_exc(
3322 : Encoder_State *st, /* i/o: state structure */
3323 : const float *speech, /* i : Input speech */
3324 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
3325 : const float *Aq, /* i : 12k8 Lp coefficient */
3326 : const float Es_pred, /* i : predicted scaled innov. energy */
3327 : const float *res, /* i : residual signal */
3328 : float *synth, /* i/o: core synthesis */
3329 : float *exc, /* i/o: current non-enhanced excitation */
3330 : int16_t *T0, /* i/o: close loop integer pitch */
3331 : int16_t *T0_frac, /* i/o: close-loop pitch period - fractional part */
3332 : float *pitch_buf, /* i/o: Fractionnal per subframe pitch */
3333 : const int16_t nb_subfr, /* i : Number of subframe considered */
3334 : float *gpit, /* o : pitch gain per subframe */
3335 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
3336 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
3337 : );
3338 :
3339 : void GSC_enc_init(
3340 : GSC_ENC_HANDLE hGSCEnc /* i/o: GSC data handle */
3341 : );
3342 :
3343 : void encod_audio(
3344 : Encoder_State *st, /* i/o: state structure */
3345 : const float speech[], /* i : input speech */
3346 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
3347 : const float Aq[], /* i : 12k8 Lp coefficient */
3348 : const float *res, /* i : residual signal */
3349 : float *synth, /* i/o: core synthesis */
3350 : float *exc, /* i/o: current non-enhanced excitation */
3351 : float *pitch_buf, /* i/o: floating pitch values for each subframe */
3352 : float *voice_factors, /* o : voicing factors */
3353 : float *bwe_exc, /* o : excitation for SWB TBE */
3354 : const int16_t attack_flag, /* i : attack flag (GSC or TC) */
3355 : float *lsf_new, /* i : current frame ISF vector */
3356 : float *tmp_noise, /* o : long-term noise energy */
3357 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
3358 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
3359 : );
3360 :
3361 : /*! r: index of the last band where pitch contribution is significant */
3362 : int16_t Pit_exc_contribution_len(
3363 : Encoder_State *st, /* i/o: state structure */
3364 : const float *dct_res, /* i : DCT of residual */
3365 : float *dct_pitex, /* i/o: DCT of pitch contribution */
3366 : float *pitch_buf, /* i/o: Pitch per subframe */
3367 : int16_t *hangover /* i : Hangover for the time contribution switching */
3368 : );
3369 :
3370 : int16_t stab_est(
3371 : float etot, /* i : Total energy of the current frame */
3372 : float *lt_diff_etot, /* i/o: Long term total energy variation */
3373 : float *mem_etot, /* i/o: Total energy memory */
3374 : int16_t *nb_thr_3, /* i/o: Number of consecutives frames of level 3 */
3375 : int16_t *nb_thr_1, /* i/o: Number of consecutives frames of level 1 */
3376 : float *thresh, /* i/o: Detection thresold */
3377 : int16_t *last_music_flag, /* i/o: Previous music detection ouptut */
3378 : const int16_t vad_flag /* i : VAD flag */
3379 : );
3380 :
3381 : float gsc_gainQ(
3382 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3383 : const int16_t element_mode, /* i : element mode */
3384 : const int16_t idchan, /* i : channel ID */
3385 : const float y_gain4[], /* i : gain per band */
3386 : float y_gainQ[], /* o : quantized gain per band */
3387 : const int32_t core_brate, /* i : Core rate */
3388 : const int16_t coder_type, /* i : coding type */
3389 : const int16_t bwidth, /* i : input signal bandwidth */
3390 : const int16_t L_frame, /* i : frame length */
3391 : const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */
3392 : const int32_t core_brate_inp /* i : true core brate */
3393 : );
3394 :
3395 : void Ener_per_band_comp(
3396 : const float exc_diff[], /* i : gain per band */
3397 : float y_gain4[], /* o : gain per band to quantize */
3398 : const int16_t Mband, /* i : Max band */
3399 : const int16_t Eflag, /* i : flag of highest band */
3400 : const int16_t L_frame /* i : frame length */
3401 : );
3402 :
3403 : void Comp_and_apply_gain(
3404 : float exc_diffQ[], /* i/o: gain per band */
3405 : float Ener_per_bd_iQ[], /* o : Quant Ener per band */
3406 : float Ener_per_bd_yQ[], /* o : Ener per band for quantize y */
3407 : int16_t Mbands_gn, /* i : number of bands */
3408 : const int16_t ReUseGain /* i : Reuse the gain in Ener_per_bd_yQ */
3409 : );
3410 :
3411 : void bands_and_bit_alloc(
3412 : const int16_t cor_strong_limit, /* i : HF correlation */
3413 : const int16_t noise_lev, /* i : dwn scaling factor */
3414 : const int32_t core_brate, /* i : core bitrate */
3415 : const int16_t Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/
3416 : const int16_t bits_used, /* i : Number of bit used before frequency Q */
3417 : int16_t *bit, /* i/o: Number of bit allowed for frequency quantization */
3418 : float *ener_vec, /* i/o: Quantized energy vector */
3419 : int16_t *max_ener_band, /* o : Sorted order */
3420 : int16_t *bits_per_bands_s, /* i/o: Number of bit allowed per allowed subband (Q3) */
3421 : int16_t *nb_subbands, /* o : Number of subband allowed */
3422 : const float *exc_diff, /* i : Difference signal to quantize (encoder side only) */
3423 : float *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */
3424 : int16_t *pvq_len, /* o : Number of bin covered with the PVQ */
3425 : const int16_t coder_type, /* i : coding type */
3426 : const int16_t bwidth, /* i : input signal bandwidth */
3427 : const int16_t GSC_noisy_speech, /* i : GSC noisy speech flag */
3428 : const int16_t L_frame, /* i : frame length */
3429 : const int16_t element_mode, /* i : element mode */
3430 : const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */
3431 : );
3432 :
3433 : /*! r: average frequency gain */
3434 : float gsc_gaindec(
3435 : Decoder_State *st, /* i/o: decoder state structure */
3436 : float y_gainQ[], /* o : quantized gain per band */
3437 : const int32_t core_brate, /* i : core used */
3438 : float old_y_gain[], /* i/o: AR gain quantizer for low rate */
3439 : const int16_t coder_type, /* i : coding type */
3440 : const int16_t bwidth /* i : input signal bandwidth */
3441 : );
3442 :
3443 : void freq_dnw_scaling(
3444 : const int16_t cor_strong_limit, /* i : HF correlation */
3445 : const int16_t coder_type, /* i : coder type */
3446 : const int16_t noise_lev, /* i : Noise level */
3447 : const int32_t core_brate, /* i : Core bitrate */
3448 : float fy_norm[], /* i/o: Frequency quantized parameter */
3449 : const int16_t L_frame /* i : frame length */
3450 : );
3451 :
3452 : void GSC_dec_init(
3453 : GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */
3454 : );
3455 :
3456 : void decod_audio(
3457 : Decoder_State *st, /* i/o: decoder static memory */
3458 : float dct_epit[], /* o : GSC excitation in DCT domain */
3459 : const float *Aq, /* i : LP filter coefficient */
3460 : float *tmp_noise, /* o : long term temporary noise energy */
3461 : float *pitch_buf, /* o : floating pitch values for each subframe */
3462 : float *voice_factors, /* o : voicing factors */
3463 : float *exc_dct_in, /* i/o: adapt. excitation exc */
3464 : float *exc2, /* i/o: adapt. excitation/total exc */
3465 : float *bwe_exc, /* o : excitation for SWB TBE */
3466 : float *lsf_new, /* i : current frame ISF vector */
3467 : float *gain_buf, /* o : floating pitch gain for each subframe */
3468 : const int16_t tdm_lp_reuse_flag, /* i : LPC reuse flag */
3469 : const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
3470 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
3471 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
3472 : );
3473 :
3474 : void gsc_dec(
3475 : Decoder_State *st, /* i/o: State structure */
3476 : float exc_dct_in[], /* i/o: dct of pitch-only/total excitation */
3477 : const int16_t pit_band_idx, /* i : pitch band index */
3478 : const int16_t Diff_len, /* i : */
3479 : const int16_t bits_used, /* i : total number of bits used */
3480 : const int16_t nb_subfr, /* i : Number of subframe considered */
3481 : const int16_t coder_type, /* i : coding type */
3482 : int16_t *last_bin, /* i : last bin of bit allocation */
3483 : const float *lsf_new, /* i : ISFs at the end of the frame */
3484 : float *exc_wo_nf, /* o : excitation (in f domain) without noisefill*/
3485 : float *tmp_noise /* o : long-term noise energy */
3486 : );
3487 :
3488 : void dec_pit_exc(
3489 : Decoder_State *st, /* i/o: decoder static memory */
3490 : const int16_t L_frame, /* i : length of the frame */
3491 : const float *Aq, /* i : LP filter coefficient */
3492 : const float Es_pred, /* i : predicted scaled innov. energy */
3493 : float *pitch_buf, /* o : floating pitch values for each subframe */
3494 : float *code, /* o : innovation */
3495 : float *exc, /* i/o: adapt. excitation exc */
3496 : const int16_t nb_subfr, /* i : Number of subframe considered */
3497 : float *gain_buf, /* o : floating pitch gain for each subframe */
3498 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
3499 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
3500 : );
3501 :
3502 : void highband_exc_dct_in(
3503 : const int32_t core_brate, /* i : core bitrate */
3504 : const int16_t *mfreq_bindiv_loc, /* i : bin per bands tables */
3505 : int16_t last_bin, /* i : last bin of bit allocation */
3506 : int16_t Diff_len, /* i : number of bin before cut-off frequency */
3507 : int16_t noise_lev, /* i : pulses dynamic */
3508 : int16_t pit_band_idx, /* i : bin position of the cut-off frequency */
3509 : float *exc_diffQ, /* i : frequency coefficients of per band */
3510 : int16_t *seed_tcx, /* i : Seed for noise */
3511 : float *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */
3512 : int16_t nb_subfr, /* i : Number of subframe considered */
3513 : float *exc_dct_in, /* o : dct of residual signal */
3514 : int16_t last_coder_type, /* i : coding type of last frame */
3515 : int16_t *bitallocation_band, /* i : bit allocation flag of each band */
3516 : const float *lsf_new, /* i : ISFs at the end of the frame */
3517 : float *last_exc_dct_in, /* i : dct of residual signal of last frame */
3518 : float *last_ener, /* i : frequency energy of last frame */
3519 : int16_t *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */
3520 : int16_t *bitallocation_exc, /* i : flag of decoded coefficients */
3521 : const int16_t bfi, /* i : bad frame indicator */
3522 : const int16_t coder_type, /* i : coder type */
3523 : const int16_t bwidth, /* i : audio bandwidth */
3524 : float *exc_wo_nf, /* o : excitation (in f domain) without noisefill */
3525 : const int16_t GSC_noisy_speech, /* i : GSC noisy speech flag */
3526 : float *lt_ener_per_band_fx, /* i/o: Average per band energy */
3527 : const int16_t L_frame, /* i : frame length */
3528 : const int16_t element_mode, /* i : IVAS element moden */
3529 : const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */
3530 : );
3531 :
3532 : void inact_switch_ematch(
3533 : float exc2[], /* i/o: CELP/GSC excitation buffer */
3534 : float dct_exc_tmp[], /* i : GSC excitation in DCT domain */
3535 : float lt_ener_per_band[], /* i/o: long-term energy per band */
3536 : const int16_t coder_type, /* i : coder type */
3537 : const int16_t inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
3538 : const int16_t L_frame, /* i : frame length */
3539 : const int16_t bfi, /* i : frame lost indicator */
3540 : const int16_t last_core, /* i : Last core used */
3541 : const int16_t last_codec_mode, /* i : Last codec mode */
3542 : const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
3543 : const int16_t element_mode /* i : element mode */
3544 : );
3545 :
3546 : void music_postfilt_init(
3547 : MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */
3548 : );
3549 :
3550 : void LD_music_post_filter(
3551 : MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */
3552 : const float dtc_in[], /* i : input synthesis */
3553 : float dtc_out[], /* o : output synthesis */
3554 : const int32_t core_brate, /* i : core bitrate */
3555 : const int16_t coder_type, /* i : Coder type : -1 in case of IO */
3556 : const int16_t Last_coder_type /* i : last Coder type */
3557 : );
3558 :
3559 : void Post_music_postP(
3560 : float dct_buffer_in[], /* i/o: excitation buffer */
3561 : float exc_buffer_out[], /* o : DCT output buffer */
3562 : float *exc2, /* i/o: Current excitation to be overwriten */
3563 : const float *mem_tmp, /* i : previous frame synthesis memory */
3564 : float *st_mem_syn2, /* i/o: current frame synthesis memory */
3565 : const float *Aq, /* i : LPC filter coefficients */
3566 : float *syn /* i/o: 12k8 synthesis */
3567 : );
3568 :
3569 : void Prep_music_postP(
3570 : float exc_buffer_in[], /* i/o: excitation buffer */
3571 : float dct_buffer_out[], /* o : DCT output buffer */
3572 : float filt_lfE[], /* i/o: long term spectrum energy */
3573 : const int16_t last_core, /* i : last core */
3574 : const float *pitch_buf, /* i : current frame pitch information */
3575 : float *LDm_enh_lp_gbin /* o : smoothed suppression gain, per bin FFT */
3576 : );
3577 :
3578 : void speech_music_classif(
3579 : Encoder_State *st, /* i/o: encoder state structure */
3580 : const float *new_inp, /* i : new input signal */
3581 : const float *inp, /* i : input signal to locate attach position */
3582 : const int16_t localVAD_HE_SAD, /* i : HE-SAD flag without hangover */
3583 : const float lsp_new[M], /* i : LSPs in current frame */
3584 : const float cor_map_sum, /* i : correlation map sum (from multi-harmonic anal.) */
3585 : const float epsP[M + 1], /* i : LP prediciton error */
3586 : const float PS[], /* i : energy spectrum */
3587 : const float Etot, /* i : total frame energy */
3588 : const float old_cor, /* i : max correlation from previous frame */
3589 : int16_t *attack_flag, /* o : attack flag (GSC or TC) */
3590 : const float non_staX, /* i : unbound non-stationarity for sp/mus classifier */
3591 : const float relE, /* i : relative frame energy */
3592 : int16_t *high_lpn_flag, /* o : sp/mus LPN flag */
3593 : const int16_t flag_spitch /* i : flag to indicate very short stable pitch */
3594 : );
3595 :
3596 : void find_wsp(
3597 : const int16_t L_frame, /* i : length of the frame */
3598 : const int16_t L_subfr, /* i : length of subframe */
3599 : const int16_t nb_subfr, /* i : number of subframes */
3600 : const float *A, /* i : A(z) filter coefficients */
3601 : float *Aw, /* o : weighted A(z) filter coefficients */
3602 : const float *speech, /* i : pointer to the denoised speech frame */
3603 : const float tilt_fact, /* i : tilt factor */
3604 : float *wsp, /* o : poitnter to the weighted speech frame */
3605 : float *mem_wsp, /* i/o: W(Z) denominator memory */
3606 : const float gamma, /* i : weighting factor */
3607 : const int16_t L_look /* i : look-ahead */
3608 : );
3609 :
3610 : void pitch_ol_init(
3611 : float *old_thres, /* o : threshold for reinforcement of past pitch influence */
3612 : int16_t *old_pitch, /* o : pitch of the 2nd half-frame of previous frame */
3613 : int16_t *delta_pit, /* o : pitch evolution extrapolation */
3614 : float *old_corr /* o : correlation */
3615 : );
3616 :
3617 : void pitch_ol(
3618 : int16_t pitch[3], /* o : open loop pitch lag for each half-frame */
3619 : float voicing[3], /* o : maximum normalized correlation for each half-frame */
3620 : int16_t *old_pitch, /* i/o: OL pitch of the 2nd half-frame of the last frame */
3621 : float *old_corr, /* i/o: correlation */
3622 : float corr_shift, /* i : normalized correlation correction */
3623 : float *old_thres, /* i/o: maximum correlation weighting with respect to past frame pitch */
3624 : int16_t *delta_pit, /* i/o: old pitch extrapolation correction (added to old pitch) */
3625 : float *st_old_wsp2, /* i/o: weighted speech memory */
3626 : const float *wsp, /* i : weighted speech for current frame and look-ahead */
3627 : float mem_decim2[3], /* i/o: wsp decimation filter memory */
3628 : const float relE, /* i : relative frame energy */
3629 : const int16_t L_look, /* i : look-ahead length */
3630 : const int16_t last_class, /* i : frame classification of last frame */
3631 : const int16_t bwidth, /* i : audio bandwidth */
3632 : const int16_t Opt_SC_VBR /* i : SC-VBR flag */
3633 : );
3634 :
3635 : void pitch_ol2(
3636 : const int16_t pit_min, /* i : pit_min value */
3637 : const int16_t pitch_ol, /* i : pitch to be improved */
3638 : float *pitch_fr, /* o : adjusted 1/4 fractional pitch */
3639 : float *voicing_fr, /* o : adjusted 1/4 fractional voicing */
3640 : const int16_t pos, /* i : position in frame where to calculate the improv. */
3641 : const float *wsp, /* i : weighted speech for current frame and look-ahead */
3642 : const int16_t delta /* i : delta for pitch search */
3643 : );
3644 :
3645 : void StableHighPitchDetect(
3646 : int16_t *flag_spitch, /* o : flag to indicate very short stable pitch */
3647 : int16_t pitch[], /* i/o: OL pitch buffer */
3648 : const float voicing[], /* i : OL pitch gains */
3649 : const float Bin_E[], /* i : per bin log energy spectrum */
3650 : const float wsp[], /* i : weighted speech */
3651 : const int16_t localVAD, /* i : local VAD flag */
3652 : float *voicing_sm, /* i/o: smoothed open-loop pitch gains */
3653 : float *voicing0_sm, /* i/o: smoothed high pitch gains */
3654 : float *LF_EnergyRatio_sm, /* i/o: smoothed [0, 300Hz] relative peak energy */
3655 : int16_t *predecision_flag, /* i/o: predecision flag */
3656 : float *diff_sm, /* i/o: smoothed pitch frequency difference */
3657 : float *energy_sm /* i/o: smoothed energy around pitch frequency */
3658 : );
3659 :
3660 : void pitchDoubling_det(
3661 : const float *wspeech,
3662 : int16_t *pitch_ol,
3663 : float *pitch_fr,
3664 : float *voicing_fr );
3665 :
3666 : void gain_enc_amr_wb(
3667 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3668 : const float *xn, /* i : target vector */
3669 : const float *y1, /* i : zero-memory filtered adaptive excitation */
3670 : const float *y2, /* i : zero-memory filtered algebraic codebook excitation */
3671 : const float *code, /* i : algebraic excitation */
3672 : const int32_t core_brate, /* i : core bitrate */
3673 : float *gain_pit, /* i/o: Pitch gain / Quantized pitch gain */
3674 : float *gain_code, /* o : Quantized codebook gain */
3675 : float *gain_inov, /* o : innovation gain */
3676 : float *norm_gain_code, /* o : norm. gain of the codebook excitation */
3677 : float *coeff, /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
3678 : const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
3679 : float *past_qua_en /* i/o: gain quantization memory (4 words) */
3680 : );
3681 :
3682 : void gain_enc_lbr(
3683 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3684 : const int16_t gains_mode[], /* i : gain bits */
3685 : const int16_t coder_type, /* i : coding type */
3686 : const int16_t i_subfr, /* i : subframe index */
3687 : const float *xn, /* i : target vector */
3688 : const float *y1, /* i : zero-memory filtered adaptive excitation */
3689 : const float *y2, /* i : zero-memory filtered algebraic codebook excitation */
3690 : const float *code, /* i : algebraic excitation */
3691 : float *gain_pit, /* o : quantized pitch gain */
3692 : float *gain_code, /* o : quantized codebook gain */
3693 : float *gain_inov, /* o : gain of the innovation (used for normalization) */
3694 : float *norm_gain_code, /* o : norm. gain of the codebook excitation */
3695 : float *g_corr, /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
3696 : float gains_mem[], /* i/o: pitch gain and code gain from previous subframes */
3697 : const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
3698 : const int16_t L_subfr /* i : subfr Lenght */
3699 : );
3700 :
3701 : void gain_enc_mless(
3702 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3703 : const int16_t gains_mode[], /* i : gain bits */
3704 : const int16_t element_mode, /* i : element mode */
3705 : const int16_t L_frame, /* i : length of the frame */
3706 : const int16_t i_subfr, /* i : subframe index */
3707 : const int16_t tc_subfr, /* i : TC subframe index */
3708 : const float *xn, /* i : target vector */
3709 : const float *y1, /* i : zero-memory filtered adaptive excitation */
3710 : const float *y2, /* i : zero-memory filtered algebraic codebook excitation */
3711 : const float *code, /* i : algebraic excitation */
3712 : const float Es_pred, /* i : predicted scaled innovation energy */
3713 : float *gain_pit, /* o : quantized pitch gain */
3714 : float *gain_code, /* o : quantized codebook gain */
3715 : float *gain_inov, /* o : innovation gain */
3716 : float *norm_gain_code, /* o : norm. gain of the codebook excitation */
3717 : float *coeff, /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
3718 : const int16_t clip_gain /* i : gain pitch clipping flag (1 = clipping) */
3719 : );
3720 :
3721 : void gain_enc_SQ(
3722 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3723 : const int16_t gains_mode[], /* i : gain bits */
3724 : const int16_t i_subfr, /* i : subframe index */
3725 : const float *xn, /* i : target vector */
3726 : const float *yy1, /* i : zero-memory filtered adaptive excitation */
3727 : const float *y2, /* i : zero-memory filtered algebraic codebook excitation */
3728 : const float *code, /* i : algebraic excitation */
3729 : const float Es_pred, /* i : predicted scaled innovation energy */
3730 : float *gain_pit, /* o : quantized pitch gain */
3731 : float *gain_code, /* o : quantized codebook gain */
3732 : float *gain_inov, /* o : gain of the innovation (used for normalization) */
3733 : float *norm_gain_code, /* o : norm. gain of the codebook excitation */
3734 : float *g_corr, /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
3735 : const int16_t clip_gain /* i : gain pitch clipping flag (1 = clipping) */
3736 : );
3737 :
3738 : /*! r: Return index of quantization */
3739 : int16_t gain_enc_gaus(
3740 : float *gain, /* i/o: Code gain to quantize */
3741 : const int16_t bits, /* i : number of bits to quantize */
3742 : const float lowBound, /* i : lower bound of quantizer (dB) */
3743 : const float topBound /* i : upper bound of quantizer (dB) */
3744 : );
3745 :
3746 : void E_corr_xy2(
3747 : const float xn[], /* i : target vector */
3748 : const float y1[], /* i : filtered excitation components 1 */
3749 : const float y2[], /* i : filtered excitation components 2 */
3750 : float g_corr[], /* o : correlations between x, y1, y2, y3, y4 */
3751 : const int16_t L_subfr /* i : subframe size */
3752 : );
3753 :
3754 : /*! r: Floating pitch for each subframe */
3755 : float pit_encode(
3756 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3757 : const int16_t pitch_bits[], /* i : pitch bits */
3758 : const int32_t core_brate, /* i : core bitrate */
3759 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
3760 : const int16_t L_frame, /* i : length of the frame */
3761 : const int16_t coder_type, /* i : coding type */
3762 : int16_t *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
3763 : const int16_t i_subfr, /* i : subframe index */
3764 : float *exc, /* i/o: pointer to excitation signal frame */
3765 : const int16_t L_subfr, /* i : subframe length */
3766 : const int16_t *pitch, /* i : open loop pitch estimates in current frame */
3767 : int16_t *T0_min, /* i/o: lower limit for close-loop search */
3768 : int16_t *T0_max, /* i/o: higher limit for close-loop search */
3769 : int16_t *T0, /* i/o: close loop integer pitch */
3770 : int16_t *T0_frac, /* i/o: close loop fractional part of the pitch */
3771 : const float *h1, /* i : weighted filter input response */
3772 : const float *xn, /* i : target vector */
3773 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
3774 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
3775 : );
3776 :
3777 : /*! r: coding type */
3778 : int16_t find_uv(
3779 : Encoder_State *st, /* i/o: encoder state structure */
3780 : const float *pitch_fr, /* i : pointer to adjusted fractional pitch (4 val.) */
3781 : const float *voicing_fr, /* i : refined correlation for each subframes */
3782 : const float *speech, /* i : pointer to speech signal for E computation */
3783 : const float *ee, /* i : lf/hf Energy ratio for present frame */
3784 : float *dE1X, /* o : sudden energy increase for S/M classifier */
3785 : const float corr_shift, /* i : normalized correlation correction in noise */
3786 : const float relE, /* i : relative frame energy */
3787 : const float Etot, /* i : total energy */
3788 : const float hp_E[], /* i : energy in HF */
3789 : int16_t *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */
3790 : const int16_t last_core_orig, /* i : original last core */
3791 : STEREO_CLASSIF_HANDLE hStereoClf /* i/o: stereo classifier structure */
3792 : );
3793 :
3794 : /*! r: classification for current frames */
3795 : int16_t signal_clas(
3796 : Encoder_State *st, /* i/o: encoder state structure */
3797 : const float *speech, /* i : pointer to speech signal for E computation */
3798 : const float *ee, /* i : lf/hf E ration for 2 half-frames */
3799 : const float relE, /* i : frame relative E to the long term average */
3800 : const int16_t L_look, /* i : look-ahead */
3801 : int16_t *clas_mod /* o : class flag for NOOP detection */
3802 : );
3803 :
3804 : void select_TC(
3805 : const int16_t codec_mode, /* i : codec mode */
3806 : const int16_t tc_cnt, /* i : TC frame counter */
3807 : int16_t *coder_type, /* i/o: coder type */
3808 : const int16_t localVAD /* i : VAD without hangover */
3809 : );
3810 :
3811 : void coder_type_modif(
3812 : Encoder_State *st, /* i/o: encoder state structure */
3813 : const float relE /* i : frame relative E to the long term average */
3814 : );
3815 :
3816 : void wb_vad_init(
3817 : VAD_HANDLE hVAD /* i/o: VAD data handle */
3818 : );
3819 :
3820 : int16_t dtx_hangover_addition(
3821 : Encoder_State *st, /* i/o: encoder state structure */
3822 : const int16_t vad_flag, /* i : VAD flag */
3823 : const float snr, /* i : input single SNR estimate */
3824 : const int16_t cldfb_subtraction, /* i : */
3825 : int16_t *vad_hover_flag, /* o : VAD hangover flag */
3826 : VAD_HANDLE hVAD, /* i/o: VAD handle for L or R channel */
3827 : NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */
3828 : int16_t *rem_dtx_ho /* o : Expected remaining hangover frames */
3829 : );
3830 :
3831 : int16_t wb_vad(
3832 : Encoder_State *st, /* i/o: encoder state structure */
3833 : const float fr_bands[], /* i : per band input energy (contains 2 vectors) */
3834 : int16_t *noisy_speech_HO, /* o : SC-VBR noisy speech HO flag */
3835 : int16_t *clean_speech_HO, /* o : SC-VBR clean speech HO flag */
3836 : int16_t *NB_speech_HO, /* o : SC-VBR NB speech HO flag */
3837 : float *snr_sum_he, /* i : voicing metric from SAD */
3838 : int16_t *localVAD_HE_SAD, /* o : HE_SAD decision without hangovers */
3839 : int16_t *flag_noisy_speech_snr, /* o : */
3840 : VAD_HANDLE hVAD, /* i/o: VAD handle */
3841 : NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation handle */
3842 : float lp_speech, /* i : long term active speech energy average */
3843 : float lp_noise /* i : long term noise energy */
3844 : );
3845 :
3846 : void bw_detect(
3847 : Encoder_State *st, /* i/o: Encoder State */
3848 : const float signal_in[], /* i : input signal */
3849 : float *spectrum, /* i : MDCT spectrum */
3850 : const float *enerBuffer, /* i : energy buffer */
3851 : const IVAS_FORMAT ivas_format, /* i : IVAS format */
3852 : const int16_t mct_on /* i : flag MCT mode */
3853 : );
3854 :
3855 : void set_bw(
3856 : const int16_t element_mode, /* i : element mode */
3857 : const int32_t element_brate, /* i : element bitrate */
3858 : Encoder_State *st, /* i/o: Encoder State */
3859 : const int16_t codec_mode /* i : codec mode */
3860 : );
3861 :
3862 : float gaus_encode(
3863 : Encoder_State *st, /* i/o: encoder state structure */
3864 : const int16_t i_subfr, /* i : subframe index */
3865 : const float *h1, /* i : weighted filter input response */
3866 : const float *xn, /* i : target vector */
3867 : float *exc, /* o : pointer to excitation signal frame */
3868 : float *mem_w0, /* o : weighting filter denominator memory */
3869 : float *gp_clip_mem, /* o : memory of gain of pitch clipping algorithm */
3870 : float *tilt_code, /* o : synthesis excitation spectrum tilt */
3871 : float *code, /* o : algebraic excitation */
3872 : float *gain_code, /* o : Code gain. */
3873 : float *y2, /* o : zero-memory filtered adaptive excitation */
3874 : float *gain_inov, /* o : innovation gain */
3875 : float *voice_fac, /* o : voicing factor */
3876 : float *gain_pit, /* o : adaptive excitation gain */
3877 : float *norm_gain_code /* o : normalized innovative cb. gain */
3878 : );
3879 :
3880 : void td_cng_enc_init(
3881 : TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */
3882 : const int16_t Opt_DTX_ON, /* i : flag indicating DTX operation */
3883 : const int16_t max_bwidth /* i : maximum encoded bandwidth */
3884 : );
3885 :
3886 : void dtx(
3887 : Encoder_State *st, /* i/o: encoder state structure */
3888 : const int32_t last_ivas_total_brate, /* i : last IVAS total bitrate */
3889 : const int32_t ivas_total_brate, /* i : IVAS total bitrate */
3890 : const int16_t vad, /* i : VAD flag for DTX */
3891 : const float speech[] /* i : Pointer to the speech frame */
3892 : );
3893 :
3894 : void dtx_hangover_control(
3895 : Encoder_State *st, /* i/o: encoder state structure */
3896 : const float lsp_new[M] /* i : current frame LSPs */
3897 : );
3898 :
3899 : void updt_enc(
3900 : Encoder_State *st, /* i/o: state structure */
3901 : const float *old_exc, /* i : buffer of excitation */
3902 : const float *pitch_buf, /* i : Floating pitch for each subframe */
3903 : const float Es_pred, /* i : predicited scaled innovation energy */
3904 : const float *Aq, /* i : A(z) quantized for all subframes */
3905 : const float *lsf_new, /* i : current frame LSF vector */
3906 : const float *lsp_new, /* i : current frame LSP vector */
3907 : const float *old_bwe_exc /* o : buffer of excitation for SWB TBE */
3908 : );
3909 :
3910 : void updt_enc_common(
3911 : Encoder_State *st /* i/o: encoder state structure */
3912 : );
3913 :
3914 : void updt_IO_switch_enc(
3915 : Encoder_State *st, /* i/o: state structure */
3916 : const int16_t input_frame /* i : input frame length */
3917 : );
3918 :
3919 : void transition_enc(
3920 : Encoder_State *st, /* i/o: encoder state structure */
3921 : const int16_t i_subfr, /* i : subframe index */
3922 : int16_t *tc_subfr, /* i/o: TC subframe index */
3923 : int16_t *Jopt_flag, /* i : joint optimization flag */
3924 : int16_t *position, /* i/o: maximum of residual signal index */
3925 : int16_t *T0, /* i/o: close loop integer pitch */
3926 : int16_t *T0_frac, /* i/o: close loop fractional part of the pitch */
3927 : int16_t *T0_min, /* i/o: lower limit for close-loop search */
3928 : int16_t *T0_max, /* i/o: higher limit for close-loop search */
3929 : float *exc, /* i/o: pointer to excitation signal frame */
3930 : float *y1, /* o : zero-memory filtered adaptive excitation */
3931 : const float *h1, /* i : weighted filter input response */
3932 : const float *xn, /* i : target vector */
3933 : float *xn2, /* o : target vector for innovation search */
3934 : float *gp_cl, /* i/o: memory of gain of pitch clipping algorithm */
3935 : float *gain_pit, /* o : adaptive excitation gain */
3936 : float *g_corr, /* o : ACELP correlation values */
3937 : int16_t *clip_gain, /* i/o: adaptive gain clipping flag */
3938 : float **pt_pitch, /* o : floating pitch values */
3939 : float *bwe_exc, /* i/o: excitation for SWB TBE */
3940 : int16_t *unbits /* i/o: unused bits */
3941 : );
3942 :
3943 : void tc_classif_enc(
3944 : const int16_t L_frame, /* i : length of the frame */
3945 : int16_t *tc_subfr, /* i/o: TC subframe index */
3946 : int16_t *position, /* i/o: maximum of residual signal index */
3947 : const int16_t attack_flag, /* i : attack flag */
3948 : const int16_t pitch, /* i : open loop pitch estimates for first halfframe */
3949 : const float *res /* i : pointer to the LP residual signal frame */
3950 : );
3951 :
3952 : void set_impulse(
3953 : const float xn[], /* i : target signal */
3954 : const float h_orig[], /* i : impulse response of weighted synthesis filter */
3955 : float exc[], /* o : adaptive codebook excitation */
3956 : float y1[], /* o : filtered adaptive codebook excitation */
3957 : int16_t *imp_shape, /* o : adaptive codebook index */
3958 : int16_t *imp_pos, /* o : position of the glottal impulse center index */
3959 : float *gain_trans /* o : transition gain */
3960 : );
3961 :
3962 : void gain_enc_tc(
3963 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
3964 : const int16_t gains_mode[], /* i : gain bits */
3965 : const int16_t i_subfr, /* i : subframe index */
3966 : const float xn[], /* i : target vector */
3967 : const float y2[], /* i : zero-memory filtered algebraic codebook excitation */
3968 : const float code[], /* i : algebraic excitation */
3969 : const float Es_pred, /* i : predicted scaled innovation energy */
3970 : float *gain_pit, /* o : pitch gain / Quantized pitch gain */
3971 : float *gain_code, /* o : quantized codebook gain */
3972 : float *gain_inov, /* o : innovation gain */
3973 : float *norm_gain_code /* o : norm. gain of the codebook excitation */
3974 : );
3975 :
3976 : /*! r: pitch gain (0..GAIN_PIT_MAX) */
3977 : float corr_xy1(
3978 : const float xn[], /* i : target signal */
3979 : const float y1[], /* i : filtered adaptive codebook excitation */
3980 : float g_corr[], /* o : correlations <y1,y1> and -2<xn,y1> */
3981 : const int16_t L_subfr, /* i : subframe length */
3982 : const int16_t norm_flag /* i : flag for constraining pitch contribution */
3983 : );
3984 :
3985 : void norm_corr(
3986 : const float exc[], /* i : excitation buffer */
3987 : const float xn[], /* i : target signal */
3988 : const float h[], /* i : weighted synthesis filter impulse response */
3989 : const int16_t t_min, /* i : minimum value of searched range */
3990 : const int16_t t_max, /* i : maximum value of searched range */
3991 : float corr_norm[], /* o : normalized correlation */
3992 : const int16_t L_subfr /* i : subframe size */
3993 : );
3994 :
3995 : /*! r: chosen integer pitch lag */
3996 : int16_t pitch_fr4(
3997 : const float exc[], /* i : excitation buffer */
3998 : const float xn[], /* i : target signal */
3999 : const float h[], /* i : weighted synthesis filter impulse response */
4000 : const int16_t t0_min, /* i : minimum value in the searched range. */
4001 : const int16_t t0_max, /* i : maximum value in the searched range. */
4002 : int16_t *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */
4003 : const int16_t i_subfr, /* i : flag to first subframe */
4004 : const int16_t limit_flag, /* i : flag for limits (0=restrained, 1=extended) */
4005 : const int16_t t0_fr2, /* i : minimum value for resolution 1/2 */
4006 : const int16_t t0_fr1, /* i : minimum value for resolution 1 */
4007 : const int16_t L_frame, /* i : length of the frame */
4008 : const int16_t L_subfr /* i : size of subframe */
4009 : );
4010 :
4011 : void pit_Q_enc(
4012 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
4013 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
4014 : const int16_t nBits, /* i : # of Q bits */
4015 : const int16_t delta, /* i : Half the CL searched interval */
4016 : const int16_t pit_flag, /* i : absolute(0) or delta(1) pitch Q */
4017 : const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */
4018 : const int16_t T0, /* i : integer pitch lag */
4019 : const int16_t T0_frac, /* i : pitch fraction */
4020 : int16_t *T0_min, /* i/o: delta search min */
4021 : int16_t *T0_max /* o : delta search max */
4022 : );
4023 :
4024 : void pit16k_Q_enc(
4025 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
4026 : const int16_t nBits, /* i : # of Q bits */
4027 : const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */
4028 : const int16_t T0, /* i : integer pitch lag */
4029 : const int16_t T0_frac, /* i : pitch fraction */
4030 : int16_t *T0_min, /* i/o: delta search min */
4031 : int16_t *T0_max /* o : delta search max */
4032 : );
4033 :
4034 : /*! r: pitch index */
4035 : int16_t abs_pit_enc(
4036 : const int16_t fr_steps, /* i : fractional resolution step */
4037 : const int16_t limit_flag, /* i : restrained(0) or extended(1) limits */
4038 : const int16_t T0, /* i : integer pitch lag */
4039 : const int16_t T0_frac /* i : pitch fraction */
4040 : );
4041 :
4042 : /*! r: pitch index */
4043 : int16_t delta_pit_enc(
4044 : const int16_t fr_steps, /* i : fractional resolution steps (2 or 4) */
4045 : const int16_t T0, /* i : integer pitch lag */
4046 : const int16_t T0_frac, /* i : pitch fraction */
4047 : const int16_t T0_min /* i : delta search min */
4048 : );
4049 :
4050 : /*! r: comfort noise gain factor */
4051 : float AVQ_cod(
4052 : const float xri[], /* i : vector to quantize */
4053 : int16_t xriq[], /* o : quantized normalized vector (assuming the bit budget is enough) */
4054 : const int16_t nb_bits, /* i : number of allocated bits */
4055 : const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */
4056 : );
4057 :
4058 : void AVQ_encmux(
4059 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
4060 : const int16_t extl, /* i : extension layer */
4061 : int16_t xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */
4062 : int16_t *nb_bits, /* i/o: number of allocated bits */
4063 : const int16_t Nsv, /* i : number of subvectors */
4064 : int16_t nq[], /* o : AVQ nq index */
4065 : int16_t avq_bit_sFlag, /* i : flag indicating AVQ bit savings */
4066 : int16_t trgtSvPos /* i : target SV for AVQ bit savings */
4067 : );
4068 :
4069 : void ordr_esti(
4070 : const int16_t k, /* i : sub-vector index */
4071 : int16_t *Mpos, /* i/o: dominant sub-vector position from ACV */
4072 : int16_t svOrder[], /* i/o: AVQ sub-vector order */
4073 : const int16_t Nsv /* i : total sub-vectors in a sub-frames */
4074 : );
4075 :
4076 : void re8_cod(
4077 : int16_t x[], /* i : point in RE8 (8-dimensional integer vector) */
4078 : int16_t *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */
4079 : uint16_t *I, /* o : index of c (pointer to unsigned 16-bit word) */
4080 : int16_t k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index */
4081 : );
4082 :
4083 : void pre_exc(
4084 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
4085 : const int16_t L_frame, /* i : frame length */
4086 : const float *speech, /* i : input speech */
4087 : const float *p_Aq, /* i : 12k8 Lp coefficient */
4088 : const float *p_A, /* i : unquantized A(q) filter with bandwidth expansion */
4089 : const int16_t coder_type, /* i : coding type */
4090 : const int16_t i_subfr, /* i : current sub frame indicator */
4091 : float *Ap, /* o : weighted LP filter coefficients */
4092 : const float *res, /* i : residual signal */
4093 : float *h1, /* o : impulse response of weighted synthesis filter */
4094 : float *xn, /* o : close-loop Pitch search target vector */
4095 : float *cn, /* o : target vector in residual domain */
4096 : float *mem_syn, /* i/o: memory of the synthesis filter */
4097 : float *mem_w0, /* i/o: weighting filter denominator memory */
4098 : const int16_t L_subfr /* i : subframe length */
4099 : );
4100 :
4101 : void encod_unvoiced(
4102 : Encoder_State *st, /* i/o: state structure */
4103 : const float *speech, /* i : input speech */
4104 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
4105 : const float *Aq, /* i : LP coefficients */
4106 : const float Es_pred, /* i : predicted scaled innov. energy */
4107 : const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */
4108 : const float *res, /* i : residual signal */
4109 : float *syn, /* o : core synthesis */
4110 : float *tmp_noise, /* o : long-term noise energy */
4111 : float *exc, /* i/o: current non-enhanced excitation */
4112 : float *pitch_buf, /* o : floating pitch values for each subframe */
4113 : float *voice_factors, /* o : voicing factors */
4114 : float *bwe_exc /* i/o: excitation for SWB TBE */
4115 : );
4116 :
4117 : void encod_gen_voic(
4118 : Encoder_State *st, /* i/o: state structure */
4119 : const float speech[], /* i : input speech */
4120 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
4121 : const float Aq[], /* i : LP coefficients */
4122 : const float Es_pred, /* i : predicted scaled innov. energy */
4123 : const float *res, /* i : residual signal */
4124 : float *syn, /* o : core synthesis */
4125 : float *exc, /* i/o: current non-enhanced excitation */
4126 : float *exc2, /* i/o: current enhanced excitation */
4127 : float *pitch_buf, /* o : floating pitch values for each subframe */
4128 : float *voice_factors, /* o : voicing factors */
4129 : float *bwe_exc, /* i/o: excitation for SWB TBE */
4130 : int16_t *unbits, /* i/o: number of unused bits */
4131 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
4132 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
4133 : );
4134 :
4135 : int16_t encod_tran(
4136 : Encoder_State *st, /* i/o: state structure */
4137 : const float speech[], /* i : input speech */
4138 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
4139 : const float Aq[], /* i : LP coefficients */
4140 : const float Es_pred, /* i : predicted scaled innov. energy */
4141 : const float *res, /* i : residual signal */
4142 : float *syn, /* o : synthesis */
4143 : float *exc, /* i/o: current non-enhanced excitation */
4144 : float *exc2, /* i/o: current enhanced excitation */
4145 : float *pitch_buf, /* o : floating pitch values for each subframe */
4146 : float *voice_factors, /* o : voicing factors */
4147 : float *bwe_exc, /* i/o: excitation for SWB TBE */
4148 : int16_t tc_subfr, /* i/o: TC subframe classification */
4149 : int16_t position, /* i : maximum of residual signal index */
4150 : int16_t *unbits /* i/o: number of unused bits */
4151 : );
4152 :
4153 : void encod_amr_wb(
4154 : Encoder_State *st, /* i/o: state structure */
4155 : const float speech[], /* i : input speech */
4156 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
4157 : const float Aq[], /* i : 12k8 Lp coefficient */
4158 : const float *res, /* i : residual signal */
4159 : float *syn, /* i/o: core synthesis */
4160 : float *exc, /* i/o: current non-enhanced excitation */
4161 : float *exc2, /* i/o: current enhanced excitation */
4162 : float *pitch_buf, /* i/o: floating pitch values for each subframe */
4163 : int16_t hf_gain[NB_SUBFR], /* o : decoded HF gain */
4164 : const float *speech16k /* i : input speech @16kHz */
4165 : );
4166 :
4167 : void stat_noise_uv_enc(
4168 : Encoder_State *st, /* i/o: state structure */
4169 : const float *epsP, /* i : LP prediction errors */
4170 : const float *isp_new, /* i : immittance spectral pairs at 4th sfr */
4171 : const float *isp_mid, /* i : immittance spectral pairs at 2nd sfr */
4172 : float *Aq, /* i/o: A(z) quantized for the 4 subframes */
4173 : float *exc2, /* i/o: excitation buffer */
4174 : const int16_t uc_two_stage_flag /* o : flag undicating two-stage UC */
4175 : );
4176 :
4177 : void re8_compute_base_index(
4178 : const int16_t *x, /* i : Elemen of Q2, Q3 or Q4 */
4179 : const int16_t ka, /* i : Identifier of the absolute leader related to x */
4180 : uint16_t *I /* o : index */
4181 : );
4182 :
4183 : void transf_cdbk_enc(
4184 : Encoder_State *st, /* i/o: encoder state structure */
4185 : const int16_t harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
4186 : const int16_t i_subfr, /* i : subframe index */
4187 : float cn[], /* i/o: target vector in residual domain */
4188 : float exc[], /* i/o: pointer to excitation signal frame */
4189 : const float *p_Aq, /* i : 12k8 Lp coefficient */
4190 : const float Ap[], /* i : weighted LP filter coefficients */
4191 : const float h1[], /* i : weighted filter input response */
4192 : float xn[], /* i/o: target vector */
4193 : float xn2[], /* i/o: target vector for innovation search */
4194 : float y1[], /* i/o: zero-memory filtered adaptive excitation */
4195 : const float y2[], /* i : zero-memory filtered innovative excitation */
4196 : const float Es_pred, /* i : predicited scaled innovation energy */
4197 : float *gain_pit, /* i/o: adaptive excitation gain */
4198 : const float gain_code, /* i : innovative excitation gain */
4199 : float g_corr[], /* o : ACELP correlation values */
4200 : const int16_t clip_gain, /* i : adaptive gain clipping flag */
4201 : float *gain_preQ, /* o : prequantizer excitation gain */
4202 : float code_preQ[], /* o : prequantizer excitation */
4203 : int16_t *unbits /* i/o: number of AVQ unused bits */
4204 : );
4205 :
4206 : /*! r: quantization index */
4207 : int16_t gain_quant(
4208 : float *gain, /* i/o: quantized gain */
4209 : const float min_val, /* i : value of lower limit */
4210 : const float max_val, /* i : value of upper limit */
4211 : const int16_t bits /* i : number of bits to quantize */
4212 : );
4213 :
4214 : void deemph_lpc(
4215 : float *p_Aq_cuerr, /* i : LP coefficients current frame */
4216 : float *p_Aq_old, /* i : LP coefficients previous frame */
4217 : float *LPC_de_curr, /* o : De-emphasized LP coefficients current frame */
4218 : float *LPC_de_old, /* o : De-emphasized LP coefficients previous frame*/
4219 : const int16_t deemph_old );
4220 :
4221 : void Interpol_delay(
4222 : float *out, /* o : pitch interpolation output */
4223 : float *last, /* i : last frame pitch lag */
4224 : float *current, /* i : current frame pitch lag */
4225 : int16_t SubNum, /* i : subframe number */
4226 : const float *frac /* i : interpolation constant */
4227 : );
4228 :
4229 : void dequantize_uvg(
4230 : int16_t iG1, /* i : gain 1 index */
4231 : int16_t *iG2, /* i : gain 2 index */
4232 : float *G, /* o : quantized gain */
4233 : const int16_t bwidth /* i : audio bandwidth */
4234 : );
4235 :
4236 : void generate_nelp_excitation(
4237 : int16_t *seed, /* i/o: random number seed */
4238 : float *Gains, /* i : excitation gains */
4239 : float *output, /* o : excitation output */
4240 : float gain_fac /* i : gain factor */
4241 : );
4242 :
4243 : void nelp_encoder(
4244 : Encoder_State *st, /* i/o: encoder state */
4245 : float *in, /* i : residual signal */
4246 : float *exc, /* o : NELP quantized excitation signal */
4247 : const int16_t reduce_gains );
4248 :
4249 : void encod_nelp(
4250 : Encoder_State *st, /* i/o: state structure */
4251 : const float *speech, /* i : input speech */
4252 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
4253 : const float *Aq, /* i : 12k8 Lp coefficient */
4254 : float *res, /* o : residual signal */
4255 : float *synth, /* o : core synthesis */
4256 : float *tmp_noise, /* o : long-term noise energy */
4257 : float *exc, /* i/o: current non-enhanced excitation */
4258 : float *exc2, /* i/o: current enhanced excitation */
4259 : float *pitch_buf, /* o : floating pitch values for each subframe */
4260 : float *voice_factors, /* o : voicing factors */
4261 : float *bwe_exc /* o : excitation for SWB TBE */
4262 : );
4263 :
4264 : void realft(
4265 : float *data, /* i/o: data array */
4266 : int16_t n, /* i : length of data array */
4267 : int16_t isign /* i : sign +1 or -1 */
4268 : );
4269 :
4270 : ivas_error DTFS_new(
4271 : DTFS_STRUCTURE **dtfs_out );
4272 :
4273 : void DTFS_copy(
4274 : DTFS_STRUCTURE *Xout, /* o : DTFS */
4275 : DTFS_STRUCTURE Xinp /* i : DTFS */
4276 : );
4277 :
4278 : void DTFS_sub(
4279 : DTFS_STRUCTURE *tmp, /* o : output DFTS */
4280 : DTFS_STRUCTURE X1, /* i : DTFS input 1 */
4281 : DTFS_STRUCTURE X2 /* i : DTFS input 2 */
4282 : );
4283 :
4284 : void DTFS_to_fs(
4285 : const float *x, /* i : Time domain signal */
4286 : const int16_t N, /* i : Length of input vector */
4287 : DTFS_STRUCTURE *X, /* o : DTFS structure with a, b, lag */
4288 : const int32_t sampling_rate,
4289 : const int16_t FR_flag /* i : FR flag */
4290 : );
4291 :
4292 : void DTFS_fs_inv(
4293 : DTFS_STRUCTURE *X, /* i : DTFS */
4294 : float *x, /* o : time domain sig */
4295 : const int16_t N, /* i : Output length */
4296 : float ph0 /* i : Input phase */
4297 : );
4298 :
4299 : void DTFS_car2pol(
4300 : DTFS_STRUCTURE *X /* i/o: DTFS structure a, b, lag */
4301 : /* input in Cartesion, output in Polar */
4302 : );
4303 :
4304 : void DTFS_pol2car(
4305 : DTFS_STRUCTURE *X /* i/o: DTFS structure a, b, lag */
4306 : /* input in Polar, output in Cartesian */
4307 : );
4308 :
4309 : /*! r: Return Input RMS between f1/f2 b4 scaling */
4310 : float DTFS_setEngyHarm(
4311 : float f1, /* i : lower band freq of input to control energy */
4312 : float f2, /* i : upper band freq of input to control energy */
4313 : float g1, /* i : lower band freq of output to control energy */
4314 : float g2, /* i : upper band freq of output to control energy */
4315 : float en2, /* i : Target Energy to set the DTFS to */
4316 : DTFS_STRUCTURE *X /* i/o: DTFS to adjust the energy of */
4317 : );
4318 :
4319 : void DTFS_to_erb(
4320 : DTFS_STRUCTURE X, /* i : DTFS input */
4321 : float *out /* o : ERB output */
4322 : );
4323 :
4324 : void DTFS_zeroPadd(
4325 : const int16_t N, /* i : Target lag */
4326 : DTFS_STRUCTURE *X /* i/o: DTFS */
4327 : );
4328 :
4329 : /*! r: Energy */
4330 : float DTFS_getEngy(
4331 : DTFS_STRUCTURE X /* i : DTFS to compute energy of */
4332 : );
4333 :
4334 : void DTFS_adjustLag(
4335 : DTFS_STRUCTURE *X_DTFS, /* i/o: DTFS to adjust lag for */
4336 : const int16_t N /* i : Target lag */
4337 : );
4338 :
4339 : void DTFS_poleFilter(
4340 : DTFS_STRUCTURE *X, /* i/o: DTFS to poleFilter inplace */
4341 : const float *LPC, /* i : LPCs */
4342 : const int16_t N /* i : LPCORDER */
4343 : );
4344 :
4345 : void DTFS_zeroFilter(
4346 : DTFS_STRUCTURE *X, /* i/o: DTFS to zeroFilter inplace */
4347 : const float *LPC, /* i : LPCs */
4348 : const int16_t N /* i : LPCORDER */
4349 : );
4350 :
4351 : float DTFS_alignment_full(
4352 : DTFS_STRUCTURE X1_DTFS, /* i : reference DTFS */
4353 : DTFS_STRUCTURE X2_DTFS, /* i : DTFS to shift */
4354 : const int16_t num_steps /* i : resolution */
4355 : );
4356 :
4357 : void DTFS_phaseShift(
4358 : DTFS_STRUCTURE *X, /* i : DTFS to shift */
4359 : float ph /* i : phase to shift */
4360 : );
4361 :
4362 : void erb_add(
4363 : float *curr_erb, /* i/o: current ERB */
4364 : const int16_t l, /* i : current lag */
4365 : const float *prev_erb, /* i : previous ERB */
4366 : const int16_t pl, /* i : previous lag */
4367 : const int16_t *index, /* i : ERB index */
4368 : const int16_t num_erb /* i : number of ERBs */
4369 : );
4370 :
4371 : void erb_slot(
4372 : int16_t lag, /* i : input lag */
4373 : int16_t *out, /* o : ERB slots */
4374 : float *mfreq, /* i : ERB frequencies */
4375 : int16_t num_erb /* i : number of ERBs */
4376 : );
4377 :
4378 : void erb_diff(
4379 : const float *prev_erb, /* i : previous ERB */
4380 : const int16_t pl, /* i : previous lag */
4381 : const float *curr_erb, /* i : current ERB */
4382 : const int16_t l, /* i : current lag */
4383 : const float *curr_lsp, /* i : current LSP coefficients */
4384 : float *out, /* o : ERB difference */
4385 : int16_t *index, /* i : ERB index */
4386 : const int16_t num_erb /* i : Number of ERBs */
4387 : );
4388 :
4389 : void DTFS_erb_inv(
4390 : float *in, /* i : ERB inpt */
4391 : int16_t *slot, /* i : ERB slots filled based on lag */
4392 : float *mfreq, /* i : erb frequence edges */
4393 : DTFS_STRUCTURE *X, /* o : DTFS after erb-inv */
4394 : const int16_t num_erb /* i : Number of ERB bands */
4395 : );
4396 :
4397 : ivas_error ppp_quarter_encoder(
4398 : int16_t *returnFlag, /* o : return value */
4399 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
4400 : DTFS_STRUCTURE *CURRCW_Q, /* o : Quantized (amp/phase) DTFS */
4401 : DTFS_STRUCTURE *TARGETCW, /* o : DTFS with quant phase but unquant Amp */
4402 : const int16_t prevCW_lag, /* i : previous lag */
4403 : DTFS_STRUCTURE vCURRCW_NQ, /* i : Unquantized DTFS */
4404 : const float *curr_lpc, /* i : LPCS */
4405 : float *lastLgainE, /* i/o: last low band gain */
4406 : float *lastHgainE, /* i/o: last high band gain */
4407 : float *lasterbE, /* i/o: last ERB vector */
4408 : DTFS_STRUCTURE PREV_CW_E /* i : past DTFS */
4409 : );
4410 :
4411 : ivas_error WIsyn(
4412 : DTFS_STRUCTURE PREVCW, /* i : Prev frame DTFS */
4413 : DTFS_STRUCTURE *CURR_CW_DTFS, /* i/o: Curr frame DTFS */
4414 : const float *curr_lpc, /* i : LPC */
4415 : float *ph_offset, /* i/o: Phase offset to line up at end of frame */
4416 : float *out, /* o : Waveform Interpolated time domain signal */
4417 : const int16_t N, /* i : Number of samples of output to generate */
4418 : const int16_t FR_flag /* i : called for post-smoothing in FR */
4419 : );
4420 :
4421 : void set_ppp_mode(
4422 : Encoder_State *st, /* i/o: encoder state structure */
4423 : const int16_t noisy_speech_HO, /* i : SC-VBR noisy speech HO flag */
4424 : const int16_t clean_speech_HO, /* i : SC-VBR clean speech HO flag */
4425 : const int16_t NB_speech_HO, /* i : SC-VBR NB speech HO flag */
4426 : const int16_t localVAD_he /* i : HE-SAD flag without hangover */
4427 : );
4428 :
4429 : void lsf_syn_mem_backup(
4430 : Encoder_State *st, /* i : state structure */
4431 : float *btilt_code, /* i : tilt code */
4432 : float *bgc_threshold, /* i : */
4433 : float *clip_var_bck, /* o : */
4434 : int16_t *next_force_sf_bck, /* o : */
4435 : float *lsp_new, /* i : LSP vector to quantize */
4436 : float *lsp_mid, /* i : mid-frame LSP vector */
4437 : float *clip_var, /* o : pitch clipping state var */
4438 : float *mem_AR, /* o : quantizer memory for AR model */
4439 : float *mem_MA, /* o : quantizer memory for AR model */
4440 : float *lsp_new_bck, /* o : LSP vector to quantize- backup */
4441 : float *lsp_mid_bck, /* o : mid-frame LSP vector - backup */
4442 : float *Bin_E, /* o : FFT Bin energy 128 *2 sets */
4443 : float *Bin_E_old, /* o : FFT Bin energy 128 sets */
4444 : float *mem_syn_bck, /* o : synthesis filter memory */
4445 : float *mem_w0_bck, /* o : memory of the weighting filter */
4446 : float *streaklimit,
4447 : int16_t *pstreaklen );
4448 :
4449 : void lsf_syn_mem_restore(
4450 : Encoder_State *st, /* o : state structure */
4451 : float btilt_code, /* i : */
4452 : float gc_threshold, /* i : */
4453 : float *clip_var_bck, /* i : */
4454 : int16_t next_force_sf_bck, /* i : */
4455 : float *lsp_new, /* o : LSP vector to quantize */
4456 : float *lsp_mid, /* o : mid-frame LSP vector */
4457 : float clip_var, /* i : pitch clipping state var */
4458 : float *mem_AR, /* i : quantizer memory for AR model */
4459 : float *mem_MA, /* i : quantizer memory for AR model */
4460 : float *lsp_new_bck, /* i : LSP vector to quantize- backup */
4461 : float *lsp_mid_bck, /* i : mid-frame LSP vector - backup */
4462 : float *Bin_E, /* i : FFT Bin energy 128 *2 sets */
4463 : float *Bin_E_old, /* i : FFT Bin energy 128 sets */
4464 : float *mem_syn_bck, /* i : synthesis filter memory */
4465 : float mem_w0_bck, /* i : memory of the weighting filter */
4466 : const float streaklimit,
4467 : const int16_t pstreaklen );
4468 :
4469 : ivas_error ppp_voiced_encoder(
4470 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
4471 : SC_VBR_ENC_HANDLE hSC_VBR, /* i/o: SC-VBR state structure */
4472 : const int16_t bwidth, /* i : audio bandwidth */
4473 : const int16_t last_coder_type_raw, /* i : raw last_coder_type */
4474 : const float old_pitch_buf[], /* i : buffer of old subframe pitch values */
4475 : float *in, /* i : residual signal */
4476 : float *out, /* o : Quantized residual signal */
4477 : const int16_t delay, /* i : open loop pitch */
4478 : float *lpc1, /* i : prev frame de-emphasized LPC */
4479 : float *lpc2, /* i : current frame de-emphasized LPC */
4480 : float *exc, /* i : previous frame quantized excitation */
4481 : float *pitch /* o : floating pitch values for each subframe */
4482 : );
4483 :
4484 : ivas_error encod_ppp(
4485 : Encoder_State *st, /* i/o: state structure */
4486 : const float speech[], /* i : input speech */
4487 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
4488 : const float Aq[], /* i : 12k8 Lp coefficient */
4489 : float *res, /* i/o: residual signal */
4490 : float *synth, /* i/o: core synthesis */
4491 : float *exc, /* i/o: current non-enhanced excitation */
4492 : float *exc2, /* i/o: current enhanced excitation */
4493 : float *pitch_buf, /* i/o: floating pitch values for each subframe */
4494 : float *voice_factors, /* o : voicing factors */
4495 : float *bwe_exc /* o : excitation for SWB TBE */
4496 : );
4497 :
4498 : void reset_rf_indices(
4499 : RF_ENC_HANDLE hRF, /* i/o: RF state structure */
4500 : const int16_t L_frame, /* i : frame length */
4501 : int16_t *rf_target_bits_write );
4502 :
4503 : void signaling_enc_rf(
4504 : Encoder_State *st /* i/o: encoder state structure */
4505 : );
4506 :
4507 : ivas_error acelp_core_dec(
4508 : Decoder_State *st, /* i/o: Decoder state structure */
4509 : float output[], /* o : synthesis @internal Fs */
4510 : float synth[], /* o : synthesis */
4511 : float save_hb_synth[], /* o : HB synthesis */
4512 : float bwe_exc_extended[], /* i/o: bandwidth extended excitation */
4513 : float *voice_factors, /* o : voicing factors */
4514 : float old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
4515 : const int16_t sharpFlag, /* i : formant sharpening flag */
4516 : float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */
4517 : int16_t *unbits, /* o : number of unused bits */
4518 : int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */
4519 : STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */
4520 : const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
4521 : const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
4522 : const int16_t last_element_mode, /* i : last element mode */
4523 : const int32_t last_element_brate, /* i : last element bitrate */
4524 : const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */
4525 : const int16_t nchan_out, /* i : number of output channels */
4526 : STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
4527 : const int16_t read_sid_info /* i : read SID info flag */
4528 : );
4529 :
4530 : void bass_psfilter_init(
4531 : BPF_DEC_HANDLE hBPF /* o : BPF data handle */
4532 : );
4533 :
4534 : void bass_psfilter(
4535 : BPF_DEC_HANDLE hBPF, /* o : BPF data handle */
4536 : const int16_t Opt_AMR_WB, /* i : AMR-WB IO flag */
4537 : const float synth_in[], /* i : synthesis (at 16kHz) */
4538 : const int16_t L_frame, /* i : length of the last frame */
4539 : const float pitch_buf[], /* i : pitch for every subfr [0,1,2,3] */
4540 : const int16_t bpf_off, /* i : do not use BPF when set to 1 */
4541 : float v_stab, /* i : stability factor */
4542 : float *v_stab_smooth, /* i : smoothed stability factor */
4543 : const int16_t coder_type, /* i : coder_type */
4544 : float bpf_noise_buf[] /* o : BPF error signal (at int_fs) */
4545 : );
4546 :
4547 : void CNG_reset_dec(
4548 : Decoder_State *st, /* i/o: decoder state structure */
4549 : float *pitch_buf, /* o : floating pitch for each subframe */
4550 : float *voice_factors /* o : voicing factors */
4551 : );
4552 :
4553 : void updt_dec(
4554 : Decoder_State *st, /* i/o: state structure */
4555 : const float *old_exc, /* i : buffer of excitation */
4556 : const float *pitch_buf, /* i : floating pitch values for each subframe */
4557 : const float Es_pred, /* i : predicited scaled innovation energy */
4558 : const float *Aq, /* i : A(z) quantized for all subframes */
4559 : const float *lsf_new, /* i : current frame LSF vector */
4560 : const float *lsp_new, /* i : current frame LSP vector */
4561 : const float voice_factors[], /* i : voicing factors */
4562 : const float *old_bwe_exc, /* i : buffer of excitation */
4563 : const float *gain_buf /* o : floating pitch gain for each subframe */
4564 : );
4565 :
4566 : void updt_IO_switch_dec(
4567 : const int16_t output_frame, /* i : output frame length */
4568 : Decoder_State *st /* i/o: state structure */
4569 : );
4570 :
4571 : void updt_dec_common(
4572 : Decoder_State *st, /* i/o: decoder state structure */
4573 : const int16_t hq_core_type, /* i : HQ core type */
4574 : const int16_t concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */
4575 : const float *synth /* i : decoded synthesis */
4576 : );
4577 :
4578 : void td_cng_dec_init(
4579 : DEC_CORE_HANDLE st /* i/o: decoder state structure */
4580 : );
4581 :
4582 : void CNG_dec(
4583 : Decoder_State *st, /* i/o: State structure */
4584 : const int16_t last_element_mode, /* i : last element mode */
4585 : float Aq[], /* o : LP coefficients */
4586 : float *lsp_new, /* i/o: current frame LSPs */
4587 : float *lsf_new, /* i/o: current frame LSFs */
4588 : int16_t *allow_cn_step, /* o : allow cn step */
4589 : int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */
4590 : float *q_env );
4591 :
4592 : void swb_CNG_dec(
4593 : Decoder_State *st, /* i/o: State structure */
4594 : const float *synth, /* i : ACELP core synthesis at 32kHz */
4595 : float *shb_synth, /* o : high-band CNG synthesis */
4596 : const int16_t sid_bw /* i : 0-NB/WB, 1-SWB SID */
4597 : );
4598 :
4599 : void lsf_dec(
4600 : Decoder_State *st, /* i/o: State structure */
4601 : const int16_t tc_subfr, /* i : TC subframe index */
4602 : float *Aq, /* o : quantized A(z) for 4 subframes */
4603 : int16_t *LSF_Q_prediction, /* o : LSF prediction mode */
4604 : float *lsf_new, /* o : de-quantized LSF vector */
4605 : float *lsp_new, /* o : de-quantized LSP vector */
4606 : float *lsp_mid, /* o : de-quantized mid-frame LSP vector */
4607 : const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
4608 : const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
4609 : );
4610 :
4611 : void isf_dec_amr_wb(
4612 : Decoder_State *st, /* i/o: State structure */
4613 : float *Aq, /* o : quantized A(z) for 4 subframes */
4614 : float *isf_new, /* o : de-quantized ISF vector */
4615 : float *isp_new /* o : de-quantized ISP vector */
4616 : );
4617 :
4618 : void Es_pred_dec(
4619 : float *Es_pred, /* o : predicted scaled innovation energy */
4620 : const int16_t enr_idx, /* i : indice */
4621 : const int16_t nb_bits, /* i : number of bits */
4622 : const int16_t no_ltp /* i : no LTP flag */
4623 : );
4624 :
4625 : void gaus_dec(
4626 : Decoder_State *st, /* i/o: decoder state structure */
4627 : const int16_t i_subfr, /* i : subframe index */
4628 : float *code, /* o : gaussian excitation */
4629 : float *norm_gain_code, /* o : gain of the normalized gaussian excitation */
4630 : float *lp_gainp, /* i/o: lp filtered pitch gain(FER) */
4631 : float *lp_gainc, /* i/o: lp filtered code gain (FER) */
4632 : float *gain_inov, /* o : unscaled innovation gain */
4633 : float *tilt_code, /* o : synthesis excitation spectrum tilt */
4634 : float *voice_fac, /* o : estimated voicing factor */
4635 : float *gain_pit, /* o : reset pitch gain */
4636 : float *pt_pitch, /* o : reset floating pitch buffer */
4637 : float *exc, /* o : excitation signal frame */
4638 : float *gain_code, /* o : gain of the gaussian excitation */
4639 : float *exc2 /* o : scaled excitation signal frame */
4640 : );
4641 :
4642 : void gain_dec_amr_wb(
4643 : Decoder_State *st, /* i/o: decoder state structure */
4644 : const int32_t core_brate, /* i : core bitrate */
4645 : float *gain_pit, /* o : Quantized pitch gain */
4646 : float *gain_code, /* o : Quantized codeebook gain */
4647 : float *past_qua_en, /* i/o: gain quantization memory (4 words) */
4648 : float *gain_inov, /* o : unscaled innovation gain */
4649 : const float *code, /* i : algebraic code excitation */
4650 : float *norm_gain_code /* o : norm. gain of the codebook excitation */
4651 : );
4652 :
4653 : void gain_dec_lbr(
4654 : Decoder_State *st, /* i/o: decoder state structure */
4655 : const int16_t coder_type, /* i : coding type */
4656 : const int16_t i_subfr, /* i : subframe index */
4657 : const float *code, /* i : algebraic excitation */
4658 : float *gain_pit, /* o : quantized pitch gain */
4659 : float *gain_code, /* o : quantized codebook gain */
4660 : float *gain_inov, /* o : gain of the innovation (used for normalization) */
4661 : float *norm_gain_code, /* o : norm. gain of the codebook excitation */
4662 : float gains_mem[], /* i/o: pitch gain and code gain from previous subframes */
4663 : const int16_t L_subfr /* i : subframe length */
4664 : );
4665 :
4666 : void gain_dec_mless(
4667 : Decoder_State *st, /* i/o: decoder state structure */
4668 : const int16_t L_frame, /* i : length of the frame */
4669 : const int16_t coder_type, /* i : coding type */
4670 : const int16_t i_subfr, /* i : subframe number */
4671 : const int16_t tc_subfr, /* i : TC subframe index */
4672 : const float *code, /* i : algebraic code excitation */
4673 : const float Es_pred, /* i : predicted scaled innov. energy */
4674 : float *gain_pit, /* o : Quantized pitch gain */
4675 : float *gain_code, /* o : Quantized codeebook gain */
4676 : float *gain_inov, /* o : unscaled innovation gain */
4677 : float *norm_gain_code /* o : norm. gain of the codebook excitation */
4678 : );
4679 :
4680 : void gain_dec_SQ(
4681 : Decoder_State *st, /* i/o: decoder state structure */
4682 : const int16_t i_subfr, /* i : subframe number */
4683 : const float *code, /* i : algebraic code excitation */
4684 : const float Es_pred, /* i : predicted scaled innov. energy */
4685 : float *gain_pit, /* o : Quantized pitch gain */
4686 : float *gain_code, /* o : Quantized codeebook gain */
4687 : float *gain_inov, /* o : unscaled innovation gain */
4688 : float *norm_gain_code /* o : norm. gain of the codebook excitation */
4689 : );
4690 :
4691 : /*! r: quantized codebook gain */
4692 : float gain_dec_gaus(
4693 : const int16_t index, /* i : quantization index */
4694 : const int16_t bits, /* i : number of bits to quantize */
4695 : const float lowBound, /* i : lower bound of quantizer (dB) */
4696 : const float topBound, /* i : upper bound of quantizer (dB) */
4697 : const float gain_inov, /* i : unscaled innovation gain */
4698 : float *norm_gain_code /* o : gain of normalized gaus. excit. */
4699 : );
4700 :
4701 : /*! r: floating pitch value */
4702 : float pit_decode(
4703 : Decoder_State *st, /* i/o: decoder state structure */
4704 : const int32_t core_brate, /* i : core bitrate */
4705 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
4706 : const int16_t L_frame, /* i : length of the frame */
4707 : int16_t i_subfr, /* i : subframe index */
4708 : const int16_t coder_type, /* i : coding type */
4709 : int16_t *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
4710 : int16_t *T0, /* o : close loop integer pitch */
4711 : int16_t *T0_frac, /* o : close loop fractional part of the pitch */
4712 : int16_t *T0_min, /* i/o: delta search min for sf 2 & 4 */
4713 : int16_t *T0_max, /* i/o: delta search max for sf 2 & 4 */
4714 : const int16_t L_subfr, /* i : subframe length */
4715 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
4716 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
4717 : );
4718 :
4719 : void abs_pit_dec(
4720 : const int16_t fr_steps, /* i : fractional resolution steps (0, 2, 4) */
4721 : int16_t pitch_index, /* i : pitch index */
4722 : const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */
4723 : int16_t *T0, /* o : integer pitch lag */
4724 : int16_t *T0_frac /* o : pitch fraction */
4725 : );
4726 :
4727 : void delta_pit_dec(
4728 : const int16_t fr_steps, /* i : fractional resolution steps (0, 2, 4) */
4729 : const int16_t pitch_index, /* i : pitch index */
4730 : int16_t *T0, /* o : integer pitch lag */
4731 : int16_t *T0_frac, /* o : pitch fraction */
4732 : const int16_t T0_min /* i : delta search min */
4733 : );
4734 :
4735 : void pit_Q_dec(
4736 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
4737 : const int16_t pitch_index, /* i : pitch index */
4738 : const int16_t nBits, /* i : # of Q bits */
4739 : const int16_t delta, /* i : Half the CL searched interval */
4740 : const int16_t pit_flag, /* i : absolute(0) or delta(1) pitch Q */
4741 : const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */
4742 : int16_t *T0, /* o : integer pitch lag */
4743 : int16_t *T0_frac, /* o : pitch fraction */
4744 : int16_t *T0_min, /* i/o: delta search min */
4745 : int16_t *T0_max, /* i/o: delta search max */
4746 : int16_t *BER_detect /* o : BER detect flag */
4747 : );
4748 :
4749 : void pit16k_Q_dec(
4750 : const int16_t pitch_index, /* i : pitch index */
4751 : const int16_t nBits, /* i : # of Q bits */
4752 : const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */
4753 : int16_t *T0, /* o : integer pitch lag */
4754 : int16_t *T0_frac, /* o : pitch fraction */
4755 : int16_t *T0_min, /* i/o: delta search min */
4756 : int16_t *T0_max, /* i/o: delta search max */
4757 : int16_t *BER_detect /* o : BER detect flag */
4758 : );
4759 :
4760 : void lp_filt_exc_dec(
4761 : Decoder_State *st, /* i/o: decoder state structure */
4762 : const int16_t codec_mode, /* i : codec mode */
4763 : const int16_t i_subfr, /* i : subframe index */
4764 : const int16_t L_subfr, /* i : subframe size */
4765 : const int16_t L_Frame, /* i : frame size */
4766 : int16_t lp_flag, /* i : operation mode signaling */
4767 : float *exc /* i/o: pointer to the excitation signal frame */
4768 : );
4769 :
4770 : void inov_decode(
4771 : Decoder_State *st, /* i/o: decoder state structure */
4772 : const int32_t core_brate, /* i : core bitrate */
4773 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
4774 : const int16_t L_frame, /* i : length of the frame */
4775 : const int16_t sharpFlag, /* i : formant sharpening flag */
4776 : const int16_t i_subfr, /* i : subframe index */
4777 : const float *p_Aq, /* i : LP filter coefficients */
4778 : const float tilt_code, /* i : tilt of of the excitation of previous subframe */
4779 : const float pt_pitch, /* i : pointer to current subframe fractional pitch */
4780 : float *code, /* o : algebraic excitation */
4781 : const int16_t L_subfr /* i : subframe length */
4782 : );
4783 :
4784 : void dec_acelp_1t64(
4785 : Decoder_State *st, /* i/o: decoder state structure */
4786 : float code[], /* o : algebraic (fixed) codebook excitation */
4787 : const int16_t L_subfr /* i : subframe length */
4788 : );
4789 :
4790 : void dec_acelp_2t32(
4791 : Decoder_State *st, /* i/o: decoder state structure */
4792 : float code[] /* o : algebraic (fixed) codebook excitation */
4793 : );
4794 :
4795 : void dec_acelp_4t64(
4796 : Decoder_State *st, /* i/o: decoder state structure */
4797 : int16_t nbbits, /* i : number of bits per codebook */
4798 : float code[], /* o : algebraic (fixed) codebook excitation */
4799 : const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
4800 : );
4801 :
4802 : void FEC_exc_estim(
4803 : Decoder_State *st, /* i/o: Decoder static memory */
4804 : const int16_t L_frame, /* i : length of the frame */
4805 : float *old_exc, /* i/o: excitation buffer */
4806 : float *exc2, /* o : excitation buffer (for synthesis) */
4807 : float *exc_dct_in, /* o : GSC excitation in DCT domain */
4808 : float *pitch_buf, /* o : Floating pitch for each subframe */
4809 : float *tmp_tc, /* o : FEC pitch */
4810 : float *voice_factors, /* o : voicing factors */
4811 : float *bwe_exc, /* i/o: excitation for SWB TBE */
4812 : float *lsf_new, /* i : ISFs at the end of the frame */
4813 : float *tmp_noise /* o : long-term noise energy */
4814 : );
4815 :
4816 : void FEC_lsf2lsp_interp(
4817 : Decoder_State *st, /* i/o: Decoder static memory */
4818 : const int16_t L_frame, /* i : length of the frame */
4819 : float *Aq, /* o : calculated A(z) for 4 subframes */
4820 : float *lsf, /* o : estimated LSF vector */
4821 : float *lsp /* o : estimated LSP vector */
4822 : );
4823 :
4824 : void FEC_lsf_estim_enc(
4825 : Encoder_State *st, /* i : Encoder static memory */
4826 : float *lsf /* o : estimated LSF vector */
4827 : );
4828 :
4829 : float frame_energy(
4830 : const int16_t L_frame, /* i : length of the frame */
4831 : const float *pitch, /* i : pitch values for each subframe */
4832 : const float *speech, /* i : pointer to speech signal for E computation */
4833 : const float lp_speech, /* i : long term active speech energy average */
4834 : float *frame_ener /* o : pitch-synchronous energy at frame end */
4835 : );
4836 :
4837 : void FEC_SinOnset(
4838 : float *exc, /* i/o: exc vector to modify */
4839 : int16_t puls_pos, /* i : Last pulse position desired */
4840 : int16_t T0, /* i : decoded first frame pitch */
4841 : float enr_q, /* i : energy provided by the encoder */
4842 : float *Aq, /* i : Lsp coefficient */
4843 : const int16_t L_frame /* i : Frame length */
4844 : );
4845 :
4846 : int16_t FEC_enhACB(
4847 : const int16_t L_frame, /* i : Frame length */
4848 : const int16_t last_L_frame, /* i : frame length of last frame */
4849 : float *exc_io, /* i/o: Adaptive codebook memory */
4850 : const int16_t new_pit, /* i : decoded first frame pitch */
4851 : const int16_t puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */
4852 : const float bfi_pitch /* i : Pitch used for concealment */
4853 : );
4854 :
4855 : void FEC_scale_syn(
4856 : const int16_t L_frame, /* i : length of the frame */
4857 : int16_t clas, /* i/o: frame classification */
4858 : const int16_t last_good, /* i : last good frame classification */
4859 : float *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */
4860 : const float *pitch, /* i : pitch values for each subframe */
4861 : float enr_old, /* i : energy at the end of prvious frame */
4862 : float enr_q, /* i : transmitted energy for current frame */
4863 : const int16_t coder_type, /* i : coding type */
4864 : const int16_t LSF_Q_prediction, /* i : LSF prediction mode */
4865 : int16_t *scaling_flag, /* i/o: flag to indicate energy control of syn */
4866 : float *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */
4867 : float *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */
4868 : const int16_t bfi, /* i : current frame BFI */
4869 : const int32_t total_brate, /* i : total bitrate */
4870 : const int16_t prev_bfi, /* i : previous frame BFI */
4871 : const int32_t last_core_brate, /* i : previous frame core bitrate */
4872 : float *exc, /* i/o: excitation signal without enhancement */
4873 : float *exc2, /* i/o: excitation signal with enhancement */
4874 : const float Aq[], /* i : LP filter coefs */
4875 : float *old_enr_LP, /* i/o: LP filter E of last good voiced frame */
4876 : const float *mem_tmp, /* i : temp. initial synthesis filter states */
4877 : float *mem_syn, /* o : initial synthesis filter states */
4878 : const int16_t avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */
4879 : const int16_t force_scaling /* i : force scaling */
4880 : );
4881 :
4882 : void FEC_pitch_estim(
4883 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
4884 : const int16_t last_core, /* i : last core */
4885 : const int16_t L_frame, /* i : length of the frame */
4886 : const int16_t clas, /* i : current frame classification */
4887 : const int16_t last_good, /* i : last good clas information */
4888 : const float pitch_buf[], /* i : Floating pitch for each subframe */
4889 : const float old_pitch_buf[], /* i : buffer of old subframe pitch values */
4890 : float *bfi_pitch, /* i/o: update of the estimated pitch for FEC */
4891 : int16_t *bfi_pitch_frame, /* o : frame length when pitch was updated */
4892 : int16_t *upd_cnt, /* i/o: update counter */
4893 : const int16_t coder_type );
4894 :
4895 : void FEC_encode(
4896 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
4897 : const ACELP_config acelp_cfg, /* i : configuration of the ACELP */
4898 : const float *synth, /* i : pointer to synthesized speech for E computation */
4899 : const int16_t coder_type, /* i : type of coder */
4900 : int16_t clas, /* i : signal clas for current frame */
4901 : const float *fpit, /* i : close loop fractional pitch buffer */
4902 : const float *res, /* i : LP residual signal frame */
4903 : int16_t *last_pulse_pos, /* i/o: Position of the last pulse */
4904 : const int16_t L_frame, /* i : Frame length */
4905 : const int32_t total_brate /* i : total codec bitrate */
4906 : );
4907 :
4908 : int16_t FEC_pos_dec(
4909 : Decoder_State *st, /* i/o: decoder state structure */
4910 : int16_t *last_pulse_pos, /* o : Last glottal pulse position in the lost ACB */
4911 : float *enr_q, /* o : Decoded energy */
4912 : const int16_t nBits_es_Pred /* i : number of bits for Es_pred Q */
4913 : );
4914 :
4915 : void improv_amr_wb_gs(
4916 : const int16_t clas, /* i : bitrate allocated to the core */
4917 : const int16_t coder_type, /* i : coder_type */
4918 : const int32_t core_brate, /* i : bitrate allocated to the core */
4919 : int16_t *seed_tcx, /* i/o: Seed used for noise generation */
4920 : float *old_Aq, /* i/o: old LPC filter coefficient */
4921 : float *mem_syn2, /* i/o: synthesis memory */
4922 : const float lt_voice_fac, /* i/o: long term voice factor */
4923 : const int16_t locattack, /* i : Flag for a detected attack */
4924 : float *Aq, /* i/o: Decoded LP filter coefficient */
4925 : float *exc2, /* i/o: Decoded complete excitation */
4926 : float *mem_tmp, /* i/o: synthesis temporary memory */
4927 : float *syn, /* i/o: Decoded synthesis to be updated */
4928 : const float *pitch_buf, /* i : Decoded pitch buffer */
4929 : const float Last_ener, /* i : Last energy */
4930 : const int16_t rate_switching_reset, /* i : rate switching reset flag */
4931 : const int16_t last_coder_type, /* i : Last coder_type */
4932 : const int16_t VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */
4933 : );
4934 :
4935 : int16_t tc_classif(
4936 : Decoder_State *st /* i/o: decoder state structure */
4937 : );
4938 :
4939 : void transition_dec(
4940 : Decoder_State *st, /* i/o: decoder state structure */
4941 : const int16_t L_frame, /* i : length of the frame */
4942 : const int16_t i_subfr, /* i : subframe index */
4943 : const int16_t tc_subfr, /* i : TC subframe index */
4944 : int16_t *Jopt_flag, /* i : joint optimization flag */
4945 : float *exc, /* i/o: current frame excitation signal */
4946 : int16_t *T0, /* o : close loop integer pitch */
4947 : int16_t *T0_frac, /* o : close loop fractional part of the pitch */
4948 : int16_t *T0_min, /* i/o: delta search min for sf 2 & 4 */
4949 : int16_t *T0_max, /* i/o: delta search max for sf 2 & 4 */
4950 : float **pt_pitch, /* o : floating pitch values */
4951 : int16_t *position, /* i/o: first glottal impulse position in frame */
4952 : float *bwe_exc /* i/o: excitation for SWB TBE */
4953 : );
4954 :
4955 : void gain_dec_tc(
4956 : Decoder_State *st, /* i/o: decoder state structure */
4957 : const int16_t i_subfr, /* i : subframe number */
4958 : const float Es_pred, /* i : predicted scaled innov. energy */
4959 : const float *code, /* i : algebraic code excitation */
4960 : float *gain_pit, /* o : pitch gain */
4961 : float *gain_code, /* o : Quantized codeebook gain */
4962 : float *gain_inov, /* o : unscaled innovation gain */
4963 : float *norm_gain_code /* o : norm. gain of the codebook excit. */
4964 : );
4965 :
4966 : void stat_noise_uv_dec(
4967 : Decoder_State *st, /* i/o: decoder static memory */
4968 : const float *lsp_new, /* i : end-frame LSP vector */
4969 : const float *lsp_mid, /* i : mid-frame LSP vector */
4970 : float *Aq, /* o : A(z) quantized for the 4 subframes */
4971 : float *exc2, /* i/o: excitation buffer */
4972 : const int16_t uc_two_stage_flag /* 1 : flag undicating two-stage UC */
4973 : );
4974 :
4975 : void sc_vbr_dec_init(
4976 : SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle */
4977 : );
4978 :
4979 : void decod_nelp(
4980 : Decoder_State *st, /* i/o: decoder static memory */
4981 : float *tmp_noise, /* o : long term temporary noise energy */
4982 : float *pitch_buf, /* o : floating pitch values for each subframe */
4983 : float *exc, /* o : adapt. excitation exc */
4984 : float *exc2, /* o : adapt. excitation/total exc */
4985 : float *voice_factors, /* o : voicing factors */
4986 : float *bwe_exc, /* o : excitation for SWB TBE */
4987 : const int16_t bfi, /* i : bad frame indicator */
4988 : float *gain_buf /* o : floating pitch gain for each subframe */
4989 : );
4990 :
4991 : void nelp_decoder(
4992 : Decoder_State *st, /* i/o: decoder static memory */
4993 : float *exc_nelp, /* o : adapt. excitation/total exc */
4994 : float *exc, /* o : adapt. excitation exc */
4995 : int16_t bfi, /* i : frame error rate */
4996 : const int16_t coder_type, /* i : coding type */
4997 : float *gain_buf /* o : floating pitch gain for each subframe */
4998 : );
4999 :
5000 : ivas_error decod_ppp(
5001 : Decoder_State *st, /* i/o: state structure */
5002 : const float Aq[], /* i : 12k8 Lp coefficient */
5003 : float *pitch_buf, /* i/o: floating pitch values for each subframe */
5004 : float *exc, /* i/o: current non-enhanced excitation */
5005 : float *exc2, /* i/o: current enhanced excitation */
5006 : float *voice_factors, /* o : voicing factors */
5007 : float *bwe_exc, /* o : excitation for SWB TBE */
5008 : float *gain_buf, /* o : floating pitch gain for each subframe */
5009 : const int16_t bfi /* i : BFI flag */
5010 : );
5011 :
5012 : ivas_error ppp_quarter_decoder(
5013 : Decoder_State *st, /* i/o: decoder state structure */
5014 : DTFS_STRUCTURE *CURRCW_Q_DTFS, /* i/o: Current CW DTFS */
5015 : int16_t prevCW_lag, /* i : Previous lag */
5016 : float *lastLgainD, /* i/o: Last gain lowband */
5017 : float *lastHgainD, /* i/o: Last gain highwband */
5018 : float *lasterbD, /* i/o: Last ERB vector */
5019 : int16_t bfi, /* i : FER flag */
5020 : DTFS_STRUCTURE PREV_CW_D /* i : Previous DTFS */
5021 : );
5022 :
5023 : ivas_error ppp_voiced_decoder(
5024 : Decoder_State *st, /* i/o: state structure */
5025 : float *out, /* o : residual signal */
5026 : const float *lpc2, /* i : current frame LPC */
5027 : float *exc, /* i : previous frame excitation */
5028 : float *pitch, /* o : floating pitch values for each subframe */
5029 : const int16_t bfi /* i : BFI flag */
5030 : );
5031 :
5032 : void AVQ_demuxdec(
5033 : Decoder_State *st, /* i/o: decoder state structure */
5034 : int16_t xriq[], /* o : decoded subvectors [0..8*Nsv-1] */
5035 : int16_t *nb_bits, /* i/o: number of allocated bits */
5036 : const int16_t Nsv, /* i : number of subvectors */
5037 : int16_t nq[], /* i/o: AVQ nq index */
5038 : int16_t avq_bit_sFlag, /* i : flag for AVQ bit saving solution*/
5039 : int16_t trgtSvPos /* i : target SV for AVQ bit savings */
5040 : );
5041 :
5042 : void re8_dec(
5043 : int16_t nq, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */
5044 : const uint16_t I, /* i : index of c (pointer to unsigned 16-bit word) */
5045 : const int16_t kv[], /* i : index of v (8-dimensional vector of binary indices) = Voronoi index */
5046 : int16_t y[] /* o : point in RE8 (8-dimensional integer vector) */
5047 : );
5048 :
5049 : void re8_decode_base_index(
5050 : const int16_t n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */
5051 : uint16_t I, /* i : index of c (pointer to unsigned 16-bit word) */
5052 : int16_t *x /* o : point in RE8 (8-dimensional integer vector) */
5053 : );
5054 :
5055 : void Init_post_filter(
5056 : PFSTAT_HANDLE hPFstat /* i : post-filter state memories */
5057 : );
5058 :
5059 : void nb_post_filt(
5060 : const int16_t L_frame, /* i : frame length */
5061 : const int16_t L_subfr, /* i : sub-frame length */
5062 : PFSTAT_HANDLE hPFstat, /* i/o: Post filter related memories */
5063 : float *lp_noise, /* i/o: long term noise energy */
5064 : const float tmp_noise, /* i : noise energy */
5065 : float *synth, /* i/o: synthesis */
5066 : const float *Aq, /* i : LP filter coefficient */
5067 : const float *pitch_buf, /* i : Floating pitch for each subframe */
5068 : const int16_t coder_type, /* i : coder_type -> deactivated in AUDIO */
5069 : const int16_t BER_detect, /* i : BER detect flag */
5070 : const int16_t disable_hpf /* i : flag to diabled HPF */
5071 : );
5072 :
5073 : void decod_unvoiced(
5074 : Decoder_State *st, /* i/o: decoder static memory */
5075 : const float *Aq, /* i : LP filter coefficient */
5076 : const float Es_pred, /* i : predicted scaled innov. energy */
5077 : const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */
5078 : float *tmp_noise, /* o : long term temporary noise energy */
5079 : float *pitch_buf, /* o : floating pitch values for each subframe */
5080 : float *voice_factors, /* o : voicing factors */
5081 : float *exc, /* o : adapt. excitation exc */
5082 : float *exc2, /* o : adapt. excitation/total exc */
5083 : float *bwe_exc, /* i/o: excitation for SWB TBE */
5084 : float *gain_buf /* o : floating pitch gain for each subfram */
5085 : );
5086 :
5087 : void decod_tran(
5088 : Decoder_State *st, /* i/o: decoder static memory */
5089 : const int16_t L_frame, /* i : length of the frame */
5090 : const int16_t tc_subfr, /* i : TC subframe index */
5091 : const float *Aq, /* i : LP filter coefficient */
5092 : const float Es_pred, /* i : predicted scaled innov. energy */
5093 : float *pitch_buf, /* o : floating pitch values for each subframe */
5094 : float *voice_factors, /* o : voicing factors */
5095 : float *exc, /* i/o: adapt. excitation exc */
5096 : float *exc2, /* i/o: adapt. excitation/total exc */
5097 : float *bwe_exc, /* i/o: excitation for SWB TBE */
5098 : int16_t *unbits, /* i/o: number of unused bits */
5099 : const int16_t sharpFlag, /* i : formant sharpening flag */
5100 : float *gain_buf /* o : floating pitch gain for each subframe */
5101 : );
5102 :
5103 : ivas_error decod_gen_voic(
5104 : Decoder_State *st, /* i/o: decoder static memory */
5105 : const int16_t L_frame, /* i : length of the frame */
5106 : const int16_t sharpFlag, /* i : formant sharpening flag */
5107 : const float *Aq, /* i : LP filter coefficient */
5108 : const float Es_pred, /* i : predicted scaled innov. energy */
5109 : const int16_t do_WI, /* i : FEC fast recovery flag */
5110 : float *pitch_buf, /* o : floating pitch for each subframe */
5111 : float *voice_factors, /* o : voicing factors */
5112 : float *exc, /* i/o: adapt. excitation exc */
5113 : float *exc2, /* i/o: adapt. excitation/total exc */
5114 : float *bwe_exc, /* i/o: excitation for SWB TBE */
5115 : int16_t *unbits, /* i/o: number of unused bits */
5116 : float *gain_buf, /* o : floating pitch gain for each subframe */
5117 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
5118 : const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
5119 : );
5120 :
5121 : void decod_amr_wb(
5122 : Decoder_State *st, /* i/o: decoder static memory */
5123 : const float *Aq, /* i : LP filter coefficients */
5124 : float *pitch_buf, /* o : floating pitch values for each subframe */
5125 : float *exc, /* i/o: adapt. excitation exc */
5126 : float *exc2, /* i/o: adapt. excitation/total exc */
5127 : int16_t hf_gain[NB_SUBFR], /* o : decoded HF gain */
5128 : float *voice_factors, /* o : voicing factors */
5129 : float *gain_buf /* o : floating pitch gain for each subframe */
5130 : );
5131 :
5132 : ivas_error init_decoder(
5133 : Decoder_State *st, /* o : Decoder static variables structure */
5134 : const int16_t idchan, /* i : channel ID */
5135 : const MC_MODE mc_mode /* i : MC mode */
5136 : );
5137 :
5138 : void destroy_cldfb_decoder(
5139 : Decoder_State *st /* o : Decoder static variables structure */
5140 : );
5141 :
5142 : void HQ_core_dec_init(
5143 : HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */
5144 : );
5145 :
5146 : void HQ_nbfec_init(
5147 : HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */
5148 : );
5149 :
5150 : ivas_error evs_dec(
5151 : Decoder_State *st, /* i/o: Decoder state structure */
5152 : float mem_hp20_out[L_HP20_MEM], /* i/o: HP filter memory for synthesis */
5153 : float *output, /* o : output synthesis signal */
5154 : FRAME_MODE frameMode /* i : Decoder frame mode */
5155 : );
5156 :
5157 : void get_next_frame_parameters(
5158 : Decoder_State *st /* i/o: Decoder state structure */
5159 : );
5160 :
5161 : ivas_error amr_wb_dec(
5162 : Decoder_State *st, /* i/o: decoder state structure */
5163 : float mem_hp20_out[L_HP20_MEM], /* i/o: HP filter memory for synthesis */
5164 : float *output /* o : synthesis output */
5165 : );
5166 :
5167 : void transf_cdbk_dec(
5168 : Decoder_State *st, /* i/o: decoder state structure */
5169 : const int16_t harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
5170 : const int16_t i_subfr, /* i : subframe index */
5171 : const float Es_pred, /* i : predicited scaled innovation energy */
5172 : const float gain_code, /* i : innovative excitation gain */
5173 : float *gain_preQ, /* o : prequantizer excitation gain */
5174 : float *norm_gain_preQ, /* o : normalized prequantizer excitation gain */
5175 : float code_preQ[], /* o : prequantizer excitation */
5176 : int16_t *unbits /* o : number of AVQ unused bits */
5177 : );
5178 :
5179 : /*! r: decoded gain */
5180 : float gain_dequant(
5181 : int16_t index, /* i : quantization index */
5182 : const float min_val, /* i : value of lower limit */
5183 : const float max_val, /* i : value of upper limit */
5184 : const int16_t bits /* i : number of bits to dequantize */
5185 : );
5186 :
5187 : void HQ_core_enc_init(
5188 : HQ_ENC_HANDLE hHQ_core /* i/o: HQ core data handle */
5189 : );
5190 :
5191 : void hq_core_enc(
5192 : Encoder_State *st, /* i/o: encoder state structure */
5193 : const float *audio, /* i : input audio signal */
5194 : const int16_t input_frame, /* i : frame length */
5195 : const int16_t hq_core_type, /* i : HQ core type */
5196 : const int16_t Voicing_flag, /* i : Voicing flag for FER method selection */
5197 : const int16_t vad_hover_flag /* i : VAD hangover flag */
5198 : );
5199 :
5200 : int16_t detect_transient(
5201 : Encoder_State *st, /* i/o: encoder state structure */
5202 : const float *in, /* i : input signal */
5203 : const int16_t L /* i : length */
5204 : );
5205 :
5206 : void wtda(
5207 : const float *new_audio, /* i : input audio */
5208 : float *wtda_audio, /* o : windowed audio */
5209 : float *old_wtda, /* i/o: windowed audio from previous frame */
5210 : const int16_t left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */
5211 : const int16_t right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
5212 : const int16_t L /* i : length */
5213 : );
5214 :
5215 : void wtda_ext(
5216 : const float *new_audio, /* i : input audio */
5217 : float *wtda_audio, /* o : windowed audio */
5218 : const int16_t left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */
5219 : const int16_t right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
5220 : const int16_t L, /* i : length */
5221 : const uint16_t kernel_type /* i : transform kernel type (0 - 3) */
5222 : );
5223 :
5224 : void tcx_get_windows_mode1(
5225 : const int16_t left_mode, /* i : overlap mode of left window half */
5226 : const int16_t right_mode, /* i : overlap mode of right window half */
5227 : float *left_win, /* o : left overlap window */
5228 : float *right_win, /* o : right overlap window */
5229 : float *left_win_int, /* o : left overlap window */
5230 : float *right_win_int, /* o : right overlap window */
5231 : const int16_t L /* i : length */
5232 : );
5233 :
5234 : void direct_transform(
5235 : const float *in32, /* i : input signal */
5236 : float *out32, /* o : output transformation */
5237 : const int16_t is_transient, /* i : transient flag */
5238 : const int16_t L, /* i : length */
5239 : const int16_t element_mode /* i : IVAS element mode */
5240 : );
5241 :
5242 : /*! r: index of noise attenuation */
5243 : int16_t noise_adjust(
5244 : const float *coeffs_norm, /* i : normalized coefficients */
5245 : const int16_t *bitalloc, /* i : bit allocation */
5246 : const int16_t *sfm_start, /* i : Start of bands */
5247 : const int16_t *sfm_end, /* i : End of bands */
5248 : const int16_t core_sfm /* i : index of the end band for core */
5249 : );
5250 :
5251 : void interleave_spectrum(
5252 : float *coefs, /* i/o: input and output coefficients */
5253 : const int16_t length /* i : length of spectrum */
5254 : );
5255 :
5256 : void hq_hr_enc(
5257 : Encoder_State *st, /* i/o: encoder state structure */
5258 : float *coefs, /* i/o: transform-domain coefficients */
5259 : const int16_t length, /* i : length of spectrum */
5260 : int16_t *num_bits, /* i/o: number of available bits */
5261 : const int16_t is_transient, /* i : transient flag */
5262 : const int16_t vad_hover_flag /* i : VAD hangover flag */
5263 : );
5264 :
5265 : void logqnorm(
5266 : const float *x, /* i : coefficient vector */
5267 : int16_t *k, /* o : index */
5268 : const int16_t L, /* i : codebook length */
5269 : const int16_t N, /* i : sub-vector size */
5270 : const float *thren );
5271 :
5272 : void huff_dec(
5273 : Decoder_State *st, /* i/o: decoder state structure */
5274 : const int16_t N, /* i : Number of codewords to decode */
5275 : const int16_t buffer_len, /* i : Number of bits to read */
5276 : const int16_t num_lengths, /* i : Number of different huffman codeword lengths */
5277 : const int16_t *thres, /* i : Threshold of first codeword of each length */
5278 : const int16_t *offset, /* i : Offset for first codeword */
5279 : const int16_t *huff_tab, /* i : Huffman table order by codeword lengths */
5280 : int16_t *index /* o : Decoded index */
5281 : );
5282 :
5283 : void calc_norm(
5284 : const float *x, /* i : Input vector. */
5285 : int16_t *norm, /* o : Quantization indices for norms */
5286 : int16_t *normlg, /* o : Quantized norms in log2 */
5287 : const int16_t start_band, /* i : Indice of band to start coding */
5288 : const int16_t num_bands, /* i : Number of bands */
5289 : const int16_t *band_len, /* i : Length of bands */
5290 : const int16_t *band_start /* i : Start of bands */
5291 : );
5292 :
5293 : void reordernorm(
5294 : const int16_t *ynrm, /* i : quantization indices for norms */
5295 : const int16_t *normqlg2, /* i : quantized norms */
5296 : int16_t *idxbuf, /* o : reordered quantization indices */
5297 : int16_t *normbuf, /* o : reordered quantized norms */
5298 : const int16_t nb_sfm /* i : number of bands */
5299 : );
5300 :
5301 : void diffcod(
5302 : const int16_t N, /* i : number of sub-vectors */
5303 : int16_t *y, /* i/o: indices of quantized norms */
5304 : int16_t *difidx /* o : differential code */
5305 : );
5306 :
5307 : void diffcod_lrmdct(
5308 : const int16_t N, /* i : number of sub-vectors */
5309 : const int16_t be_ref, /* i : band energy reference */
5310 : int16_t *y, /* i/o: indices of quantized norms */
5311 : int16_t *difidx, /* o : differential code */
5312 : const int16_t is_transient /* i : transient flag */
5313 : );
5314 :
5315 : void normalizecoefs(
5316 : float *coefs, /* i/o: MDCT coefficients */
5317 : const int16_t *ynrm, /* i : quantization indices for norms */
5318 : const int16_t num_bands, /* i : Number of bands */
5319 : const int16_t *band_start, /* i : Start of bands */
5320 : const int16_t *band_end /* i : End of bands */
5321 : );
5322 :
5323 : void bitallocsum(
5324 : int16_t *R, /* i : bit-allocation vector */
5325 : const int16_t nb_sfm, /* i : number of sub-vectors */
5326 : int16_t *sum, /* o : total number of bits allocated */
5327 : int16_t *Rsubband, /* o : rate per subband (Q3) */
5328 : const int16_t num_bits, /* i : number of bits */
5329 : const int16_t length, /* i : length of spectrum */
5330 : const int16_t *sfmsize /* i : Length of bands */
5331 : );
5332 :
5333 : void hq_generic_hf_encoding(
5334 : const float *coefs, /* i : MDCT coefficients of weighted original */
5335 : float *hq_generic_fenv, /* i/o: energy of SWB envelope */
5336 : const int16_t hq_generic_offset, /* i : frequency offset for extracting energy */
5337 : Encoder_State *st, /* i/o: encoder state structure */
5338 : int16_t *hq_generic_exc_clas, /* o : HF excitation class */
5339 : const int16_t length /* i : Length of spectrum */
5340 : );
5341 :
5342 : /*! r: BWE class */
5343 : int16_t swb_bwe_gain_deq(
5344 : Decoder_State *st, /* i/o: decoder state structure */
5345 : const int16_t core, /* i : core */
5346 : float *SWB_tenv, /* o : time-domain BWE envelope */
5347 : float *SWB_fenv, /* o : frequency-domain BWE envelope */
5348 : const int16_t hr_flag, /* i : high rate flag */
5349 : const int16_t hqswb_clas /* i : HQ BWE class */
5350 : );
5351 :
5352 : void save_old_syn(
5353 : const int16_t L_frame, /* i : frame length */
5354 : const float syn[], /* i : ACELP synthesis */
5355 : float old_syn[], /* o : old synthesis buffer */
5356 : float old_syn_12k8_16k[], /* i/o: old synthesis buffer */
5357 : const float preemph_fac, /* i : preemphasis factor */
5358 : float *mem_deemph /* i/o: deemphasis filter memory */
5359 : );
5360 :
5361 : void hq_generic_hf_decoding(
5362 : const int16_t HQ_mode, /* i : HQ mode */
5363 : float *coeff_out1, /* i/o: BWE input & temporary buffer */
5364 : const float *hq_generic_fenv, /* i : SWB frequency envelopes */
5365 : float *coeff_out, /* o : SWB signal in MDCT domain */
5366 : const int16_t hq_generic_offset, /* i : frequency offset for representing hq swb bwe*/
5367 : int16_t *prev_L_swb_norm, /* i/o: last normalize length */
5368 : const int16_t hq_swb_bwe_exc_clas, /* i : bwe excitation class */
5369 : const int16_t *R );
5370 :
5371 : void hq_core_dec(
5372 : Decoder_State *st, /* i/o: decoder state structure */
5373 : float out[], /* o : output synthesis */
5374 : const int16_t output_frame, /* i : output frame length */
5375 : const int16_t hq_core_type, /* i : HQ core type */
5376 : const int16_t core_switching_flag, /* i : ACELP->HQ switching frame flag */
5377 : float *output /* o : LB synthesis in case of ACELP-HQ switch */
5378 : );
5379 :
5380 : void IMDCT(
5381 : float *x,
5382 : float *old_syn_overl,
5383 : float *syn_Overl_TDAC,
5384 : float *xn_buf,
5385 : const float *tcx_aldo_window_1_trunc,
5386 : const float *tcx_aldo_window_2,
5387 : const float *tcx_mdct_window_half,
5388 : const float *tcx_mdct_window_minimum,
5389 : const float *tcx_mdct_window_trans,
5390 : const int16_t tcx_mdct_window_half_length,
5391 : const int16_t tcx_mdct_window_min_length,
5392 : int16_t index,
5393 : const uint16_t kernel_type, /* i : TCX transform kernel type */
5394 : const int16_t left_rect,
5395 : const int16_t tcx_offset,
5396 : const int16_t overlap,
5397 : const int16_t L_frame,
5398 : const int16_t L_frameTCX,
5399 : const int16_t L_spec_TCX5,
5400 : const int16_t L_frame_glob,
5401 : const int16_t frame_cnt,
5402 : const int16_t bfi,
5403 : float *old_out,
5404 : const int16_t FB_flag,
5405 : Decoder_State *st,
5406 : const int16_t fullband,
5407 : float *acelp_zir );
5408 :
5409 : void hq_hr_dec(
5410 : Decoder_State *st, /* i/o: decoder state structure */
5411 : float *t_audio_q, /* o : transform-domain coefficients */
5412 : const int16_t length, /* i : frame length */
5413 : const int16_t num_bits, /* i : number of available bits */
5414 : int16_t *ynrm, /* o : norm quantization index vector */
5415 : int16_t *is_transient, /* o : transient flag */
5416 : int16_t *hqswb_clas, /* o : HQ SWB class */
5417 : float *SWB_fenv, /* o : SWB frequency envelopes */
5418 : const int16_t core_switching_flag /* i : Core switching flag */
5419 :
5420 : );
5421 :
5422 : void hdecnrm_context(
5423 : Decoder_State *st, /* i/o: decoder state structure */
5424 : const int16_t N, /* i : number of norms */
5425 : int16_t *index, /* o : indices of quantized norms */
5426 : int16_t *n_length /* o : decoded stream length */
5427 : );
5428 :
5429 : void hdecnrm_tran(
5430 : Decoder_State *st, /* i/o: decoder state structure */
5431 : const int16_t N, /* i : number of norms */
5432 : int16_t *index /* o : indices of quantized norms */
5433 : );
5434 :
5435 : void hdecnrm_resize(
5436 : Decoder_State *st, /* i/o: decoder state structure */
5437 : const int16_t N, /* i : number of SFMs */
5438 : int16_t *index /* o : norm quantization index vector */
5439 : );
5440 :
5441 : void hdecnrm(
5442 : Decoder_State *st, /* i/o: decoder state structure */
5443 : const int16_t N, /* i : number of norms */
5444 : int16_t *index /* o : indices of quantized norms */
5445 : );
5446 :
5447 : /*! r: index of last band */
5448 : int16_t find_last_band(
5449 : const int16_t *bitalloc, /* i : bit allocation */
5450 : const int16_t nb_sfm /* i : number of possibly coded bands */
5451 : );
5452 :
5453 : void fill_spectrum(
5454 : float *coeff, /* i/o: normalized MLT spectrum / nf spectrum */
5455 : int16_t *R, /* i : number of pulses per band */
5456 : const int16_t is_transient, /* i : transient flag */
5457 : int16_t norm[], /* i : quantization indices for norms */
5458 : const float *hq_generic_fenv, /* i : HQ GENERIC envelope */
5459 : const int16_t hq_generic_offset, /* i : HQ GENERIC offset */
5460 : const int16_t nf_idx, /* i : noise fill index */
5461 : const int16_t length, /* i : Length of spectrum (32 or 48 kHz) */
5462 : const float env_stab, /* i : Envelope stability measure [0..1] */
5463 : int16_t *no_att_hangover, /* i/o: Frame counter for attenuation hangover */
5464 : float *energy_lt, /* i/o: Long-term energy measure for transient detection */
5465 : int16_t *bwe_seed, /* i/o: random seed for generating BWE input */
5466 : const int16_t hq_generic_exc_clas, /* i : HF excitation class */
5467 : const int16_t core_sfm, /* i : index of the end band for core */
5468 : int16_t HQ_mode, /* i : HQ mode */
5469 : float noise_level[], /* i : noise level for harmonic modes */
5470 : int32_t core_brate, /* i : target bitrate */
5471 : float prev_noise_level[], /* i/o: noise factor in previous frame */
5472 : int16_t *prev_R, /* i/o: bit allocation info. in previous frame */
5473 : float *prev_coeff_out, /* i/o: decoded spectrum in previous frame */
5474 : const int16_t *peak_idx, /* i : peak positions */
5475 : const int16_t Npeaks, /* i : number of peaks */
5476 : const int16_t *npulses, /* i : Number of assigned pulses per band */
5477 : int16_t prev_is_transient, /* i : previous transient flag */
5478 : float *prev_normq, /* i : previous norms */
5479 : float *prev_env, /* i : previous noise envelopes */
5480 : int16_t prev_bfi, /* i : previous bad frame indicator */
5481 : const int16_t *sfmsize, /* i : Length of bands */
5482 : const int16_t *sfm_start, /* i : Start of bands */
5483 : const int16_t *sfm_end, /* i : End of bands */
5484 : int16_t *prev_L_swb_norm, /* i/o: last normalize length for harmonic mode */
5485 : int16_t prev_hq_mode, /* i : previous HQ mode */
5486 : const int16_t num_sfm, /* i : Number of bands */
5487 : const int16_t num_env_bands, /* i : Number of envelope bands */
5488 : const int16_t element_mode /* i : element mode */
5489 : );
5490 :
5491 : void env_stab_transient_detect(
5492 : const int16_t is_transient, /* i : Transient flag */
5493 : const int16_t length, /* i : Length of spectrum (32 or 48 kHz) */
5494 : const int16_t norm[], /* i : quantization indices for norms */
5495 : int16_t *no_att_hangover, /* i/o: Frame counter for attenuation hangover */
5496 : float *energy_lt, /* i/o: Long-term energy measure for transient detection */
5497 : const int16_t HQ_mode, /* i : HQ coding mode */
5498 : const int16_t bin_th, /* i : HVQ cross-over frequency bin */
5499 : const float *coeff /* i : Coded spectral coefficients */
5500 : );
5501 :
5502 : void de_interleave_spectrum(
5503 : float *coefs, /* i/o: input and output coefficients */
5504 : int16_t length /* i : length of spectrum */
5505 : );
5506 :
5507 : void inverse_transform(
5508 : const float *InMDCT, /* i : input MDCT vector */
5509 : float *Out, /* o : output vector */
5510 : const int16_t IsTransient, /* i : transient flag */
5511 : const int16_t L, /* i : output frame length */
5512 : const int16_t L_inner, /* i : length of the transform */
5513 : const int16_t element_mode /* i : IVAS element mode */
5514 : );
5515 :
5516 : void window_ola(
5517 : const float *ImdctOut, /* i : input */
5518 : float *auOut, /* o : output audio */
5519 : float *OldauOut, /* i/o: audio from previous frame */
5520 : const int16_t L, /* i : length */
5521 : const int16_t right_mode,
5522 : const int16_t left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
5523 : const int16_t use_bfi_win, /* i : use BFI windowing */
5524 : const int16_t oldHqVoicing, /* i : previous HqVoicing */
5525 : float *oldgapsynth /* i : previous gapsynth */
5526 : );
5527 :
5528 : void window_ola_ext(
5529 : const float *ImdstOut, /* i : input */
5530 : float *auOut, /* o : output audio */
5531 : float *OldauOut, /* i/o: audio from previous frame */
5532 : const int16_t L, /* i : length */
5533 : const int16_t right_mode,
5534 : const int16_t left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
5535 : const uint16_t kernel_type /* i : transform kernel type */
5536 : );
5537 :
5538 : void map_quant_weight(
5539 : const int16_t normqlg2[], /* i : quantized norms */
5540 : int16_t wnorm[], /* o : weighted norm */
5541 : const int16_t is_transient /* i : transient flag */
5542 : );
5543 :
5544 : void recovernorm(
5545 : const int16_t *const idxbuf, /* i : reordered quantization indices */
5546 : int16_t *ynrm, /* o : recovered quantization indices */
5547 : int16_t *normqlg2, /* o : recovered quantized norms */
5548 : const int16_t nb_sfm /* i : number of subbands */
5549 : );
5550 :
5551 : void reordvct(
5552 : int16_t *y, /* i/o: vector to rearrange */
5553 : const int16_t N, /* i : dimensions */
5554 : int16_t *idx /* o : reordered vector index */
5555 : );
5556 :
5557 : void bitalloc(
5558 : int16_t *y, /* i : reordered norm of sub-vectors */
5559 : int16_t *idx, /* i : reordered sub-vector indices */
5560 : int16_t sum, /* i : number of available bits */
5561 : int16_t N, /* i : number of norms */
5562 : int16_t K, /* i : maximum number of bits per dimension */
5563 : int16_t *r, /* o : bit-allacation vector */
5564 : const int16_t *sfmsize, /* i : Length of bands */
5565 : const int16_t hqswb_clas /* i : signal classification flag */
5566 : );
5567 :
5568 : /*! r: Integer (truncated) number of allocated bits */
5569 : int16_t BitAllocF(
5570 : int16_t *y, /* i : norm of sub-vectors */
5571 : int32_t bit_rate, /* i : bitrate */
5572 : int16_t B, /* i : number of available bits */
5573 : int16_t N, /* i : number of sub-vectors */
5574 : int16_t *R, /* o : bit-allocation indicator */
5575 : int16_t *Rsubband, /* o : sub-band bit-allocation vector (Q3) */
5576 : const int16_t hqswb_clas, /* i : hq swb class */
5577 : const int16_t num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */
5578 : );
5579 :
5580 : /*! r: Integer (truncated) number of allocated bits */
5581 : int16_t BitAllocWB(
5582 : int16_t *y, /* i : norm of sub-vectors */
5583 : int16_t B, /* i : number of available bits */
5584 : int16_t N, /* i : number of sub-vectors */
5585 : int16_t *R, /* o : bit-allocation indicator */
5586 : int16_t *Rsubband ); /* o : sub-band bit-allocation vector (Q3) */
5587 :
5588 : /*! r: Number of low frequency bands */
5589 : int16_t hvq_pvq_bitalloc(
5590 : int16_t num_bits, /* i/o: Number of available bits (including gain bits) */
5591 : const int32_t core_brate, /* i : bitrate */
5592 : const int16_t bwidth, /* i : Encoded bandwidth */
5593 : const int16_t *ynrm, /* i : Envelope coefficients */
5594 : const int32_t manE_peak, /* i : Peak energy mantissa */
5595 : const int16_t expE_peak, /* i : Peak energy exponent */
5596 : int16_t *Rk, /* o : bit allocation for concatenated vector */
5597 : int16_t *R, /* i/o: Global bit allocation */
5598 : int16_t *sel_bands, /* o : Selected bands for encoding */
5599 : int16_t *n_sel_bands /* o : No. of selected bands for encoding */
5600 : );
5601 :
5602 : void floating_point_add(
5603 : int32_t *mx, /* i/o: mantissa of the addend Q31 */
5604 : int16_t *ex, /* i/o: exponent of the addend Q0 */
5605 : const int32_t my, /* i : mantissa of the adder Q31 */
5606 : const int16_t ey /* i : exponent of the adder Q0 */
5607 : );
5608 :
5609 : /*! r: Number of bits needed */
5610 : int16_t rc_get_bits2(
5611 : const int16_t N, /* i : Number of bits currently used */
5612 : const uint32_t range /* i : Range of range coder */
5613 : );
5614 :
5615 : void rc_enc_init(
5616 : PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
5617 : int16_t tot_bits /* i : Total bit budget */
5618 : );
5619 :
5620 : void rc_encode(
5621 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
5622 : PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
5623 : const uint32_t cum_freq, /* i : Cumulative frequency up to symbol */
5624 : const uint32_t sym_freq, /* i : Symbol probability */
5625 : const uint32_t tot /* i : Total cumulative frequency */
5626 : );
5627 :
5628 : void rc_enc_finish(
5629 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
5630 : PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */
5631 : );
5632 :
5633 : void rc_enc_bits(
5634 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
5635 : PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
5636 : const uint32_t value, /* i : Value to encode */
5637 : const int16_t bits /* i : Number of bits used */
5638 : );
5639 :
5640 : void rc_enc_uniform(
5641 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
5642 : PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
5643 : uint32_t value, /* i : Value to encode */
5644 : uint32_t tot /* i : Maximum value */
5645 : );
5646 :
5647 : void rc_dec_init(
5648 : Decoder_State *st, /* i/o: Decoder State */
5649 : PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
5650 : int16_t tot_bits /* i : Total bit budget */
5651 : );
5652 :
5653 : /*! r: Decoded value */
5654 : uint32_t rc_decode(
5655 : int16_t *BER_detect, /* o : Bit error detection flag */
5656 : PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
5657 : uint32_t tot /* i : Total cumulative frequency */
5658 : );
5659 :
5660 : void rc_dec_update(
5661 : Decoder_State *st, /* i/o: Decoder State */
5662 : PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
5663 : const uint32_t cum_freq, /* i : Cumulative frequency */
5664 : const uint32_t sym_freq /* i : Symbol frequency */
5665 : );
5666 :
5667 : /*! r: Decoded value */
5668 : uint32_t rc_dec_bits(
5669 : Decoder_State *st, /* i/o: Decoder State */
5670 : PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
5671 : const int16_t bits /* i : Number of bits */
5672 : );
5673 :
5674 : /*! r: Decoded value */
5675 : uint32_t rc_dec_uniform(
5676 : Decoder_State *st, /* i/o: Decoder State */
5677 : PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
5678 : const uint32_t tot /* i : Maximum value */
5679 : );
5680 :
5681 : void rc_dec_finish(
5682 : Decoder_State *st, /* i/o: decoder state structure */
5683 : PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle */
5684 : );
5685 :
5686 : /*! r: number of bits encoded */
5687 : int16_t pvq_core_enc(
5688 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
5689 : float coefs_norm[], /* i/o: normalized coefficients to encode */
5690 : float coefs_quant[], /* o : quantized coefficients */
5691 : const int16_t bits_tot, /* i : total number of bits */
5692 : const int16_t nb_sfm, /* i : number of bands */
5693 : const int16_t *sfm_start, /* i : Subband start coefficient */
5694 : const int16_t *sfm_end, /* i : Subband end coefficient */
5695 : const int16_t *sfmsize, /* i : subband width */
5696 : int16_t *R, /* i/o: Bit allocation/Adjusted bit alloc. (Q3) */
5697 : int16_t *Rs, /* i/o: Integer bit allocation */
5698 : int16_t *npulses, /* o : number of pulses */
5699 : int16_t *maxpulse, /* i : maximum pulse per band */
5700 : const int16_t core /* i : number of bands */
5701 : );
5702 :
5703 : /*! r: number of bits decoded */
5704 : int16_t pvq_core_dec(
5705 : Decoder_State *st, /* i/o: Decoder state */
5706 : const int16_t *sfm_start, /* i : indices of first coeffs in the bands */
5707 : const int16_t *sfm_end, /* i : indices of last coeffs in the bands */
5708 : const int16_t *sfmsize, /* i : band sizes */
5709 : float coefs_quant[], /* o : output MDCT */
5710 : const int16_t bits_tot, /* i : bit budget */
5711 : const int16_t nb_sfm, /* i : number of bands */
5712 : int16_t *R, /* i/o: Bit allocation/Adjusted bit alloc.(Q3) */
5713 : int16_t *Rs, /* i/o: Integer bit allocation */
5714 : int16_t *npulses, /* o : number of pulses per band */
5715 : int16_t *maxpulse, /* o : maximum pulse per band */
5716 : const int16_t core /* i : core */
5717 : );
5718 :
5719 : void pvq_encode(
5720 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
5721 : PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */
5722 : const float *x, /* i : vector to quantize */
5723 : int16_t *y, /* o : quantized vector (non-scaled integer)*/
5724 : float *xq, /* o : quantized vector (scaled float) */
5725 : const int16_t pulses, /* i : number of allocated pulses */
5726 : const int16_t N, /* i : Length of vector */
5727 : const float gain /* i : Gain */
5728 : );
5729 :
5730 : void pvq_decode(
5731 : Decoder_State *st, /* i/o: Decoder State */
5732 : PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */
5733 : float *xq, /* o : decoded vector (scaled float) */
5734 : int16_t *y, /* o : decoded vector (non-scaled short)*/
5735 : const int16_t K, /* i : number of allocated pulses */
5736 : const int16_t N, /* i : Length of vector */
5737 : const float gain /* i : Gain */
5738 : );
5739 :
5740 : void rangeCoderFinalizationFBits(
5741 : const int16_t Brc, /* i : Current number of decoded bits */
5742 : const uint32_t INTrc, /* i : Range coder state */
5743 : int16_t *FBits /* i : Fractional finalization bits */
5744 : );
5745 :
5746 : void bandBitsAdjustment(
5747 : const int16_t Brc, /* i : Current number of read quanta in range coder */
5748 : const uint32_t INTrc, /* i : Range coder state */
5749 : const int16_t Bavail, /* i : Available number of quanta */
5750 : const int16_t Nbands, /* i : Number of bands */
5751 : const int16_t D, /* i : Remaining number of bands to encode */
5752 : const int16_t L, /* i : Size of current band */
5753 : const int16_t Bband, /* i : Quanta allocation for current band */
5754 : const int16_t Breserv, /* i : Quanta reservoir */
5755 : int16_t *Bband_adj, /* o : Actual used number of quanta */
5756 : int16_t *Brem, /* o : Quanta remaining */
5757 : int16_t *Breservplus /* o : Quanta pool size */
5758 : );
5759 :
5760 : void conservativeL1Norm(
5761 : const int16_t L, /* i : Length of vector segment */
5762 : const int16_t Qvec, /* i : Assigned number of quanta */
5763 : const int16_t Fcons, /* i : Conservative rounding flag */
5764 : const int16_t Qavail, /* i : Input quanta remaining */
5765 : const int16_t Qreserv, /* i : Input quanta in reservoir */
5766 : const int16_t Dspec, /* i : assigned diracs from bitalloc */
5767 : int16_t *Dvec, /* o : actual number of diracs */
5768 : int16_t *Qspare, /* o : Output quanta remaining */
5769 : int16_t *Qreservplus, /* o : Output quanta in reservoir */
5770 : int16_t *Dspecplus /* o : Output number of diracs */
5771 : );
5772 :
5773 : void NearOppSplitAdjustment(
5774 : const int16_t qband, /* i : quanta for current band */
5775 : const int16_t qzero, /* i : range coder finalization quanta */
5776 : const int16_t Qac, /* i : range coder current quanta */
5777 : const uint32_t INTac, /* i : range coder state */
5778 : const int16_t qglobal, /* i : quanta input */
5779 : const int16_t FlagCons, /* i : conservative rounding flag */
5780 : const int16_t Np, /* i : number of parts */
5781 : const int16_t Nhead, /* i : first part */
5782 : const int16_t Ntail, /* i : remaining parts */
5783 : const int16_t Nnear, /* i : length of near component */
5784 : const int16_t Nopp, /* i : length of opposite component */
5785 : int16_t oppRQ3, /* i : ratio */
5786 : int16_t *qnear, /* o : quantized near */
5787 : int16_t *qopp, /* o : quantized opposite */
5788 : int16_t *qglobalupd /* o : quanta remaining */
5789 : );
5790 :
5791 : /*! r: Approximate integer division for positive input */
5792 : int32_t intLimCDivPos(
5793 : const int32_t NUM, /* i : numerator */
5794 : const int16_t DEN /* i : denominator */
5795 : );
5796 :
5797 : /*! r: Approximate integer division */
5798 : int16_t shrtCDivSignedApprox(
5799 : const int16_t num, /* i : numerator */
5800 : const int16_t den /* i : denominator */
5801 : );
5802 :
5803 : void QuantaPerDsDirac(
5804 : const int16_t td, /* i : Length of vector segment */
5805 : const int16_t dsDiracIndex, /* i : Quanta table index */
5806 : const uint8_t *const *dimFrQuanta, /* i : Quanta lookup table */
5807 : int16_t *Quanta /* i : Quanta */
5808 : );
5809 :
5810 : void obtainEnergyQuantizerDensity(
5811 : const int16_t L_in, /* i : left vector energy */
5812 : const int16_t R_in, /* i : right vector energy */
5813 : int16_t *Density /* o : quantizer density */
5814 : );
5815 :
5816 : void densityAngle2RmsProjDec(
5817 : const int16_t D, /* i : density */
5818 : const int16_t indexphi, /* i : decoded index from AR dec */
5819 : int16_t *oppQ15, /* o : opposite */
5820 : int16_t *nearQ15, /* o : near */
5821 : int16_t *oppRatioQ3 /* o : ratio */
5822 : );
5823 :
5824 : void densityAngle2RmsProjEnc(
5825 : const int16_t D, /* i : density */
5826 : const int16_t phiQ14uq, /* i : angle */
5827 : int16_t *indexphi, /* o : index */
5828 : int16_t *oppQ15, /* o : opposite */
5829 : int16_t *nearQ15, /* o : near */
5830 : int16_t *oppRatioQ3 /* o : ratio */
5831 : );
5832 :
5833 : void env_adj(
5834 : const int16_t *pulses, /* i : number of pulses per band */
5835 : const int16_t length, /* i : length of spectrum */
5836 : const int16_t last_sfm, /* i : Index of last band */
5837 : float *adj, /* o : Adjustment factors for the envelope */
5838 : const float env_stab, /* i : Envelope stability parameter */
5839 : const int16_t *sfmsize /* i : Length of bands */
5840 : );
5841 :
5842 : float env_stability(
5843 : const int16_t *ynrm, /* i : Norm vector for current frame */
5844 : const int16_t nb_sfm, /* i : Number of sub-bands */
5845 : int16_t *mem_norm, /* i/o: Norm vector memory from past frame */
5846 : int16_t *mem_env_delta, /* i/o: Envelope stability memory for smoothing*/
5847 : const int16_t core_switching_flag /* i : Core switching flag */
5848 : );
5849 :
5850 : /*! r: New speech/music state */
5851 : float env_stab_smo(
5852 : float env_stab, /* i : env_stab value */
5853 : float *env_stab_state_p, /* i/o: env_stab state probabilities */
5854 : int16_t *ho_cnt /* i/o: hangover counter for speech state */
5855 : );
5856 :
5857 : void core_switching_pre_enc(
5858 : Encoder_State *st, /* i/o: encoder state structure */
5859 : const float *old_inp_12k8, /* i : old input signal @12.8kHz */
5860 : const float *old_inp_16k, /* i : old input signal @16kHz */
5861 : const int16_t active_cnt, /* i : Active frame counter */
5862 : const int16_t last_element_mode /* i : last_element_mode */
5863 : );
5864 :
5865 : void core_switching_post_enc(
5866 : Encoder_State *st, /* i/o: encoder state structure */
5867 : const float *old_inp_12k8, /* i : old input signal @12.8kHz */
5868 : const float *old_inp_16k, /* i : old input signal @16kHz */
5869 : const float A[] /* i : unquant LP filter coefs. */
5870 : );
5871 :
5872 : ivas_error core_switching_post_dec(
5873 : Decoder_State *st, /* i/o: decoder state structure */
5874 : float *synth, /* i/o: output synthesis */
5875 : float *output, /* i/o: LB synth/upsampled LB synth */
5876 : float output_mem[], /* i : OLA memory from last TCX/HQ frame */
5877 : const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
5878 : const int16_t output_frame, /* i : frame length */
5879 : const int16_t core_switching_flag, /* i : ACELP->HQ switching frame flag */
5880 : const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */
5881 : const int16_t nchan_out, /* i : number of output channels */
5882 : const int16_t last_element_mode /* i : element mode of previous frame */
5883 : );
5884 :
5885 : ivas_error core_switching_pre_dec(
5886 : Decoder_State *st, /* i/o: decoder state structure */
5887 : const int16_t output_frame, /* i : frame length */
5888 : const int32_t last_core_brate_st0, /* i : channel 0 last core bitrate */
5889 : const int16_t nchan_out, /* i : number of output channels */
5890 : const int16_t last_element_mode, /* i : last_element_mode */
5891 : const int32_t last_element_brate /* i : last element bitrate */
5892 : );
5893 :
5894 : void bandwidth_switching_detect(
5895 : Decoder_State *st /* i/o: decoder state structure */
5896 : );
5897 :
5898 : void bw_switching_pre_proc(
5899 : Decoder_State *st, /* i/o: decoder state structure */
5900 : const float *old_syn_12k8_16k, /* i : ACELP core synthesis @ 12.8kHz or 16kHz */
5901 : const int32_t last_element_brate, /* i : last element bitrate */
5902 : const int16_t nchan_out /* i : number of output channels */
5903 : );
5904 :
5905 : void updt_bw_switching(
5906 : Decoder_State *st, /* i/o: decoder state structure */
5907 : const float *synth /* i : float synthesis signal */
5908 : );
5909 :
5910 : void swb_tbe_reset(
5911 : float mem_csfilt[],
5912 : float mem_genSHBexc_filt_down_shb[],
5913 : float state_lpc_syn[],
5914 : float syn_overlap[],
5915 : float state_syn_shbexc[],
5916 : float *tbe_demph,
5917 : float *tbe_premph,
5918 : float mem_stp_swb[],
5919 : float *gain_prec_swb );
5920 :
5921 : void swb_tbe_reset_synth(
5922 : float genSHBsynth_Hilbert_Mem[],
5923 : float genSHBsynth_state_lsyn_filt_shb_local[] );
5924 :
5925 : void find_td_envelope(
5926 : const float inp[],
5927 : const int16_t len,
5928 : const int16_t len_h,
5929 : float mem_h[],
5930 : float out[] );
5931 :
5932 : void fb_tbe_reset_enc(
5933 : float elliptic_bpf_2_48k_mem[][4],
5934 : float *prev_fb_energy );
5935 :
5936 : void fb_tbe_reset_synth(
5937 : float fbbwe_hpf_mem[][4],
5938 : float *prev_fbbwe_ratio );
5939 :
5940 : void wb_tbe_extras_reset(
5941 : float mem_genSHBexc_filt_down_wb2[],
5942 : float mem_genSHBexc_filt_down_wb3[] );
5943 :
5944 : void wb_tbe_extras_reset_synth(
5945 : float state_lsyn_filt_shb[],
5946 : float state_lsyn_filt_dwn_shb[],
5947 : float mem_resamp_HB[] );
5948 :
5949 : void tbe_celp_exc(
5950 : const int16_t element_mode, /* i : element mode */
5951 : const int16_t idchan, /* i : channel ID */
5952 : float *bwe_exc, /* i/o: BWE excitation */
5953 : const int16_t L_frame, /* i : frame length */
5954 : const int16_t L_subfr, /* i : subframe length */
5955 : const int16_t i_subfr, /* i : subframe index */
5956 : const int16_t T0, /* i : integer pitch lag */
5957 : const int16_t T0_frac, /* i : fraction of lag */
5958 : float *error, /* i/o: error */
5959 : const int16_t tdm_LRTD_flag /* i : LRTD stereo mode flag */
5960 : );
5961 :
5962 : void prep_tbe_exc(
5963 : const int16_t L_frame, /* i : length of the frame */
5964 : const int16_t L_subfr, /* i : subframe length */
5965 : const int16_t i_subfr, /* i : subframe index */
5966 : const float gain_pit, /* i : Pitch gain */
5967 : const float gain_code, /* i : algebraic codebook gain */
5968 : const float code[], /* i : algebraic excitation */
5969 : const float voice_fac, /* i : voicing factor */
5970 : float *voice_factors, /* o : TBE voicing factor */
5971 : float bwe_exc[], /* i/o: excitation for TBE */
5972 : const float gain_preQ, /* i : prequantizer excitation gain */
5973 : const float code_preQ[], /* i : prequantizer excitation */
5974 : const int16_t T0, /* i : integer pitch variables */
5975 : const int16_t coder_type, /* i : coding type */
5976 : const int32_t core_brate, /* i : core bitrate */
5977 : const int16_t element_mode, /* i : element mode */
5978 : const int16_t idchan, /* i : channel ID */
5979 : const int16_t flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */
5980 : const int16_t tdm_LRTD_flag /* i : LRTD stereo mode flag */
5981 : );
5982 :
5983 : void synthesise_fb_high_band(
5984 : const float excitation_in[], /* i : full band excitation */
5985 : float output[], /* o : high band speech - 14.0 to 20 kHz */
5986 : const float fb_exc_energy, /* i : full band excitation energy */
5987 : const float ratio, /* i : energy ratio */
5988 : const int16_t L_frame, /* i : ACELP frame length */
5989 : const int16_t bfi, /* i : BFI flag */
5990 : float *prev_fbbwe_ratio, /* o : previous frame energy for FEC */
5991 : float bpf_memory[][4] /* i/o: memory for elliptic bpf 48k */
5992 : );
5993 :
5994 : void elliptic_bpf_48k_generic(
5995 : const float input[], /* i : input signal */
5996 : float output[], /* o : output signal */
5997 : float memory[][4], /* i/o: 4 arrays for memory */
5998 : const float full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 */
5999 : );
6000 :
6001 : void HQ_FEC_processing(
6002 : Decoder_State *st, /* i/o: decoder state structure */
6003 : float *t_audio_q, /* o : MDCT coeffs. (for synthesis) */
6004 : int16_t is_transient, /* i : Old flag for transient */
6005 : float ynrm_values[][MAX_PGF], /* i : Old average Norm values for each group of bands */
6006 : float r_p_values[][MAX_ROW], /* i : Computed y-intercept and slope by Regression */
6007 : int16_t num_Sb, /* i : Number of sub-band group */
6008 : int16_t nb_sfm, /* i : Number of sub-band */
6009 : int16_t *Num_bands_p, /* i : Number of coeffs. for each sub-band */
6010 : int16_t output_frame, /* i : Frame size */
6011 : const int16_t *sfm_start, /* i : Start of bands */
6012 : const int16_t *sfm_end /* i : End of bands */
6013 : );
6014 :
6015 : void HQ_FEC_Mem_update(
6016 : Decoder_State *st, /* i/o: decoder state structure */
6017 : const float *t_audio_q,
6018 : float *normq,
6019 : int16_t *ynrm,
6020 : const int16_t *Num_bands_p,
6021 : const int16_t is_transient,
6022 : const int16_t hqswb_clas,
6023 : const int16_t c_switching_flag,
6024 : const int16_t nb_sfm,
6025 : const int16_t num_Sb,
6026 : float *mean_en_high,
6027 : const int16_t hq_core_type, /* i : normal or low-rate MDCT(HQ) core */
6028 : const int16_t output_frame /* i : Frame size */
6029 : );
6030 :
6031 : void time_domain_FEC_HQ(
6032 : Decoder_State *st, /* i : Decoder State */
6033 : float *wtda_audio, /* i : input */
6034 : float *out, /* o : output audio */
6035 : const float mean_en_high, /* i : transient flag */
6036 : const int16_t output_frame /* i : Frame size */
6037 : );
6038 :
6039 : void save_synthesis_hq_fec(
6040 : Decoder_State *st, /* i/o: decoder state structure */
6041 : const float *output, /* i : decoded synthesis */
6042 : const int16_t output_frame, /* i : decoded synthesis */
6043 : CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */
6044 : );
6045 :
6046 : void Next_good_after_burst_erasures(
6047 : const float *ImdctOut, /* i : input */
6048 : float *auOut, /* o : output audio */
6049 : float *OldauOut, /* i/o: audio from previous frame */
6050 : const int16_t ol_size /* i : overlap size */
6051 : );
6052 :
6053 : void update_average_rate(
6054 : SC_VBR_ENC_HANDLE hSC_VBR, /* i/o: SC-VBR state structure */
6055 : const int32_t core_brate /* i : core bitrate */
6056 : );
6057 :
6058 : void reset_preecho_dec(
6059 : HQ_DEC_HANDLE hHQ_core /* i/o: HQ decoder handle */
6060 : );
6061 :
6062 : void preecho_sb(
6063 : const int32_t core_brate, /* i : core bitrate */
6064 : const float wtda_audio[], /* i : imdct signal */
6065 : float *rec_sig, /* i : reconstructed signal, output of the imdct transform */
6066 : const int16_t framelength, /* i : frame length */
6067 : float *memfilt_lb, /* i/o: memory */
6068 : float *mean_prev_hb, /* i/o: memory */
6069 : float *smoothmem, /* i/o: memory */
6070 : float *mean_prev, /* i/o: memory */
6071 : float *mean_prev_nc, /* i/o: memory */
6072 : float *wmold_hb, /* i/o: memory */
6073 : int16_t *prevflag, /* i/o: flag */
6074 : int16_t *pastpre, /* i/o: flag */
6075 : const int16_t bwidth /* i : audio bandwidth */
6076 : );
6077 :
6078 : void hq2_core_configure(
6079 : const int16_t frame_length, /* i : frame length */
6080 : const int16_t num_bits, /* i : number of bits */
6081 : const int16_t is_transient, /* i : transient flag */
6082 : int16_t *bands,
6083 : int16_t *length,
6084 : int16_t band_width[],
6085 : int16_t band_start[],
6086 : int16_t band_end[],
6087 : Word32 *L_qint, /* o : Q29 */
6088 : Word16 *eref_fx, /* o : Q10 */
6089 : Word16 *bit_alloc_weight_fx, /* o : Q13 */
6090 : int16_t *gqlevs,
6091 : int16_t *Ngq,
6092 : int16_t *p2a_bands,
6093 : float *p2a_th,
6094 : float *pd_thresh,
6095 : float *ld_slope,
6096 : float *ni_coef,
6097 : float *ni_pd_th,
6098 : int32_t bwe_br );
6099 :
6100 : void hq_lr_enc(
6101 : Encoder_State *st, /* i/o: encoder state structure */
6102 : float t_audio[], /* i/o: transform-domain coefs. */
6103 : const int16_t inner_frame, /* i : inner frame length */
6104 : int16_t *num_bits, /* i/o: number of available bits */
6105 : const int16_t is_transient /* i : transient flag */
6106 : );
6107 :
6108 : void hq_lr_dec(
6109 : Decoder_State *st, /* i/o: decoder state structure */
6110 : float yout[], /* o : transform-domain output coefs. */
6111 : const int16_t inner_frame, /* i : inner frame length */
6112 : int16_t num_bits, /* i : number of available bits */
6113 : int16_t *is_transient /* o : transient flag */
6114 : );
6115 :
6116 : void hq2_bit_alloc(
6117 : const float band_energy[], /* i : band energy of each subband */
6118 : const int16_t bands, /* i : total number of subbands in a frame */
6119 : Word32 L_Rk[], /* i/o: Bit allocation/Adjusted bit alloc. */
6120 : int16_t *bit_budget, /* i/o: bit bugdet */
6121 : int16_t *p2a_flags, /* i : HF tonal indicator */
6122 : const Word16 weight_fx, /* i : weight (Q13) */
6123 : const int16_t band_width[], /* i : Sub band bandwidth */
6124 : const int16_t num_bits, /* i : available bits */
6125 : const int16_t hqswb_clas, /* i : HQ2 class information */
6126 : const int16_t bwidth, /* i : input bandwidth */
6127 : const int16_t is_transient /* i : indicator HQ_TRANSIENT or not */
6128 : );
6129 :
6130 : void hq2_noise_inject(
6131 : float y2hat[],
6132 : const int16_t band_start[],
6133 : const int16_t band_end[],
6134 : const int16_t band_width[],
6135 : float Ep[],
6136 : float Rk[],
6137 : const int16_t npulses[],
6138 : int16_t ni_seed,
6139 : const int16_t bands,
6140 : const int16_t ni_start_band,
6141 : const int16_t bw_low,
6142 : const int16_t bw_high,
6143 : const float enerL,
6144 : const float enerH,
6145 : float last_ni_gain[],
6146 : float last_env[],
6147 : int16_t *last_max_pos_pulse,
6148 : int16_t *p2a_flags,
6149 : int16_t p2a_bands,
6150 : const int16_t hqswb_clas,
6151 : const int16_t bwidth,
6152 : const int32_t bwe_br );
6153 :
6154 : void mdct_spectrum_denorm(
6155 : const int32_t inp_vector[],
6156 : float y2[],
6157 : const int16_t band_start[],
6158 : const int16_t band_end[],
6159 : const int16_t band_width[],
6160 : const float band_energy[],
6161 : const int16_t npulses[],
6162 : const int16_t bands,
6163 : const float ld_slope,
6164 : const float pd_thresh );
6165 :
6166 : void reverse_transient_frame_energies(
6167 : float band_energy[], /* o : band energies */
6168 : const int16_t bands /* i : number of bands */
6169 : );
6170 :
6171 : int16_t peak_vq_enc(
6172 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
6173 : const int16_t bwidth, /* i : audio bandwidth */
6174 : #ifdef DEBUGGING
6175 : const int16_t idchan, /* i : channel ID */
6176 : #endif
6177 : const float *coefs, /* i : Input coefficient vector */
6178 : float *coefs_out, /* o : Quantized output vector */
6179 : const int32_t core_brate, /* i : Core bitrate */
6180 : const int16_t num_bits, /* i : Number of bits for HVQ */
6181 : const int16_t vq_peaks, /* i : Number of identified peaks */
6182 : const int16_t *ynrm, /* i : Envelope coefficients */
6183 : int16_t *R, /* i/o: Bit allocation/updated bit allocation */
6184 : int16_t *vq_peak_idx, /* i : Peak index vector */
6185 : float *nf_gains /* i : Estimated noise floor gains */
6186 : );
6187 :
6188 : void hvq_dec(
6189 : Decoder_State *st, /* i/o: decoder state structure */
6190 : const int16_t num_bits, /* i : Number of available bits */
6191 : const int32_t core_brate, /* i : Core bitrate */
6192 : const int16_t *ynrm, /* i : Envelope coefficients */
6193 : int16_t *R, /* i/o: Bit allocation/updated bit allocation */
6194 : float *noise_level, /* o : Noise level */
6195 : int16_t *peak_idx, /* o : Peak position vector */
6196 : int16_t *Npeaks, /* o : Total number of peaks */
6197 : float *coefsq_norm, /* o : Output vector */
6198 : const int16_t core /* i : Core */
6199 : );
6200 :
6201 : void hq_configure_bfi(
6202 : int16_t *nb_sfm, /* o : Number of sub bands */
6203 : int16_t *num_Sb, /* o : Number of FEC sub bands ? */
6204 : int16_t *num_bands_p, /* o : FEC sub bands */
6205 : const int16_t **sfmsize, /* o : Subband bandwidths */
6206 : const int16_t **sfm_start, /* o : Subband start coefficients */
6207 : const int16_t **sfm_end /* o : Subband end coefficients */
6208 : );
6209 :
6210 : void swb_bwe_enc_lr(
6211 : Encoder_State *st, /* i/o: encoder state structure */
6212 : const float m_core[], /* i : core synthesis (MDCT) */
6213 : const float m_orig[], /* i/o: scaled orig signal (MDCT) */
6214 : float m[], /* o : output, SWB part (MDCT) */
6215 : const int32_t total_brate, /* i : total bitrate for selecting subband pattern */
6216 : int16_t BANDS,
6217 : int16_t *band_start,
6218 : int16_t *band_end,
6219 : float *band_energy,
6220 : int16_t *p2a_flags,
6221 : const int16_t hqswb_clas,
6222 : int16_t lowlength,
6223 : int16_t highlength,
6224 : int16_t *prev_frm_index,
6225 : const int16_t har_bands,
6226 : int16_t *prev_frm_hfe2,
6227 : int16_t *prev_stab_hfe2,
6228 : int16_t band_width[],
6229 : const float y2_ni[],
6230 : int16_t *ni_seed );
6231 :
6232 : void swb_bwe_dec_lr(
6233 : Decoder_State *st, /* i/o: decoder state structure */
6234 : const float m_core[], /* i : lowband synthesis */
6235 : float m[], /* o : highband synthesis with lowband zeroed */
6236 : const int32_t total_brate, /* i : total bitrate for selecting subband pattern */
6237 : int16_t BANDS,
6238 : int16_t *band_start,
6239 : int16_t *band_end,
6240 : float *band_energy,
6241 : int16_t *p2a_flags,
6242 : const int16_t hqswb_clas,
6243 : int16_t lowlength,
6244 : int16_t highlength,
6245 : const int16_t har_bands,
6246 : int16_t *prev_frm_hfe2,
6247 : int16_t *prev_stab_hfe2,
6248 : int16_t band_width[],
6249 : const float y2_ni[],
6250 : int16_t *ni_seed );
6251 :
6252 : int16_t get_usebit_npswb(
6253 : const int16_t hqswb_clas );
6254 :
6255 : void GetPredictedSignal(
6256 : const float *predBuf, /* i : prediction buffer */
6257 : float *outBuf, /* o : output buffer */
6258 : const int16_t lag, /* i : prediction buffer offset */
6259 : const int16_t fLen, /* i : length of loop (output) */
6260 : const float gain /* i : gain to be applied */
6261 : );
6262 :
6263 : void convert_lagIndices_pls2smp(
6264 : int16_t lagIndices_in[],
6265 : int16_t nBands_search,
6266 : int16_t lagIndices_out[],
6267 : const float sspectra[],
6268 : const int16_t sbWidth[],
6269 : const int16_t fLenLow );
6270 :
6271 : void FindNBiggest2_simple(
6272 : const float *inBuf, /* i : input buffer (searched) */
6273 : GainItem *g, /* o : N biggest components found */
6274 : const int16_t nIdx, /* i : search length */
6275 : int16_t *n, /* i : number of components searched (N biggest) */
6276 : const int16_t N_NBIGGESTSEARCH );
6277 :
6278 : void updat_prev_frm(
6279 : float y2[],
6280 : float t_audio[],
6281 : const int32_t bwe_br,
6282 : const int16_t length,
6283 : const int16_t inner_frame,
6284 : const int16_t bands,
6285 : const int16_t bwidth,
6286 : const int16_t is_transient,
6287 : const int16_t hqswb_clas,
6288 : int16_t *prev_hqswb_clas,
6289 : int16_t *prev_SWB_peak_pos,
6290 : int16_t prev_SWB_peak_pos_tmp[],
6291 : int16_t *prev_frm_hfe2,
6292 : int16_t *prev_stab_hfe2,
6293 : const int16_t bws_cnt );
6294 :
6295 : void hf_parinitiz(
6296 : const int32_t total_brate,
6297 : const int16_t hqswb_clas,
6298 : int16_t lowlength,
6299 : int16_t highlength,
6300 : int16_t wBands[],
6301 : const int16_t **subband_search_offset,
6302 : const int16_t **subband_offsets,
6303 : int16_t *nBands,
6304 : int16_t *nBands_search,
6305 : int16_t *swb_lowband,
6306 : int16_t *swb_highband );
6307 :
6308 : float spectrumsmooth_noiseton(
6309 : float spectra[],
6310 : const float spectra_ni[],
6311 : float sspectra[],
6312 : float sspectra_diff[],
6313 : float sspectra_ni[],
6314 : const int16_t fLenLow,
6315 : int16_t *ni_seed );
6316 :
6317 : void noiseinj_hf(
6318 : float xSynth_har[],
6319 : const float th_g[],
6320 : const float band_energy[],
6321 : float *prev_En_sb,
6322 : const int16_t p2a_flags[],
6323 : const int16_t BANDS,
6324 : const int16_t band_start[],
6325 : const int16_t band_end[],
6326 : const int16_t fLenLow );
6327 :
6328 : void noise_extr_corcod(
6329 : float spectra[],
6330 : const float spectra_ni[],
6331 : float sspectra[],
6332 : float sspectra_diff[],
6333 : float sspectra_ni[],
6334 : const int16_t fLenLow,
6335 : int16_t prev_hqswb_clas,
6336 : float *prev_ni_ratio );
6337 :
6338 : void genhf_noise(
6339 : float noise_flr[],
6340 : float xSynth_har[],
6341 : float *predBuf,
6342 : int16_t bands, /* i : total number of subbands in a frame */
6343 : int16_t harmonic_band, /* i : Number of LF harmonic frames */
6344 : int16_t har_freq_est2,
6345 : int16_t pos_max_hfe2,
6346 : int16_t *pul_res,
6347 : GainItem pk_sf[],
6348 : const int16_t fLenLow,
6349 : const int16_t fLenHigh,
6350 : const int16_t sbWidth[],
6351 : const int16_t lagIndices[],
6352 : const int16_t subband_offsets[],
6353 : const int16_t subband_search_offset[] );
6354 :
6355 : void ton_ene_est(
6356 : float xSynth_har[],
6357 : float be_tonal[],
6358 : float band_energy[],
6359 : int16_t band_start[],
6360 : int16_t band_end[],
6361 : int16_t band_width[],
6362 : const int16_t fLenLow,
6363 : const int16_t fLenHigh,
6364 : int16_t bands,
6365 : int16_t har_bands,
6366 : float ni_lvl,
6367 : GainItem pk_sf[],
6368 : int16_t *pul_res );
6369 :
6370 : void Gettonl_scalfact(
6371 : float *outBuf, /* o : synthesized spectrum */
6372 : const float *codbuf, /* i : core coder */
6373 : const int16_t fLenLow, /* i : lowband length */
6374 : const int16_t fLenHigh, /* i : highband length */
6375 : int16_t harmonic_band, /* i : Number of LF harmonic frames */
6376 : int16_t bands, /* i : total number of subbands in a frame */
6377 : float *band_energy, /* i : band energy of each subband */
6378 : int16_t *band_start, /* i : subband start indices */
6379 : int16_t *band_end, /* i : subband end indices */
6380 : const int16_t p2aflags[],
6381 : float be_tonal[],
6382 : GainItem *pk_sf,
6383 : int16_t *pul_res );
6384 :
6385 : void SpectrumSmoothing(
6386 : float *inBuf,
6387 : float *outBuf,
6388 : const int16_t fLen,
6389 : const float th_cut );
6390 :
6391 : void hq2_bit_alloc_har(
6392 : float *y, /* i : band energy of sub-vectors */
6393 : int16_t B, /* i : number of available bits */
6394 : int16_t N, /* i : number of sub-vectors */
6395 : Word32 *L_Rsubband,
6396 : int16_t p2a_bands,
6397 : int32_t core_brate, /* i : core bitrate */
6398 : int16_t p2a_flags[],
6399 : int16_t band_width[] );
6400 :
6401 : void GetSynthesizedSpecThinOut(
6402 : const float *predBuf,
6403 : float *outBuf,
6404 : const int16_t nBands,
6405 : const int16_t *sbWidth,
6406 : const int16_t *lagIndices,
6407 : const float *lagGains,
6408 : const int16_t predBufLen );
6409 :
6410 : void return_bits_normal2(
6411 : int16_t *bit_budget,
6412 : const int16_t p2a_flags[],
6413 : const int16_t bands,
6414 : const int16_t bits_lagIndices[] );
6415 :
6416 : void GetlagGains(
6417 : const float *predBuf,
6418 : const float *band_energy,
6419 : const int16_t nBands,
6420 : const int16_t *sbWidth,
6421 : const int16_t *lagIndices,
6422 : const int16_t predBufLen,
6423 : float *lagGains );
6424 :
6425 : void preset_hq2_swb(
6426 : const int16_t hqswb_clas,
6427 : const int16_t band_end[],
6428 : int16_t *har_bands,
6429 : int16_t p2a_bands,
6430 : const int16_t length,
6431 : const int16_t bands,
6432 : int16_t *lowlength,
6433 : int16_t *highlength,
6434 : float m[] );
6435 :
6436 : void post_hq2_swb(
6437 : const float m[],
6438 : const int16_t lowlength,
6439 : const int16_t highlength,
6440 : const int16_t hqswb_clas,
6441 : const int16_t har_bands,
6442 : const int16_t bands,
6443 : const int16_t p2a_flags[],
6444 : const int16_t band_start[],
6445 : const int16_t band_end[],
6446 : float y2[],
6447 : int16_t npulses[] );
6448 :
6449 : void har_denorm_pulcnt(
6450 : float spectra[], /* i/o: MDCT domain spectrum */
6451 : const int16_t band_start[], /* i : Number subbands/Frame */
6452 : const int16_t band_end[], /* i : Band Start of each SB */
6453 : const float band_energy[], /* i : Band end of each SB */
6454 : const int16_t band_width[],
6455 : const int16_t npulses[],
6456 : const int16_t har_bands /* i : No. of harmonic bands */
6457 : );
6458 :
6459 : int16_t har_est(
6460 : float spectra[],
6461 : const int16_t N,
6462 : int16_t *har_freq_est1,
6463 : int16_t *har_freq_est2,
6464 : int16_t *flag_dis,
6465 : int16_t *prev_frm_hfe2,
6466 : const int16_t subband_search_offset[],
6467 : const int16_t sbWidth[],
6468 : int16_t *prev_stab_hfe2 );
6469 :
6470 : void spt_shorten_domain_pre(
6471 : const int16_t band_start[],
6472 : const int16_t band_end[],
6473 : const int16_t prev_SWB_peak_pos[],
6474 : const int16_t BANDS,
6475 : const int32_t bwe_br,
6476 : int16_t new_band_start[],
6477 : int16_t new_band_end[],
6478 : int16_t new_band_width[] );
6479 :
6480 : void spt_shorten_domain_band_save(
6481 : const int16_t bands,
6482 : const int16_t band_start[],
6483 : const int16_t band_end[],
6484 : const int16_t band_width[],
6485 : int16_t org_band_start[],
6486 : int16_t org_band_end[],
6487 : int16_t org_band_width[] );
6488 :
6489 : void spt_shorten_domain_band_restore(
6490 : const int16_t bands,
6491 : int16_t band_start[],
6492 : int16_t band_end[],
6493 : int16_t band_width[],
6494 : const int16_t org_band_start[],
6495 : const int16_t org_band_end[],
6496 : const int16_t org_band_width[] );
6497 :
6498 : void spt_swb_peakpos_tmp_save(
6499 : const float y2[],
6500 : const int16_t bands,
6501 : const int16_t band_start[],
6502 : const int16_t band_end[],
6503 : int16_t prev_SWB_peak_pos_tmp[] );
6504 :
6505 : void hq_ecu(
6506 : const float *prevsynth, /* i : buffer of previously synthesized signal */
6507 : float *ecu_rec, /* o : reconstructed frame in tda domain */
6508 : int16_t *time_offs, /* i/o: Sample offset for consecutive frame losses*/
6509 : float *X_sav, /* i/o: Stored spectrum of prototype frame */
6510 : int16_t *num_p, /* i/o: Number of identified peaks */
6511 : int16_t *plocs, /* i/o: Peak locations */
6512 : float *plocsi, /* i/o: Interpolated peak locations */
6513 : const float env_stab, /* i : Envelope stability parameter */
6514 : int16_t *last_fec, /* i/o: Flag for usage of pitch dependent ECU */
6515 : const int16_t ph_ecu_HqVoicing, /* i : HQ Voicing flag */
6516 : int16_t *ph_ecu_active, /* i : Phase ECU active flag */
6517 : float *gapsynth, /* o : Gap synthesis */
6518 : const int16_t prev_bfi, /* i : indicating burst frame error */
6519 : const int16_t old_is_transient[2], /* i : flags indicating previous transient frames*/
6520 : float *mag_chg_1st, /* i/o: per band magnitude modifier for transients*/
6521 : float Xavg[LGW_MAX], /* i/o: Frequency group average gain to fade to */
6522 : float *beta_mute, /* o : Factor for long-term mute */
6523 : const int16_t output_frame, /* i : frame length */
6524 : Decoder_State *st /* i/o: decoder state structure */
6525 : );
6526 :
6527 : void peakfinder(
6528 : const float *x0, /* i : vector from which the maxima will be found */
6529 : const int16_t len0, /* i : length of input vector */
6530 : int16_t *plocs, /* o : the indicies of the identified peaks in x0 */
6531 : int16_t *cInd, /* o : number of identified peaks */
6532 : const float sel, /* i : The amount above surrounding data for a peak to be identified */
6533 : const int16_t endpoints /* i : Flag to include endpoints in peak search */
6534 : );
6535 :
6536 : /*! r: interpolated maximum position */
6537 : float imax_pos(
6538 : const float *y /* i : Input vector for peak interpolation */
6539 : );
6540 :
6541 :
6542 : void fft3(
6543 : const float X[], /* i : input frame */
6544 : float Y[], /* o : DFT of input frame */
6545 : const int16_t n /* i : block length (must be radix 3) */
6546 : );
6547 :
6548 : void ifft3(
6549 : const float X[], /* i : input frame */
6550 : float Y[], /* o : iDFT of input frame */
6551 : const int16_t n /* i : block length (must be radix 3) */
6552 : );
6553 :
6554 : /*! r: updated estimate of background noise */
6555 : void minimumStatistics(
6556 : float *noiseLevelMemory, /* i/o: internal state */
6557 : int16_t *noiseLevelIndex, /* i/o: internal state */
6558 : int16_t *currLevelIndex, /* i/o: internal state (circular buffer) */
6559 : float *noiseEstimate, /* i/o: previous estimate of background noise */
6560 : float *lastFrameLevel, /* i/o: level of the last frame */
6561 : float currentFrameLevel, /* i : level of the current frame */
6562 : const float minLev, /* i : minimum level */
6563 : const int16_t buffSize /* i : buffer size */
6564 : );
6565 :
6566 : void E_LPC_int_lpc_tcx(
6567 : const float lsf_old[], /* i : LSFs from past frame */
6568 : const float lsf_new[], /* i : LSFs from present frame */
6569 : float a[] /* o : interpolated LP coefficients */
6570 : );
6571 :
6572 : int16_t E_GAIN_closed_loop_search(
6573 : float exc[],
6574 : float xn[],
6575 : float h[],
6576 : int16_t t0_min,
6577 : int16_t t0_min_frac,
6578 : int16_t t0_max,
6579 : int16_t t0_max_frac,
6580 : const int16_t t0_min_max_res,
6581 : int16_t *pit_frac,
6582 : int16_t *pit_res,
6583 : const int16_t pit_res_max,
6584 : const int16_t i_subfr,
6585 : const int16_t pit_min,
6586 : const int16_t pit_fr2,
6587 : const int16_t pit_fr1,
6588 : const int16_t L_subfr );
6589 :
6590 : void E_ACELP_toeplitz_mul(
6591 : const float R[],
6592 : const float c[],
6593 : float d[] );
6594 :
6595 : void acelp_pulsesign(
6596 : const float cn[],
6597 : float dn[],
6598 : float dn2[],
6599 : float sign[],
6600 : float vec[],
6601 : const float alp );
6602 :
6603 : void E_ACELP_4t(
6604 : float dn[],
6605 : float cn[],
6606 : float H[],
6607 : float R[],
6608 : const int16_t acelpautoc,
6609 : float code[],
6610 : const int16_t cdk_index,
6611 : int16_t _index[],
6612 : const int16_t L_frame,
6613 : const int16_t last_L_frame,
6614 : const int32_t total_brate,
6615 : const int16_t i_subfr,
6616 : const int16_t cmpl_flag );
6617 :
6618 : void E_ACELP_4tsearch(
6619 : float dn[],
6620 : const float cn[],
6621 : const float H[],
6622 : float code[],
6623 : PulseConfig *config,
6624 : int16_t ind[],
6625 : float y[] );
6626 :
6627 : void E_ACELP_4tsearchx(
6628 : float dn[],
6629 : const float cn[],
6630 : float Rw[],
6631 : float code[],
6632 : PulseConfig *config,
6633 : int16_t ind[] );
6634 :
6635 : int16_t E_ACELP_indexing(
6636 : float code[],
6637 : PulseConfig config,
6638 : const int16_t num_tracks,
6639 : int16_t prm[] );
6640 :
6641 : void acelp_findcandidates(
6642 : float dn2[],
6643 : int16_t dn2_pos[],
6644 : int16_t pos_max[],
6645 : const int16_t L_subfr,
6646 : const int16_t tracks );
6647 :
6648 : void E_ACELP_innovative_codebook(
6649 : const float *exc, /* i : pointer to the excitation frame */
6650 : const int16_t T0, /* i : integer pitch lag */
6651 : const int16_t T0_frac, /* i : fraction of lag */
6652 : const int16_t T0_res, /* i : pitch resolution */
6653 : const float pitch_gain, /* i : adaptive codebook gain */
6654 : const float tilt_code, /* i : tilt factor */
6655 : ACELP_config *acelp_cfg, /* i/o: configuration of the ACELP */
6656 : const int16_t i_subfr, /* i : subframe index */
6657 : const float *Aq, /* i : quantized LPC coefficients */
6658 : const float *h1, /* i : impulse response of weighted synthesis filter */
6659 : const float *xn, /* i : Close-loop Pitch search target vector */
6660 : const float *cn, /* i : Innovative codebook search target vector */
6661 : const float *y1, /* i : zero-memory filtered adaptive excitation */
6662 : float *y2, /* o : zero-memory filtered algebraic excitation */
6663 : const int16_t acelpautoc, /* i : autocorrelation mode enabled */
6664 : int16_t **pt_indice, /* i/o: quantization indices pointer */
6665 : float *code, /* o : innovative codebook */
6666 : const int16_t L_frame, /* i : length of the frame */
6667 : const int16_t last_L_frame, /* i : length of the last frame */
6668 : const int32_t total_brate /* i : total bitrate */
6669 : );
6670 :
6671 : int16_t E_ACELP_code43bit(
6672 : const float code[],
6673 : uint32_t *ps,
6674 : int16_t *p,
6675 : uint16_t idxs[] );
6676 :
6677 : void fcb_pulse_track_joint(
6678 : uint16_t *idxs,
6679 : const int16_t wordcnt,
6680 : uint32_t *index_n,
6681 : const int16_t *pulse_num,
6682 : const int16_t track_num );
6683 :
6684 : void D_ACELP_indexing(
6685 : float code[],
6686 : PulseConfig config,
6687 : const int16_t num_tracks,
6688 : int16_t prm[],
6689 : int16_t *BER_detect );
6690 :
6691 : void D_ACELP_decode_43bit(
6692 : uint16_t idxs[],
6693 : float code[],
6694 : int16_t *pulsestrack );
6695 :
6696 : void fcb_pulse_track_joint_decode(
6697 : uint16_t *idxs,
6698 : const int16_t wordcnt,
6699 : uint32_t *index_n,
6700 : const int16_t *pulse_num,
6701 : const int16_t track_num );
6702 :
6703 : void lag_wind(
6704 : float r[], /* i/o: autocorrelations */
6705 : const int16_t m, /* i : order of LP filter */
6706 : const int32_t sr_core, /* i : sampling rate */
6707 : const int16_t strength /* i : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG */
6708 : );
6709 :
6710 : void adapt_lag_wind(
6711 : float r[], /* i/o: autocorrelations */
6712 : const int16_t m, /* i : order of LP filter */
6713 : const int16_t Top, /* i : open loop pitch lags from curr. frame (or NULL if n/a) */
6714 : const float Tnc, /* i : open loop pitch gains from curr. frame (NULL if n/a) */
6715 : const int32_t sr_core /* i : core sampling rate */
6716 : );
6717 :
6718 : void hp20(
6719 : Float32 signal[],
6720 : const Word16 lg,
6721 : Float32 mem[],
6722 : const Word32 Fs );
6723 :
6724 : void ham_cos_window(
6725 : float *fh,
6726 : const int16_t n1,
6727 : const int16_t n2 );
6728 :
6729 : /*! r: noise dependent voicing correction */
6730 : float correlation_shift(
6731 : const float totalNoise /* i : noise estimate over all critical bands */
6732 : );
6733 :
6734 : void init_coder_ace_plus(
6735 : Encoder_State *st, /* i : Encoder state handle */
6736 : const int32_t last_total_brate, /* i : last total bitrate */
6737 : const int32_t igf_brate, /* i : IGF configuration bitrate */
6738 : const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
6739 : );
6740 :
6741 : void core_coder_reconfig(
6742 : Encoder_State *st, /* i/o: encoder state structure */
6743 : const int32_t last_total_brate /* i : last total bitrate */
6744 : );
6745 :
6746 : void core_coder_mode_switch(
6747 : Encoder_State *st, /* i/o: encoder state structure */
6748 : const int32_t last_total_brate, /* i : last bitrate */
6749 : const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
6750 : );
6751 :
6752 : void enc_acelp_tcx_main(
6753 : Encoder_State *st, /* i/o: encoder state structure */
6754 : const float new_samples[], /* i : new samples */
6755 : float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
6756 : const float lsp_new[M], /* i : LSPs at the end of the frame */
6757 : const float lsp_mid[M], /* i : LSPs at the middle of the frame */
6758 : float bwe_exc_extended[], /* i/o: bandwidth extended excitation */
6759 : float *voice_factors, /* o : voicing factors */
6760 : float pitch_buf[], /* o : floating pitch for each subframe */
6761 : const int16_t vad_hover_flag /* i : VAD hangover flag */
6762 : );
6763 :
6764 : void getTCXMode(
6765 : Decoder_State *st, /* i/o: decoder memory state */
6766 : Decoder_State *st0, /* i : bitstream */
6767 : const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
6768 : );
6769 :
6770 : void getTCXWindowing(
6771 : const int16_t core, /* i : current frame mode */
6772 : const int16_t last_core, /* i : last frame mode */
6773 : const int16_t element_mode, /* i : element mode */
6774 : TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */
6775 : Decoder_State *st0 /* i : bitstream */
6776 : );
6777 :
6778 : void getLPCparam(
6779 : Decoder_State *st, /* i/o: decoder memory state */
6780 : int16_t param_lpc[], /* o : LTP parameters */
6781 : Decoder_State *st0, /* i : bitstream */
6782 : const int16_t ch, /* i : channel */
6783 : const int16_t sns_low_br_mode /* i : SNS low-bitrate mode */
6784 : );
6785 :
6786 : void getTCXparam(
6787 : Decoder_State *st, /* i/o: Decoder State handle */
6788 : Decoder_State *st0, /* i : bitstream */
6789 : CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */
6790 : int16_t param[], /* o : decoded parameters */
6791 : const int16_t bits_common, /* i : number of common bits */
6792 : const int16_t start_bit_pos, /* i : position of the start bit */
6793 : const int16_t *no_param_tns, /* i : number of TNS parameters per subframe */
6794 : int16_t p_param[2], /* o : pointer to parameters for next round of bs reading*/
6795 : int16_t nTnsBitsTCX10[2],
6796 : const int16_t pre_past_flag );
6797 :
6798 : void pitch_pred_linear_fit(
6799 : const int16_t nbLostCmpt, /* i : bfi counter */
6800 : const int16_t last_good, /* i : last classification type */
6801 : float *old_pitch_buf, /* i : pitch lag buffer */
6802 : float *old_fpitch, /* i/o: pitch used for initial ACB generation */
6803 : float *T0_out, /* o : estimated close loop pitch */
6804 : const int16_t pit_min, /* i : Minimum pitch lag */
6805 : const int16_t pit_max, /* i : Maximum pitch lag */
6806 : float *mem_pitch_gain, /* i : lag pitch gain [0] is the most recent subfr lag */
6807 : const int16_t limitation,
6808 : const int16_t plc_use_future_lag, /* i : number of subframes to predict */
6809 : int16_t *extrapolationFailed, /* o : flag if extrap decides not to change the pitch */
6810 : const int16_t nb_subfr /* i : number of ACELP subframes */
6811 : );
6812 :
6813 : void get_subframe_pitch(
6814 : const int16_t nSubframes, /* i : number of subframes */
6815 : float pitchStart, /* i : starting pitch lag (in subframe -1) */
6816 : float pitchEnd, /* i : ending pitch lag (in subframe nSubframes-1) */
6817 : float *pitchBuf /* o : interpolated pitch lag per subframe */
6818 : );
6819 :
6820 : void core_encode_openloop(
6821 : Encoder_State *st, /* i/o: encoder state structure */
6822 : const float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
6823 : const float lsp_new[M], /* i : LSPs at the end of the frame */
6824 : const float lsp_mid[M], /* i : LSPs at the middle of the frame */
6825 : float *pitch_buf, /* i/o: floating pitch values for each subfr*/
6826 : float *voice_factors, /* o : voicing factors */
6827 : float *ptr_bwe_exc, /* o : excitation for SWB TBE */
6828 : const int16_t vad_hover_flag /* i : VAD hangover flag */
6829 : );
6830 :
6831 : void core_acelp_tcx20_switching(
6832 : Encoder_State *st, /* i/o: encoder state structure */
6833 : float non_staX, /* i : unbound non-stationarity for sp/mu clas */
6834 : float *pitch_fr, /* i/o: fraction pitch values */
6835 : float *voicing_fr, /* i/o: fractional voicing values */
6836 : const float currTempFlatness, /* i : flatness */
6837 : const float lsp_mid[M], /* i : LSPs at the middle of the frame */
6838 : const float stab_fac /* i : LP filter stability */
6839 : );
6840 :
6841 : void core_encode_twodiv(
6842 : Encoder_State *st, /* i/o: coder memory state */
6843 : const float new_samples[], /* i : new samples */
6844 : float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
6845 : const int16_t vad_hover_flag /* i : VAD hangover flag */
6846 : );
6847 :
6848 : void core_encode_update(
6849 : Encoder_State *st /* i/o: encoder state structure */
6850 : );
6851 :
6852 : void core_encode_update_cng(
6853 : Encoder_State *st, /* i/o: encoder state structure */
6854 : float *timeDomainBuffer,
6855 : float *A,
6856 : const float Aw[] /* i : weighted A(z) unquant. for subframes*/
6857 : );
6858 :
6859 : void core_signal_analysis_high_bitrate(
6860 : const float *new_samples,
6861 : const int16_t T_op[3], /* i : open-loop pitch values for quantiz. */
6862 : float lsp_new[],
6863 : float lsp_mid[],
6864 : Encoder_State *st,
6865 : float *mdst_spectrum[2],
6866 : int16_t pTnsSize[],
6867 : int16_t pTnsBits[],
6868 : int16_t param_core[],
6869 : int16_t *ltpBits,
6870 : float *windowed_samples, /* i/o: backup of windowed time signal */
6871 : const int16_t L_frame,
6872 : const int16_t L_frameTCX,
6873 : const int16_t last_element_mode,
6874 : const int16_t vad_hover_flag /* i : VAD hangover flag */
6875 : );
6876 :
6877 : /*! r: codebook gain (adaptive or fixed) */
6878 : float get_gain(
6879 : const float x[], /* i : target signal */
6880 : const float y[], /* i : filtered codebook excitation */
6881 : const int16_t n, /* i : segment length */
6882 : float *en_y /* o : energy of y (sum of y[]^2, optional) */
6883 : );
6884 :
6885 : void encode_acelp_gains(
6886 : const float *code,
6887 : const int16_t gains_mode,
6888 : const float mean_ener_code,
6889 : const int16_t clip_gain,
6890 : ACELP_CbkCorr *g_corr,
6891 : float *gain_pit,
6892 : float *gain_code,
6893 : int16_t **pt_indice,
6894 : float *past_gcode,
6895 : float *gain_inov,
6896 : const int16_t L_subfr,
6897 : float *code2,
6898 : float *gain_code2,
6899 : const int16_t noisy_speech_flag );
6900 :
6901 : int16_t gain_enc_gacelp_uv(
6902 : const float *code, /* i : algebraic excitation */
6903 : const float *code2, /* i : gaussian excitation */
6904 : const int16_t lcode, /* i : Subframe size */
6905 : const float mean_ener, /* i : quantized mean energy of the frame */
6906 : float *gain_pit, /* o : quantized pitch gain */
6907 : float *gain_code, /* o : quantized codebook gain */
6908 : float *gain_code2, /* o : quantized codebook gain */
6909 : ACELP_CbkCorr *coeff, /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
6910 : float *past_gcode, /* i/o: past gain of code */
6911 : float *gain_inov, /* o : unscaled innovation gain */
6912 : const int16_t noisy_speech_flag /* i : noisy speech flag */
6913 : );
6914 :
6915 : int16_t Mode2_gain_enc_mless(
6916 : const float *code, /* i : algebraic excitation */
6917 : const int16_t lcode, /* i : Subframe size */
6918 : float *gain_pit, /* o : quantized pitch gain */
6919 : float *gain_code, /* o : quantized codebook gain */
6920 : ACELP_CbkCorr *coeff, /* i/o: correlations <y1,y1>, -2<xn,y1>,<y2,y2>, -2<xn,y2> and 2<y1,y2> */
6921 : const float mean_ener, /* i : mean_ener defined in open-loop (3 bits) */
6922 : const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
6923 : float *past_gcode, /* i/o: past gain of code */
6924 : float *gain_inov, /* o : unscaled innovation gain */
6925 : const int16_t coder_type /* i : type of coder */
6926 : );
6927 :
6928 : void decode_acelp_gains(
6929 : const float *code,
6930 : const int16_t gains_mode,
6931 : const float mean_ener_code,
6932 : float *gain_pit,
6933 : float *gain_code,
6934 : int16_t **pt_indice,
6935 : float *past_gpit,
6936 : float *past_gcode,
6937 : float *gain_inov,
6938 : const int16_t L_subfr,
6939 : float *code2,
6940 : float *gain_code2 );
6941 :
6942 : void gain_dec_gacelp_uv(
6943 : int16_t index, /* i/o: Quantization index vector */
6944 : const float *code, /* i : algebraic code excitation */
6945 : const float *code2, /* i : algebraic code excitation */
6946 : const float mean_ener, /* i : mean energy */
6947 : const int16_t lcode, /* i : Subframe size */
6948 : float *gain_pit, /* o : Quantized pitch gain */
6949 : float *gain_code, /* o : Quantized codebook gain */
6950 : float *gain_code2, /* o : Quantized codebook gain */
6951 : float *past_gpit, /* i/o: past gain of pitch */
6952 : float *past_gcode, /* i/o: past energy of code */
6953 : float *gain_inov /* o : unscaled innovation gain */
6954 : );
6955 :
6956 : void Mode2_pit_encode(
6957 : const int16_t coder_type, /* i : coding model */
6958 : const int16_t i_subfr, /* i : subframe index */
6959 : int16_t **pt_indice, /* i/o: quantization indices pointer */
6960 : float *exc, /* i/o: pointer to excitation signal frame */
6961 : const int16_t *T_op, /* i : open loop pitch estimates in current frame */
6962 : int16_t *T0_min, /* i/o: lower limit for close-loop search */
6963 : int16_t *T0_min_frac, /* i/o: lower limit for close-loop search */
6964 : int16_t *T0_max, /* i/o: higher limit for close-loop search */
6965 : int16_t *T0_max_frac, /* i/o: higher limit for close-loop search */
6966 : int16_t *T0, /* i/o: close loop integer pitch */
6967 : int16_t *T0_frac, /* i/o: close loop fractional part of the pitch */
6968 : int16_t *T0_res, /* i/o: close loop pitch resolution */
6969 : float *h1, /* i : weighted filter impulse response */
6970 : float *xn, /* i : target vector */
6971 : const int16_t pit_min,
6972 : const int16_t pit_fr1,
6973 : const int16_t pit_fr1b,
6974 : const int16_t pit_fr2,
6975 : const int16_t pit_max,
6976 : const int16_t pit_res_max );
6977 :
6978 : void limit_T0_voiced(
6979 : const int16_t nbits,
6980 : const int16_t res,
6981 : const int16_t T0, /* i : rough pitch estimate around which the search is done */
6982 : const int16_t T0_frac, /* i : pitch estimate fractional part */
6983 : const int16_t T0_res, /* i : pitch resolution */
6984 : int16_t *T0_min, /* o : lower pitch limit */
6985 : int16_t *T0_min_frac, /* o : lower pitch limit */
6986 : int16_t *T0_max, /* o : higher pitch limit */
6987 : int16_t *T0_max_frac, /* o : higher pitch limit */
6988 : const int16_t pit_min, /* i : Minimum pitch lag */
6989 : const int16_t pit_max /* i : Maximum pitch lag */
6990 : );
6991 :
6992 : void Mode2_abs_pit_enc(
6993 : const int16_t T0, /* i : integer pitch lag */
6994 : const int16_t T0_frac, /* i : pitch fraction */
6995 : int16_t **pt_indice, /* i/o: pointer to Vector of Q indexes */
6996 : const int16_t pit_min,
6997 : const int16_t pit_fr1,
6998 : const int16_t pit_fr2,
6999 : const int16_t pit_res_max );
7000 :
7001 : void Mode2_delta_pit_enc(
7002 : const int16_t T0, /* i : integer pitch lag */
7003 : const int16_t T0_frac, /* i : pitch fraction */
7004 : const int16_t T0_res, /* i : pitch resolution */
7005 : const int16_t T0_min, /* i : delta search min */
7006 : const int16_t T0_min_frac, /* i : delta search min */
7007 : int16_t **pt_indice /* o : pointer to Vector of Q indexes */
7008 : );
7009 :
7010 : /*! r: floating pitch value */
7011 : float Mode2_pit_decode(
7012 : const int16_t coder_type, /* i : coding model */
7013 : const int16_t i_subfr, /* i : subframe index */
7014 : const int16_t L_subfr, /* i : sub-frame length */
7015 : int16_t **pt_indice, /* i/o: quantization indices pointer */
7016 : int16_t *T0, /* o : close loop integer pitch */
7017 : int16_t *T0_frac, /* o : close loop fractional part of the pitch */
7018 : int16_t *T0_res, /* i/o: pitch resolution */
7019 : int16_t *T0_min, /* i/o: lower limit for close-loop search */
7020 : int16_t *T0_min_frac, /* i/o: lower limit for close-loop search */
7021 : int16_t *T0_max, /* i/o: higher limit for close-loop search */
7022 : int16_t *T0_max_frac, /* i/o: higher limit for close-loop search */
7023 : const int16_t pit_min,
7024 : const int16_t pit_fr1,
7025 : const int16_t pit_fr1b,
7026 : const int16_t pit_fr2,
7027 : const int16_t pit_max,
7028 : const int16_t pit_res_max );
7029 :
7030 : void Mode2_abs_pit_dec(
7031 : int16_t *T0, /* o : integer pitch lag */
7032 : int16_t *T0_frac, /* o : pitch fraction */
7033 : int16_t *T0_res, /* o : pitch resolution */
7034 : int16_t **pt_indice, /* i/o: pointer to Vector of Q indexes */
7035 : const int16_t pit_min,
7036 : const int16_t pit_fr1,
7037 : const int16_t pit_fr2,
7038 : const int16_t pit_res_max );
7039 :
7040 : void Mode2_delta_pit_dec(
7041 : int16_t *T0, /* o : integer pitch lag */
7042 : int16_t *T0_frac, /* o : pitch fraction */
7043 : int16_t T0_res, /* i : pitch resolution */
7044 : int16_t *T0_min, /* i : delta search min */
7045 : int16_t *T0_min_frac, /* i : delta search min */
7046 : int16_t **pt_indice /* i/o: pointer to Vector of Q indexes */
7047 : );
7048 :
7049 : void formant_post_filt(
7050 : PFSTAT_HANDLE hPFstat, /* i/o: Post filter related memories */
7051 : float *synth_in, /* i : 12k8 synthesis */
7052 : const float *Aq, /* i : LP filter coefficient */
7053 : float *synth_out, /* i/o: input signal */
7054 : const int16_t L_frame, /* i : frame length */
7055 : const int16_t L_subfr, /* i : sub-frame length */
7056 : const float lp_noise, /* i : background noise energy */
7057 : const int32_t brate, /* i : bitrate */
7058 : const int16_t off_flag /* i : Off flag */
7059 : );
7060 :
7061 : void qlpc_avq(
7062 : const float *lsp, /* i : Input LSF vectors */
7063 : const float *lspmid, /* i : Input mid-LSF vectors */
7064 : float *lsf_q, /* o : Quantized LFS vectors */
7065 : float *lsfmid_q, /* o : Quantized mid-LFS vectors */
7066 : int16_t *index, /* o : Quantization indices */
7067 : int16_t *nb_indices, /* o : Number of quantization indices */
7068 : int16_t *nbbits, /* o : Number of quantization bits */
7069 : const int16_t core, /* i : core */
7070 : const int32_t sr_core /* i : internal sampling rate */
7071 : );
7072 :
7073 : int16_t encode_lpc_avq(
7074 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
7075 : const int16_t numlpc, /* i : Number of sets of lpc */
7076 : const int16_t *param_lpc, /* i : lpc parameters */
7077 : const int16_t core, /* i : core */
7078 : const int16_t element_mode /* i : element mode */
7079 : );
7080 :
7081 : int16_t dlpc_avq(
7082 : int16_t *index, /* i : Quantization indices */
7083 : float *LSF_Q, /* o : Quantized LSF vectors */
7084 : const int16_t numlpc, /* i : Number of sets of lpc */
7085 : const int32_t sr_core /* i : internal sampling rate */
7086 : );
7087 :
7088 : int16_t decode_lpc_avq(
7089 : Decoder_State *st, /* i/o: decoder state structure */
7090 : const int16_t numlpc, /* i : Number of sets of lpc */
7091 : int16_t *param_lpc, /* o : lpc parameters */
7092 : const int16_t ch, /* i : channel */
7093 : const int16_t element_mode, /* i : element mode */
7094 : const int16_t sns_low_br_mode /* i : SNS low-bitrate mode */
7095 : );
7096 :
7097 : /*! r: codebook index */
7098 : int16_t vlpc_1st_cod(
7099 : const float *lsf, /* i : vector to quantize */
7100 : float *lsfq, /* i/o: i:prediction o:quantized lsf */
7101 : const int32_t sr_core, /* i : internal sampling rate */
7102 : float *w /* o : lsf weights */
7103 : );
7104 :
7105 : /*! r: number of allocated bits */
7106 : int16_t vlpc_2st_cod(
7107 : const float *lsf, /* i : normalized vector to quantize */
7108 : float *lsfq, /* i/o: i:1st stage o:1st+2nd stage */
7109 : int16_t *indx, /* o : index[] (4 bits per words) */
7110 : const int16_t mode, /* i : 0=abs, >0=rel */
7111 : const int32_t sr_core /* i : internal sampling rate */
7112 : );
7113 :
7114 : void vlpc_2st_dec(
7115 : float *lsfq, /* i/o: i:1st stage o:1st+2nd stage */
7116 : int16_t *indx, /* i : index[] (4 bits per words) */
7117 : const int16_t mode, /* i : 0=abs, >0=rel */
7118 : const int32_t sr_core /* i : internal sampling rate */
7119 : );
7120 :
7121 : void lsf_weight_2st(
7122 : const float *lsfq,
7123 : float *w,
7124 : const int16_t mode,
7125 : const int32_t sr_core );
7126 :
7127 : void mdct_window_sine(
7128 : float *window,
7129 : const int32_t Fs,
7130 : const int16_t n,
7131 : const int16_t window_type,
7132 : const int16_t element_mode );
7133 :
7134 : void mdct_window_aldo(
7135 : float *window1,
7136 : float *window2,
7137 : const int16_t n );
7138 :
7139 : void AVQ_cod_lpc(
7140 : const float nvec[], /* i : vector to quantize */
7141 : int16_t nvecq[], /* o : quantized normalized vector (assuming the bit budget is enough) */
7142 : int16_t *indx, /* o : index[] (4 bits per words) */
7143 : const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */
7144 : );
7145 :
7146 : void AVQ_dec_lpc(
7147 : const int16_t indx[], /* i : index[] (4 bits per words) */
7148 : int16_t nvecq[], /* o : vector quantized */
7149 : const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */
7150 : );
7151 :
7152 : void vlpc_1st_dec(
7153 : const int16_t index, /* i : codebook index */
7154 : float *lsfq, /* i/o: i:prediction o:quantized lsf */
7155 : const int32_t sr_core );
7156 :
7157 : void WindowSignal(
7158 : TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
7159 : int16_t offset, /* i : left folding point offset relative to the input signal pointer */
7160 : const int16_t left_overlap_mode, /* i : overlap mode of left window half */
7161 : const int16_t right_overlap_mode, /* i : overlap mode of right window half */
7162 : int16_t *left_overlap_length, /* o : TCX window left overlap length */
7163 : int16_t *right_overlap_length, /* o : TCX window right overlap length */
7164 : const float in[], /* i : input signal */
7165 : int16_t *L_frame, /* i/o: frame length */
7166 : float out[], /* o : output windowed signal */
7167 : const int16_t truncate_aldo, /* i : nonzero to truncate long ALDO slope */
7168 : const int16_t fullband /* i : fullband flag */
7169 : );
7170 :
7171 : void HBAutocorrelation(
7172 : TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
7173 : const int16_t left_mode, /* i : overlap mode of left window half */
7174 : const int16_t right_mode, /* i : overlap mode of right window half */
7175 : float speech[], /* i : speech */
7176 : int16_t L_frame_glob, /* i/o: frame length */
7177 : float *r /* o : autocorrelations vector */
7178 : );
7179 :
7180 : void TNSAnalysis(
7181 : TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
7182 : const int16_t L_frame, /* i : frame length */
7183 : int16_t L_spec, /* i : length of the spectrum */
7184 : const int16_t transform_type, /* i : transform type for the frame/subframe - TCX20 | TCX10 | TCX 5 (meaning 2 x TCX 5) */
7185 : const int16_t isAfterACELP, /* i : Flag indicating if the last frame was ACELP. For the second TCX subframe it should be 0 */
7186 : float spectrum[], /* i : MDCT spectrum of the subframe */
7187 : TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */
7188 : const float ltp_gain, /* i : ltp gain */
7189 : STnsData *pTnsData, /* o : TNS data */
7190 : int16_t *pfUseTns, /* o : Flag indicating if TNS is used */
7191 : float *predictionGain /* o : TNS prediction gain */
7192 : );
7193 :
7194 : void CalculateTnsFilt(
7195 : STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */
7196 : const float pSpectrum[], /* i : MDCT spectrum */
7197 : STnsData *pTnsData, /* o : TNS data struct */
7198 : float *predictionGain /* o : TNS prediction gain */
7199 : );
7200 :
7201 : void ShapeSpectrum(
7202 : TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
7203 : const float A[], /* i : quantized coefficients NxAz_q[M+1] */
7204 : float gainlpc[], /* o : MDCT gains for the previous frame */
7205 : const int16_t L_frame_glob, /* i : frame length */
7206 : int16_t L_spec, /* i : length of the spectrum */
7207 : float spectrum[], /* i/o: MDCT spectrum */
7208 : const int16_t fUseTns, /* i : Flag indicating if TNS is used */
7209 : Encoder_State *st, /* i/o: encoder state structure */
7210 : float *scf /* i : scale factors */
7211 : );
7212 :
7213 : void QuantizeSpectrum(
7214 : Encoder_State *st, /* i/o: encoder state structure */
7215 : const float A[], /* i : quantized coefficients NxAz_q[M+1] */
7216 : const Word16 Aqind[], /* i : frame-independent quantized coeffs (M+1) */
7217 : float gainlpc[], /* i : MDCT gains of the previous frame */
7218 : float synth[], /* o : synthesis buffer */
7219 : const int16_t nb_bits, /* i : bit budget */
7220 : const int16_t tnsSize, /* i : number of tns parameters put into prm */
7221 : int16_t prm[], /* o : tcx parameters */
7222 : const int16_t frame_cnt, /* i : frame counter in the super_frame */
7223 : CONTEXT_HM_CONFIG *hm_cfg, /* i : HM configuration */
7224 : const int16_t vad_hover_flag /* i : VAD hangover flag */
7225 : );
7226 :
7227 : /*! r: index of next coefficient */
7228 : int16_t get_next_coeff_mapped(
7229 : int16_t ii[2], /* i/o: coefficient indexes */
7230 : int32_t *pp, /* o : peak(1)/hole(0) indicator */
7231 : int16_t *idx, /* o : index in unmapped domain */
7232 : CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */
7233 : );
7234 :
7235 : /*! r: index of next coefficient */
7236 : int16_t get_next_coeff_unmapped(
7237 : int16_t *ii, /* i/o: coefficient index */
7238 : int16_t *idx /* o : index in unmapped domain */
7239 : );
7240 :
7241 : int32_t update_mixed_context(
7242 : int32_t ctx,
7243 : int16_t a );
7244 :
7245 : void ACcontextMapping_encode2_no_mem_s17_LC(
7246 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
7247 : int16_t *x,
7248 : int16_t nt,
7249 : int16_t lastnz,
7250 : int16_t nbbits,
7251 : int16_t resQMaxBits,
7252 : CONTEXT_HM_CONFIG *hm_cfg );
7253 :
7254 : int16_t ACcontextMapping_decode2_no_mem_s17_LC(
7255 : Decoder_State *st, /* i/o: decoder state */
7256 : int16_t *x, /* o : decoded spectrum */
7257 : int16_t nt, /* i : size of spectrum */
7258 : int16_t nbbits, /* i : bit budget */
7259 : int16_t resQMaxBits, /* i : residual coding maximum bits */
7260 : CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration */
7261 : );
7262 :
7263 : int16_t ACcontextMapping_encode2_estimate_no_mem_s17_LC(
7264 : const int16_t *x,
7265 : const int16_t nt,
7266 : int16_t *lastnz,
7267 : int16_t *nEncoded,
7268 : const int16_t target,
7269 : int16_t *stop,
7270 : CONTEXT_HM_CONFIG *hm_cfg );
7271 :
7272 : void RCcontextMapping_encode2_no_mem_s17_LCS(
7273 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
7274 : int16_t *x,
7275 : const int16_t nt,
7276 : int16_t lastnz,
7277 : const int16_t nbbits,
7278 : const int16_t resQMaxBits,
7279 : CONTEXT_HM_CONFIG *hm_cfg );
7280 :
7281 : int16_t RCcontextMapping_decode2_no_mem_s17_LCS(
7282 : Decoder_State *st, /* i/o: decoder state */
7283 : int16_t *x, /* o : decoded spectrum */
7284 : const int16_t nt, /* i : size of spectrum */
7285 : const int16_t nbbits, /* i : bit budget */
7286 : const int16_t resQMaxBits, /* i : residual coding maximum bits */
7287 : CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration */
7288 : );
7289 :
7290 : int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
7291 : int16_t *x, /* Spectral coefficients */
7292 : const int16_t nt, /* L - size of spectrum (no. of spectral coefficients) */
7293 : int16_t *lastnz_out,
7294 : int16_t *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring */
7295 : const int16_t target, /* Target bits */
7296 : int16_t *stop,
7297 : int16_t mode,
7298 : CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
7299 : );
7300 :
7301 : int16_t RCcontextMapping_encode2_estimate_bandWise_start(
7302 : int16_t *x,
7303 : const int16_t nt,
7304 : const int16_t target,
7305 : HANDLE_RC_CONTEXT_MEM hContextMem );
7306 :
7307 : int16_t RCcontextMapping_encode2_estimate_bandWise(
7308 : int16_t *x,
7309 : const int16_t start_line,
7310 : const int16_t end_line,
7311 : HANDLE_RC_CONTEXT_MEM hContextMem );
7312 :
7313 : void tcx_get_windows(
7314 : TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */
7315 : const int16_t left_mode, /* i : overlap mode of left window half */
7316 : const int16_t right_mode, /* i : overlap mode of right window half */
7317 : int16_t *left_overlap, /* o : left overlap length */
7318 : const float **left_win, /* o : left overlap window */
7319 : int16_t *right_overlap, /* o : right overlap length */
7320 : const float **right_win, /* o : right overlap window */
7321 : const int16_t fullband /* i : fullband flag */
7322 : );
7323 :
7324 : void tcx_windowing_analysis(
7325 : const float *signal, /* i : signal vector */
7326 : const int16_t L_frame, /* i : frame length */
7327 : const int16_t left_overlap, /* i : left overlap length */
7328 : const float *left_win, /* i : left overlap window */
7329 : const int16_t right_overlap, /* i : right overlap length */
7330 : const float *right_win, /* i : right overlap window */
7331 : float *output /* o : windowed signal vector */
7332 : );
7333 :
7334 : void tcx_windowing_synthesis_current_frame(
7335 : float *signal, /* i/o: signal vector */
7336 : const float *window, /* i : TCX window vector */
7337 : const float *window_half, /* i : TCX window vector for half-overlap window */
7338 : const float *window_min, /* i : TCX minimum overlap window */
7339 : const int16_t window_length, /* i : TCX window length */
7340 : const int16_t window_half_length, /* i : TCX half window length */
7341 : const int16_t window_min_length, /* i : TCX minimum overlap length */
7342 : const int16_t left_rect, /* i : left part is rectangular */
7343 : const int16_t left_mode, /* i : overlap mode of left window half */
7344 : float *acelp_zir, /* i/o: acelp ZIR */
7345 : const float *old_syn, /* i : old synthesis */
7346 : const float *syn_overl, /* i : overlap synthesis */
7347 : const float *A_zir,
7348 : const float *window_trans, /* i : window for transition from ACELP */
7349 : int16_t acelp_zir_len,
7350 : const int16_t acelp_mem_len,
7351 : const int16_t last_core_bfi, /* i : last mode */
7352 : const int16_t last_is_cng,
7353 : const int16_t fullbandScale );
7354 :
7355 : void tcx_windowing_synthesis_past_frame(
7356 : float *signal, /* i/o: signal vector */
7357 : const float *window, /* i : TCX window vector */
7358 : const float *window_half, /* i : TCX window vector for half-overlap window */
7359 : const float *window_min, /* i : TCX minimum overlap window */
7360 : const int16_t window_length, /* i : TCX window length */
7361 : const int16_t window_half_length, /* i : TCX half window length */
7362 : const int16_t window_min_length, /* i : TCX minimum overlap length */
7363 : const int16_t right_mode /* i : overlap mode (left_mode of current frame) */
7364 : );
7365 :
7366 : void ProcessIGF(
7367 : Encoder_State *st, /* i : Encoder state */
7368 : float *pMDCTSpectrum, /* i : MDCT spectrum */
7369 : const float *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */
7370 : float *pPowerSpectrum, /* i : MDCT^2 + MDST^2 spectrum, or estimate */
7371 : const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
7372 : const int16_t frameno, /* i : flag indicating index of current subframe */
7373 : const int16_t sp_aud_decision0, /* i : first stage switching decision */
7374 : const int16_t vad_hover_flag /* i : VAD hangover flag */
7375 : );
7376 :
7377 : void ProcessStereoIGF(
7378 : STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct,
7379 : Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
7380 : int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
7381 : float *pITFMDCTSpectrum[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */
7382 : float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
7383 : float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */
7384 : float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
7385 : const int16_t frameno, /* i : flag indicating index of current subframe*/
7386 : const int16_t sp_aud_decision0, /* i : sp_aud_decision0 */
7387 : const int32_t element_brate, /* i : element bitrate */
7388 : const int16_t mct_on /* i : flag mct block (1) or stereo (0) */
7389 : );
7390 :
7391 : void AnalyzePowerSpectrum(
7392 : Encoder_State *st, /* i/o: encoder states */
7393 : const int16_t L_frame, /* i : frame length */
7394 : const int16_t L_frameTCX, /* i : full band frame length */
7395 : const int16_t left_overlap, /* i : left overlap length */
7396 : const int16_t right_overlap, /* i : right overlap length */
7397 : const float mdctSpectrum[], /* i : MDCT spectrum */
7398 : const float signal[], /* i : windowed signal corresponding to mdctSpectrum */
7399 : float powerSpec[] /* o : Power spectrum */
7400 : );
7401 :
7402 : void lpc2mdct(
7403 : float *lpcCoeffs,
7404 : const int16_t lpcOrder,
7405 : float mdct_gains[],
7406 : const int16_t length,
7407 : const int16_t noInverse );
7408 :
7409 : void mdct_preShaping(
7410 : float x[],
7411 : const int16_t lg,
7412 : const float gains[] );
7413 :
7414 : void mdct_noiseShaping(
7415 : float x[],
7416 : const int16_t lg,
7417 : const float gains[],
7418 : const int16_t nBands );
7419 :
7420 : void AdaptLowFreqEmph(
7421 : float x[],
7422 : int16_t xq[],
7423 : float invGain,
7424 : const int16_t tcx_lpc_shaped_ari,
7425 : const float lpcGains[],
7426 : const int16_t lg );
7427 :
7428 : void PsychAdaptLowFreqEmph(
7429 : float x[],
7430 : const float lpcGains[] );
7431 :
7432 : void PsychAdaptLowFreqDeemph(
7433 : float x[],
7434 : const float lpcGains[],
7435 : float lf_deemph_factors[] );
7436 :
7437 : void AdaptLowFreqDeemph(
7438 : float x[],
7439 : int16_t tcx_lpc_shaped_ari,
7440 : const float lpcGains[],
7441 : const int16_t lg,
7442 : float lf_deemph_factors[] );
7443 :
7444 : /*! r: SQ gain */
7445 : float SQ_gain(
7446 : const float x[], /* i : vector to quantize */
7447 : const int16_t nbitsSQ, /* i : number of bits targeted */
7448 : const int16_t lg /* i : vector size (2048 max) */
7449 : );
7450 :
7451 : /*! r: SQ gain */
7452 : float SQ_gain_estimate(
7453 : const float x[], /* i : vector to quantize */
7454 : const int16_t nbitsSQ, /* i : number of bits targeted */
7455 : const int16_t lg /* i : vector size (2048 max) */
7456 : );
7457 :
7458 :
7459 : void tcx_scalar_quantization(
7460 : float *x, /* i : input coefficients */
7461 : int16_t *xq, /* o : quantized coefficients */
7462 : const int16_t L_frame, /* i : frame length */
7463 : const float gain, /* i : quantization gain */
7464 : const float offset, /* i : rounding offset (deadzone) */
7465 : int16_t *memQuantZeros, /* o : coefficients set to 0 */
7466 : const int16_t tcxonly );
7467 :
7468 : int16_t tcx_scalar_quantization_rateloop(
7469 : float *x, /* i : input coefficients */
7470 : int16_t *xq, /* o : quantized coefficients */
7471 : const int16_t L_frame, /* i : frame length */
7472 : float *gain, /* i/o: quantization gain */
7473 : float offset, /* i : rounding offset (deadzone) */
7474 : int16_t *memQuantZeros, /* o : coefficients set to 0 */
7475 : int16_t *lastnz_out, /* i/o: last nonzero coeff index */
7476 : const int16_t target, /* i : target number of bits */
7477 : int16_t *nEncoded, /* o : number of encoded coeff */
7478 : int16_t *stop, /* i/o: stop param */
7479 : 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) */
7480 : const int16_t sqBits_in, /* i : number of sqBits as determined in prev. quant. stage, using stop mechanism (ie always <= target bits) */
7481 : const int16_t tcxRateLoopOpt, /* i : turns on/off rateloop optimization */
7482 : const int16_t tcxonly,
7483 : CONTEXT_HM_CONFIG *hm_cfg,
7484 : const int16_t iter_max,
7485 : const int16_t element_mode );
7486 :
7487 : void tcx_QuantizeGain(
7488 : const int16_t n,
7489 : float *pGain,
7490 : int16_t *pQuantizedGain );
7491 :
7492 : void tcx_noise_factor(
7493 : const float *x_orig, /* i : unquantized mdct coefficients */
7494 : float *sqQ, /* i/o: quantized mdct coefficients */
7495 : const int16_t iFirstLine, /* i : first coefficient to be considered */
7496 : const int16_t lowpassLine, /* i : last nonzero coefficients after low-pass */
7497 : const int16_t nMinHoleSize, /* i : minimum size of hole to be checked */
7498 : const int16_t L_frame, /* i : frame length */
7499 : const float gain_tcx, /* i : tcx gain */
7500 : const float tiltCompFactor, /* i : LPC tilt compensation factor */
7501 : float *fac_ns, /* o : noise factor */
7502 : int16_t *quantized_fac_ns, /* o : quantized noise factor */
7503 : const int16_t element_mode /* i : IVAS element mode */
7504 : );
7505 :
7506 : void tcx_noise_filling(
7507 : float *Q,
7508 : const int16_t noiseFillSeed,
7509 : const int16_t iFirstLine,
7510 : const int16_t lowpassLine,
7511 : const int16_t nTransWidth,
7512 : const int16_t L_frame,
7513 : const float tiltCompFactor,
7514 : float fac_ns,
7515 : uint8_t *infoTCXNoise,
7516 : const int16_t element_mode /* i : IVAS element mode */
7517 : );
7518 :
7519 : void tcx_encoder_memory_update(
7520 : Encoder_State *st, /* i/o: encoder memory state */
7521 : float *xn_buf, /* i/o: mdct output buffer/TD weigthed synthesis */
7522 : const float *Ai, /* i : Unquantized (interpolated) LPC coefficients */
7523 : const float *A /* i : Quantized LPC coefficients */
7524 : );
7525 :
7526 : void tcx_decoder_memory_update(
7527 : Decoder_State *st, /* i/o: decoder memory state */
7528 : const float *xn_buf, /* i : mdct output buffer */
7529 : float *synth, /* i/o: synth */
7530 : const float *A /* i : Quantized LPC coefficients */
7531 : );
7532 :
7533 : /*! r: number of bits used (including "bits") */
7534 : int16_t tcx_ari_res_Q_spec(
7535 : const float x_orig[], /* i : original spectrum */
7536 : const int16_t signs[], /* i : signs (x_orig[.]<0) */
7537 : float x_Q[], /* i/o: quantized spectrum */
7538 : const int16_t L_frame, /* i : number of lines */
7539 : const float gain, /* i : TCX gain */
7540 : int16_t prm[], /* o : bitstream */
7541 : int16_t target_bits, /* i : number of bits available */
7542 : int16_t bits, /* i : number of bits used so far */
7543 : const float deadzone, /* i : quantizer deadzone */
7544 : const float x_fac[] /* i : spectrum post-quantization factors */
7545 : );
7546 :
7547 : /*! r: number of bits used (including "bits") */
7548 : int16_t tcx_ari_res_invQ_spec(
7549 : float x_Q[], /* i/o: quantized spectrum */
7550 : const int16_t L_frame, /* i : number of lines */
7551 : const int16_t prm[], /* i : bitstream */
7552 : int16_t target_bits, /* i : number of bits available */
7553 : int16_t bits, /* i : number of bits used so far */
7554 : const float deadzone, /* i : quantizer deadzone */
7555 : const float x_fac[] /* i : spectrum post-quantization factors */
7556 : );
7557 :
7558 : int16_t tcx_res_Q_gain(
7559 : float sqGain,
7560 : float *gain_tcx,
7561 : int16_t *prm,
7562 : int16_t sqTargetBits );
7563 :
7564 : int16_t tcx_res_Q_spec(
7565 : const float *x_orig,
7566 : float *x_Q,
7567 : const int16_t L_frame,
7568 : const float sqGain,
7569 : int16_t *prm,
7570 : int16_t sqTargetBits,
7571 : int16_t bits,
7572 : const float sq_round,
7573 : const float lf_deemph_factors[] );
7574 :
7575 : int16_t tcx_res_invQ_gain(
7576 : float *gain_tcx,
7577 : const int16_t *prm,
7578 : const int16_t resQBits );
7579 :
7580 : int16_t tcx_res_invQ_spec(
7581 : float *x,
7582 : const int16_t L_frame,
7583 : const int16_t *prm,
7584 : int16_t resQBits,
7585 : int16_t bits,
7586 : const float sq_round,
7587 : const float lf_deemph_factors[] );
7588 :
7589 : void InitTnsConfigs(
7590 : const int16_t bwidth,
7591 : const int16_t L_frame,
7592 : STnsConfig tnsConfig[2][2],
7593 : const int16_t igfStopFreq,
7594 : const int32_t total_brate,
7595 : const int16_t element_mode,
7596 : const int16_t MCT_flag );
7597 :
7598 : void SetAllowTnsOnWhite(
7599 : STnsConfig tnsConfig[2][2],
7600 : const int8_t allowTnsOnWhite );
7601 :
7602 : void SetTnsConfig(
7603 : TCX_CONFIG_HANDLE hTcxCfg,
7604 : const int16_t isTCX20,
7605 : const int16_t isAfterACELP );
7606 :
7607 : void ari_copy_states(
7608 : Tastat *source,
7609 : Tastat *dest );
7610 :
7611 : int32_t mul_sbc_14bits(
7612 : int32_t r,
7613 : int32_t c );
7614 :
7615 : void ari_start_encoding_14bits(
7616 : Tastat *s );
7617 :
7618 : int16_t ari_encode_14bits_ext(
7619 : int16_t *ptr,
7620 : int16_t bp,
7621 : Tastat *s,
7622 : int32_t symbol,
7623 : const uint16_t *cum_freq );
7624 :
7625 : int16_t ari_done_encoding_14bits(
7626 : int16_t *ptr,
7627 : int16_t bp,
7628 : Tastat *s );
7629 :
7630 : void ari_start_decoding_14bits(
7631 : Decoder_State *st,
7632 : Tastat *s );
7633 :
7634 : int16_t ari_start_decoding_14bits_prm(
7635 : const int16_t *ptr,
7636 : int16_t bp,
7637 : Tastat *s );
7638 :
7639 : void ari_decode_14bits_s17_ext(
7640 : Decoder_State *st,
7641 : uint16_t *res,
7642 : Tastat *s,
7643 : const uint16_t *cum_freq );
7644 :
7645 : void ari_decode_14bits_s27_ext(
7646 : Decoder_State *st,
7647 : uint16_t *res,
7648 : Tastat *s,
7649 : const uint16_t *cum_freq );
7650 :
7651 : void ari_decode_14bits_bit_ext(
7652 : Decoder_State *st,
7653 : uint16_t *res,
7654 : Tastat *s );
7655 :
7656 : /*! r: Q15 */
7657 : Word16 expfp(
7658 : const Word16 x, /* i : mantissa Q15-e */
7659 : const Word16 x_e /* i : exponent Q0 */
7660 : );
7661 :
7662 : void powfp_odd2(
7663 : const Word16 base, /* Q15 */
7664 : const Word16 exp, /* Q0 */
7665 : Word16 *pout1, /* Q15 */
7666 : Word16 *pout2 /* Q15 */
7667 : );
7668 :
7669 : void tcx_arith_scale_envelope(
7670 : const Word16 L_spec_core, /* i : number of lines to scale Q0 */
7671 : Word16 L_frame, /* i : number of lines Q0 */
7672 : const Word32 env[], /* i : unscaled envelope Q16 */
7673 : Word16 target_bits, /* i : number of available bits Q0 */
7674 : const Word16 low_complexity, /* i : low-complexity flag Q0 */
7675 : Word16 s_env[], /* o : scaled envelope Q15-e */
7676 : Word16 *s_env_e /* o : scaled envelope exponent Q0 */
7677 : );
7678 :
7679 : void tcx_arith_render_envelope(
7680 : const Word16 A_ind[], /* i : LPC coefficients of signal envelope */
7681 : const Word16 L_frame, /* i : number of spectral lines */
7682 : const Word16 L_spec, /* i : length of the coded spectrum */
7683 : const Word16 preemph_fac, /* i : pre-emphasis factor */
7684 : const Word16 gamma_w, /* i : A_ind -> weighted envelope factor */
7685 : const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor */
7686 : Word32 env[] /* o : shaped signal envelope */
7687 : );
7688 :
7689 : int16_t ari_encode_14bits_range(
7690 : int16_t *ptr,
7691 : int16_t bp,
7692 : int32_t bits,
7693 : Tastat *s,
7694 : uint16_t cum_freq_low,
7695 : uint16_t cum_freq_high );
7696 :
7697 : int16_t ari_encode_14bits_sign(
7698 : int16_t *ptr,
7699 : int16_t bp,
7700 : int32_t bits,
7701 : Tastat *s,
7702 : int32_t sign );
7703 :
7704 : int16_t ari_done_cbr_encoding_14bits(
7705 : int16_t *ptr,
7706 : int16_t bp,
7707 : int32_t bits,
7708 : Tastat *s );
7709 :
7710 : int16_t ari_decode_14bits_pow(
7711 : const int16_t *ptr,
7712 : int16_t bp,
7713 : int16_t bits,
7714 : int16_t *res,
7715 : Tastat *s,
7716 : uint16_t base );
7717 :
7718 : int16_t ari_decode_14bits_sign(
7719 : const int16_t *ptr,
7720 : int16_t bp,
7721 : int16_t bits,
7722 : uint16_t *res,
7723 : Tastat *s );
7724 :
7725 : void tcx_arith_encode_envelope(
7726 : float spectrum[], /* i/o: MDCT coefficients */
7727 : int16_t signs[], /* o : signs (spectrum[.]<0) */
7728 : const int16_t L_frame, /* i : frame or MDCT length */
7729 : const int16_t L_spec, /* i : length w/o BW limitation */
7730 : Encoder_State *st, /* i/o: coder state */
7731 : const Word16 A_ind[], /* i : quantised LPC coefficients */
7732 : int16_t target_bits, /* i : number of available bits */
7733 : int16_t prm[], /* o : bitstream parameters */
7734 : const int16_t use_hm, /* i : use HM in current frame? */
7735 : int16_t prm_hm[], /* o : HM parameter area */
7736 : const int16_t tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/
7737 : int16_t *arith_bits, /* o : bits used for ari. coding */
7738 : int16_t *signaling_bits, /* o : bits used for signaling */
7739 : const int16_t low_complexity /* i : low-complexity flag */
7740 : );
7741 :
7742 : void tcx_arith_decode_envelope(
7743 : Decoder_State *st, /* i/o: coder state */
7744 : float q_spectrum[], /* o : quantised MDCT coefficients */
7745 : const int16_t L_frame, /* i : frame or MDCT length */
7746 : int16_t L_spec, /* i : length w/o BW limitation */
7747 : const Word16 A_ind[], /* i : quantised LPC coefficients */
7748 : const int16_t target_bits, /* i : number of available bits */
7749 : const int16_t prm[], /* i : bitstream parameters */
7750 : const int16_t use_hm, /* i : use HM in current frame? */
7751 : const int16_t prm_hm[], /* i : HM parameter area */
7752 : int16_t tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/
7753 : int16_t *arith_bits, /* o : bits used for ari. coding */
7754 : int16_t *signaling_bits, /* o : bits used for signaling */
7755 : const int16_t low_complexity /* i : low-complexity flag */
7756 : );
7757 :
7758 : void UnmapIndex(
7759 : const int16_t PeriodicityIndex,
7760 : const int16_t Bandwidth,
7761 : const int16_t LtpPitchLag,
7762 : const int16_t SmallerLags,
7763 : int16_t *FractionalResolution,
7764 : int32_t *Lag );
7765 :
7766 : /*! r: PeriodicityIndex */
7767 : int16_t SearchPeriodicityIndex(
7768 : const float Mdct[], /* i : Coefficients, Mdct[0..NumCoeffs-1] */
7769 : const float UnfilteredMdct[], /* i : Unfiltered coefficients, UnfilteredMdct[0..NumCoeffs-1] */
7770 : const int16_t NumCoeffs, /* i : Number of coefficients */
7771 : const int16_t shortTargetBits, /* i : Target bit budget (excl. Done flag) */
7772 : const int16_t LtpPitchLag, /* i : TCX-LTP pitch */
7773 : const float LtpGain, /* i : LTP gain */
7774 : float *RelativeScore /* o : Energy concentration factor */
7775 : );
7776 :
7777 : void ConfigureContextHm(
7778 : const int16_t NumCoeffs, /* i : Number of coefficients */
7779 : const int16_t TargetBits, /* i : Target bit budget (excl. Done flag) */
7780 : const int16_t PeriodicityIndex, /* i : Pitch related index */
7781 : const int16_t LtpPitchLag, /* i : TCX-LTP pitch in F.D. */
7782 : CONTEXT_HM_CONFIG *hm_cfg /* o : Context-based harmonic model configuration */
7783 : );
7784 :
7785 : int16_t EncodeIndex(
7786 : const int16_t Bandwidth, /* o : NB, 1: (S)WB */
7787 : int16_t PeriodicityIndex,
7788 : BSTR_ENC_HANDLE hBstr );
7789 :
7790 : int16_t CountIndexBits(
7791 : const int16_t Bandwidth, /* o : NB, 1: (S)WB */
7792 : const int16_t PeriodicityIndex );
7793 :
7794 : int16_t DecodeIndex(
7795 : Decoder_State *st,
7796 : const int16_t Bandwidth, /* o : NB, 1: (S)WB */
7797 : int16_t *PeriodicityIndex );
7798 :
7799 : #define GET_ADJ( T, L ) GET_ADJ2( T, L, *FractionalResolution )
7800 : #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) )
7801 :
7802 : int16_t tcx_hm_render(
7803 : const int32_t lag, /* i : pitch lag */
7804 : const int16_t fract_res, /* i : fractional resolution of the lag */
7805 : Word16 p[] /* o : harmonic model (Q13) */
7806 : );
7807 :
7808 : void tcx_hm_modify_envelope(
7809 : const Word16 gain, /* i : HM gain (Q11) */
7810 : const int32_t lag,
7811 : const int16_t fract_res,
7812 : const Word16 p[], /* i : harmonic model (Q13) */
7813 : Word32 env[], /* i/o: envelope (Q16) */
7814 : const int16_t L_frame /* i : number of spectral lines */
7815 : );
7816 :
7817 : void tcx_hm_analyse(
7818 : const float abs_spectrum[], /* i : absolute spectrum */
7819 : const int16_t L_frame, /* i : number of spectral lines */
7820 : Word32 env[], /* i/o: envelope shape (Q16) */
7821 : const int16_t targetBits, /* i : target bit budget */
7822 : const int16_t coder_type, /* i : GC/VC coder type */
7823 : int16_t prm_hm[], /* o : HM parameters */
7824 : int16_t LtpPitchLag, /* i : LTP pitch lag or -1 if none */
7825 : const float LtpGain, /* i : LTP gain */
7826 : int16_t *hm_bits /* o : bit consumption */
7827 : );
7828 :
7829 : void tcx_hm_decode(
7830 : const int16_t L_frame, /* i : number of spectral lines */
7831 : Word32 env[], /* i/o: envelope shape (Q16) */
7832 : const int16_t targetBits, /* i : target bit budget */
7833 : const int16_t coder_type, /* i : GC/VC coder type */
7834 : const int16_t prm_hm[], /* i : HM parameters */
7835 : const int16_t LtpPitchLag, /* i : LTP pitch lag or -1 if none */
7836 : int16_t *hm_bits /* o : bit consumption */
7837 : );
7838 :
7839 : void coder_tcx(
7840 : Encoder_State *st, /* i/o: encoder state structure */
7841 : TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */
7842 : const float A[], /* i : quantized coefficients NxAz_q[M+1] */
7843 : const Word16 Aqind[], /* i : frame-independent quantized coefficients (M+1) */
7844 : float synth[], /* o : decoded synthesis */
7845 : const int16_t L_frame_glob, /* i : frame length */
7846 : const int16_t L_frameTCX_glob,
7847 : const int16_t L_spec,
7848 : int16_t nb_bits, /* i : bit budget */
7849 : float spectrum[], /* i/o: MDCT spectrum */
7850 : int16_t prm[], /* o : tcx parameters */
7851 : CONTEXT_HM_CONFIG *hm_cfg,
7852 : const int16_t vad_hover_flag /* i : VAD hangover flag */
7853 : );
7854 :
7855 : void coder_tcx_post(
7856 : Encoder_State *st, /* i/o: encoder memory state */
7857 : float *A, /* o : Quantized LPC coefficients */
7858 : const float *Ai /* i : Unquantized (interpolated) LPC coefficients */
7859 : );
7860 :
7861 : void decoder_tcx(
7862 : Decoder_State *st, /* i/o: coder memory state */
7863 : int16_t prm[], /* i : parameters */
7864 : float A[], /* i : coefficients NxAz[M+1] */
7865 : Word16 Aind[], /* i : frame-independent coefficients Az[M+1]*/
7866 : float synth[], /* i/o: synth[-M..lg] */
7867 : float synthFB[], /* i/o: encoder memory state */
7868 : const int16_t bfi, /* i : Bad frame indicator */
7869 : const int16_t frame_cnt, /* i : frame counter in the super_frame */
7870 : const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */
7871 : );
7872 :
7873 : void decoder_tcx_post(
7874 : Decoder_State *st, /* i/o: decoder memory state */
7875 : float *synth,
7876 : float *synthFB,
7877 : float *A, /* i : A(z) filter coefficients */
7878 : const int16_t bfi,
7879 : const int16_t isMCT );
7880 :
7881 : void coder_acelp(
7882 : Encoder_State *st, /* i/o: coder memory state */
7883 : const float A[], /* i : coefficients 4xAz[M+1] */
7884 : const float Aq[], /* i : coefficients 4xAz_q[M+1] */
7885 : const float speech[], /* i : speech[-M..lg] */
7886 : LPD_state *LPDmem, /* i/o: ACELP memories */
7887 : int16_t *prm, /* o : acelp parameters */
7888 : const float stab_fac,
7889 : const int16_t target_bits,
7890 : float *gain_pitch_buf, /* o : gain pitch values */
7891 : float *gain_code_buf, /* o : gain code values */
7892 : float *pitch_buf, /* o : pitch values for each subfr.*/
7893 : float *voice_factors, /* o : voicing factors */
7894 : float *bwe_exc /* o : excitation for SWB TBE */
7895 : );
7896 :
7897 : void coder_acelp_rf(
7898 : const int16_t target_bits, /* i : target bits */
7899 : const float speech[], /* i : speech[-M..lg] */
7900 : const int16_t coder_type, /* i : coding type */
7901 : const int16_t rf_frame_type, /* i : rf_frame_type */
7902 : const float A[], /* i : coefficients 4xAz[M+1] */
7903 : const float Aq[], /* i : coefficients 4xAz_q[M+1] */
7904 : const float voicing[], /* i : open-loop LTP gain */
7905 : const int16_t T_op[], /* i : open-loop LTP lag */
7906 : const float stab_fac, /* i : LP stability factor */
7907 : Encoder_State *st, /* i/o: coder memory state */
7908 : ACELP_config *acelp_cfg, /* i/o: configuration of the ACELP */
7909 : float *exc_rf, /* i/o: pointer to RF excitation */
7910 : float *syn_rf /* i/o: pointer to RF synthesis */
7911 : );
7912 :
7913 : void decoder_acelp(
7914 : Decoder_State *st, /* i/o: coder memory state */
7915 : int16_t prm[], /* i : parameters */
7916 : const float A[], /* i : coefficients NxAz[M+1] */
7917 : ACELP_config acelp_cfg, /* i : ACELP config */
7918 : float synth[], /* i/o: synthesis */
7919 : int16_t *pT, /* o : pitch for all subframe */
7920 : float *pgainT, /* o : pitch gain for all subfr */
7921 : const float stab_fac, /* i : stability of isf */
7922 : float *pitch_buffer, /* o : pitch values for each subfr.*/
7923 : float *voice_factors, /* o : voicing factors */
7924 : const int16_t LSF_Q_prediction, /* i : LSF prediction mode */
7925 : float *bwe_exc /* o : excitation for SWB TBE */
7926 : );
7927 :
7928 : void writeTCXMode(
7929 : Encoder_State *st, /* i/o: encoder state structure */
7930 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
7931 : const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/
7932 : int16_t *nbits_start /* o : nbits start */
7933 : );
7934 :
7935 : void writeTCXWindowing(
7936 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
7937 : const int16_t overlap_mode /* i : overlap mode */
7938 : );
7939 :
7940 : void writeLPCparam(
7941 : Encoder_State *st, /* i/o: encoder state structure */
7942 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
7943 : const int16_t param_lpc[], /* i : LPC parameters to write */
7944 : const int16_t bits_param_lpc[], /* i : bits per LPC parameter */
7945 : const int16_t no_param_lpc, /* i : number of LPC parameters */
7946 : int16_t *nbits_lpc /* o : LPC bits written */
7947 : );
7948 :
7949 : void enc_prm(
7950 : Encoder_State *st, /* i/o: encoder state structure */
7951 : int16_t param[], /* i : parameters */
7952 : int16_t param_lpc[], /* i : LPC parameters */
7953 : CONTEXT_HM_CONFIG hm_cfg[],
7954 : const int16_t bits_param_lpc[],
7955 : const int16_t no_param_lpc );
7956 :
7957 : void writeTCXparam(
7958 : Encoder_State *st, /* i/o: Encoder State handle */
7959 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
7960 : CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */
7961 : int16_t param[], /* i : parameters */
7962 : const int16_t nbits_header,
7963 : const int16_t nbits_start,
7964 : const int16_t nbits_lpc,
7965 : const int16_t *no_param_tns, /* i : number of TNS parameters per subframe */
7966 : int16_t p_param[2], /* i/o: pointer to parameters from previous bs writing */
7967 : const int16_t target_bitsTCX10[2],
7968 : const int16_t pre_past_flag );
7969 :
7970 : void enc_prm_rf(
7971 : Encoder_State *st, /* i/o: encoder memory state */
7972 : const int16_t rf_frame_type,
7973 : const int16_t fec_offset );
7974 :
7975 : void dec_prm_hm(
7976 : Decoder_State *st, /* i/o: decoder memory state */
7977 : int16_t *prm_hm,
7978 : const int16_t hm_size );
7979 :
7980 : void dec_prm(
7981 : Decoder_State *st, /* i/o: decoder memory state */
7982 : int16_t param[], /* o : decoded parameters */
7983 : int16_t param_lpc[], /* i : LPC parameters */
7984 : int16_t *total_nbbits, /* i/o: number of bits / decoded bits */
7985 : int16_t *bitsRead );
7986 :
7987 : void gauss_L2(
7988 : const float h[], /* i : weighted LP filter impulse response */
7989 : float code[], /* o : gaussian excitation */
7990 : float y2[], /* i : zero-memory filtered code. excitation */
7991 : float y11[], /* o : zero-memory filtered gauss. excitation */
7992 : float *gain, /* o : excitation gain */
7993 : float g_corr[], /* i/o: correlation structure for gain coding */
7994 : float tilt_code, /* i : tilt of code */
7995 : const float *Aq, /* i : quantized LPCs */
7996 : float formant_enh_num, /* i : formant enhancement factor */
7997 : int16_t *seed_acelp /* i/o: random seed */
7998 : );
7999 :
8000 : void gaus_L2_dec(
8001 : float *code, /* o : decoded gaussian codevector */
8002 : float tilt_code,
8003 : const float *A,
8004 : float formant_enh_num,
8005 : int16_t *seed_acelp /* i/o: random seed */
8006 : );
8007 :
8008 : /*! r: interpolated value */
8009 : float interpolation(
8010 : const float *x, /* i : input vector */
8011 : const float *win, /* i : interpolation window */
8012 : const int16_t frac, /* i : fraction */
8013 : const int16_t up_samp, /* i : upsampling factor */
8014 : const int16_t nb_coef /* i : nb of filter coef */
8015 : );
8016 :
8017 : void predict_signal(
8018 : const float excI[], /* i : input excitation buffer */
8019 : float excO[], /* o : output excitation buffer */
8020 : const int16_t T0, /* i : integer pitch lag */
8021 : int16_t frac, /* i : fraction of lag */
8022 : const int16_t frac_max, /* i : max fraction */
8023 : const int16_t L_subfr /* i : subframe size */
8024 : );
8025 :
8026 : void tcx_ltp_encode(
8027 : Encoder_State *st,
8028 : const int16_t tcxMode,
8029 : const int16_t L_frame,
8030 : const float *speech,
8031 : float *speech_ltp,
8032 : const float *wsp,
8033 : const int16_t Top[],
8034 : int16_t *ltp_param,
8035 : int16_t *ltp_bits,
8036 : float *A,
8037 : const int16_t disable_ltp,
8038 : const int16_t element_mode );
8039 :
8040 : void tcx_ltp_post(
8041 : Decoder_State *st,
8042 : TCX_LTP_DEC_HANDLE hTcxLtpDec,
8043 : const int16_t core,
8044 : const int16_t output_frame,
8045 : const int16_t L_frame,
8046 : float sig[],
8047 : const float tcx_buf[] );
8048 :
8049 : int16_t tcx_ltp_decode_params(
8050 : int16_t *ltp_param,
8051 : int16_t *pitch_int,
8052 : int16_t *pitch_fr,
8053 : float *gain,
8054 : const int16_t pitmin,
8055 : const int16_t pitfr1,
8056 : const int16_t pitfr2,
8057 : const int16_t pitmax,
8058 : const int16_t pitres );
8059 :
8060 : int16_t enc_lsf_tcxlpc(
8061 : const int16_t **indices, /* i : Ptr to VQ indices */
8062 : BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
8063 : );
8064 :
8065 : void msvq_enc(
8066 : const float *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */
8067 : const int16_t dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */
8068 : const int16_t offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */
8069 : const float u[], /* i : Vector to be encoded (prediction and mean removed) */
8070 : const int16_t *levels, /* i : Number of levels in each stage */
8071 : const int16_t maxC, /* i : Tree search size (number of candidates kept from one stage to the next == M-best) */
8072 : const int16_t stages, /* i : Number of stages */
8073 : const float w[], /* i : Weights */
8074 : const int16_t N, /* i : Vector dimension */
8075 : const int16_t maxN, /* i : Codebook dimension */
8076 : const int16_t applyDCT_flag, /* i : applyDCT flag */
8077 : float *invTrfMatrix, /* i/o: expanded synthesis matrix */
8078 : int16_t Idx[] /* o : Indices */
8079 : );
8080 :
8081 : void msvq_dec(
8082 : const float *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */
8083 : const int16_t dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */
8084 : const int16_t offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */
8085 : const int16_t stages, /* i : Number of stages */
8086 : const int16_t N, /* i : Vector dimension */
8087 : const int16_t maxN, /* i : Codebook dimension */
8088 : const int16_t Idx[], /* i : Indices */
8089 : const int16_t applyIDCT_flag, /* i : applyIDCT flag */
8090 : const float *invTrfMatrix, /* i : synthesis matrix */
8091 : float *uq, /* o : quantized vector */
8092 : Word16 *uq_ind /* o : quantized vector (fixed point) */
8093 : );
8094 :
8095 :
8096 : void dec_FDCNG_MSVQ_stage1(
8097 : int16_t j_full, /* i : index full range */
8098 : int16_t n, /* i : dimension to generate */
8099 : const float *invTrfMatrix, /* i : IDCT matrix for synthesis */
8100 : const DCTTYPE idcttype, /* i : specify which IDCT */
8101 : float *uq, /* o : synthesized stage1 vector */
8102 : Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */
8103 : );
8104 :
8105 : void create_IDCT_N_Matrix(
8106 : float *inv_matrixFloatQ, /* i/o: RAM buffer */
8107 : const int16_t N, /* i : DCT length, number of time samples */
8108 : const int16_t n_cols, /* i : number of dct coeffs (as DCT may be truncated) */
8109 : const int16_t alloc_size /* i : RAM buffer size in elements */
8110 : );
8111 :
8112 : void dctT2_N_apply_matrix(
8113 : const float *input, /* i : input in fdcng or DCT(fdcng) domain */
8114 : float *output, /* o : output in DCT(fdcng) or fdcng ordomain */
8115 : const int16_t dct_dim, /* i : dct processing dim possibly truncated */
8116 : const int16_t fdcngvq_dim, /* i : fdcng domain length */
8117 : const float *matrix, /* i : IDCT matrix */
8118 : const int16_t matrix_row_dim, /* i : */
8119 : const DCTTYPE dcttype /* i : matrix operation type */
8120 : );
8121 :
8122 : void extend_dctN_input(
8123 : const float *input, /* i : input in fdcng domain */
8124 : const float *dct_input, /* i : input in dctN(fdcng) domain */
8125 : const int16_t in_dim, /* i : in_dim == N */
8126 : float *ext_sig, /* o : extended output in fdcng domain */
8127 : const int16_t out_dim, /* i : output total dim */
8128 : float *matrix, /* i : idct synthesis matrix N rows, n_cols columns */
8129 : const int16_t n_cols, /* i : number of columns == DCT truncation length */
8130 : const DCTTYPE dcttype /* i : matrix operation type */
8131 : );
8132 :
8133 : /*! r: (p_max , best candidate sofar ) */
8134 : int16_t msvq_stage1_dct_search(
8135 : const float *u, /* i : target */
8136 : const int16_t N, /* i : target length and IDCT synthesis length */
8137 : const int16_t maxC_st1, /* i : number of final stage 1 candidates to provide */
8138 : const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */
8139 : const int16_t max_dct_trunc, /* i : maximum of truncation lenghts */
8140 : float *invTrfMatrix, /* i : IDCT synthesis matrix for dim N */
8141 : const float *midQ_truncQ, /* i : midQ vector */
8142 : const float *dct_invScaleF, /* i : global inv scale factors */
8143 : const float *dct_scaleF, /* i : global scale factors */
8144 : const Word16 n_segm, /* i : number of segments */
8145 : const Word16 *cols_per_segment, /* i : remaining length per segment */
8146 : const Word16 *trunc_dct_cols_per_segment, /* i : trunc length per segment */
8147 : const Word16 *entries_per_segment, /* i : number of rows per segment */
8148 : const Word16 *cum_entries_per_segment, /* i : number of cumulative entries */
8149 : const Word8 *const W8Qx_dct_sections[], /* i : Word8(byte) segment table ptrs */
8150 : const Word16 *col_syn_shift[], /* i : columnwise syn shift tables */
8151 : const Word8 *segm_neighbour_fwd, /* i : circular neighbour list fwd */
8152 : const Word8 *segm_neighbour_rev, /* i : circular neighbour list reverse */
8153 : const Word16 npost_check, /* i : number of neigbours to check , should be even */
8154 : float *st1_mse_ptr, /* i : dynRAM buffer for MSEs */
8155 : int16_t *indices_st1_local, /* o : selected cand indices */
8156 : float *st1_syn_vec_ptr, /* i/o: buffer for IDCT24 synthesis */
8157 : float *dist1_ptr /* o : resulting stage 1 MSEs in DCT-N domain */
8158 : );
8159 :
8160 : /*! r: (updated p_max) */
8161 : int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb(
8162 : const float *st1_syn_vec_ptr, /* i : IDCT24 synthesis vectors */
8163 : const float *u, /* i : target signal */
8164 : const int16_t maxC_st1, /* i : number of candidates in stage1 */
8165 : float *dist_ptr /* i/o: updated MSE vector for stage1 */
8166 : );
8167 :
8168 : void PulseResynchronization(
8169 : const float *src_exc, /* i : Input excitation buffer */
8170 : float *dst_exc, /* o : output excitation buffer */
8171 : const int16_t nFrameLength, /* i : frame length */
8172 : const int16_t nSubframes, /* i : Number of subframes */
8173 : const float pitchStart, /* i : Pitch at the end of the last frame */
8174 : const float pitchEnd /* i : Pitch at the end of the current frame */
8175 : );
8176 :
8177 : void con_acelp(
8178 : float A[], /* i : coefficients NxAz[M+1] */
8179 : const int16_t coder_type, /* i : ACELP coder type */
8180 : float synth[], /* i/o: synthesis */
8181 : int16_t *pT, /* o : pitch for all subframe */
8182 : float *pgainT, /* o : pitch gain for all subfr */
8183 : float stab_fac, /* i : stability of isf */
8184 : Decoder_State *st, /* i/o: coder memory state */
8185 : float pitch_buffer[], /* i/o: floating pitch values for each subframe */
8186 : float *voice_factors, /* o : voicing factors */
8187 : float *bwe_exc /* o : excitation for SWB TBE */
8188 : );
8189 :
8190 : void con_tcx(
8191 : Decoder_State *st, /* i/o: coder memory state */
8192 : float synth[], /* i/o: synth[] */
8193 : const float coh, /* i : coherence of stereo signal */
8194 : int16_t *noise_seed, /* i/o: noise seed for stereo */
8195 : const int16_t only_left, /* i : TD-PLC only in left channel */
8196 : const float A_cng[] /* i : CNG LP filter coefficients */
8197 : );
8198 :
8199 : /*! r: codebook index */
8200 : int16_t tcxlpc_get_cdk(
8201 : const int16_t coder_type /* i : GC/VC indicator */
8202 : );
8203 :
8204 : int16_t lsf_msvq_ma_encprm(
8205 : BSTR_ENC_HANDLE hBstr,
8206 : const int16_t *param_lpc,
8207 : const int16_t core,
8208 : const int16_t acelp_mode,
8209 : const int16_t acelp_midLpc,
8210 : const int16_t bits_param_lpc[],
8211 : const int16_t no_indices );
8212 :
8213 : int16_t lsf_msvq_ma_decprm(
8214 : Decoder_State *st,
8215 : int16_t *param_lpc );
8216 :
8217 : int16_t dec_lsf_tcxlpc(
8218 : Decoder_State *st, /* i : Decoder state */
8219 : int16_t **indices, /* o : Ptr to VQ indices */
8220 : const int16_t narrowband, /* i : narrowband flag */
8221 : const int16_t cdk /* i : codebook selector */
8222 : );
8223 :
8224 : int16_t D_lsf_tcxlpc(
8225 : const int16_t indices[], /* i : VQ indices */
8226 : float lsf_q[], /* o : quantized lsf */
8227 : Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */
8228 : const int16_t narrowband, /* i : narrowband flag */
8229 : const int16_t cdk, /* i : codebook selector */
8230 : const float mem_MA[] /* i : MA memory */
8231 : );
8232 :
8233 : void lsf_update_memory(
8234 : const int16_t narrowband, /* i : narrowband flag */
8235 : const float qlsf[], /* i : quantized lsf coefficients */
8236 : float old_mem_MA[], /* i : MA memory */
8237 : float mem_MA[] /* o : updated MA memory */
8238 : );
8239 :
8240 : int16_t Q_lsf_tcxlpc(
8241 : /* const */ float lsf[], /* i : original lsf */
8242 : float lsf_q[], /* o : quantized lsf */
8243 : Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */
8244 : int16_t indices[], /* o : VQ indices */
8245 : const int16_t narrowband, /* i : narrowband flag */
8246 : const int16_t cdk, /* i : codebook selector */
8247 : const float mem_MA[], /* i : MA memory */
8248 : const int16_t coder_type, /* i : acelp extended mode */
8249 : const float *Bin_Ener /* i : Spectrum energy */
8250 : );
8251 :
8252 : int16_t E_LPC_lsp_unweight(
8253 : const float lsp_w[], /* i : weighted lsp */
8254 : float lsp_uw[], /* o : unweighted lsp */
8255 : float lsf_uw[], /* o : unweighted lsf */
8256 : const float inv_gamma /* i : inverse weighting factor */
8257 : );
8258 :
8259 : int16_t lsf_ind_is_active(
8260 : const Word16 lsf_q_ind[],
8261 : const float means[],
8262 : const int16_t narrowband,
8263 : const int16_t cdk );
8264 :
8265 : void midlsf_enc(
8266 : const float qlsf0[],
8267 : const float qlsf1[],
8268 : const float lsf[],
8269 : int16_t *idx,
8270 : const int16_t N,
8271 : const float *Bin_Ener,
8272 : const int16_t narrowBand,
8273 : const int32_t sr_core,
8274 : const int16_t coder_type );
8275 :
8276 : void midlsf_dec(
8277 : const float qlsf0[],
8278 : const float qlsf1[],
8279 : const int16_t idx,
8280 : float qlsf[],
8281 : const int16_t N,
8282 : const int16_t coder_type,
8283 : int16_t *mid_lsf_int,
8284 : const int16_t prev_bfi,
8285 : const int16_t safety_net );
8286 :
8287 : void lsf_end_enc(
8288 : Encoder_State *st,
8289 : const float *lsf,
8290 : float *qlsf,
8291 : const int16_t nBits,
8292 : const int16_t coder_type_org,
8293 : const int16_t force_sf,
8294 : int16_t *lpc_param,
8295 : int16_t *no_stages,
8296 : int16_t *bits_param_lpc,
8297 : const int16_t coder_type_raw,
8298 : const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
8299 : );
8300 :
8301 : void lsf_end_dec(
8302 : Decoder_State *st, /* i/o: decoder state structure */
8303 : const int16_t coder_type_org, /* i : coding type */
8304 : const int16_t bwidth, /* i : input signal bandwidth */
8305 : const int16_t nBits, /* i : number of bits used for ISF quantization*/
8306 : float *qlsf, /* o : quantized LSFs in the cosine domain */
8307 : int16_t *lpc_param, /* i : LPC parameters */
8308 : int16_t *LSF_Q_prediction, /* o : LSF prediction mode */
8309 : int16_t *nb_indices, /* o : number of indices */
8310 : const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
8311 : );
8312 :
8313 : ivas_error find_pred_mode(
8314 : int16_t *predmode,
8315 : const int16_t coder_type,
8316 : const int16_t bwidth,
8317 : const int32_t int_fs,
8318 : int16_t *p_mode_lvq,
8319 : int16_t *p_mode_lvq_p,
8320 : const int32_t core_brate );
8321 :
8322 : void lpc_quantization(
8323 : Encoder_State *st,
8324 : const float lsp[],
8325 : const float lspmid[],
8326 : float lsp_q[],
8327 : float lsf_q[],
8328 : float lspmid_q[],
8329 : const int16_t coder_type,
8330 : const int16_t acelp_midLpc,
8331 : int16_t param_lpc[],
8332 : int16_t nbits_lpc[],
8333 : int16_t *bits_param_lpc,
8334 : int16_t *no_param_lpc );
8335 :
8336 : void lpc_unquantize(
8337 : Decoder_State *st,
8338 : float *lsf,
8339 : float *lsp,
8340 : int16_t *param_lpc,
8341 : float *lspmid,
8342 : float *lsfmid,
8343 : const int16_t coder_type,
8344 : int16_t *LSF_Q_prediction /* o : LSF prediction mode */
8345 : );
8346 :
8347 : void dlpc_bfi(
8348 : const int16_t L_frame,
8349 : float *lsf_q, /* o : quantized lsfs */
8350 : const float *lsfold, /* i : past quantized lsf */
8351 : const int16_t last_good, /* i : last good received frame */
8352 : const int16_t nbLostCmpt, /* i : counter of consecutive bad frames */
8353 : float mem_MA[], /* i/o: quantizer memory for MA model */
8354 : float mem_AR[], /* i/o: quantizer memory for MA model */
8355 : float *stab_fac, /* i : lsf stability factor */
8356 : float *lsf_adaptive_mean, /* i : lsf adaptive mean, updated when BFI==0 */
8357 : const int16_t numlpc, /* i : Number of division per superframe */
8358 : float lsf_cng[],
8359 : const int16_t plcBackgroundNoiseUpdated,
8360 : float *lsf_q_cng, /* o : quantized lsfs of background noise */
8361 : float *old_lsf_q_cng, /* o : old quantized lsfs for background noise */
8362 : const float lsfBase[] /* i : base for differential lsf coding */
8363 : );
8364 :
8365 : void lsf_dec_bfi(
8366 : const int16_t codec_mode, /* i : codec_mode: MODE1 | MODE2 */
8367 : float *lsf, /* o : estimated LSF vector */
8368 : const float *lsfold, /* i : past quantized lsf */
8369 : float *lsf_adaptive_mean, /* i : lsf adaptive mean, updated when BFI==0 */
8370 : const float lsfBase[], /* i : base for differential lsf coding */
8371 : float *mem_MA, /* i/o: quantizer memory for MA model */
8372 : float *mem_AR, /* o : quantizer memory for AR model */
8373 : const float stab_fac, /* i : lsf stability factor */
8374 : const int16_t last_coder_type, /* i : last coder type */
8375 : const int16_t L_frame, /* i : frame length */
8376 : const int16_t last_good, /* i : last good received frame */
8377 : const int16_t nbLostCmpt, /* i : counter of consecutive bad frames */
8378 : const int16_t plcBackgroundNoiseUpdated, /* i : background noise already updated? */
8379 : float *lsf_q_cng, /* o : quantized lsfs of background noise */
8380 : float *lsf_cng, /* i : long term target for fading to bg noise*/
8381 : float *old_lsf_q_cng, /* o : old quantized lsfs for background noise*/
8382 : const int16_t Last_GSC_pit_band_idx, /* i : AC mode (GSC) - Last pitch band index */
8383 : const int16_t Opt_AMR_WB, /* i : IO flag */
8384 : const int16_t bwidth /* i : coded bandwidth */
8385 : );
8386 :
8387 : const float *PlcGetlsfBase(
8388 : const int16_t pcQuantization,
8389 : const int16_t narrowBand,
8390 : const int32_t sr_core );
8391 :
8392 : void Unified_weighting(
8393 : const float Bin_Ener_128[], /* i : FFT Bin energy 128 bins in two sets */
8394 : const float lsf[], /* i : LSF vector */
8395 : float w[], /* o : LP weighting filter (numerator) */
8396 : const int16_t narrowBand, /* i : flag for Narrowband */
8397 : const int16_t unvoiced, /* i : flag for Unvoiced frame */
8398 : const int32_t sr_core, /* i : sampling rate of core-coder */
8399 : const int16_t order /* i : LP order */
8400 : );
8401 :
8402 : int16_t vad_init(
8403 : VAD_CLDFB_HANDLE hVAD_CLDFB /* i/o: CLDFB VAD state */
8404 : );
8405 :
8406 : int16_t vad_proc(
8407 : float realValues[16][60], /* i : CLDFB real values */
8408 : float imagValues[16][60], /* i : CLDFB imag values */
8409 : float *sb_power, /* i/o: Energy of CLDFB data */
8410 : const int16_t numBands, /* i : number of input bands */
8411 : VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
8412 : int16_t *cldfb_addition,
8413 : const int16_t vada_flag /* i : VAD flag */
8414 : );
8415 :
8416 : void subband_FFT(
8417 : float Sr[16][60], /* i : real part */
8418 : float Si[16][60], /* i : imag part */
8419 : float *spec_amp /* o : spectral amplitude */
8420 : );
8421 :
8422 : int16_t update_decision(
8423 : VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
8424 : const float snr, /* i : frequency domain SNR */
8425 : const float tsnr, /* i : time domain SNR */
8426 : const float frame_energy, /* i : current frame energy */
8427 : const float high_eng, /* i : current frame high frequency energy */
8428 : const int16_t vad_flag, /* i : VAD flag */
8429 : const int16_t music_backgound_f /* i : background music flag */
8430 : );
8431 :
8432 : void frame_spec_dif_cor_rate(
8433 : float spec_amp[], /* i : spectral amplitude */
8434 : float pre_spec_low_dif[], /* i/o: low spectrum different */
8435 : float f_tonality_rate[] /* o : tonality rate */
8436 : );
8437 :
8438 : void ltd_stable(
8439 : float frames_power[], /* i/o: energy of several frames */
8440 : float ltd_stable_rate[], /* o : time-domain stable rate */
8441 : const float frame_energy, /* i : current frame energy */
8442 : const int16_t frameloop /* i : number of frames */
8443 : );
8444 :
8445 : void SNR_calc(
8446 : const float frame_sb_energy[], /* i : energy of sub-band divided non-uniformly*/
8447 : const float sb_bg_energy[], /* i : sub-band background energy */
8448 : const float t_bg_energy, /* i : time background energy of several frames*/
8449 : float *snr, /* o : frequency domain SNR */
8450 : float *tsnr, /* o : time domain SNR */
8451 : const float frame_energy, /* i : current frame energy */
8452 : const int16_t bwidth /* i : audio bandwidth */
8453 : );
8454 :
8455 : void background_update(
8456 : VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
8457 : float frame_energy, /* i : current frame energy 2 */
8458 : const int16_t update_flag, /* i : current frame update flag */
8459 : const int16_t music_backgound_f, /* i : background music flag */
8460 : const float snr );
8461 :
8462 : void bg_music_decision(
8463 : VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
8464 : int16_t *music_backgound_f, /* i : background music flag */
8465 : const float frame_energy /* i : current frame energy 1 */
8466 : );
8467 :
8468 : void est_energy(
8469 : float sb_power[], /* o : energy of sub-band divided uniformly */
8470 : float frame_sb_energy[], /* o : energy of sub-band divided non-uniformly*/
8471 : float *p_frame_energy, /* o : frame energy 1 */
8472 : float *p_frame_energy2, /* o : frame energy 2 */
8473 : float *p_high_energy, /* o : high frequency energy */
8474 : const int16_t bw /* i : bandwidth */
8475 : );
8476 :
8477 : void spec_center(
8478 : float spec_power[], /* i : energy of sub-band divided uniformly */
8479 : float sp_center[], /* o : spectral center */
8480 : const int16_t bw_index /* i : bandwidth */
8481 : );
8482 :
8483 : void spec_flatness(
8484 : float spec_amp[], /* i : spectral amplitude */
8485 : float smooth_spec_amp[], /* i : smoothed spectral amplitude */
8486 : float sSFM[] /* o : spectral flatness rate */
8487 : );
8488 :
8489 : int16_t comvad_decision(
8490 : VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */
8491 : const float snr, /* i : frequency domain SNR */
8492 : const float tsnr, /* i : time domain SNR */
8493 : const float snr_flux, /* i : average tsnr of several frames */
8494 : const float lt_snr, /* i : long time SNR calculated by fg_energy and bg_energy*/
8495 : const float lt_snr_org, /* i : original long time SNR */
8496 : const float lf_snr, /* i : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/
8497 : const float frame_energy, /* i : current frame energy */
8498 : const int16_t music_backgound_f, /* i : background music flag */
8499 : int16_t *cldfb_addition,
8500 : const int16_t vada_flag /* i : VAD flag */
8501 : );
8502 :
8503 : void calc_snr_flux(
8504 : float tsnr, /* i : time-domain SNR */
8505 : float pre_snr[], /* i/o: time-domain SNR storage */
8506 : float *snr_flux /* o : average tsnr */
8507 : );
8508 :
8509 : void calc_lt_snr(
8510 : float *lt_snr_org, /* o : original long time SNR */
8511 : float *lt_snr, /* o : long time SNR calculated by fg_energy and bg_energy*/
8512 : const float fg_energy, /* i : foreground energy sum */
8513 : const int16_t fg_energy_count, /* i : number of the foreground energy frame */
8514 : const float bg_energy, /* i : background energy sum */
8515 : const int16_t bg_energy_count, /* i : number of the background energy frame */
8516 : const int16_t bw_index, /* i : band width index */
8517 : const float lt_noise_sp_center0 /* i : long time noise spectral center by 0 */
8518 : );
8519 :
8520 : void calc_lf_snr(
8521 : float *lf_snr_smooth, /* o : smoothed lf_snr */
8522 : float *lf_snr, /* o : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/
8523 : const float l_speech_snr, /* i : sum of active frames snr */
8524 : const int16_t l_speech_snr_count, /* i : number of the active frame */
8525 : const float l_silence_snr, /* i : sum of the nonactive frames snr */
8526 : const int16_t l_silence_snr_count, /* i : number of the nonactive frame */
8527 : const int16_t fg_energy_count, /* i : number of the foreground energy frame */
8528 : const int16_t bg_energy_count, /* i : number of the background energy frame */
8529 : const int16_t bw_index /* i : band width index */
8530 : );
8531 :
8532 : float construct_snr_thresh(
8533 : const float sp_center[], /* i : spectral center */
8534 : const float snr_flux, /* i : snr flux */
8535 : const float lt_snr, /* i : long time time domain snr */
8536 : const float lf_snr, /* i : long time frequency domain snr */
8537 : const int16_t continuous_speech_num, /* i : continuous speech number */
8538 : const int16_t continuous_noise_num, /* i : continuous noise number */
8539 : const int16_t fg_energy_est_start, /* i : whether if estimated energy */
8540 : const int16_t bw_index /* i : band width index */
8541 : );
8542 :
8543 : ivas_error createFdCngCom(
8544 : HANDLE_FD_CNG_COM *hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
8545 : );
8546 :
8547 : void deleteFdCngCom(
8548 : HANDLE_FD_CNG_COM *hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
8549 : );
8550 :
8551 : void initFdCngCom(
8552 : HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
8553 : const float scale );
8554 :
8555 : void initPartitions(
8556 : const int16_t *part_in,
8557 : const int16_t npart_in,
8558 : const int16_t startBand,
8559 : const int16_t stopBand,
8560 : int16_t *part_out,
8561 : int16_t *npart_out,
8562 : int16_t *midband,
8563 : float *psize,
8564 : float *psize_inv,
8565 : const int16_t stopBandFR );
8566 :
8567 : void minimum_statistics(
8568 : const int16_t len, /* i : Vector length */
8569 : const int16_t lenFFT, /* i : Length of the FFT part of the vectors */
8570 : float *psize,
8571 : float *msPeriodog, /* i : Periodograms */
8572 : float *msNoiseFloor,
8573 : float *msNoiseEst, /* o : Noise estimates */
8574 : float *msAlpha,
8575 : float *msPsd,
8576 : float *msPsdFirstMoment,
8577 : float *msPsdSecondMoment,
8578 : float *msMinBuf,
8579 : float *msBminWin,
8580 : float *msBminSubWin,
8581 : float *msCurrentMin,
8582 : float *msCurrentMinOut,
8583 : float *msCurrentMinSubWindow,
8584 : int16_t *msLocalMinFlag,
8585 : int16_t *msNewMinFlag,
8586 : float *msPeriodogBuf,
8587 : int16_t *msPeriodogBufPtr,
8588 : HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
8589 : const int16_t enc_dec, /* i : encoder/decoder indicator */
8590 : const int16_t element_mode /* i : IVAS element mode */
8591 : );
8592 :
8593 : void generate_comfort_noise_enc(
8594 : Encoder_State *st /* i/o: encoder state structure */
8595 : );
8596 :
8597 : void generate_comfort_noise_dec(
8598 : float **bufferReal, /* o : Real part of input bands */
8599 : float **bufferImag, /* o : Imaginary part of input bands */
8600 : Decoder_State *st, /* i/o: decoder state structure */
8601 : const int16_t nchan_out /* i : number of output channels */
8602 : );
8603 :
8604 : void generate_comfort_noise_dec_hf(
8605 : float **bufferReal, /* o : Real part of input bands */
8606 : float **bufferImag, /* o : Imaginary part of input bands */
8607 : HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
8608 : const int16_t cng_flag /* i : CNG Flag */
8609 : );
8610 :
8611 : void generate_masking_noise(
8612 : float *timeDomainBuffer, /* i/o: time-domain signal */
8613 : HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
8614 : const int16_t length, /* i : frame size */
8615 : const int16_t core, /* i : core */
8616 : const int16_t return_noise, /* i : noise is returned instead of added */
8617 : const int16_t secondary, /* i : indicator for secondary channel */
8618 : const int16_t element_mode, /* i : element mode */
8619 : STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
8620 : const int16_t nchan_out /* i : number of output channels */
8621 : );
8622 :
8623 : void generate_masking_noise_update_seed(
8624 : HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
8625 : );
8626 :
8627 : void generate_masking_noise_mdct(
8628 : float *mdctBuffer, /* i/o: time-domain signal */
8629 : HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
8630 : );
8631 :
8632 : void SynthesisSTFT_dirac(
8633 : float *fftBuffer, /* i : FFT bins */
8634 : float *timeDomainOutput,
8635 : float *olapBuffer,
8636 : const float *olapWin,
8637 : const int16_t samples_out,
8638 : HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
8639 : );
8640 :
8641 : void generate_masking_noise_dirac(
8642 : HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
8643 : HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */
8644 : float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */
8645 : float *Cldfb_RealBuffer, /* o : CLDFD real buffer */
8646 : float *Cldfb_ImagBuffer, /* o : CLDFD imaginary buffer */
8647 : const int16_t slot_index, /* i : CLDFB slot index */
8648 : const int16_t cna_flag, /* i : CNA flag for LB and HB */
8649 : const int16_t fd_cng_flag /* i : FD-CNG flag for HB */
8650 : );
8651 :
8652 : void generate_stereo_masking_noise(
8653 : float *syn, /* i/o: time-domain signal */
8654 : Decoder_State *st, /* i/o: decoder state structure */
8655 : STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */
8656 : const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */
8657 : const int16_t fadeOut, /* i : only fade out of previous state */
8658 : STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
8659 : const int16_t nchan_out /* i : number of output channels */
8660 : );
8661 :
8662 : void apply_scale(
8663 : float *scale, /* i : scale factor */
8664 : const int16_t bwidth, /* i : audio bandwidth */
8665 : const int32_t brate, /* i : Bit rate */
8666 : const SCALE_SETUP *scaleTable, /* i : Scale table */
8667 : const int16_t scaleTableSize /* i : Size of scale table */
8668 : );
8669 :
8670 : void compress_range(
8671 : float *in,
8672 : float *out,
8673 : const int16_t len );
8674 :
8675 : void expand_range(
8676 : float *in,
8677 : float *out,
8678 : const int16_t len );
8679 :
8680 : void bandcombinepow(
8681 : const float *bandpow, /* i : Power for each band */
8682 : const int16_t nband, /* i : Number of bands */
8683 : int16_t *part, /* i : Partition upper boundaries (band indices starting from 0) */
8684 : const int16_t npart, /* i : Number of partitions */
8685 : const float *psize_inv, /* i : Inverse partition sizes */
8686 : float *partpow /* o : Power for each partition */
8687 : );
8688 :
8689 : void scalebands(
8690 : const float *partpow, /* i : Power for each partition */
8691 : int16_t *part, /* i : Partition upper boundaries (band indices starting from 0) */
8692 : const int16_t npart, /* i : Number of partitions */
8693 : int16_t *midband, /* i : Central band of each partition */
8694 : const int16_t nFFTpart, /* i : Number of FFT partitions */
8695 : const int16_t nband, /* i : Number of bands */
8696 : float *bandpow, /* o : Power for each band */
8697 : const int16_t flag_fft_en );
8698 :
8699 : void AnalysisSTFT(
8700 : const float *timeDomainInput,
8701 : float *fftBuffer, /* o : FFT bins */
8702 : HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */
8703 : );
8704 :
8705 : void SynthesisSTFT(
8706 : float *fftBuffer,
8707 : float *timeDomainOutput,
8708 : float *olapBuffer,
8709 : const float *olapWin,
8710 : const int16_t tcx_transition,
8711 : HANDLE_FD_CNG_COM hFdCngCom,
8712 : const int16_t element_mode, /* i : element mode */
8713 : const int16_t nchan_out /* i : number of output channels */
8714 : );
8715 :
8716 : float rand_gauss(
8717 : float *x,
8718 : int16_t *seed );
8719 :
8720 : void lpc_from_spectrum(
8721 : HANDLE_FD_CNG_COM hFdCngCom,
8722 : const int16_t start,
8723 : const int16_t stop,
8724 : const float preemph_fac );
8725 :
8726 : ivas_error createFdCngDec(
8727 : HANDLE_FD_CNG_DEC *hFdCngDec );
8728 :
8729 : void deleteFdCngDec(
8730 : HANDLE_FD_CNG_DEC *hFdCngDec );
8731 :
8732 : void initFdCngDec(
8733 : DEC_CORE_HANDLE st /* i/o: decoder state structure */
8734 : );
8735 :
8736 : void configureFdCngDec(
8737 : HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */
8738 : const int16_t bwidth,
8739 : const int32_t total_brate,
8740 : const int16_t L_frame,
8741 : const int16_t last_L_frame,
8742 : const int16_t element_mode );
8743 :
8744 : void ApplyFdCng(
8745 : float *timeDomainInput,
8746 : float *powerSpectrum,
8747 : float **realBuffer, /* i/o: Real part of the buffer */
8748 : float **imagBuffer, /* i/o: Imaginary part of the buffer */
8749 : Decoder_State *st,
8750 : const int16_t concealWholeFrame, /* i : binary flag indicating frame loss */
8751 : const int16_t is_music );
8752 :
8753 : void generate_comfort_noise_dec(
8754 : float **bufferReal, /* o : Real part of input bands */
8755 : float **bufferImag, /* o : Imaginary part of input bands */
8756 : Decoder_State *st, /* i/o: decoder state structure */
8757 : const int16_t nchan_out /* i : number of output channels */
8758 : );
8759 :
8760 : /*! r: CNG energy */
8761 : float cng_energy(
8762 : const int16_t element_mode, /* i : element mode */
8763 : const int16_t bwidth, /* i : audio bandwidh */
8764 : const int16_t CNG_mode, /* i : mode for DTX configuration */
8765 : const float CNG_att, /* i : attenuation factor for CNG */
8766 : const float *inputBuffer, /* i : input signal */
8767 : const int16_t len /* i : vector length */
8768 : );
8769 :
8770 : void FdCng_decodeSID(
8771 : Decoder_State *st /* i/o: decoder state structure */
8772 : );
8773 :
8774 : void FdCng_exc(
8775 : HANDLE_FD_CNG_COM hFdCngCom,
8776 : int16_t *CNG_mode,
8777 : const int16_t L_frame,
8778 : const float *lsp_old,
8779 : const int16_t first_CNG,
8780 : float *lsp_CNG,
8781 : float *Aq, /* o : LPC coeffs */
8782 : float *lsp_new, /* o : lsp */
8783 : float *lsf_new, /* o : lsf */
8784 : float *exc, /* o : LP excitation */
8785 : float *exc2, /* o : LP excitation */
8786 : float *bwe_exc /* o : LP excitation for BWE */
8787 : );
8788 :
8789 : void noisy_speech_detection(
8790 : HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */
8791 : const int16_t vad, /* i : VAD flag */
8792 : const float syn[] /* i : input time-domain frame */
8793 : );
8794 :
8795 : ivas_error createFdCngEnc(
8796 : HANDLE_FD_CNG_ENC *hFdCngEnc /* i/o: FD_CNG structure */
8797 : );
8798 :
8799 : void deleteFdCngEnc(
8800 : HANDLE_FD_CNG_ENC *hFdCngEnc /* i/o: FD_CNG structure */
8801 : );
8802 :
8803 : void configureFdCngEnc(
8804 : HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */
8805 : const int16_t bwidth,
8806 : const int32_t total_brate );
8807 :
8808 : void initFdCngEnc(
8809 : HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */
8810 : const int32_t input_Fs, /* i : input signal sampling frequency in Hz */
8811 : const float scale /* i : scaling factor */
8812 : );
8813 :
8814 : void resetFdCngEnc(
8815 : Encoder_State *st /* i/o: encoder state structure */
8816 : );
8817 :
8818 : void perform_noise_estimation_enc(
8819 : float *band_energies, /* i : energy in critical bands without minimum noise floor E_MIN */
8820 : float *enerBuffer, /* i : energy buffer */
8821 : HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */
8822 : const int32_t input_Fs, /* i : input sampling rate */
8823 : CPE_ENC_HANDLE hCPE );
8824 :
8825 : void AdjustFirstSID(
8826 : Encoder_State *st /* i/o: encoder state structure */
8827 : );
8828 :
8829 : void FdCng_encodeSID(
8830 : Encoder_State *st /* i/o: encoder state structure */
8831 : );
8832 :
8833 : void GetParameters(
8834 : ParamsBitMap const *paramsBitMap,
8835 : const int16_t nParams,
8836 : void const *pParameter,
8837 : int16_t **pStream,
8838 : int16_t *pnSize,
8839 : int16_t *pnBits );
8840 :
8841 : void SetParameters(
8842 : ParamsBitMap const *paramsBitMap,
8843 : const int16_t nParams,
8844 : void *pParameter,
8845 : const int16_t **pStream,
8846 : int16_t *pnSize );
8847 :
8848 : void WriteToBitstream(
8849 : ParamsBitMap const *paramsBitMap,
8850 : const int16_t nParams,
8851 : const int16_t **pStream,
8852 : int16_t *pnSize,
8853 : BSTR_ENC_HANDLE hBstr,
8854 : int16_t *pnBits );
8855 :
8856 : void ReadFromBitstream(
8857 : ParamsBitMap const *paramsBitMap,
8858 : const int16_t nArrayLength,
8859 : Decoder_State *st,
8860 : int16_t **pStream,
8861 : int16_t *pnSize );
8862 :
8863 : void const *GetTnsFilterOrder( void const *p, const int16_t index, int16_t *pValue );
8864 : void *SetTnsFilterOrder( void *p, const int16_t index, const int16_t value );
8865 : void const *GetNumOfTnsFilters( void const *p, const int16_t index, int16_t *pValue );
8866 : void *SetNumOfTnsFilters( void *p, const int16_t index, const int16_t value );
8867 : void const *GetTnsEnabled( void const *p, const int16_t index, int16_t *pValue );
8868 : void *SetTnsEnabled( void *p, const int16_t index, const int16_t value );
8869 : void const *GetTnsEnabledSingleFilter( void const *p, const int16_t index, int16_t *pValue );
8870 : void *SetTnsEnabledSingleFilter( void *p, const int16_t index, const int16_t value );
8871 : void const *GetTnsFilterCoeff( void const *p, const int16_t index, int16_t *pValue );
8872 : void *SetTnsFilterCoeff( void *p, const int16_t index, const int16_t value );
8873 :
8874 : void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue );
8875 : void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value );
8876 :
8877 : int16_t GetSWBTCX10TnsFilterCoeffBits( const int16_t value, const int16_t index );
8878 : int16_t EncodeSWBTCX10TnsFilterCoeff( const int16_t value, const int16_t index );
8879 : int16_t DecodeSWBTCX10TnsFilterCoeff( Decoder_State *st, const int16_t index, int16_t *pValue );
8880 : int16_t GetSWBTCX20TnsFilterCoeffBits( const int16_t value, const int16_t index );
8881 : int16_t EncodeSWBTCX20TnsFilterCoeff( const int16_t value, const int16_t index );
8882 : int16_t DecodeSWBTCX20TnsFilterCoeff( Decoder_State *st, const int16_t index, int16_t *pValue );
8883 :
8884 : int16_t GetWBTCX20TnsFilterCoeffBits( const int16_t value, const int16_t index );
8885 : int16_t EncodeWBTCX20TnsFilterCoeff( const int16_t, const int16_t index );
8886 : int16_t DecodeWBTCX20TnsFilterCoeff( Decoder_State *st, const int16_t index, int16_t *pValue );
8887 :
8888 : int16_t GetTnsFilterOrderBitsSWBTCX10( const int16_t value, const int16_t index );
8889 : int16_t EncodeTnsFilterOrderSWBTCX10( const int16_t value, const int16_t index );
8890 : int16_t DecodeTnsFilterOrderSWBTCX10( Decoder_State *st, const int16_t index, int16_t *pValue );
8891 : int16_t GetTnsFilterOrderBitsSWBTCX20( const int16_t value, const int16_t index );
8892 : int16_t EncodeTnsFilterOrderSWBTCX20( const int16_t value, const int16_t index );
8893 : int16_t DecodeTnsFilterOrderSWBTCX20( Decoder_State *st, const int16_t index, int16_t *pValue );
8894 : int16_t GetTnsFilterOrderBits( const int16_t value, const int16_t index );
8895 : int16_t EncodeTnsFilterOrder( const int16_t value, const int16_t index );
8896 : int16_t DecodeTnsFilterOrder( Decoder_State *st, const int16_t index, int16_t *pValue );
8897 :
8898 : void ResetTnsData(
8899 : STnsData *pTnsData );
8900 :
8901 : void ClearTnsFilterCoefficients(
8902 : STnsFilter *pTnsFilter );
8903 :
8904 : void InitTnsConfiguration(
8905 : const int16_t bwidth,
8906 : const int16_t frameLength,
8907 : STnsConfig *pTnsConfig,
8908 : const int16_t igfStopFreq,
8909 : const int32_t total_brate,
8910 : const int16_t element_mode,
8911 : const int16_t MCT_flag );
8912 :
8913 : int16_t DetectTnsFilt(
8914 : const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */
8915 : const float pSpectrum[], /* i : MDCT spectrum */
8916 : TRAN_DET_HANDLE hTranDet, /* i : transient detection handle */
8917 : const int16_t isTCX10, /* i : TCX10 or TCX20? */
8918 : const float ltp_gain, /* i : LTP gain */
8919 : STnsData *pTnsData, /* o : TNS data struct */
8920 : float *predictionGain /* o : TNS prediction gain */
8921 : );
8922 :
8923 : void ApplyTnsFilter(
8924 : STnsConfig const *pTnsConfig,
8925 : STnsData const *pTnsData,
8926 : float spectrum[],
8927 : const int16_t fIsAnalysis );
8928 :
8929 : int16_t ITF_Detect(
8930 : const float pSpectrum[],
8931 : const int16_t startLine,
8932 : const int16_t stopLine,
8933 : const int16_t maxOrder,
8934 : float *A,
8935 : float *predictionGain,
8936 : int16_t *curr_order );
8937 :
8938 : void ITF_Apply(
8939 : float spectrum[],
8940 : const int16_t startLine,
8941 : const int16_t stopLine,
8942 : const float *A,
8943 : const int16_t curr_order );
8944 :
8945 : void EncodeTnsData(
8946 : STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */
8947 : STnsData const *pTnsData, /* i : TNS data struct (quantized param) */
8948 : int16_t *stream, /* o : internal data stream */
8949 : int16_t *pnSize, /* o : number of written parameters */
8950 : int16_t *pnBits /* o : number of written bits */
8951 : );
8952 :
8953 : int16_t DecodeTnsData(
8954 : STnsConfig const *pTnsConfig,
8955 : const int16_t *stream,
8956 : int16_t *pnSize,
8957 : STnsData *pTnsData );
8958 :
8959 : void WriteTnsData(
8960 : const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */
8961 : const int16_t *stream, /* i : internal data stream */
8962 : int16_t *pnSize, /* o : number of written parameters */
8963 : BSTR_ENC_HANDLE hBstr, /* o : bitstream */
8964 : int16_t *pnBits /* o : number of written bits */
8965 : );
8966 :
8967 : void ReadTnsData(
8968 : STnsConfig const *pTnsConfig,
8969 : Decoder_State *st,
8970 : int16_t *pnBits,
8971 : int16_t *stream,
8972 : int16_t *pnSize );
8973 :
8974 : void cldfbAnalysis(
8975 : const float *timeIn, /* i : time buffer */
8976 : float **realBuffer, /* o : real value buffer */
8977 : float **imagBuffer, /* o : imag value buffer */
8978 : const int16_t samplesToProcess, /* i : number of input samples */
8979 : HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */
8980 : );
8981 :
8982 : void cldfbAnalysis_ts(
8983 : const float *timeIn, /* i : time buffer */
8984 : float realBuffer[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */
8985 : float imagBuffer[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */
8986 : const int16_t samplesToProcess, /* i : samples to process */
8987 : HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */
8988 : );
8989 :
8990 : void cldfbSynthesis(
8991 : float **realBuffer, /* i : real values */
8992 : float **imagBuffer, /* i : imag values */
8993 : float *timeOut, /* o : synthesized output */
8994 : const int16_t samplesToProcess, /* i : number of samples */
8995 : HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */
8996 : );
8997 :
8998 : void configureCldfb(
8999 : HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */
9000 : const int32_t sampling_rate /* i : sampling rate */
9001 : );
9002 :
9003 : void analysisCldfbEncoder(
9004 : Encoder_State *st, /* i/o: encoder state structure */
9005 : const float *timeIn,
9006 : const int16_t samplesToProcess,
9007 : float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
9008 : float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
9009 : float *ppBuf_Ener );
9010 :
9011 : ivas_error openCldfb(
9012 : HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */
9013 : CLDFB_TYPE type, /* i : analysis or synthesis */
9014 : const int32_t sampling_rate, /* i : sampling rate */
9015 : CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */
9016 : );
9017 :
9018 : void resampleCldfb(
9019 : HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */
9020 : const int32_t newSamplerate /* i : new samplerate to operate */
9021 : );
9022 :
9023 : ivas_error cldfb_save_memory(
9024 : HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
9025 : );
9026 :
9027 : void cldfb_restore_memory(
9028 : HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
9029 : );
9030 :
9031 : void cldfb_reset_memory(
9032 : HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
9033 : );
9034 :
9035 : void deleteCldfb(
9036 : HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */
9037 : );
9038 :
9039 : void fft_cldfb(
9040 : float *data, /* i/o: input/output vector */
9041 : const int16_t size /* i : size of fft operation */
9042 : );
9043 :
9044 : void BITS_ALLOC_init_config_acelp(
9045 : const int32_t bit_rate,
9046 : const int16_t narrowBand,
9047 : const int16_t nb_subfr,
9048 : ACELP_config *acelp_cfg /* o : configuration structure of ACELP */
9049 : );
9050 :
9051 : int16_t BITS_ALLOC_config_acelp(
9052 : const int16_t bits_frame, /* i : remaining bit budget for the frame */
9053 : const int16_t coder_type, /* i : acelp coder type */
9054 : ACELP_config *acelp_cfg, /* i/o: configuration structure of ACELP */
9055 : const int16_t narrowband, /* i : narrowband flag */
9056 : const int16_t nb_subfr /* i : number of subframes */
9057 : );
9058 :
9059 : ivas_error config_acelp1(
9060 : const int16_t enc_dec, /* i : encoder/decoder flag */
9061 : const int32_t total_brate, /* i : total bitrate */
9062 : const int32_t core_brate_inp, /* i : core bitrate */
9063 : const int16_t core, /* i : core */
9064 : const int16_t extl, /* i : extension layer */
9065 : const int32_t extl_brate, /* i : extension layer bitrate */
9066 : const int16_t L_frame, /* i : frame length at internal Fs */
9067 : const int16_t GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
9068 : ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
9069 : const int16_t signaling_bits, /* i : number of signaling bits */
9070 : const int16_t coder_type, /* i : coder type */
9071 : const int16_t inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
9072 : const int16_t tc_subfr, /* i : TC subfr ID */
9073 : const int16_t tc_call, /* i : TC call number (0,1,2) */
9074 : int16_t *nBits_es_Pred, /* o : number of bits for Es_pred Q */
9075 : int16_t *unbits, /* o : number of unused bits */
9076 : const int16_t element_mode, /* i : element mode */
9077 : int16_t *uc_two_stage_flag, /* o : flag undicating two-stage UC */
9078 : const int16_t tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel*/
9079 : const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/
9080 : const int16_t idchan, /* i : channel id */
9081 : const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
9082 : const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */
9083 : const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */
9084 : );
9085 :
9086 : /*! r: ACELP16k flag */
9087 : int16_t set_ACELP_flag(
9088 : const int16_t element_mode, /* i : element mode */
9089 : const int32_t element_brate, /* i : element bitrate */
9090 : const int32_t total_brate, /* i : total bitrate per channel */
9091 : const int16_t idchan, /* i : Channel id */
9092 : const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */
9093 : const int16_t bwidth, /* i : audio bandwidth */
9094 : const int16_t cng_type /* i : CNG type */
9095 : );
9096 :
9097 : void FEC_clas_estim(
9098 : const float *syn,
9099 : const float *pitch, /* i : pitch values for each subframe */
9100 : const int16_t L_frame, /* i : length of the frame */
9101 : const int16_t coder_type, /* i : coder type */
9102 : const int16_t codec_mode, /* i : codec mode */
9103 : float *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */
9104 : int16_t *clas, /* i/o: frame classification */
9105 : float *lp_speech, /* i/o: long term active speech energy average */
9106 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
9107 : int16_t *decision_hyst, /* i/o: hysteresis of the music/speech decision */
9108 : int16_t *locattack, /* i/o: detection of attack (mainly to localized speech burst) */
9109 : int16_t *UV_cnt, /* i/o: number of consecutives frames classified as UV */
9110 : float *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV */
9111 : float *Last_ener, /* i/o: last_energy frame */
9112 : int16_t *amr_io_class, /* i/o: classification for AMR-WB IO mode */
9113 : float *lt_diff_etot, /* i/o: long-term total energy variation */
9114 : float *class_para, /* o : classification para. fmerit1 */
9115 : const float LTP_Gain, /* i : */
9116 : const int16_t narrowBand, /* i : */
9117 : const SIGNAL_CLASSIFIER_MODE mode, /* i : */
9118 : const int16_t bfi, /* i : */
9119 : const float preemph_fac, /* i : */
9120 : const int16_t tcxonly, /* i : */
9121 : const int32_t last_core_brate, /* i : last core bitrate */
9122 : const int16_t FEC_mode /* i : ACELP FEC mode */
9123 : );
9124 :
9125 : void InitTransientDetection(
9126 : const int16_t nFrameLength,
9127 : const int16_t nTCXDelay,
9128 : TRAN_DET_HANDLE hTranDet,
9129 : const int16_t ext_mem_flag );
9130 :
9131 : void RunTransientDetection(
9132 : const float *input, /* i : input signal */
9133 : const int16_t length, /* i : frame length */
9134 : TRAN_DET_HANDLE hTranDet /* i/o: transient detection handle */
9135 : );
9136 :
9137 : float GetTCXAvgTemporalFlatnessMeasure(
9138 : TRAN_DET_HANDLE hTranDet,
9139 : const int16_t nCurrentSubblocks,
9140 : const int16_t nPrevSubblocks );
9141 :
9142 : float GetTCXMaxenergyChange(
9143 : TRAN_DET_HANDLE hTranDet,
9144 : const int16_t isTCX10,
9145 : const int16_t nCurrentSubblocks,
9146 : const int16_t nPrevSubblocks );
9147 :
9148 : void SetTCXModeInfo(
9149 : Encoder_State *st, /* i/o: encoder state structure */
9150 : TRAN_DET_HANDLE hTranDet, /* i/o: transient detection handle */
9151 : int16_t *tcxModeOverlap /* o : window overlap of current frame */
9152 : );
9153 :
9154 : void TCX_MDCT(
9155 : const float *x,
9156 : float *y,
9157 : const int16_t l,
9158 : const int16_t m,
9159 : const int16_t r,
9160 : const int16_t element_mode );
9161 :
9162 : void TCX_MDST(
9163 : const float *x,
9164 : float *y,
9165 : const int16_t l,
9166 : const int16_t m,
9167 : const int16_t r,
9168 : const int16_t element_mode );
9169 :
9170 : void TCX_MDCT_Inverse(
9171 : const float *x,
9172 : float *y,
9173 : const int16_t l,
9174 : const int16_t m,
9175 : const int16_t r,
9176 : const int16_t element_mode );
9177 :
9178 : void TCX_MDST_Inverse(
9179 : const float *x,
9180 : float *y,
9181 : const int16_t l,
9182 : const int16_t m,
9183 : const int16_t r,
9184 : const int16_t element_mode );
9185 :
9186 : void TCX_MDXT_Inverse(
9187 : const float *x,
9188 : float *y,
9189 : const int16_t l,
9190 : const int16_t m,
9191 : const int16_t r,
9192 : const uint16_t kernel_type );
9193 :
9194 : void post_decoder(
9195 : Decoder_State *st,
9196 : float synth_buf[],
9197 : const float pit_gain[],
9198 : const int16_t pitch[],
9199 : float signal_out[],
9200 : float bpf_noise_buf[] );
9201 :
9202 : float bass_pf_enc(
9203 : const float *orig, /* i : 12.8kHz original signal */
9204 : const float *syn, /* i : 12.8kHz synthesis to postfilter */
9205 : const float pitch_buf[], /* i : Pitch gain for all subframes (gainT_sf[16]) */
9206 : const float gainT_sf[], /* i : Pitch gain for all subframes (gainT_sf[16]) */
9207 : const int16_t l_frame, /* i : frame length (should be multiple of l_subfr)*/
9208 : const int16_t l_subfr_in, /* i : sub-frame length (60/64) */
9209 : float mem_bpf[], /* i/o: memory state [2*L_FILT] */
9210 : float mem_error_bpf[], /* i/o: memory state [2*L_FILT] */
9211 : int16_t *gain_factor_param, /* o : quantized gain factor */
9212 : const int16_t mode, /* i : coding mode of adapt bpf */
9213 : float *mem_deemph_err, /* i/o: Error deemphasis memory */
9214 : float *lp_ener /* i/o: long_term error signal energy */
9215 : );
9216 :
9217 : void cldfb_synth_set_bandsToZero(
9218 : Decoder_State *st, /* i/o: decoder state structure */
9219 : float **rAnalysis,
9220 : float **iAnalysis,
9221 : const int16_t nTimeSlots );
9222 :
9223 : void longadd(
9224 : uint16_t a[], /* i/o: vector of the length lena */
9225 : const uint16_t b[], /* i/o: vector of the length lenb */
9226 : const int16_t lena, /* i/o: length of vector a[] */
9227 : const int16_t lenb /* i/o: length of vector b[] */
9228 : );
9229 :
9230 : void longshiftright(
9231 : uint16_t a[], /* i : vector of the length lena */
9232 : const int16_t b, /* i : number of bit positions to shift right */
9233 : uint16_t d[], /* o : vector of the length lend */
9234 : int16_t lena, /* i : length of vector a[] */
9235 : const int16_t lend /* i : length of vector d[] */
9236 : );
9237 :
9238 : void longshiftleft(
9239 : const uint16_t a[], /* i : vector of the length len */
9240 : const int16_t b, /* i : number of bit positions to shift left */
9241 : uint16_t d[], /* o : vector of the length len */
9242 : const int16_t len /* i : length of vector a[] and d[] */
9243 : );
9244 :
9245 : void open_decoder_LPD(
9246 : Decoder_State *st, /* i/o: decoder state structure */
9247 : const int32_t total_brate, /* i : total bitrate */
9248 : const int32_t last_total_brate, /* i : last total bitrate */
9249 : const int16_t bwidth, /* i : audio bandwidth */
9250 : const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
9251 : const int16_t last_element_mode, /* i : last element mode */
9252 : const int16_t is_init /* i : indicate call during initialization */
9253 : );
9254 :
9255 : void acelp_plc_mdct_transition(
9256 : Decoder_State *st /* i/o: Decoder state */
9257 : );
9258 :
9259 : void tcxltp_dec_init(
9260 : TCX_LTP_DEC_HANDLE hTcxLtpDec,
9261 : const int16_t ini_frame,
9262 : const int16_t last_codec_mode,
9263 : const int16_t element_mode,
9264 : const int16_t pit_max,
9265 : const int32_t sr_core );
9266 :
9267 : void reset_tcx_overl_buf(
9268 : TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */
9269 : );
9270 :
9271 : void update_decoder_LPD_cng(
9272 : Decoder_State *st, /* i/o: decoder state structure */
9273 : float *timeDomainBuffer,
9274 : float *A,
9275 : float *bpf_noise_buf );
9276 :
9277 : void reconfig_decoder_LPD(
9278 : Decoder_State *st, /* i/o: decoder state structure */
9279 : const int16_t bits_frame, /* i : bit budget */
9280 : const int16_t bwidth, /* i : audio bandwidth */
9281 : const int32_t total_brate, /* i : total bitrate */
9282 : const int16_t L_frame_old /* i : frame length */
9283 : );
9284 :
9285 : void mode_switch_decoder_LPD(
9286 : Decoder_State *st, /* i/o: decoder state structure */
9287 : const int16_t bwidth, /* i : audio bandwidth */
9288 : const int32_t total_brate, /* i : total bitrate */
9289 : const int32_t last_total_brate, /* i : last frame total bitrate */
9290 : const int16_t frame_size_index, /* i : index determining the frame size */
9291 : const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/
9292 : const int16_t last_element_mode /* i : last element mode */
9293 : );
9294 :
9295 : void dec_acelp_tcx_frame(
9296 : Decoder_State *st, /* i/o: decoder state structure */
9297 : int16_t *concealWholeFrame, /* i/o: concealment flag */
9298 : float *output, /* o : synthesis */
9299 : float *bpf_noise_buf, /* i/o: BPF noise buffer */
9300 : float *pcmbufFB, /* o : synthesis @output_FS */
9301 : float bwe_exc_extended[], /* i/o: bandwidth extended excitation */
9302 : float *voice_factors, /* o : voicing factors */
9303 : float pitch_buf[], /* o : floating pitch for each subframe */
9304 : STEREO_CNG_DEC_HANDLE hStereoCng /* i : stereo CNG handle */
9305 : );
9306 :
9307 : void decoder_LPD(
9308 : Decoder_State *st, /* i/o: decoder memory state pointer */
9309 : float signal_out[], /* o : signal with LPD delay (7 subfrs) */
9310 : float signal_outFB[], /* o : synthesis @output_FS */
9311 : int16_t *total_nbbits, /* i/o: number of bits / decoded bits */
9312 : float *bpf_noise_buf, /* i/o: BPF noise buffer */
9313 : int16_t bfi, /* i : BFI flag */
9314 : int16_t *bitsRead, /* o : number of read bits */
9315 : int16_t param[], /* o : buffer of parameters */
9316 : float *pitch_buf, /* i/o: floating pitch values for each subfr*/
9317 : float *voice_factors, /* o : voicing factors */
9318 : float *ptr_bwe_exc /* o : excitation for SWB TBE */
9319 : );
9320 :
9321 : int16_t tcxGetNoiseFillingTilt(
9322 : const float A[],
9323 : const int16_t L_frame,
9324 : const int16_t mode,
9325 : float *noiseTiltFactor );
9326 :
9327 : void tcxFormantEnhancement(
9328 : float xn_buf[],
9329 : const float *gainlpc,
9330 : float spectrum[],
9331 : const int16_t L_frame );
9332 :
9333 : void tcxInvertWindowGrouping(
9334 : TCX_CONFIG_HANDLE hTcxCfg,
9335 : float xn_buf[],
9336 : float spectrum[],
9337 : const int16_t L_frame,
9338 : const int16_t fUseTns,
9339 : const int16_t last_core,
9340 : const int16_t index,
9341 : const int16_t frame_cnt,
9342 : const int16_t bfi );
9343 :
9344 : void tcx5SpectrumInterleaving(
9345 : const int16_t tcx5Size,
9346 : float *spectrum );
9347 :
9348 : void tcx5SpectrumDeinterleaving(
9349 : const int16_t tcx5Size,
9350 : float *spectrum );
9351 :
9352 : void tcx5TnsGrouping(
9353 : const int16_t L_frame,
9354 : const int16_t L_spec,
9355 : float *spectrum );
9356 :
9357 : void tcx5TnsUngrouping(
9358 : const int16_t L_frame,
9359 : const int16_t L_spec,
9360 : float *spectrum,
9361 : const int16_t enc_dec );
9362 :
9363 : void lerp(
9364 : const float *f,
9365 : float *f_out,
9366 : const int16_t bufferNewSize,
9367 : const int16_t bufferOldSize );
9368 :
9369 : void encoderSideLossSimulation(
9370 : Encoder_State *st,
9371 : PLC_ENC_EVS_HANDLE hPlc_Ext,
9372 : float *isf_q,
9373 : const float stab_fac,
9374 : const int16_t calcOnlyISF,
9375 : const int16_t L_frame );
9376 :
9377 : void enc_prm_side_Info(
9378 : PLC_ENC_EVS_HANDLE hPlc_Ext,
9379 : Encoder_State *st );
9380 :
9381 : void GplcTcxEncSetup(
9382 : const int16_t tcxltp_pitch_int,
9383 : PLC_ENC_EVS_HANDLE hPlc_Ext );
9384 :
9385 : int16_t encSideSpecPowDiffuseDetector(
9386 : float *isf_ref,
9387 : float *isf_con,
9388 : const int32_t sr_core,
9389 : float *prev_isf4_mean,
9390 : const int16_t sw,
9391 : const int16_t coder_type );
9392 :
9393 : void updateSpecPowDiffuseIdx(
9394 : const float gain_pitch_buf[], /* i : gain pitch values */
9395 : const float gain_code_buf[], /* i : gain pitch values */
9396 : int16_t glr_idx[2], /* o : */
9397 : float mean_gc[2] /* o : */
9398 : );
9399 :
9400 : void getLookAheadResSig(
9401 : float *speechLookAhead,
9402 : const float *A,
9403 : float *res,
9404 : const int16_t L_frame,
9405 : const int16_t L_subfr,
9406 : const int16_t m,
9407 : const int16_t numSubFrame );
9408 :
9409 : void updatelsfForConcealment(
9410 : PLC_ENC_EVS_HANDLE decState,
9411 : float *lsf );
9412 :
9413 : void getConcealedLP(
9414 : PLC_ENC_EVS_HANDLE memDecState,
9415 : float *AqCon,
9416 : const float xsfBase[],
9417 : const int32_t sr_core,
9418 : const int16_t last_good,
9419 : const int16_t L_frame );
9420 :
9421 : void RecLpcSpecPowDiffuseLc(
9422 : float *ispq,
9423 : float *isp_old,
9424 : float *isfq,
9425 : Decoder_State *st,
9426 : const int16_t reset_q );
9427 :
9428 : void modify_lsf(
9429 : float *lsf,
9430 : const int16_t n,
9431 : const int32_t sr_core,
9432 : const int16_t reset_q );
9433 :
9434 : void init_PLC_enc(
9435 : PLC_ENC_EVS_HANDLE hPlcExt,
9436 : const int32_t sr_core );
9437 :
9438 : void gPLC_encInfo(
9439 : PLC_ENC_EVS_HANDLE hPlcExt,
9440 : const int32_t total_brate,
9441 : const int16_t bwidth,
9442 : const int16_t last_clas,
9443 : const int16_t coder_type );
9444 :
9445 : void resetTecDec(
9446 : TEC_DEC_HANDLE hTecDec );
9447 :
9448 : void calcGainTemp_TBE(
9449 : float **pCldfbRealSrc,
9450 : float **pCldfbImagSrc,
9451 : float *loBuffer,
9452 : const int16_t startPos, /*!< Start position of the current envelope. */
9453 : const int16_t stopPos, /*!< Stop position of the current envelope. */
9454 : const int16_t lowSubband, /* lowSubband */
9455 : float *pGainTemp,
9456 : const int16_t code );
9457 :
9458 : void procTecTfa_TBE(
9459 : float *hb_synth,
9460 : float *gain,
9461 : const int16_t flat_flag,
9462 : const int16_t last_core,
9463 : const int16_t L_subfr,
9464 : const int16_t code );
9465 :
9466 : void resetTecEnc(
9467 : TEC_ENC_HANDLE hTecEnc,
9468 : const int16_t flag );
9469 :
9470 : void calcHiEnvLoBuff(
9471 : const int16_t noCols,
9472 : const int16_t *pFreqBandTable, /* i : freqbandTable */
9473 : const int16_t nSfb, /* i : Number of scalefactors */
9474 : float **pYBuf,
9475 : float *loBuf,
9476 : float *hiTempEnv );
9477 :
9478 : void calcLoEnvCheckCorrHiLo(
9479 : const int16_t noCols,
9480 : const int16_t *pFreqBandTable, /* i : freqbandTable */
9481 : float *loBuf,
9482 : float *loTempEnv,
9483 : float *loTempEnv_ns,
9484 : float *hiTempEnv,
9485 : int16_t *corr_flag /* o : 0 for original, 1 for TEC */
9486 : );
9487 :
9488 : void tfaCalcEnv(
9489 : const float *shb_speech,
9490 : float *enr );
9491 :
9492 : int16_t tfaEnc_TBE(
9493 : const float *enr,
9494 : const int16_t last_core,
9495 : const float *voicing,
9496 : const float *pitch_buf );
9497 :
9498 : void tecEnc_TBE(
9499 : int16_t *corrFlag,
9500 : const float *voicing,
9501 : const int16_t coder_type );
9502 :
9503 : void set_TEC_TFA_code(
9504 : const int16_t corrFlag,
9505 : int16_t *tec_flag,
9506 : int16_t *tfa_flag );
9507 :
9508 : float Damping_fact(
9509 : const int16_t coder_type, /* i : ACELP core coder type */
9510 : const int16_t nbLostCmpt, /* i : compt for number of consecutive lost frame */
9511 : int16_t last_good, /* i : class of last good received frame */
9512 : float stab_fac, /* i : LSF stability factor */
9513 : float *lp_gainp, /* i/o: low passed pitch gain used for concealment */
9514 : const int16_t core /* i : current core: ACELP = 0, TCX20 = 1, TCX10 = 2 */
9515 : );
9516 :
9517 : void fer_energy(
9518 : const int16_t L_frame, /* i : frame length */
9519 : const int16_t clas, /* i : frame classification */
9520 : const float synth[], /* i : synthesized speech at Fs = 12k8 Hz */
9521 : const float pitch, /* i : pitch period */
9522 : float *enr, /* o : pitch-synchronous or half_frame energy */
9523 : const int16_t useOffset /* i : speech pointer offset (0 or L_FRAME) */
9524 : );
9525 :
9526 : float getLevelSynDeemph(
9527 : const float h1Init[], /* i : input value or vector to be processed */
9528 : const float A[], /* i : LPC coefficients */
9529 : const int16_t lenLpcExc, /* i : length of the LPC excitation buffer */
9530 : const float preemph_fac, /* i : preemphasis factor */
9531 : const int16_t numLoops /* i : number of loops */
9532 : );
9533 :
9534 : void genPlcFiltBWAdap(
9535 : const int32_t sr_core, /* i : core sampling rate */
9536 : float *lpFiltAdapt, /* o : filter coefficients for filtering codebooks in case of flc */
9537 : const int16_t type, /* i : type of filter, either 0 : lowpass or 1 : highpass */
9538 : const float alpha /* i : fade out factor [0 1) used decrease filter tilt */
9539 : );
9540 :
9541 : void highPassFiltering(
9542 : const int16_t last_good, /* i : last classification type */
9543 : const int16_t L_buffer, /* i : buffer length */
9544 : float exc2[], /* i/o: unvoiced excitation before the high pass filtering */
9545 : const float hp_filt[], /* i : high pass filter coefficients */
9546 : const int16_t l_fir_fer /* i : high pass filter length */
9547 : );
9548 :
9549 : int16_t GetPLCModeDecision(
9550 : Decoder_State *st /* i/o: decoder memory state pointer */
9551 : );
9552 :
9553 : void addBassPostFilter(
9554 : const float *harm_timeIn,
9555 : const int16_t samplesToProcess,
9556 : float **rAnalysis,
9557 : float **iAnalysis,
9558 : HANDLE_CLDFB_FILTER_BANK cldfb );
9559 :
9560 : ivas_error TonalMDCTConceal_Init(
9561 : TonalMDCTConcealPtr hTonalMDCTConc,
9562 : const uint16_t samplesPerBlock,
9563 : const uint16_t nSamplesCore,
9564 : const uint16_t nScaleFactors,
9565 : TCX_CONFIG_HANDLE hTcxCfg );
9566 :
9567 : void TonalMDCTConceal_SaveFreqSignal(
9568 : TonalMDCTConcealPtr hTonalMDCTConc,
9569 : const float *mdctSpectrum,
9570 : const uint16_t numSamples,
9571 : const uint16_t nNewSamplesCore,
9572 : const float *scaleFactors,
9573 : const int16_t infoIGFStartLine );
9574 :
9575 : void TonalMDCTConceal_UpdateState(
9576 : TonalMDCTConcealPtr hTonalMDCTConc,
9577 : const int16_t numSamples,
9578 : const float pitchLag,
9579 : const int16_t badBlock,
9580 : const int16_t tonalConcealmentActive );
9581 :
9582 : void TonalMDCTConceal_SaveTimeSignal(
9583 : TonalMDCTConcealPtr hTonalMDCTConc,
9584 : float *timeSignal,
9585 : const int16_t numSamples );
9586 :
9587 : void TonalMDCTConceal_Detect(
9588 : const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
9589 : const float pitchLag, /*IN */
9590 : int16_t *umIndices, /*OUT*/
9591 : const PsychoacousticParameters *psychParamsCurrent /*IN*/
9592 : );
9593 :
9594 : void TonalMDCTConceal_Apply(
9595 : TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
9596 : float *mdctSpectrum, /*OUT*/
9597 : const PsychoacousticParameters *psychParamsCurrent /*IN*/
9598 : );
9599 :
9600 : void TonalMDCTConceal_InsertNoise(
9601 : const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
9602 : float *mdctSpectrum, /*OUT*/
9603 : const int16_t tonalConcealmentActive,
9604 : int16_t *pSeed, /*IN/OUT*/
9605 : const float tiltCompFactor,
9606 : const float crossfadeGain,
9607 : const float concealment_noise[L_FRAME48k],
9608 : const float cngLevelBackgroundTrace_bfi,
9609 : const int16_t crossOverFreq );
9610 :
9611 : void DetectTonalComponents(
9612 : uint16_t indexOfTonalPeak[],
9613 : uint16_t lowerIndex[],
9614 : uint16_t upperIndex[],
9615 : uint16_t *pNumIndexes,
9616 : const float lastPitchLag,
9617 : const float currentPitchLag,
9618 : const float lastMDCTSpectrum[],
9619 : const float scaleFactors[],
9620 : const float secondLastPowerSpectrum[],
9621 : const uint16_t nSamples,
9622 : const uint16_t nSamplesCore,
9623 : float floorPowerSpectrum,
9624 : const PsychoacousticParameters *psychParamsCurrent );
9625 :
9626 : void RefineTonalComponents(
9627 : uint16_t indexOfTonalPeak[],
9628 : uint16_t lowerIndex[],
9629 : uint16_t upperIndex[],
9630 : float phaseDiff[],
9631 : float phases[],
9632 : uint16_t *pNumIndexes,
9633 : const float lastPitchLag,
9634 : const float currentPitchLag,
9635 : const float lastMDCTSpectrum[],
9636 : const float scaleFactors[],
9637 : const float secondLastPowerSpectrum[],
9638 : const uint16_t nSamples,
9639 : const uint16_t nSamplesCore,
9640 : float floorPowerSpectrum,
9641 : const PsychoacousticParameters *psychParamsCurrent );
9642 :
9643 : ivas_error PsychoacousticParameters_Init(
9644 : const int32_t sr_core, /* i : sampling rate of core-coder */
9645 : const int16_t nBins, /* i : Number of bins (spectral lines) */
9646 : const int8_t nBands, /* i : Number of spectrum subbands */
9647 : const int16_t isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */
9648 : const int16_t isWarped, /* i : Flag indicating if the scale is linear or warped */
9649 : PsychoacousticParameters *pPsychParams );
9650 :
9651 : void concealment_init(
9652 : const int16_t L_frameTCX,
9653 : T_PLCInfo_HANDLE hPlcInfo );
9654 :
9655 : void concealment_decode(
9656 : const int16_t core,
9657 : float *invkoef,
9658 : T_PLCInfo_HANDLE hPlcInfo );
9659 :
9660 : void concealment_update(
9661 : const int16_t bfi,
9662 : const int16_t core,
9663 : const int16_t harmonic,
9664 : float *invkoef,
9665 : T_PLCInfo_HANDLE hPlcInfo );
9666 :
9667 : void concealment_update2(
9668 : const float *outx_new,
9669 : T_PLCInfo_HANDLE hPlcInfo,
9670 : const int16_t L_frameTCX );
9671 :
9672 : void concealment_signal_tuning(
9673 : Decoder_State *st,
9674 : const int16_t bfi,
9675 : float *outx_new,
9676 : const int16_t past_core_mode );
9677 :
9678 : void waveform_adj2(
9679 : T_PLCInfo_HANDLE hPlcInfo,
9680 : float *overlapbuf,
9681 : float *outx_new,
9682 : const int16_t delay,
9683 : const int16_t bfi_cnt,
9684 : const int16_t bfi );
9685 :
9686 : float SFM_Cal(
9687 : const float fcoef[],
9688 : const int16_t n );
9689 :
9690 : void set_state(
9691 : int16_t *state,
9692 : const int16_t num,
9693 : const int16_t N );
9694 :
9695 : int16_t RFFTN(
9696 : float *afftData,
9697 : const float *trigPtr,
9698 : const int16_t len,
9699 : const int16_t isign );
9700 :
9701 : void DoFFT(
9702 : float *re2,
9703 : float *im2,
9704 : const int16_t length );
9705 :
9706 : /*! r: flag indicating a valid bitrate */
9707 : int16_t is_EVS_bitrate(
9708 : const int32_t ivas_total_brate, /* i : EVS total bitrate */
9709 : int16_t *Opt_AMR_WB /* i : AMR-WB IO flag */
9710 : );
9711 :
9712 : /*! r: codec mode */
9713 : int16_t get_codec_mode(
9714 : const int32_t total_brate /* i : total bitrate */
9715 : );
9716 :
9717 : int16_t getTcxonly(
9718 : const int16_t element_mode, /* i : IVAS element mode */
9719 : const int32_t total_brate, /* i : total bitrate */
9720 : const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/
9721 : const int16_t is_ism_format /* i : flag indicating ISM format */
9722 : );
9723 :
9724 : int16_t getTnsAllowed(
9725 : const int32_t total_brate, /* i : total bitrate */
9726 : const int16_t igf, /* i : flag indicating IGF activity*/
9727 : const int16_t element_mode /* i : IVAS element mode */
9728 : );
9729 :
9730 : int16_t getCtxHm(
9731 : const int16_t element_mode, /* i : IVAS element mode */
9732 : const int32_t total_brate, /* i : total bitrate */
9733 : const int16_t rf_flag /* i : flag to signal the RF mode */
9734 : );
9735 :
9736 : int16_t getResq(
9737 : const int32_t total_brate /* i : total bitrate */
9738 : );
9739 :
9740 : int16_t getRestrictedMode(
9741 : const int16_t element_mode, /* i : IVAS element mode */
9742 : const int32_t total_brate, /* i : total bitrate */
9743 : const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
9744 : );
9745 :
9746 : int16_t getMdctWindowLength(
9747 : const int16_t fscale );
9748 :
9749 : int16_t sr2fscale(
9750 : const int32_t sr_core /* i : internal sampling rate */
9751 : );
9752 :
9753 : int32_t getCoreSamplerateMode2(
9754 : const int16_t element_mode, /* i : IVAS element mode */
9755 : const int32_t total_brate, /* i : total bitrate */
9756 : const int16_t bwidth, /* i : audio bandwidth */
9757 : const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */
9758 : const int16_t rf_mode, /* i : flag to signal the RF mode */
9759 : const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */
9760 : );
9761 :
9762 : float getTcxBandwidth(
9763 : const int16_t bwidth /* i : audio bandwidth */
9764 : );
9765 :
9766 : int16_t getIgfPresent(
9767 : const int16_t element_mode, /* i : IVAS element mode */
9768 : const int32_t total_brate, /* i : total bitrate */
9769 : const int16_t bwidth, /* i : audio bandwidth */
9770 : const int16_t rf_mode /* i : flag to signal the RF mode */
9771 : );
9772 :
9773 : int16_t getCnaPresent(
9774 : const int16_t element_mode, /* i : element mode */
9775 : const int32_t element_brate, /* i : element bitrate */
9776 : const int32_t total_brate, /* i : total bitrate */
9777 : const int16_t bwidth /* i : audio bandwidth */
9778 : );
9779 :
9780 : int16_t getTcxLtp(
9781 : const int32_t sr_core /* i : internal sampling rate */
9782 : );
9783 :
9784 : int16_t initPitchLagParameters(
9785 : const int32_t sr_core, /* i : internal sampling rate */
9786 : int16_t *pit_min,
9787 : int16_t *pit_fr1,
9788 : int16_t *pit_fr1b,
9789 : int16_t *pit_fr2,
9790 : int16_t *pit_max );
9791 :
9792 : void attenuateNbSpectrum(
9793 : const int16_t L_frame,
9794 : float *spectrum );
9795 :
9796 : void SetModeIndex(
9797 : Encoder_State *st, /* i : Encoder state */
9798 : const int32_t last_total_brate, /* i : last total bitrate */
9799 : const int16_t last_element_mode, /* i : last IVAS element mode */
9800 : const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
9801 : );
9802 :
9803 : int16_t getNumTcxCodedLines(
9804 : const int16_t bwidth /* i : audio bandwidth */
9805 : );
9806 :
9807 : int16_t getTcxLpcShapedAri(
9808 : const int32_t total_brate, /* i : total bitrate */
9809 : const int16_t rf_mode, /* i : flag to signal the RF mode */
9810 : const int16_t element_mode /* i : IVAS element mode */
9811 : );
9812 :
9813 : void IGFEncApplyMono(
9814 : Encoder_State *st, /* i : Encoder state */
9815 : const int16_t igfGridIdx, /* i : IGF grid index */
9816 : float *pMDCTSpectrum, /* i/o: MDCT spectrum */
9817 : float *pPowerSpectrum, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
9818 : const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
9819 : const int16_t isTNSActive, /* i : flag indicating if the TNS is active */
9820 : const int16_t sp_aud_decision0, /* i : first stage switching decision */
9821 : const int16_t vad_hover_flag /* i : VAD hangover flag */
9822 : );
9823 :
9824 : void IGFEncApplyStereo(
9825 : STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */
9826 : int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
9827 : const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */
9828 : const int16_t igfGridIdx, /* i : IGF grid index */
9829 : Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
9830 : float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
9831 : float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */
9832 : float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
9833 : const int16_t frameno, /* i : flag indicating index of current subframe */
9834 : const int16_t sp_aud_decision0, /* i : sp_aud_decision0 */
9835 : const int32_t element_brate, /* i : element bitrate */
9836 : const int16_t mct_on /* i : flag mct block (1) or stereo (0) */
9837 : );
9838 :
9839 : void IGFEncConcatenateBitstream(
9840 : const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
9841 : const int16_t bsBits, /* i : number of IGF bits written to list of indices */
9842 : BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */
9843 : );
9844 :
9845 : void IGFEncResetTCX10BitCounter(
9846 : const IGF_ENC_INSTANCE_HANDLE hIGFEnc /* i : instance handle of IGF Encoder */
9847 : );
9848 :
9849 : ivas_error IGF_Reconfig(
9850 : IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */
9851 : const int16_t igf, /* i : IGF on/off */
9852 : const int16_t reset, /* i : reset flag */
9853 : const int32_t brate, /* i : bitrate for configuration */
9854 : const int16_t bwidth, /* i : signal bandwidth */
9855 : const int16_t element_mode, /* i : IVAS element mode */
9856 : const int16_t rf_mode /* i : flag to signal the RF mode */
9857 : );
9858 :
9859 : void IGFEncSetMode(
9860 : const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
9861 : const int32_t total_brate, /* i : encoder total bitrate */
9862 : const int16_t bwidth, /* i : encoder audio bandwidth */
9863 : const int16_t element_mode, /* i : IVAS element mode */
9864 : const int16_t rf_mode /* i : flag to signal the RF mode */
9865 : );
9866 :
9867 : /*! r: number of bits written per frame */
9868 : int16_t IGFEncWriteBitstream(
9869 : const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
9870 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
9871 : int16_t *pBitOffset, /* i : ptr to bitOffset counter */
9872 : const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */
9873 : const int16_t isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */
9874 : );
9875 :
9876 : /*! r: total number of bits written */
9877 : int16_t IGFEncWriteConcatenatedBitstream(
9878 : const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
9879 : BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
9880 : );
9881 :
9882 : void IGFDecApplyMono(
9883 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */
9884 : float *spectrum, /* i/o: MDCT spectrum */
9885 : const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */
9886 : const int16_t bfi, /* i : frame loss == 1, frame good == 0 */
9887 : const int16_t element_mode /* i : IVAS element mode */
9888 : );
9889 :
9890 : void IGFDecCopyLPCFlatSpectrum(
9891 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */
9892 : const float *pSpectrumFlat, /* i : LPC flattend spectrum from TCX dec */
9893 : const int16_t igfGridIdx /* i : IGF grid index */
9894 : );
9895 :
9896 : void IGFDecReadData(
9897 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder */
9898 : Decoder_State *st, /* i : decoder state */
9899 : const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */
9900 : const int16_t isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */
9901 : );
9902 :
9903 : /*! r: return igfAllZero flag indicating if no envelope is transmitted */
9904 : int16_t IGFDecReadLevel(
9905 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder */
9906 : Decoder_State *st, /* i : decoder state */
9907 : const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */
9908 : const int16_t isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */
9909 : );
9910 :
9911 : void IGFDecRestoreTCX10SubFrameData(
9912 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */
9913 : const int16_t subFrameIdx /* i : index of subframe */
9914 : );
9915 :
9916 : void init_igf_dec(
9917 : IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */
9918 : );
9919 :
9920 : void IGFDecSetMode(
9921 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */
9922 : const int32_t total_brate, /* i : bitrate */
9923 : const int16_t bwidth, /* i : audio bandwidth */
9924 : const int16_t element_mode, /* i : IVAS element mode */
9925 : const int16_t defaultStartLine, /* i : default start subband index */
9926 : const int16_t defaultStopLine, /* i : default stop subband index */
9927 : const int16_t rf_mode /* i : flag to signal the RF mode */
9928 : );
9929 :
9930 : void IGFDecStoreTCX10SubFrameData(
9931 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */
9932 : const int16_t subFrameIdx /* i : index of subframe */
9933 : );
9934 :
9935 : void IGFDecUpdateInfo(
9936 : const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */
9937 : const int16_t subFrameIdx, /* i : subframe index */
9938 : const int16_t igfGridIdx /* i : IGF grid index */
9939 : );
9940 :
9941 : /*! r: error value: 0 -> error, 1 -> ok */
9942 : int16_t IGFCommonFuncsIGFConfiguration(
9943 : const int32_t total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */
9944 : const int16_t bwidth, /* i : audio bandwidth */
9945 : const int16_t element_mode, /* i : IVAS element mode */
9946 : H_IGF_INFO hIGFInfo, /* o : IGF info handle */
9947 : const int16_t rf_mode /* i : flag to signal the RF mode */
9948 : );
9949 :
9950 : /*! r: error value: 0 -> error, 1 -> ok */
9951 : int16_t IGFCommonFuncsIGFGetCFTables(
9952 : const int32_t total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */
9953 : const int16_t bwidth, /* i : audio bandwidth */
9954 : const int16_t element_mode, /* i : element mode */
9955 : const int16_t rf_mode, /* i : flag to signal the RF mode */
9956 : const uint16_t **cf_se00, /* i : CF table for t == 0 and f == 0 */
9957 : const uint16_t **cf_se01, /* i : CF table for t == 0 and f == 1 */
9958 : int16_t *cf_off_se01, /* o : offset for CF table above */
9959 : const uint16_t **cf_se02, /* i : CF tables for t == 0 and f >= 2 */
9960 : const int16_t **cf_off_se02, /* o : offsets for CF tables above */
9961 : const uint16_t **cf_se10, /* i : CF table for t == 1 and f == 0 */
9962 : int16_t *cf_off_se10, /* o : offset for CF table above */
9963 : const uint16_t **cf_se11, /* i : CF tables for t == 1 and f >= 1 */
9964 : const int16_t **cf_off_se11 /* o : offsets for CF tables above */
9965 : );
9966 :
9967 : /*! r: multiplication factor */
9968 : int16_t IGF_ApplyTransFac(
9969 : const int16_t val, /* i : input value for multiplication, Q15 */
9970 : const float transFac /* i : multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000 */
9971 : );
9972 :
9973 : /*! r: return bitrate index */
9974 : int16_t IGF_MapBitRateToIndex(
9975 : const int32_t brate, /* i : bitrate */
9976 : const int16_t bwidth, /* i : audio bandwidth */
9977 : const int16_t element_mode, /* i : IVAS element mode */
9978 : const int16_t rf_mode /* i : flag to signal the RF mode */
9979 : );
9980 :
9981 : void IGFSCFEncoderOpen(
9982 : IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */
9983 : H_IGF_INFO hIgfInfo, /* i : IGF info handle */
9984 : const int32_t total_brate, /* i : total bitrate */
9985 : const int16_t bwidth, /* i : audio bandwidth */
9986 : const int16_t element_mode, /* i : IVAS element mode */
9987 : const int16_t rf_mode /* i : flag to signal the RF mode */
9988 : );
9989 :
9990 : void IGFSCFEncoderReset(
9991 : IGFSCFENC_INSTANCE_HANDLE hPublicData /* i : handle to public data or NULL in case there was no instance created */
9992 : );
9993 :
9994 : int16_t IGFSCFEncoderEncode(
9995 : IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */
9996 : BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
9997 : const int16_t bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */
9998 : int16_t *sfe, /* i : ptr to an array which contain quantized scalefactor energies */
9999 : const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */
10000 : const int16_t indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */
10001 : );
10002 :
10003 : void IGFSCFEncoderSaveContextState(
10004 : IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */
10005 : const int16_t igfGridIdx /* i : igf grid index see declaration of IGF_GRID_IDX for details */
10006 : );
10007 :
10008 : void IGFSCFEncoderRestoreContextState(
10009 : IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */
10010 : const int16_t igfGridIdx /* i : igf grid index see declaration of IGF_GRID_IDX for details */
10011 : );
10012 :
10013 : void IGFSCFDecoderOpen(
10014 : IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */
10015 : H_IGF_INFO hIgfInfo, /* i : IGF info handle */
10016 : const int32_t total_brate,
10017 : const int16_t bwidth,
10018 : const int16_t element_mode,
10019 : const int16_t rf_mode );
10020 :
10021 : void IGFSCFDecoderReset(
10022 : IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i : handle to public data or NULL in case there was no instance created */
10023 : );
10024 :
10025 : void IGFSCFDecoderDecode(
10026 : IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */
10027 : Decoder_State *st, /* i/o: pointer to decoder state */
10028 : int16_t *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */
10029 : const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */
10030 : const int16_t indepFlag /* i : if 1 on input the decoder will be forced to reset,
10031 : if 0 on input the decoder will be forced to encode without a reset */
10032 : );
10033 :
10034 : /*! r: offset value */
10035 : int16_t tbe_celp_exc_offset(
10036 : const int16_t T0, /* i : Integer pitch */
10037 : const int16_t T0_frac /* i : Fractional part of the pitch */
10038 : );
10039 :
10040 : void blend_subfr2(
10041 : float *sigIn1, /* i : input signal for fade-out */
10042 : float *sigIn2, /* i : input signal for fade-in */
10043 : float *sigOut /* o : output signal */
10044 : );
10045 :
10046 : void init_tcx_window_cfg(
10047 : TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX Config handle */
10048 : const int32_t sr_core, /* i : SR core */
10049 : const int32_t input_Fs, /* i : input/output SR */
10050 : const int16_t L_frame, /* i : L_frame at sr_core */
10051 : const int16_t L_frameTCX, /* i : L_frame at i/o SR */
10052 : const int16_t encoderLookahead_enc, /* i : encoder LA at sr_core */
10053 : const int16_t encoderLookahead_FB, /* i : encoder LA at i/o SR */
10054 : const int16_t mdctWindowLength, /* i : window length at sr_core */
10055 : const int16_t mdctWindowLengthFB, /* i : window length at i/o SR */
10056 : const int16_t element_mode /* i : mode of CPE/SCE */
10057 : );
10058 :
10059 : void init_tcx_cfg(
10060 : TCX_CONFIG_HANDLE hTcxCfg,
10061 : const int32_t total_brate,
10062 : const int32_t sr_core,
10063 : const int32_t input_Fs,
10064 : const int16_t L_frame,
10065 : const int16_t bwidth,
10066 : const int16_t L_frameTCX,
10067 : const int16_t fscale,
10068 : const int16_t encoderLookahead_enc,
10069 : const int16_t encoderLookahead_FB,
10070 : const float preemph_fac,
10071 : const int16_t tcxonly,
10072 : const int16_t rf_mode,
10073 : const int16_t igf,
10074 : const int16_t infoIGFStopFreq,
10075 : const int16_t element_mode,
10076 : const int16_t ini_frame,
10077 : const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
10078 : );
|