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 11680969 : 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 11680969 : if ( L_frame == L_FRAME )
72 : {
73 4874672 : g1 = FORMANT_SHARPENING_G1;
74 4874672 : g2 = FORMANT_SHARPENING_G2;
75 : }
76 : else
77 : {
78 6806297 : g1 = FORMANT_SHARPENING_G1_16k;
79 6806297 : g2 = FORMANT_SHARPENING_G2_16k;
80 : }
81 :
82 11680969 : if ( !Opt_AMR_WB )
83 : {
84 11657229 : if ( st->acelp_cfg.fcb_mode )
85 : {
86 : int16_t i;
87 : int16_t indexing_indices[8], wordcnt, bitcnt;
88 : PulseConfig config;
89 :
90 10378986 : if ( st->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr] >= 0 )
91 : {
92 10378786 : if ( L_subfr == 2 * L_SUBFR )
93 : {
94 53866 : nBits = st->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr];
95 :
96 53866 : if ( nBits == 8 )
97 : {
98 0 : dec_acelp_1t64( st, code, L_subfr );
99 : }
100 : else
101 : {
102 53866 : dec_acelp_fast( st, nBits, code, L_subfr );
103 : }
104 : }
105 10324920 : 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 527067 : if ( st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] == 0 )
108 : {
109 2073 : dec_acelp_1t64( st, code, L_SUBFR );
110 : }
111 : else
112 : {
113 524994 : dec_acelp_fast( st, st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], code, L_SUBFR );
114 : }
115 : }
116 : else
117 : {
118 9797853 : wordcnt = ACELP_FIXED_CDK_BITS( st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ) >> 4;
119 9797853 : bitcnt = ACELP_FIXED_CDK_BITS( st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ) & 15;
120 :
121 33671980 : for ( i = 0; i < wordcnt; i++ )
122 : {
123 23874127 : indexing_indices[i] = get_next_indice( st, 16 );
124 : }
125 9797853 : if ( bitcnt )
126 : {
127 9291440 : indexing_indices[i] = get_next_indice( st, bitcnt );
128 : }
129 9797853 : config = PulseConfTable[st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]];
130 9797853 : D_ACELP_indexing( code, config, NB_TRACK_FCB_4T, indexing_indices, &st->BER_detect );
131 : }
132 : }
133 : else
134 : {
135 200 : set_f( code, 0.0f, L_SUBFR );
136 : }
137 : }
138 : else
139 : {
140 1278243 : nBits = st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR];
141 :
142 1278243 : if ( nBits == 7 )
143 : {
144 170 : dec_acelp_1t64( st, code, L_SUBFR );
145 : }
146 1278073 : else if ( nBits == 12 )
147 : {
148 115530 : dec_acelp_2t32( st, code );
149 : }
150 : else
151 : {
152 1162543 : dec_acelp_4t64( st, nBits, code, Opt_AMR_WB );
153 : }
154 : }
155 : }
156 : else
157 : {
158 23740 : if ( core_brate == ACELP_6k60 )
159 : {
160 2248 : dec_acelp_2t32( st, code );
161 : }
162 21492 : else if ( core_brate == ACELP_8k85 )
163 : {
164 1816 : dec_acelp_4t64( st, 20, code, Opt_AMR_WB );
165 : }
166 19676 : else if ( core_brate == ACELP_12k65 )
167 : {
168 3940 : dec_acelp_4t64( st, 36, code, Opt_AMR_WB );
169 : }
170 15736 : else if ( core_brate == ACELP_14k25 )
171 : {
172 1728 : dec_acelp_4t64( st, 44, code, Opt_AMR_WB );
173 : }
174 14008 : else if ( core_brate == ACELP_15k85 )
175 : {
176 1408 : dec_acelp_4t64( st, 52, code, Opt_AMR_WB );
177 : }
178 12600 : else if ( core_brate == ACELP_18k25 )
179 : {
180 1408 : dec_acelp_4t64( st, 64, code, Opt_AMR_WB );
181 : }
182 11192 : else if ( core_brate == ACELP_19k85 )
183 : {
184 6024 : dec_acelp_4t64( st, 72, code, Opt_AMR_WB );
185 : }
186 : else
187 : {
188 5168 : dec_acelp_4t64( st, 88, code, Opt_AMR_WB );
189 : }
190 : }
191 :
192 11680969 : cb_shape( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, pt_pitch, L_subfr );
193 :
194 11680969 : return;
195 : }
|