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 "rom_com.h"
44 : #include "prot.h"
45 : #include "wmc_auto.h"
46 :
47 : /*-------------------------------------------------------------------*
48 : * encod_nelp()
49 : *
50 : * Encode Unvoiced frames in SC-VBR
51 : *-------------------------------------------------------------------*/
52 :
53 0 : void encod_nelp(
54 : Encoder_State *st, /* i/o: state structure */
55 : const float *speech, /* i : input speech */
56 : const float Aw[], /* i : weighted A(z) unquantized for subframes */
57 : const float *Aq, /* i : 12k8 Lp coefficient */
58 : float *res, /* o : residual signal */
59 : float *synth, /* o : core synthesis */
60 : float *tmp_noise, /* o : long-term noise energy */
61 : float *exc, /* i/o: current non-enhanced excitation */
62 : float *exc2, /* i/o: current enhanced excitation */
63 : float *pitch_buf, /* o : floating pitch values for each subframe */
64 : float *voice_factors, /* o : voicing factors */
65 : float *bwe_exc /* o : excitation for SWB TBE */
66 : )
67 : {
68 : float xn[L_SUBFR]; /* Target vector for pitch search */
69 : float h1[L_SUBFR]; /* Impulse response vector */
70 : float exc_nelp[L_FRAME];
71 : const float *p_Aw, *p_Aq; /* pointer to LP filter coeff. vector */
72 : int16_t i_subfr, j;
73 :
74 0 : LPD_state_HANDLE hLPDmem = st->hLPDmem;
75 0 : SC_VBR_ENC_HANDLE hSC_VBR = st->hSC_VBR;
76 :
77 0 : int16_t reduce_gains = 0;
78 :
79 0 : if ( st->bwidth == NB && st->input_Fs >= 16000 )
80 : {
81 0 : if ( hSC_VBR->last_nelp_mode == 0 )
82 : {
83 0 : set_f( hSC_VBR->nelp_lp_fit_mem, 0, NELP_LP_ORDER * 2 );
84 : }
85 0 : polezero_filter( res, res, L_FRAME, num_nelp_lp, den_nelp_lp, NELP_LP_ORDER, hSC_VBR->nelp_lp_fit_mem ); /*16-Q of filter coeff*/
86 : }
87 :
88 0 : p_Aw = Aw;
89 0 : p_Aq = Aq;
90 :
91 0 : for ( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR )
92 : {
93 : /*----------------------------------------------------------------*
94 : * - Find the excitation search target "xn" and innovation
95 : * target in residual domain "cn"
96 : * - Compute impulse response, h1[], of weighted synthesis filter
97 : *----------------------------------------------------------------*/
98 0 : mvr2r( &res[i_subfr], &exc[i_subfr], L_SUBFR );
99 :
100 0 : find_targets( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, L_SUBFR, p_Aw, TILT_FAC, xn, NULL, h1 );
101 :
102 0 : if ( i_subfr == 0 )
103 : {
104 0 : if ( hSC_VBR->Local_VAD == 1 && st->bwidth == NB )
105 : {
106 0 : reduce_gains = 1;
107 : }
108 :
109 0 : nelp_encoder( st, res, exc_nelp, reduce_gains );
110 : }
111 0 : *tmp_noise = 0;
112 :
113 : /*-----------------------------------------------------------------*
114 : * Synthesize speech to update mem_syn[].
115 : * Update A(z) filters
116 : *-----------------------------------------------------------------*/
117 :
118 0 : syn_filt( p_Aq, M, &exc_nelp[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 );
119 :
120 0 : p_Aw += ( M + 1 );
121 0 : p_Aq += ( M + 1 );
122 0 : *pitch_buf = L_SUBFR;
123 0 : pitch_buf++;
124 : }
125 :
126 0 : mvr2r( exc_nelp, exc, L_FRAME );
127 :
128 : /*-----------------------------------------------------------------*
129 : * Updates: last value of new target is stored in mem_w0
130 : *-----------------------------------------------------------------*/
131 :
132 0 : hLPDmem->mem_w0 = xn[L_SUBFR - 1] - ( exc[L_FRAME - 1] );
133 0 : hLPDmem->tilt_code = 0.0f; /* purely unvoiced */
134 0 : hSC_VBR->prev_tilt_code = hLPDmem->tilt_code;
135 :
136 0 : mvr2r( exc, exc2, L_FRAME );
137 :
138 0 : hSC_VBR->prev_ppp_gain_pit = 0.0;
139 0 : hLPDmem->dispMem[0] = 0;
140 0 : hLPDmem->dispMem[2] = hSC_VBR->prev_ppp_gain_pit;
141 :
142 0 : for ( j = 3; j < 7; j++ )
143 : {
144 0 : hLPDmem->dispMem[j] = hLPDmem->dispMem[j - 1];
145 : }
146 :
147 0 : interp_code_5over2( exc2, bwe_exc, L_FRAME );
148 0 : set_f( voice_factors, 0.0f, NB_SUBFR16k );
149 :
150 0 : return;
151 : }
|