Line data Source code
1 : /******************************************************************************************************
2 :
3 : (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
4 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
5 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
6 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
7 : contributors to this repository. All Rights Reserved.
8 :
9 : This software is protected by copyright law and by international treaties.
10 : The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
11 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
12 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
13 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
14 : contributors to this repository retain full ownership rights in their respective contributions in
15 : the software. This notice grants no license of any kind, including but not limited to patent
16 : license, nor is any license granted by implication, estoppel or otherwise.
17 :
18 : Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
19 : contributions.
20 :
21 : This software is provided "AS IS", without any express or implied warranties. The software is in the
22 : development stage. It is intended exclusively for experts who have experience with such software and
23 : solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
24 : and fitness for a particular purpose are hereby disclaimed and excluded.
25 :
26 : Any dispute, controversy or claim arising under or in relation to providing this software shall be
27 : submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
28 : accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
29 : the United Nations Convention on Contracts on the International Sales of Goods.
30 :
31 : *******************************************************************************************************/
32 :
33 : /*====================================================================================
34 : EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
35 : ====================================================================================*/
36 :
37 : #include <stdint.h>
38 : #include "options.h"
39 : #include "prot.h"
40 : #include "wmc_auto.h"
41 :
42 : /*-------------------------------------------------------------------*
43 : * decod_unvoiced()
44 : *
45 : * Decode unvoiced (UC) frames
46 : *-------------------------------------------------------------------*/
47 :
48 6000 : void decod_unvoiced(
49 : Decoder_State *st, /* i/o: decoder static memory */
50 : const float *Aq, /* i : LP filter coefficient */
51 : const float Es_pred, /* i : predicted scaled innov. energy */
52 : const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */
53 : float *tmp_noise, /* o : long term temporary noise energy */
54 : float *pitch_buf, /* o : floating pitch values for each subframe */
55 : float *voice_factors, /* o : voicing factors */
56 : float *exc, /* o : adapt. excitation exc */
57 : float *exc2, /* o : adapt. excitation/total exc */
58 : float *bwe_exc, /* i/o: excitation for SWB TBE */
59 : float *gain_buf /* o : floating pitch gain for each subframe */
60 : )
61 : {
62 6000 : float gain_pit = 0; /* Quantized pitch gain */
63 : float gain_code; /* Quantized algebraic codeebook gain */
64 : float gain_inov; /* inovation gain */
65 : float norm_gain_code; /* normalized algebraic codeebook gain */
66 : float voice_fac; /* Voicing factor */
67 : float code[L_SUBFR]; /* algebraic codevector */
68 : int16_t i_subfr;
69 : float *pt_pitch;
70 : const float *p_Aq;
71 : int16_t i;
72 : int16_t index;
73 : float gain_code2;
74 : float code2[L_SUBFR];
75 :
76 6000 : if ( st->last_ppp_mode_dec == 1 || st->last_nelp_mode_dec == 1 )
77 : {
78 : /* SC_VBR - reset the decoder, to avoid memory not updated issue for this unrealistic case */
79 0 : CNG_reset_dec( st, pitch_buf, voice_factors );
80 : }
81 :
82 6000 : p_Aq = Aq; /* pointer to interpolated LPC parameters */
83 6000 : pt_pitch = pitch_buf; /* pointer to the pitch buffer */
84 :
85 30000 : for ( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR )
86 : {
87 24000 : if ( !uc_two_stage_flag )
88 : {
89 : /*----------------------------------------------------------------*
90 : * Unvoiced subframe processing
91 : *----------------------------------------------------------------*/
92 :
93 0 : gaus_dec( st, i_subfr, code, &norm_gain_code, &st->lp_gainp, &st->lp_gainc, &gain_inov, &st->tilt_code, &voice_fac, &gain_pit, pt_pitch, exc, &gain_code, exc2 );
94 : }
95 : else
96 : {
97 : /*----------------------------------------------------------------*
98 : * Unvoiced subframe processing in two stages
99 : *----------------------------------------------------------------*/
100 :
101 : /* No adaptive codebook (UC) */
102 24000 : set_zero( exc + i_subfr, L_SUBFR );
103 :
104 24000 : *pt_pitch = (float) L_SUBFR;
105 :
106 : /*--------------------------------------------------------------*
107 : * Innovation decoding
108 : *--------------------------------------------------------------*/
109 :
110 24000 : inov_decode( st, st->core_brate, 0, L_FRAME, 1, i_subfr, p_Aq, st->tilt_code, *pt_pitch, code, L_SUBFR );
111 :
112 : /*-------------------------------------------------------*
113 : * Generate Gaussian excitation *
114 : *-------------------------------------------------------*/
115 :
116 24000 : gaus_L2_dec( code2, st->tilt_code, p_Aq, FORMANT_SHARPENING_G1, &( st->seed_acelp ) );
117 :
118 : /*-----------------------------------------------------------------*
119 : * Gain encoding
120 : *-----------------------------------------------------------------*/
121 :
122 24000 : index = get_next_indice( st, st->acelp_cfg.gains_mode[i_subfr / L_SUBFR] );
123 24000 : gain_dec_gacelp_uv( index, code, code2, Es_pred, L_SUBFR, &gain_pit, &gain_code, &gain_code2, &( st->past_gpit ), &norm_gain_code, &gain_inov );
124 :
125 24000 : st->tilt_code = est_tilt( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, L_SUBFR, 0 );
126 :
127 : /* update LP filtered gains for the case of frame erasures */
128 24000 : lp_gain_updt( i_subfr, gain_pit, norm_gain_code, &st->lp_gainp, &st->lp_gainc, L_FRAME );
129 :
130 : /*-------------------------------------------------------*
131 : * - Find the total excitation. *
132 : *-------------------------------------------------------*/
133 :
134 1560000 : for ( i = 0; i < L_SUBFR; i++ )
135 : {
136 1536000 : exc2[i + i_subfr] = gain_pit * exc[i + i_subfr];
137 1536000 : exc2[i + i_subfr] += gain_code2 * code2[i];
138 1536000 : exc[i + i_subfr] = exc2[i + i_subfr] + gain_code * code[i];
139 : }
140 : }
141 :
142 24000 : *tmp_noise = norm_gain_code;
143 :
144 : /*----------------------------------------------------------------*
145 : * Excitation enhancements (update of total excitation signal)
146 : *----------------------------------------------------------------*/
147 :
148 24000 : enhancer( MODE1, st->core_brate, uc_two_stage_flag, 0, UNVOICED, L_FRAME, voice_fac, st->stab_fac, norm_gain_code, gain_inov, &st->gc_threshold, code, exc2 + i_subfr, gain_pit, st->dispMem );
149 :
150 24000 : voice_factors[i_subfr / L_SUBFR] = 0.0f;
151 :
152 24000 : if ( st->hBWE_TD != NULL )
153 : {
154 24000 : interp_code_5over2( &exc[i_subfr], &bwe_exc[i_subfr * HIBND_ACB_L_FAC], L_SUBFR );
155 : }
156 :
157 24000 : p_Aq += ( M + 1 );
158 24000 : pt_pitch++;
159 24000 : st->tilt_code_dec[i_subfr / L_SUBFR] = st->tilt_code;
160 : }
161 :
162 : /* SC-VBR */
163 6000 : st->prev_gain_pit_dec = gain_pit;
164 :
165 6000 : set_f( gain_buf, 0, NB_SUBFR );
166 :
167 6000 : return;
168 : }
|