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 : * pred_lt4()
49 : *
50 : * Compute the result of long term prediction with fractionnal
51 : * interpolation of resolution 1/4.
52 : *
53 : * On return, exc[0..L_subfr-1] contains the interpolated signal
54 : * (adaptive codebook excitation)
55 : *-------------------------------------------------------------------*/
56 :
57 3557570 : void pred_lt4(
58 : const float excI[], /* i : input excitation buffer */
59 : float excO[], /* o : output excitation buffer */
60 : const int16_t T0, /* i : integer pitch lag */
61 : int16_t frac, /* i : fraction of lag */
62 : const int16_t L_subfr, /* i : subframe size */
63 : const float *win, /* i : interpolation window */
64 : const int16_t nb_coef, /* i : nb of filter coef */
65 : const int16_t up_sample /* i : up_sample */
66 : )
67 : {
68 : int16_t i, j;
69 : float s;
70 : const float *x1, *x2, *x0, *c1, *c2;
71 :
72 3557570 : x0 = &excI[-T0];
73 3557570 : frac = -frac;
74 :
75 3557570 : if ( frac < 0 )
76 : {
77 2569789 : frac += up_sample;
78 2569789 : x0--;
79 : }
80 :
81 244777282 : for ( j = 0; j < L_subfr; j++ )
82 : {
83 241219712 : x1 = x0++;
84 241219712 : x2 = x1 + 1;
85 241219712 : c1 = &win[frac];
86 241219712 : c2 = &win[up_sample - frac];
87 :
88 241219712 : s = 0.0f;
89 3189670832 : for ( i = 0; i < nb_coef; i++, c1 += up_sample, c2 += up_sample )
90 : {
91 2948451120 : s += ( *x1-- ) * ( *c1 ) + ( *x2++ ) * ( *c2 );
92 : }
93 241219712 : excO[j] = s;
94 : }
95 :
96 3557570 : return;
97 : }
98 :
99 : /*-------------------------------------------------------------------*
100 : * pred_lt4_tc()
101 : *
102 : * adapt. search of the second impulse in the same subframe (when appears)
103 : * On return, exc[0..L_subfr-1] contains the interpolated signal
104 : * (adaptive codebook excitation)
105 : *-------------------------------------------------------------------*/
106 :
107 56198 : void pred_lt4_tc(
108 : float exc[], /* i/o: excitation buffer */
109 : const int16_t T0, /* i : integer pitch lag */
110 : int16_t frac, /* i : fraction of lag */
111 : const float *win, /* i : interpolation window */
112 : const int16_t imp_pos, /* i : glottal impulse position */
113 : const int16_t i_subfr /* i : subframe index */
114 : )
115 : {
116 : int16_t i, j;
117 : float s;
118 : const float *x1, *x2, *x0, *c1, *c2;
119 : float excO[L_SUBFR + 1];
120 : float excI[2 * L_SUBFR];
121 :
122 56198 : mvr2r( exc + i_subfr - L_SUBFR, excI, 2 * L_SUBFR );
123 :
124 56198 : if ( ( ( T0 + imp_pos - L_IMPULSE2 ) < L_SUBFR ) && ( T0 < L_SUBFR ) )
125 : {
126 8585 : set_f( excI + L_SUBFR - T0, 0, T0 );
127 8585 : set_f( excO, 0, L_SUBFR + 1 );
128 8585 : x0 = excI + L_SUBFR;
129 8585 : frac = -frac;
130 :
131 8585 : if ( frac < 0 )
132 : {
133 4139 : frac += PIT_UP_SAMP;
134 4139 : x0--;
135 : }
136 :
137 164925 : for ( j = T0; j < L_SUBFR + 1; j++ )
138 : {
139 156340 : x1 = x0++;
140 156340 : x2 = x1 + 1;
141 156340 : c1 = &win[frac];
142 156340 : c2 = &win[PIT_UP_SAMP - frac];
143 :
144 156340 : s = 0.0f;
145 2657780 : for ( i = 0; i < L_INTERPOL2; i++, c1 += PIT_UP_SAMP, c2 += PIT_UP_SAMP )
146 : {
147 2501440 : s += ( *x1-- ) * ( *c1 ) + ( *x2++ ) * ( *c2 );
148 : }
149 156340 : excO[j] = s;
150 : }
151 :
152 156340 : for ( i = T0; i < L_SUBFR; i++ )
153 : {
154 147755 : exc[i + i_subfr] += PIT_SHARP * excO[i];
155 : }
156 : }
157 :
158 56198 : return;
159 : }
|