Line data Source code
1 : /*====================================================================================
2 : EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
3 : ====================================================================================*/
4 :
5 : #include <stdint.h>
6 : #include "options.h" /* Compilation switches */
7 : #include "prot_fx.h" /* Function prototypes */
8 :
9 : /*---------------------------------------------------------*
10 : * stat_noise_uv_dec()
11 : *
12 : * Modifies excitation signal in UC mode when the noise is stationary
13 : *---------------------------------------------------------*/
14 129695 : void stat_noise_uv_dec_fx(
15 : Decoder_State *st_fx, /* i/o: Decoder static memory */
16 : Word16 *lsp_new, /* i : end-frame LSP vector Q15 */
17 : Word16 *lsp_mid, /* i : mid-frame LSP vector Q15 */
18 : Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q = 14 - norm_s(Aq[0]) */
19 : Word16 *exc2, /* i/o: excitation buffer, Q = st_fx->Q_exc */
20 : const Word16 uc_two_stage_flag /* i : flag indicating two-stage UC */
21 : )
22 : {
23 129695 : Word16 noisiness = 0, i;
24 129695 : move16();
25 : Word32 L_tmp;
26 129695 : Word16 coder_type = st_fx->coder_type;
27 129695 : move16();
28 :
29 :
30 : /*-----------------------------------------------------------------*
31 : * Decode the VAD flag
32 : *-----------------------------------------------------------------*/
33 129695 : test();
34 129695 : test();
35 129695 : test();
36 129695 : IF( ( EQ_16( coder_type, UNVOICED ) && !uc_two_stage_flag ) || ( coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) ) )
37 : {
38 : /* read the noisiness parameter */
39 337 : noisiness = (Word16) get_next_indice_fx( st_fx, 5 );
40 : }
41 :
42 : /*-----------------------------------------------------------------*
43 : * Update long-term energies for FEC
44 : * Update LSP vector for CNG
45 : *-----------------------------------------------------------------*/
46 129695 : IF( coder_type == INACTIVE )
47 : {
48 5829 : IF( GT_16( st_fx->unv_cnt, 20 ) )
49 : {
50 : /*ftmp = st->lp_gainc * st->lp_gainc;*/
51 3837 : L_tmp = L_mult0( st_fx->lp_gainc_fx, st_fx->lp_gainc_fx ); /*Q3 * Q3 ->Q6*/
52 : /*st->lp_ener = 0.7f * st->lp_ener + 0.3f * ftmp;*/
53 3837 : L_tmp = Mult_32_16( L_tmp, 9830 );
54 3837 : st_fx->lp_ener_fx = L_add( Mult_32_16( st_fx->lp_ener_fx, 22938 ), L_tmp ); /*Q6 + Q6*/
55 3837 : move32();
56 :
57 65229 : FOR( i = 0; i < M; i++ ) /* AR Low pass filter */
58 : {
59 : /*st->lspCNG[i] = (float)(0.9f * st->lspCNG[i] + 0.1f * lspnew[i]);*/
60 61392 : L_tmp = L_mult( lsp_new[i], 3277 );
61 61392 : st_fx->lspCNG_fx[i] = mac_r( L_tmp, st_fx->lspCNG_fx[i], 29491 );
62 61392 : move16(); /*Q15*/
63 : }
64 : }
65 : ELSE
66 : {
67 1992 : st_fx->unv_cnt = add( st_fx->unv_cnt, 1 );
68 1992 : move16();
69 : }
70 : }
71 : ELSE
72 : {
73 123866 : st_fx->unv_cnt = 0;
74 123866 : move16();
75 : }
76 :
77 129695 : IF( !st_fx->Opt_AMR_WB )
78 : {
79 129695 : IF( st_fx->element_mode > EVS_MONO )
80 : {
81 128272 : stat_noise_uv_mod_ivas_fx( coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, &st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count,
82 128272 : st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx,
83 128272 : &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth,
84 : &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge );
85 : }
86 : ELSE
87 : {
88 1423 : stat_noise_uv_mod_fx( coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count,
89 1423 : st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx,
90 1423 : &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth,
91 : &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge );
92 : }
93 : }
94 :
95 :
96 129695 : return;
97 : }
|