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 "rom_com.h"
45 : #include "wmc_auto.h"
46 :
47 : /*---------------------------------------------------------------------*
48 : * int_lsp()
49 : *
50 : * Find the interpolated LSP parameters for all subframes
51 : *---------------------------------------------------------------------*/
52 :
53 416570 : void int_lsp(
54 : const int16_t L_frame, /* i : length of the frame */
55 : const float lsp_old[], /* i : LSPs from past frame */
56 : const float lsp_new[], /* i : LSPs from present frame */
57 : float *Aq, /* o : LP coefficients in both subframes */
58 : const int16_t m, /* i : order of LP filter */
59 : const float *int_coeffs, /* i : interpolation coefficients */
60 : const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
61 : )
62 : {
63 : float lsp[M], fnew, fold;
64 : int16_t i, k;
65 : const float *pt_int_coeffs;
66 :
67 416570 : if ( L_frame == L_FRAME )
68 : {
69 171706 : pt_int_coeffs = int_coeffs;
70 : }
71 : else /* L_frame == L_FRAME16k */
72 : {
73 244864 : pt_int_coeffs = interpol_frac_16k;
74 : }
75 :
76 2327714 : for ( k = 0; k < L_frame / L_SUBFR; k++ )
77 : {
78 1911144 : fnew = pt_int_coeffs[k];
79 1911144 : fold = (float) ( 1.0f - fnew );
80 :
81 32489448 : for ( i = 0; i < m; i++ )
82 : {
83 30578304 : lsp[i] = lsp_old[i] * fold + lsp_new[i] * fnew;
84 : }
85 :
86 1911144 : if ( Opt_AMR_WB )
87 : {
88 0 : isp2a( lsp, Aq, m );
89 : }
90 : else
91 : {
92 1911144 : lsp2a_stab( lsp, Aq, m );
93 : }
94 :
95 1911144 : Aq += ( m + 1 );
96 : }
97 :
98 416570 : return;
99 : }
100 :
101 : /*---------------------------------------------------------------------*
102 : * int_lsp4()
103 : *
104 : * Interpolate LSPs find the A[z] parameters for all subframes by interpolating between
105 : * old end-frame LSPs, current mid-frame LSPs and current end-frame LSPs
106 : *---------------------------------------------------------------------*/
107 :
108 1940860 : void int_lsp4(
109 : const int16_t L_frame, /* i : length of the frame */
110 : const float lsp_old[], /* i : LSPs from past frame */
111 : const float lsp_mid[], /* i : LSPs from mid-frame */
112 : const float lsp_new[], /* i : LSPs from present frame */
113 : float *Aq, /* o : LP coefficients in both subframes */
114 : const int16_t m, /* i : order of LP filter */
115 : int16_t relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */
116 : )
117 : {
118 : float lsp[M];
119 : int16_t i;
120 : int16_t j;
121 : const float *pt_int_coeffs;
122 :
123 1940860 : if ( L_frame == L_FRAME )
124 : {
125 1483864 : if ( relax_prev_lsf_interp == 1 )
126 : {
127 321 : pt_int_coeffs = interpol_frac_mid_relaxprev_12k8;
128 : }
129 1483543 : else if ( relax_prev_lsf_interp == 2 )
130 : {
131 198 : pt_int_coeffs = interpol_frac_mid_FEC;
132 : }
133 1483345 : else if ( relax_prev_lsf_interp == -1 )
134 : {
135 48 : pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8;
136 : }
137 1483297 : else if ( relax_prev_lsf_interp == -2 )
138 : {
139 0 : pt_int_coeffs = interpol_frac2_mid;
140 : }
141 : else
142 : {
143 1483297 : pt_int_coeffs = interpol_frac_mid;
144 : }
145 : }
146 : else /* L_frame == L_FRAME16k */
147 : {
148 456996 : if ( relax_prev_lsf_interp == 1 )
149 : {
150 597 : pt_int_coeffs = interpol_frac_mid_relaxprev_16k;
151 : }
152 456399 : else if ( relax_prev_lsf_interp == 2 )
153 : {
154 297 : pt_int_coeffs = interpol_frac_mid_16k_FEC;
155 : }
156 456102 : else if ( relax_prev_lsf_interp == -1 )
157 : {
158 0 : pt_int_coeffs = interpol_frac_mid_relaxprev_pred_16k;
159 : }
160 : else
161 : {
162 456102 : pt_int_coeffs = interpol_frac_mid_16k;
163 : }
164 : }
165 :
166 10161296 : for ( j = 0; j < L_frame / L_SUBFR; j++ )
167 : {
168 139747412 : for ( i = 0; i < m; i++ )
169 : {
170 131526976 : lsp[i] = lsp_old[i] * ( *pt_int_coeffs ) + lsp_mid[i] * ( *( pt_int_coeffs + 1 ) ) + lsp_new[i] * ( *( pt_int_coeffs + 2 ) );
171 : }
172 8220436 : pt_int_coeffs += 3;
173 :
174 8220436 : lsp2a_stab( lsp, Aq, m );
175 :
176 8220436 : Aq += ( m + 1 );
177 : }
178 :
179 1940860 : return;
180 : }
|