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 : #ifdef DEBUGGING
40 : #include "debug.h"
41 : #endif
42 : #include "cnst.h"
43 : #include "prot.h"
44 : #include "ivas_prot.h"
45 : #include "rom_com.h"
46 : #include "wmc_auto.h"
47 :
48 : /*----------------------------------------------------------------------*
49 : * inov_decode()
50 : *
51 : * Decode the algebraic innovation and do pitch sharpening
52 : *----------------------------------------------------------------------*/
53 :
54 1796187 : void inov_decode(
55 : Decoder_State *st, /* i/o: decoder state structure */
56 : const int32_t core_brate, /* i : core bitrate */
57 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
58 : const int16_t L_frame, /* i : length of the frame */
59 : const int16_t sharpFlag, /* i : formant sharpening flag */
60 : const int16_t i_subfr, /* i : subframe index */
61 : const float *p_Aq, /* i : LP filter coefficients */
62 : const float tilt_code, /* i : tilt of the excitation of previous subframe */
63 : const float pt_pitch, /* i : pointer to current subframe fractional pitch*/
64 : float *code, /* o : algebraic excitation */
65 : const int16_t L_subfr /* i : subframe length */
66 : )
67 : {
68 : int16_t nBits;
69 : float g1, g2;
70 :
71 1796187 : if ( L_frame == L_FRAME )
72 : {
73 761247 : g1 = FORMANT_SHARPENING_G1;
74 761247 : g2 = FORMANT_SHARPENING_G2;
75 : }
76 : else
77 : {
78 1034940 : g1 = FORMANT_SHARPENING_G1_16k;
79 1034940 : g2 = FORMANT_SHARPENING_G2_16k;
80 : }
81 :
82 1796187 : if ( !Opt_AMR_WB )
83 : {
84 1796187 : if ( st->acelp_cfg.fcb_mode )
85 : {
86 : int16_t i;
87 : int16_t indexing_indices[8], wordcnt, bitcnt;
88 : PulseConfig config;
89 :
90 1560117 : if ( st->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr] >= 0 )
91 : {
92 1560003 : if ( L_subfr == 2 * L_SUBFR )
93 : {
94 11976 : nBits = st->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr];
95 :
96 11976 : if ( nBits == 8 )
97 : {
98 0 : dec_acelp_1t64( st, code, L_subfr );
99 : }
100 : else
101 : {
102 11976 : dec_acelp_fast( st, nBits, code, L_subfr );
103 : }
104 : }
105 1548027 : else if ( ( st->idchan == 1 && st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] <= 7 ) || ( st->idchan == 0 && st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] <= 3 ) )
106 : {
107 73449 : if ( st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] == 0 )
108 : {
109 1056 : dec_acelp_1t64( st, code, L_SUBFR );
110 : }
111 : else
112 : {
113 72393 : dec_acelp_fast( st, st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], code, L_SUBFR );
114 : }
115 : }
116 : else
117 : {
118 1474578 : wordcnt = ACELP_FIXED_CDK_BITS( st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ) >> 4;
119 1474578 : bitcnt = ACELP_FIXED_CDK_BITS( st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ) & 15;
120 :
121 4868091 : for ( i = 0; i < wordcnt; i++ )
122 : {
123 3393513 : indexing_indices[i] = get_next_indice( st, 16 );
124 : }
125 1474578 : if ( bitcnt )
126 : {
127 1369161 : indexing_indices[i] = get_next_indice( st, bitcnt );
128 : }
129 1474578 : config = PulseConfTable[st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]];
130 1474578 : D_ACELP_indexing( code, config, NB_TRACK_FCB_4T, indexing_indices, &st->BER_detect );
131 : }
132 : }
133 : else
134 : {
135 114 : set_f( code, 0.0f, L_SUBFR );
136 : }
137 : }
138 : else
139 : {
140 236070 : nBits = st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR];
141 :
142 236070 : if ( nBits == 7 )
143 : {
144 0 : dec_acelp_1t64( st, code, L_SUBFR );
145 : }
146 236070 : else if ( nBits == 12 )
147 : {
148 44775 : dec_acelp_2t32( st, code );
149 : }
150 : else
151 : {
152 191295 : dec_acelp_4t64( st, nBits, code, Opt_AMR_WB );
153 : }
154 : }
155 : }
156 : else
157 : {
158 0 : if ( core_brate == ACELP_6k60 )
159 : {
160 0 : dec_acelp_2t32( st, code );
161 : }
162 0 : else if ( core_brate == ACELP_8k85 )
163 : {
164 0 : dec_acelp_4t64( st, 20, code, Opt_AMR_WB );
165 : }
166 0 : else if ( core_brate == ACELP_12k65 )
167 : {
168 0 : dec_acelp_4t64( st, 36, code, Opt_AMR_WB );
169 : }
170 0 : else if ( core_brate == ACELP_14k25 )
171 : {
172 0 : dec_acelp_4t64( st, 44, code, Opt_AMR_WB );
173 : }
174 0 : else if ( core_brate == ACELP_15k85 )
175 : {
176 0 : dec_acelp_4t64( st, 52, code, Opt_AMR_WB );
177 : }
178 0 : else if ( core_brate == ACELP_18k25 )
179 : {
180 0 : dec_acelp_4t64( st, 64, code, Opt_AMR_WB );
181 : }
182 0 : else if ( core_brate == ACELP_19k85 )
183 : {
184 0 : dec_acelp_4t64( st, 72, code, Opt_AMR_WB );
185 : }
186 : else
187 : {
188 0 : dec_acelp_4t64( st, 88, code, Opt_AMR_WB );
189 : }
190 : }
191 :
192 1796187 : cb_shape( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, pt_pitch, L_subfr );
193 :
194 1796187 : return;
195 : }
|