OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / frameworks / base / media / libstagefright / codecs / amrwbenc / inc / acelp.h
1 /*\r
2  ** Copyright 2003-2010, VisualOn, Inc.\r
3  **\r
4  ** Licensed under the Apache License, Version 2.0 (the "License");\r
5  ** you may not use this file except in compliance with the License.\r
6  ** You may obtain a copy of the License at\r
7  **\r
8  **     http://www.apache.org/licenses/LICENSE-2.0\r
9  **\r
10  ** Unless required by applicable law or agreed to in writing, software\r
11  ** distributed under the License is distributed on an "AS IS" BASIS,\r
12  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  ** See the License for the specific language governing permissions and\r
14  ** limitations under the License.\r
15  */\r
16 \r
17 \r
18 /*--------------------------------------------------------------------------*\r
19  *                         ACELP.H                                          *\r
20  *--------------------------------------------------------------------------*\r
21  *       Function                                                            *\r
22  *--------------------------------------------------------------------------*/\r
23 #ifndef __ACELP_H__\r
24 #define __ACELP_H__\r
25 \r
26 #include "typedef.h"\r
27 #include "cod_main.h"\r
28 \r
29 /*-----------------------------------------------------------------*\r
30  *                        LPC prototypes                           *\r
31  *-----------------------------------------------------------------*/\r
32 \r
33 Word16 median5(Word16 x[]);\r
34 \r
35 void Autocorr(\r
36                 Word16 x[],                           /* (i)    : Input signal                      */\r
37                 Word16 m,                             /* (i)    : LPC order                         */\r
38                 Word16 r_h[],                         /* (o)    : Autocorrelations  (msb)           */\r
39                 Word16 r_l[]                          /* (o)    : Autocorrelations  (lsb)           */\r
40              );\r
41 \r
42 void Lag_window(\r
43                 Word16 r_h[],                         /* (i/o)   : Autocorrelations  (msb)          */\r
44                 Word16 r_l[]                          /* (i/o)   : Autocorrelations  (lsb)          */\r
45                );\r
46 \r
47 void Init_Levinson(\r
48                 Word16 * mem                          /* output  :static memory (18 words) */\r
49                 );\r
50 \r
51 void Levinson(\r
52                 Word16 Rh[],                          /* (i)     : Rh[M+1] Vector of autocorrelations (msb) */\r
53                 Word16 Rl[],                          /* (i)     : Rl[M+1] Vector of autocorrelations (lsb) */\r
54                 Word16 A[],                           /* (o) Q12 : A[M]    LPC coefficients  (m = 16)       */\r
55                 Word16 rc[],                          /* (o) Q15 : rc[M]   Reflection coefficients.         */\r
56                 Word16 * mem                          /* (i/o)   :static memory (18 words)                  */\r
57              );\r
58 \r
59 void Az_isp(\r
60                 Word16 a[],                           /* (i) Q12 : predictor coefficients                 */\r
61                 Word16 isp[],                         /* (o) Q15 : Immittance spectral pairs              */\r
62                 Word16 old_isp[]                      /* (i)     : old isp[] (in case not found M roots)  */\r
63            );\r
64 \r
65 void Isp_Az(\r
66                 Word16 isp[],                         /* (i) Q15 : Immittance spectral pairs            */\r
67                 Word16 a[],                           /* (o) Q12 : predictor coefficients (order = M)   */\r
68                 Word16 m,\r
69                 Word16 adaptive_scaling               /* (i) 0   : adaptive scaling disabled */\r
70                 /*     1   : adaptive scaling enabled  */\r
71            );\r
72 \r
73 void Isp_isf(\r
74                 Word16 isp[],                         /* (i) Q15 : isp[m] (range: -1<=val<1)                */\r
75                 Word16 isf[],                         /* (o) Q15 : isf[m] normalized (range: 0.0<=val<=0.5) */\r
76                 Word16 m                              /* (i)     : LPC order                                */\r
77             );\r
78 \r
79 void Isf_isp(\r
80                 Word16 isf[],                         /* (i) Q15 : isf[m] normalized (range: 0.0<=val<=0.5) */\r
81                 Word16 isp[],                         /* (o) Q15 : isp[m] (range: -1<=val<1)                */\r
82                 Word16 m                              /* (i)     : LPC order                                */\r
83             );\r
84 \r
85 void Int_isp(\r
86                 Word16 isp_old[],                     /* input : isps from past frame              */\r
87                 Word16 isp_new[],                     /* input : isps from present frame           */\r
88                 Word16 frac[],                        /* input : fraction for 3 first subfr (Q15)  */\r
89                 Word16 Az[]                           /* output: LP coefficients in 4 subframes    */\r
90             );\r
91 \r
92 void Weight_a(\r
93                 Word16 a[],                           /* (i) Q12 : a[m+1]  LPC coefficients             */\r
94                 Word16 ap[],                          /* (o) Q12 : Spectral expanded LPC coefficients   */\r
95                 Word16 gamma,                         /* (i) Q15 : Spectral expansion factor.           */\r
96                 Word16 m                              /* (i)     : LPC order.                           */\r
97              );\r
98 \r
99 \r
100 /*-----------------------------------------------------------------*\r
101  *                        isf quantizers                           *\r
102  *-----------------------------------------------------------------*/\r
103 \r
104 void Qpisf_2s_46b(\r
105                 Word16 * isf1,                        /* (i) Q15 : ISF in the frequency domain (0..0.5) */\r
106                 Word16 * isf_q,                       /* (o) Q15 : quantized ISF               (0..0.5) */\r
107                 Word16 * past_isfq,                   /* (io)Q15 : past ISF quantizer                   */\r
108                 Word16 * indice,                      /* (o)     : quantization indices                 */\r
109                 Word16 nb_surv                        /* (i)     : number of survivor (1, 2, 3 or 4)    */\r
110                 );\r
111 \r
112 void Qpisf_2s_36b(\r
113                 Word16 * isf1,                        /* (i) Q15 : ISF in the frequency domain (0..0.5) */\r
114                 Word16 * isf_q,                       /* (o) Q15 : quantized ISF               (0..0.5) */\r
115                 Word16 * past_isfq,                   /* (io)Q15 : past ISF quantizer                   */\r
116                 Word16 * indice,                      /* (o)     : quantization indices                 */\r
117                 Word16 nb_surv                        /* (i)     : number of survivor (1, 2, 3 or 4)    */\r
118                 );\r
119 \r
120 void Dpisf_2s_46b(\r
121                 Word16 * indice,                      /* input:  quantization indices                       */\r
122                 Word16 * isf_q,                       /* output: quantized ISF in frequency domain (0..0.5) */\r
123                 Word16 * past_isfq,                   /* i/0   : past ISF quantizer                    */\r
124                 Word16 * isfold,                      /* input : past quantized ISF                    */\r
125                 Word16 * isf_buf,                     /* input : isf buffer                                                        */\r
126                 Word16 bfi,                           /* input : Bad frame indicator                   */\r
127                 Word16 enc_dec\r
128                 );\r
129 \r
130 void Dpisf_2s_36b(\r
131                 Word16 * indice,                      /* input:  quantization indices                       */\r
132                 Word16 * isf_q,                       /* output: quantized ISF in frequency domain (0..0.5) */\r
133                 Word16 * past_isfq,                   /* i/0   : past ISF quantizer                    */\r
134                 Word16 * isfold,                      /* input : past quantized ISF                    */\r
135                 Word16 * isf_buf,                     /* input : isf buffer                                                        */\r
136                 Word16 bfi,                           /* input : Bad frame indicator                   */\r
137                 Word16 enc_dec\r
138                 );\r
139 \r
140 void Qisf_ns(\r
141                 Word16 * isf1,                        /* input : ISF in the frequency domain (0..0.5) */\r
142                 Word16 * isf_q,                       /* output: quantized ISF                        */\r
143                 Word16 * indice                       /* output: quantization indices                 */\r
144             );\r
145 \r
146 void Disf_ns(\r
147                 Word16 * indice,                      /* input:  quantization indices                  */\r
148                 Word16 * isf_q                        /* input : ISF in the frequency domain (0..0.5)  */\r
149             );\r
150 \r
151 Word16 Sub_VQ(                             /* output: return quantization index     */\r
152                 Word16 * x,                           /* input : ISF residual vector           */\r
153                 Word16 * dico,                        /* input : quantization codebook         */\r
154                 Word16 dim,                           /* input : dimention of vector           */\r
155                 Word16 dico_size,                     /* input : size of quantization codebook */\r
156                 Word32 * distance                     /* output: error of quantization         */\r
157              );\r
158 \r
159 void Reorder_isf(\r
160                 Word16 * isf,                         /* (i/o) Q15: ISF in the frequency domain (0..0.5) */\r
161                 Word16 min_dist,                      /* (i) Q15  : minimum distance to keep             */\r
162                 Word16 n                              /* (i)      : number of ISF                        */\r
163                 );\r
164 \r
165 /*-----------------------------------------------------------------*\r
166  *                       filter prototypes                         *\r
167  *-----------------------------------------------------------------*/\r
168 \r
169 void Init_Decim_12k8(\r
170                 Word16 mem[]                          /* output: memory (2*NB_COEF_DOWN) set to zeros */\r
171                 );\r
172 void Decim_12k8(\r
173                 Word16 sig16k[],                      /* input:  signal to downsampling  */\r
174                 Word16 lg,                            /* input:  length of input         */\r
175                 Word16 sig12k8[],                     /* output: decimated signal        */\r
176                 Word16 mem[]                          /* in/out: memory (2*NB_COEF_DOWN) */\r
177                );\r
178 \r
179 void Init_HP50_12k8(Word16 mem[]);\r
180 void HP50_12k8(\r
181                 Word16 signal[],                      /* input/output signal */\r
182                 Word16 lg,                            /* lenght of signal    */\r
183                 Word16 mem[]                          /* filter memory [6]   */\r
184               );\r
185 void Init_HP400_12k8(Word16 mem[]);\r
186 void HP400_12k8(\r
187                 Word16 signal[],                      /* input/output signal */\r
188                 Word16 lg,                            /* lenght of signal    */\r
189                 Word16 mem[]                          /* filter memory [6]   */\r
190                );\r
191 \r
192 void Init_Filt_6k_7k(Word16 mem[]);\r
193 void Filt_6k_7k(\r
194                 Word16 signal[],                      /* input:  signal                  */\r
195                 Word16 lg,                            /* input:  length of input         */\r
196                 Word16 mem[]                          /* in/out: memory (size=30)        */\r
197                );\r
198 void Filt_6k_7k_asm(\r
199                 Word16 signal[],                      /* input:  signal                  */\r
200                 Word16 lg,                            /* input:  length of input         */\r
201                 Word16 mem[]                          /* in/out: memory (size=30)        */\r
202                );\r
203 \r
204 void LP_Decim2(\r
205                 Word16 x[],                           /* in/out: signal to process         */\r
206                 Word16 l,                             /* input : size of filtering         */\r
207                 Word16 mem[]                          /* in/out: memory (size=3)           */\r
208               );\r
209 \r
210 void Preemph(\r
211                 Word16 x[],                           /* (i/o)   : input signal overwritten by the output */\r
212                 Word16 mu,                            /* (i) Q15 : preemphasis coefficient                */\r
213                 Word16 lg,                            /* (i)     : lenght of filtering                    */\r
214                 Word16 * mem                          /* (i/o)   : memory (x[-1])                         */\r
215             );\r
216 void Preemph2(\r
217                 Word16 x[],                           /* (i/o)   : input signal overwritten by the output */\r
218                 Word16 mu,                            /* (i) Q15 : preemphasis coefficient                */\r
219                 Word16 lg,                            /* (i)     : lenght of filtering                    */\r
220                 Word16 * mem                          /* (i/o)   : memory (x[-1])                         */\r
221              );\r
222 void Deemph(\r
223                 Word16 x[],                           /* (i/o)   : input signal overwritten by the output */\r
224                 Word16 mu,                            /* (i) Q15 : deemphasis factor                      */\r
225                 Word16 L,                             /* (i)     : vector size                            */\r
226                 Word16 * mem                          /* (i/o)   : memory (y[-1])                         */\r
227            );\r
228 void Deemph2(\r
229                 Word16 x[],                           /* (i/o)   : input signal overwritten by the output */\r
230                 Word16 mu,                            /* (i) Q15 : deemphasis factor                      */\r
231                 Word16 L,                             /* (i)     : vector size                            */\r
232                 Word16 * mem                          /* (i/o)   : memory (y[-1])                         */\r
233             );\r
234 void Deemph_32(\r
235                 Word16 x_hi[],                        /* (i)     : input signal (bit31..16) */\r
236                 Word16 x_lo[],                        /* (i)     : input signal (bit15..4)  */\r
237                 Word16 y[],                           /* (o)     : output signal (x16)      */\r
238                 Word16 mu,                            /* (i) Q15 : deemphasis factor        */\r
239                 Word16 L,                             /* (i)     : vector size              */\r
240                 Word16 * mem                          /* (i/o)   : memory (y[-1])           */\r
241               );\r
242 \r
243 void Deemph_32_asm(\r
244                 Word16 x_hi[],                        /* (i)     : input signal (bit31..16) */\r
245                 Word16 x_lo[],                        /* (i)     : input signal (bit15..4)  */\r
246                 Word16 y[],                           /* (o)     : output signal (x16)      */\r
247                 Word16 * mem                          /* (i/o)   : memory (y[-1])           */\r
248               );\r
249 \r
250 void Convolve(\r
251                 Word16 x[],                           /* (i)     : input vector                              */\r
252                 Word16 h[],                           /* (i) Q15    : impulse response                       */\r
253                 Word16 y[],                           /* (o) 12 bits: output vector                          */\r
254                 Word16 L                              /* (i)     : vector size                               */\r
255              );\r
256 \r
257 void Convolve_asm(\r
258                 Word16 x[],                           /* (i)     : input vector                              */\r
259                 Word16 h[],                           /* (i) Q15    : impulse response                       */\r
260                 Word16 y[],                           /* (o) 12 bits: output vector                          */\r
261                 Word16 L                              /* (i)     : vector size                               */\r
262              );\r
263 \r
264 void Residu(\r
265                 Word16 a[],                           /* (i) Q12 : prediction coefficients                     */\r
266                 Word16 x[],                           /* (i)     : speech (values x[-m..-1] are needed         */\r
267                 Word16 y[],                           /* (o)     : residual signal                             */\r
268                 Word16 lg                             /* (i)     : size of filtering                           */\r
269                 );\r
270 \r
271 void Residu_opt(\r
272                 Word16 a[],                           /* (i) Q12 : prediction coefficients                     */\r
273                 Word16 x[],                           /* (i)     : speech (values x[-m..-1] are needed         */\r
274                 Word16 y[],                           /* (o)     : residual signal                             */\r
275                 Word16 lg                             /* (i)     : size of filtering                           */\r
276                 );\r
277 \r
278 void Syn_filt(\r
279         Word16 a[],                           /* (i) Q12 : a[m+1] prediction coefficients           */\r
280         Word16 x[],                           /* (i)     : input signal                             */\r
281         Word16 y[],                           /* (o)     : output signal                            */\r
282         Word16 lg,                            /* (i)     : size of filtering                        */\r
283         Word16 mem[],                         /* (i/o)   : memory associated with this filtering.   */\r
284         Word16 update                         /* (i)     : 0=no update, 1=update of memory.         */\r
285         );\r
286 \r
287 void Syn_filt_asm(\r
288         Word16 a[],                           /* (i) Q12 : a[m+1] prediction coefficients           */\r
289         Word16 x[],                           /* (i)     : input signal                             */\r
290         Word16 y[],                           /* (o)     : output signal                            */\r
291         Word16 mem[]                          /* (i/o)   : memory associated with this filtering.   */\r
292         );\r
293 \r
294 void Syn_filt_32(\r
295         Word16 a[],                           /* (i) Q12 : a[m+1] prediction coefficients */\r
296         Word16 m,                             /* (i)     : order of LP filter             */\r
297         Word16 exc[],                         /* (i) Qnew: excitation (exc[i] >> Qnew)    */\r
298         Word16 Qnew,                          /* (i)     : exc scaling = 0(min) to 8(max) */\r
299         Word16 sig_hi[],                      /* (o) /16 : synthesis high                 */\r
300         Word16 sig_lo[],                      /* (o) /16 : synthesis low                  */\r
301         Word16 lg                             /* (i)     : size of filtering              */\r
302         );\r
303 \r
304 void Syn_filt_32_asm(\r
305         Word16 a[],                           /* (i) Q12 : a[m+1] prediction coefficients */\r
306         Word16 m,                             /* (i)     : order of LP filter             */\r
307         Word16 exc[],                         /* (i) Qnew: excitation (exc[i] >> Qnew)    */\r
308         Word16 Qnew,                          /* (i)     : exc scaling = 0(min) to 8(max) */\r
309         Word16 sig_hi[],                      /* (o) /16 : synthesis high                 */\r
310         Word16 sig_lo[],                      /* (o) /16 : synthesis low                  */\r
311         Word16 lg                             /* (i)     : size of filtering              */\r
312         );\r
313 /*-----------------------------------------------------------------*\r
314  *                       pitch prototypes                          *\r
315  *-----------------------------------------------------------------*/\r
316 \r
317 Word16 Pitch_ol(                           /* output: open loop pitch lag                        */\r
318      Word16 signal[],                      /* input : signal used to compute the open loop pitch */\r
319 /* signal[-pit_max] to signal[-1] should be known */\r
320      Word16 pit_min,                       /* input : minimum pitch lag                          */\r
321      Word16 pit_max,                       /* input : maximum pitch lag                          */\r
322      Word16 L_frame                        /* input : length of frame to compute pitch           */\r
323 );\r
324 \r
325 Word16 Pitch_med_ol(                       /* output: open loop pitch lag                        */\r
326      Word16 wsp[],                         /* input : signal used to compute the open loop pitch */\r
327                                            /* wsp[-pit_max] to wsp[-1] should be known   */\r
328      Coder_State *st,                      /* i/o : global codec structure */\r
329      Word16 L_frame                        /* input : length of frame to compute pitch           */\r
330 );\r
331 \r
332 Word16 Med_olag(                           /* output : median of  5 previous open-loop lags       */\r
333      Word16 prev_ol_lag,                   /* input  : previous open-loop lag                     */\r
334      Word16 old_ol_lag[5]\r
335 );\r
336 \r
337 void Init_Hp_wsp(Word16 mem[]);\r
338 void scale_mem_Hp_wsp(Word16 mem[], Word16 exp);\r
339 void Hp_wsp(\r
340      Word16 wsp[],                         /* i   : wsp[]  signal       */\r
341      Word16 hp_wsp[],                      /* o   : hypass wsp[]        */\r
342      Word16 lg,                            /* i   : lenght of signal    */\r
343      Word16 mem[]                          /* i/o : filter memory [9]   */\r
344 );\r
345 \r
346 Word16 Pitch_fr4(                          /* (o)     : pitch period.                         */\r
347      Word16 exc[],                         /* (i)     : excitation buffer                     */\r
348      Word16 xn[],                          /* (i)     : target vector                         */\r
349      Word16 h[],                           /* (i) Q15 : impulse response of synth/wgt filters */\r
350      Word16 t0_min,                        /* (i)     : minimum value in the searched range.  */\r
351      Word16 t0_max,                        /* (i)     : maximum value in the searched range.  */\r
352      Word16 * pit_frac,                    /* (o)     : chosen fraction (0, 1, 2 or 3).       */\r
353      Word16 i_subfr,                       /* (i)     : indicator for first subframe.         */\r
354      Word16 t0_fr2,                        /* (i)     : minimum value for resolution 1/2      */\r
355      Word16 t0_fr1,                        /* (i)     : minimum value for resolution 1        */\r
356      Word16 L_subfr                        /* (i)     : Length of subframe                    */\r
357 );\r
358 void Pred_lt4(\r
359      Word16 exc[],                         /* in/out: excitation buffer */\r
360      Word16 T0,                            /* input : integer pitch lag */\r
361      Word16 frac,                          /* input : fraction of lag   */\r
362      Word16 L_subfr                        /* input : subframe size     */\r
363 );\r
364 \r
365 void pred_lt4_asm(\r
366      Word16 exc[],                         /* in/out: excitation buffer */\r
367      Word16 T0,                            /* input : integer pitch lag */\r
368      Word16 frac,                          /* input : fraction of lag   */\r
369      Word16 L_subfr                        /* input : subframe size     */\r
370 );\r
371 \r
372 /*-----------------------------------------------------------------*\r
373  *                       gain prototypes                           *\r
374  *-----------------------------------------------------------------*/\r
375 \r
376 Word16 G_pitch(                            /* (o) Q14 : Gain of pitch lag saturated to 1.2   */\r
377      Word16 xn[],                          /* (i)     : Pitch target.                        */\r
378      Word16 y1[],                          /* (i)     : filtered adaptive codebook.          */\r
379      Word16 g_coeff[],                     /* : Correlations need for gain quantization. */\r
380      Word16 L_subfr                        /* : Length of subframe.                  */\r
381 );\r
382 void Init_Q_gain2(\r
383      Word16 * mem                          /* output  :static memory (2 words)      */\r
384 );\r
385 Word16 Q_gain2(                            /* Return index of quantization.        */\r
386      Word16 xn[],                          /* (i) Q_xn:Target vector.               */\r
387      Word16 y1[],                          /* (i) Q_xn:Adaptive codebook.           */\r
388      Word16 Q_xn,                          /* (i)     :xn and y1 format             */\r
389      Word16 y2[],                          /* (i) Q9  :Filtered innovative vector.  */\r
390      Word16 code[],                        /* (i) Q9  :Innovative vector.           */\r
391      Word16 g_coeff[],                     /* (i)     :Correlations <xn y1> <y1 y1> */\r
392 /* Compute in G_pitch().        */\r
393      Word16 L_subfr,                       /* (i)     :Subframe lenght.             */\r
394      Word16 nbits,                         /* (i)     : number of bits (6 or 7)     */\r
395      Word16 * gain_pit,                    /* (i/o)Q14:Pitch gain.                  */\r
396      Word32 * gain_cod,                    /* (o) Q16 :Code gain.                   */\r
397      Word16 gp_clip,                       /* (i)     : Gp Clipping flag            */\r
398      Word16 * mem                          /* (i/o)   :static memory (2 words)      */\r
399 );\r
400 \r
401 void Init_D_gain2(\r
402      Word16 * mem                          /* output  :static memory (4 words)      */\r
403 );\r
404 void D_gain2(\r
405      Word16 index,                         /* (i)     :index of quantization.       */\r
406      Word16 nbits,                         /* (i)     : number of bits (6 or 7)     */\r
407      Word16 code[],                        /* (i) Q9  :Innovative vector.           */\r
408      Word16 L_subfr,                       /* (i)     :Subframe lenght.             */\r
409      Word16 * gain_pit,                    /* (o) Q14 :Pitch gain.                  */\r
410      Word32 * gain_cod,                    /* (o) Q16 :Code gain.                   */\r
411      Word16 bfi,                           /* (i)     :bad frame indicator          */\r
412      Word16 prev_bfi,                      /* (i) : Previous BF indicator      */\r
413      Word16 state,                         /* (i) : State of BFH               */\r
414      Word16 unusable_frame,                /* (i) : UF indicator            */\r
415      Word16 vad_hist,                      /* (i)         :number of non-speech frames  */\r
416      Word16 * mem                          /* (i/o)   :static memory (4 words)      */\r
417 );\r
418 \r
419 /*-----------------------------------------------------------------*\r
420  *                       acelp prototypes                          *\r
421  *-----------------------------------------------------------------*/\r
422 \r
423 void cor_h_x(\r
424      Word16 h[],                           /* (i) Q12 : impulse response of weighted synthesis filter */\r
425      Word16 x[],                           /* (i) Q0  : target vector                                 */\r
426      Word16 dn[]                           /* (o) <12bit : correlation between target and h[]         */\r
427 );\r
428 void ACELP_2t64_fx(\r
429      Word16 dn[],                          /* (i) <12b : correlation between target x[] and H[]      */\r
430      Word16 cn[],                          /* (i) <12b : residual after long term prediction         */\r
431      Word16 H[],                           /* (i) Q12: impulse response of weighted synthesis filter */\r
432      Word16 code[],                        /* (o) Q9 : algebraic (fixed) codebook excitation         */\r
433      Word16 y[],                           /* (o) Q9 : filtered fixed codebook excitation            */\r
434      Word16 * index                        /* (o) : index (12): 5+1+5+1 = 11 bits.                     */\r
435 );\r
436 \r
437 void ACELP_4t64_fx(\r
438      Word16 dn[],                          /* (i) <12b : correlation between target x[] and H[]      */\r
439      Word16 cn[],                          /* (i) <12b : residual after long term prediction         */\r
440      Word16 H[],                           /* (i) Q12: impulse response of weighted synthesis filter */\r
441      Word16 code[],                        /* (o) Q9 : algebraic (fixed) codebook excitation         */\r
442      Word16 y[],                           /* (o) Q9 : filtered fixed codebook excitation            */\r
443      Word16 nbbits,                        /* (i) : 20, 36, 44, 52, 64, 72 or 88 bits                */\r
444      Word16 ser_size,                      /* (i) : bit rate                                         */\r
445      Word16 _index[]                       /* (o) : index (20): 5+5+5+5 = 20 bits.                   */\r
446                                            /* (o) : index (36): 9+9+9+9 = 36 bits.                   */\r
447                                            /* (o) : index (44): 13+9+13+9 = 44 bits.                 */\r
448                                            /* (o) : index (52): 13+13+13+13 = 52 bits.               */\r
449                                            /* (o) : index (64): 2+2+2+2+14+14+14+14 = 64 bits.       */\r
450                                            /* (o) : index (72): 10+2+10+2+10+14+10+14 = 72 bits.     */\r
451                                            /* (o) : index (88): 11+11+11+11+11+11+11+11 = 88 bits.   */\r
452 );\r
453 \r
454 void Pit_shrp(\r
455      Word16 * x,                           /* in/out: impulse response (or algebraic code) */\r
456      Word16 pit_lag,                       /* input : pitch lag                            */\r
457      Word16 sharp,                         /* input : pitch sharpening factor (Q15)        */\r
458      Word16 L_subfr                        /* input : subframe size                        */\r
459 );\r
460 \r
461 \r
462 /*-----------------------------------------------------------------*\r
463  *                        others prototypes                        *\r
464  *-----------------------------------------------------------------*/\r
465 \r
466 void Copy(\r
467      Word16 x[],                           /* (i)   : input vector   */\r
468      Word16 y[],                           /* (o)   : output vector  */\r
469      Word16 L                              /* (i)   : vector length  */\r
470 );\r
471 void Set_zero(\r
472      Word16 x[],                           /* (o)    : vector to clear     */\r
473      Word16 L                              /* (i)    : length of vector    */\r
474 );\r
475 void Updt_tar(\r
476      Word16 * x,                           /* (i) Q0  : old target (for pitch search)     */\r
477      Word16 * x2,                          /* (o) Q0  : new target (for codebook search)  */\r
478      Word16 * y,                           /* (i) Q0  : filtered adaptive codebook vector */\r
479      Word16 gain,                          /* (i) Q14 : adaptive codebook gain            */\r
480      Word16 L                              /* (i)     : subframe size                     */\r
481 );\r
482 Word16 voice_factor(                       /* (o) Q15 : factor (-1=unvoiced to 1=voiced) */\r
483      Word16 exc[],                         /* (i) Q_exc: pitch excitation                */\r
484      Word16 Q_exc,                         /* (i)     : exc format                       */\r
485      Word16 gain_pit,                      /* (i) Q14 : gain of pitch                    */\r
486      Word16 code[],                        /* (i) Q9  : Fixed codebook excitation        */\r
487      Word16 gain_code,                     /* (i) Q0  : gain of code                     */\r
488      Word16 L_subfr                        /* (i)     : subframe length                  */\r
489 );\r
490 void Scale_sig(\r
491      Word16 x[],                           /* (i/o) : signal to scale               */\r
492      Word16 lg,                            /* (i)   : size of x[]                   */\r
493      Word16 exp                            /* (i)   : exponent: x = round(x << exp) */\r
494 );\r
495 \r
496 void Scale_sig_opt(\r
497      Word16 x[],                           /* (i/o) : signal to scale               */\r
498      Word16 lg,                            /* (i)   : size of x[]                   */\r
499      Word16 exp                            /* (i)   : exponent: x = round(x << exp) */\r
500 );\r
501 \r
502 Word16 Random(Word16 * seed);\r
503 \r
504 void Init_gp_clip(\r
505      Word16 mem[]                          /* (o) : memory of gain of pitch clipping algorithm */\r
506 );\r
507 Word16 Gp_clip(\r
508      Word16 mem[]                          /* (i/o) : memory of gain of pitch clipping algorithm */\r
509 );\r
510 void Gp_clip_test_isf(\r
511      Word16 isf[],                         /* (i)   : isf values (in frequency domain)           */\r
512      Word16 mem[]                          /* (i/o) : memory of gain of pitch clipping algorithm */\r
513 );\r
514 void Gp_clip_test_gain_pit(\r
515      Word16 gain_pit,                      /* (i)   : gain of quantized pitch                    */\r
516      Word16 mem[]                          /* (i/o) : memory of gain of pitch clipping algorithm */\r
517 );\r
518 \r
519 \r
520 #endif   //__ACELP_H__\r
521 \r