summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/amrwbenc/inc/acelp.h
blob: 97555d5d74f3f14d329098147a6c345b6c2ab827 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
/*
 ** Copyright 2003-2010, VisualOn, Inc.
 **
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 **
 **     http://www.apache.org/licenses/LICENSE-2.0
 **
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.
 */


/*--------------------------------------------------------------------------*
 *                         ACELP.H                                          *
 *--------------------------------------------------------------------------*
 *       Function                                    *
 *--------------------------------------------------------------------------*/
#ifndef __ACELP_H__
#define __ACELP_H__

#include "typedef.h"
#include "cod_main.h"

/*-----------------------------------------------------------------*
 *                        LPC prototypes                           *
 *-----------------------------------------------------------------*/

Word16 median5(Word16 x[]);

void Autocorr(
        Word16 x[],                           /* (i)    : Input signal                      */
        Word16 m,                             /* (i)    : LPC order                         */
        Word16 r_h[],                         /* (o)    : Autocorrelations  (msb)           */
        Word16 r_l[]                          /* (o)    : Autocorrelations  (lsb)           */
         );

void Lag_window(
        Word16 r_h[],                         /* (i/o)   : Autocorrelations  (msb)          */
        Word16 r_l[]                          /* (i/o)   : Autocorrelations  (lsb)          */
           );

void Init_Levinson(
        Word16 * mem                          /* output  :static memory (18 words) */
        );

void Levinson(
        Word16 Rh[],                          /* (i)     : Rh[M+1] Vector of autocorrelations (msb) */
        Word16 Rl[],                          /* (i)     : Rl[M+1] Vector of autocorrelations (lsb) */
        Word16 A[],                           /* (o) Q12 : A[M]    LPC coefficients  (m = 16)       */
        Word16 rc[],                          /* (o) Q15 : rc[M]   Reflection coefficients.         */
        Word16 * mem                          /* (i/o)   :static memory (18 words)                  */
         );

void Az_isp(
        Word16 a[],                           /* (i) Q12 : predictor coefficients                 */
        Word16 isp[],                         /* (o) Q15 : Immittance spectral pairs              */
        Word16 old_isp[]                      /* (i)     : old isp[] (in case not found M roots)  */
       );

void Isp_Az(
        Word16 isp[],                         /* (i) Q15 : Immittance spectral pairs            */
        Word16 a[],                           /* (o) Q12 : predictor coefficients (order = M)   */
        Word16 m,
        Word16 adaptive_scaling               /* (i) 0   : adaptive scaling disabled */
        /*     1   : adaptive scaling enabled  */
       );

void Isp_isf(
        Word16 isp[],                         /* (i) Q15 : isp[m] (range: -1<=val<1)                */
        Word16 isf[],                         /* (o) Q15 : isf[m] normalized (range: 0.0<=val<=0.5) */
        Word16 m                              /* (i)     : LPC order                                */
        );

void Isf_isp(
        Word16 isf[],                         /* (i) Q15 : isf[m] normalized (range: 0.0<=val<=0.5) */
        Word16 isp[],                         /* (o) Q15 : isp[m] (range: -1<=val<1)                */
        Word16 m                              /* (i)     : LPC order                                */
        );

void Int_isp(
        Word16 isp_old[],                     /* input : isps from past frame              */
        Word16 isp_new[],                     /* input : isps from present frame           */
        Word16 frac[],                        /* input : fraction for 3 first subfr (Q15)  */
        Word16 Az[]                           /* output: LP coefficients in 4 subframes    */
        );

void Weight_a(
        Word16 a[],                           /* (i) Q12 : a[m+1]  LPC coefficients             */
        Word16 ap[],                          /* (o) Q12 : Spectral expanded LPC coefficients   */
        Word16 gamma,                         /* (i) Q15 : Spectral expansion factor.           */
        Word16 m                              /* (i)     : LPC order.                           */
         );


/*-----------------------------------------------------------------*
 *                        isf quantizers                           *
 *-----------------------------------------------------------------*/

void Qpisf_2s_46b(
        Word16 * isf1,                        /* (i) Q15 : ISF in the frequency domain (0..0.5) */
        Word16 * isf_q,                       /* (o) Q15 : quantized ISF               (0..0.5) */
        Word16 * past_isfq,                   /* (io)Q15 : past ISF quantizer                   */
        Word16 * indice,                      /* (o)     : quantization indices                 */
        Word16 nb_surv                        /* (i)     : number of survivor (1, 2, 3 or 4)    */
        );

void Qpisf_2s_36b(
        Word16 * isf1,                        /* (i) Q15 : ISF in the frequency domain (0..0.5) */
        Word16 * isf_q,                       /* (o) Q15 : quantized ISF               (0..0.5) */
        Word16 * past_isfq,                   /* (io)Q15 : past ISF quantizer                   */
        Word16 * indice,                      /* (o)     : quantization indices                 */
        Word16 nb_surv                        /* (i)     : number of survivor (1, 2, 3 or 4)    */
        );

void Dpisf_2s_46b(
        Word16 * indice,                      /* input:  quantization indices                       */
        Word16 * isf_q,                       /* output: quantized ISF in frequency domain (0..0.5) */
        Word16 * past_isfq,                   /* i/0   : past ISF quantizer                    */
        Word16 * isfold,                      /* input : past quantized ISF                    */
        Word16 * isf_buf,                     /* input : isf buffer                                                        */
        Word16 bfi,                           /* input : Bad frame indicator                   */
        Word16 enc_dec
        );

void Dpisf_2s_36b(
        Word16 * indice,                      /* input:  quantization indices                       */
        Word16 * isf_q,                       /* output: quantized ISF in frequency domain (0..0.5) */
        Word16 * past_isfq,                   /* i/0   : past ISF quantizer                    */
        Word16 * isfold,                      /* input : past quantized ISF                    */
        Word16 * isf_buf,                     /* input : isf buffer                                                        */
        Word16 bfi,                           /* input : Bad frame indicator                   */
        Word16 enc_dec
        );

void Qisf_ns(
        Word16 * isf1,                        /* input : ISF in the frequency domain (0..0.5) */
        Word16 * isf_q,                       /* output: quantized ISF                        */
        Word16 * indice                       /* output: quantization indices                 */
        );

void Disf_ns(
        Word16 * indice,                      /* input:  quantization indices                  */
        Word16 * isf_q                        /* input : ISF in the frequency domain (0..0.5)  */
        );

Word16 Sub_VQ(                             /* output: return quantization index     */
        Word16 * x,                           /* input : ISF residual vector           */
        Word16 * dico,                        /* input : quantization codebook         */
        Word16 dim,                           /* input : dimention of vector           */
        Word16 dico_size,                     /* input : size of quantization codebook */
        Word32 * distance                     /* output: error of quantization         */
         );

void Reorder_isf(
        Word16 * isf,                         /* (i/o) Q15: ISF in the frequency domain (0..0.5) */
        Word16 min_dist,                      /* (i) Q15  : minimum distance to keep             */
        Word16 n                              /* (i)      : number of ISF                        */
        );

/*-----------------------------------------------------------------*
 *                       filter prototypes                         *
 *-----------------------------------------------------------------*/

void Init_Decim_12k8(
        Word16 mem[]                          /* output: memory (2*NB_COEF_DOWN) set to zeros */
        );
void Decim_12k8(
        Word16 sig16k[],                      /* input:  signal to downsampling  */
        Word16 lg,                            /* input:  length of input         */
        Word16 sig12k8[],                     /* output: decimated signal        */
        Word16 mem[]                          /* in/out: memory (2*NB_COEF_DOWN) */
           );

void Init_HP50_12k8(Word16 mem[]);
void HP50_12k8(
        Word16 signal[],                      /* input/output signal */
        Word16 lg,                            /* lenght of signal    */
        Word16 mem[]                          /* filter memory [6]   */
          );
void Init_HP400_12k8(Word16 mem[]);
void HP400_12k8(
        Word16 signal[],                      /* input/output signal */
        Word16 lg,                            /* lenght of signal    */
        Word16 mem[]                          /* filter memory [6]   */
           );

void Init_Filt_6k_7k(Word16 mem[]);
void Filt_6k_7k(
        Word16 signal[],                      /* input:  signal                  */
        Word16 lg,                            /* input:  length of input         */
        Word16 mem[]                          /* in/out: memory (size=30)        */
           );
void Filt_6k_7k_asm(
        Word16 signal[],                      /* input:  signal                  */
        Word16 lg,                            /* input:  length of input         */
        Word16 mem[]                          /* in/out: memory (size=30)        */
           );

void LP_Decim2(
        Word16 x[],                           /* in/out: signal to process         */
        Word16 l,                             /* input : size of filtering         */
        Word16 mem[]                          /* in/out: memory (size=3)           */
          );

void Preemph(
        Word16 x[],                           /* (i/o)   : input signal overwritten by the output */
        Word16 mu,                            /* (i) Q15 : preemphasis coefficient                */
        Word16 lg,                            /* (i)     : lenght of filtering                    */
        Word16 * mem                          /* (i/o)   : memory (x[-1])                         */
        );
void Preemph2(
        Word16 x[],                           /* (i/o)   : input signal overwritten by the output */
        Word16 mu,                            /* (i) Q15 : preemphasis coefficient                */
        Word16 lg,                            /* (i)     : lenght of filtering                    */
        Word16 * mem                          /* (i/o)   : memory (x[-1])                         */
         );
void Deemph(
        Word16 x[],                           /* (i/o)   : input signal overwritten by the output */
        Word16 mu,                            /* (i) Q15 : deemphasis factor                      */
        Word16 L,                             /* (i)     : vector size                            */
        Word16 * mem                          /* (i/o)   : memory (y[-1])                         */
       );
void Deemph2(
        Word16 x[],                           /* (i/o)   : input signal overwritten by the output */
        Word16 mu,                            /* (i) Q15 : deemphasis factor                      */
        Word16 L,                             /* (i)     : vector size                            */
        Word16 * mem                          /* (i/o)   : memory (y[-1])                         */
        );
void Deemph_32(
        Word16 x_hi[],                        /* (i)     : input signal (bit31..16) */
        Word16 x_lo[],                        /* (i)     : input signal (bit15..4)  */
        Word16 y[],                           /* (o)     : output signal (x16)      */
        Word16 mu,                            /* (i) Q15 : deemphasis factor        */
        Word16 L,                             /* (i)     : vector size              */
        Word16 * mem                          /* (i/o)   : memory (y[-1])           */
          );

void Deemph_32_asm(
        Word16 x_hi[],                        /* (i)     : input signal (bit31..16) */
        Word16 x_lo[],                        /* (i)     : input signal (bit15..4)  */
        Word16 y[],                           /* (o)     : output signal (x16)      */
        Word16 * mem                          /* (i/o)   : memory (y[-1])           */
          );

void Convolve(
        Word16 x[],                           /* (i)     : input vector                              */
        Word16 h[],                           /* (i) Q15    : impulse response                       */
        Word16 y[],                           /* (o) 12 bits: output vector                          */
        Word16 L                              /* (i)     : vector size                               */
         );

void Convolve_asm(
        Word16 x[],                           /* (i)     : input vector                              */
        Word16 h[],                           /* (i) Q15    : impulse response                       */
        Word16 y[],                           /* (o) 12 bits: output vector                          */
        Word16 L                              /* (i)     : vector size                               */
         );

void Residu(
        Word16 a[],                           /* (i) Q12 : prediction coefficients                     */
        Word16 x[],                           /* (i)     : speech (values x[-m..-1] are needed         */
        Word16 y[],                           /* (o)     : residual signal                             */
        Word16 lg                             /* (i)     : size of filtering                           */
        );

void Residu_opt(
        Word16 a[],                           /* (i) Q12 : prediction coefficients                     */
        Word16 x[],                           /* (i)     : speech (values x[-m..-1] are needed         */
        Word16 y[],                           /* (o)     : residual signal                             */
        Word16 lg                             /* (i)     : size of filtering                           */
        );

void Syn_filt(
    Word16 a[],                           /* (i) Q12 : a[m+1] prediction coefficients           */
    Word16 x[],                           /* (i)     : input signal                             */
    Word16 y[],                           /* (o)     : output signal                            */
    Word16 lg,                            /* (i)     : size of filtering                        */
    Word16 mem[],                         /* (i/o)   : memory associated with this filtering.   */
    Word16 update                         /* (i)     : 0=no update, 1=update of memory.         */
    );

void Syn_filt_asm(
    Word16 a[],                           /* (i) Q12 : a[m+1] prediction coefficients           */
    Word16 x[],                           /* (i)     : input signal                             */
    Word16 y[],                           /* (o)     : output signal                            */
    Word16 mem[]                          /* (i/o)   : memory associated with this filtering.   */
    );

void Syn_filt_32(
    Word16 a[],                           /* (i) Q12 : a[m+1] prediction coefficients */
    Word16 m,                             /* (i)     : order of LP filter             */
    Word16 exc[],                         /* (i) Qnew: excitation (exc[i] >> Qnew)    */
    Word16 Qnew,                          /* (i)     : exc scaling = 0(min) to 8(max) */
    Word16 sig_hi[],                      /* (o) /16 : synthesis high                 */
    Word16 sig_lo[],                      /* (o) /16 : synthesis low                  */
    Word16 lg                             /* (i)     : size of filtering              */
    );

void Syn_filt_32_asm(
    Word16 a[],                           /* (i) Q12 : a[m+1] prediction coefficients */
    Word16 m,                             /* (i)     : order of LP filter             */
    Word16 exc[],                         /* (i) Qnew: excitation (exc[i] >> Qnew)    */
    Word16 Qnew,                          /* (i)     : exc scaling = 0(min) to 8(max) */
    Word16 sig_hi[],                      /* (o) /16 : synthesis high                 */
    Word16 sig_lo[],                      /* (o) /16 : synthesis low                  */
    Word16 lg                             /* (i)     : size of filtering              */
    );
/*-----------------------------------------------------------------*
 *                       pitch prototypes                          *
 *-----------------------------------------------------------------*/

Word16 Pitch_ol(                           /* output: open loop pitch lag                        */
     Word16 signal[],                      /* input : signal used to compute the open loop pitch */
/* signal[-pit_max] to signal[-1] should be known */
     Word16 pit_min,                       /* input : minimum pitch lag                          */
     Word16 pit_max,                       /* input : maximum pitch lag                          */
     Word16 L_frame                        /* input : length of frame to compute pitch           */
);

Word16 Pitch_med_ol(                       /* output: open loop pitch lag                        */
     Word16 wsp[],                         /* input : signal used to compute the open loop pitch */
                                           /* wsp[-pit_max] to wsp[-1] should be known   */
     Coder_State *st,                      /* i/o : global codec structure */
     Word16 L_frame                        /* input : length of frame to compute pitch           */
);

Word16 Med_olag(                           /* output : median of  5 previous open-loop lags       */
     Word16 prev_ol_lag,                   /* input  : previous open-loop lag                     */
     Word16 old_ol_lag[5]
);

void Init_Hp_wsp(Word16 mem[]);
void scale_mem_Hp_wsp(Word16 mem[], Word16 exp);
void Hp_wsp(
     Word16 wsp[],                         /* i   : wsp[]  signal       */
     Word16 hp_wsp[],                      /* o   : hypass wsp[]        */
     Word16 lg,                            /* i   : lenght of signal    */
     Word16 mem[]                          /* i/o : filter memory [9]   */
);

Word16 Pitch_fr4(                          /* (o)     : pitch period.                         */
     Word16 exc[],                         /* (i)     : excitation buffer                     */
     Word16 xn[],                          /* (i)     : target vector                         */
     Word16 h[],                           /* (i) Q15 : impulse response of synth/wgt filters */
     Word16 t0_min,                        /* (i)     : minimum value in the searched range.  */
     Word16 t0_max,                        /* (i)     : maximum value in the searched range.  */
     Word16 * pit_frac,                    /* (o)     : chosen fraction (0, 1, 2 or 3).       */
     Word16 i_subfr,                       /* (i)     : indicator for first subframe.         */
     Word16 t0_fr2,                        /* (i)     : minimum value for resolution 1/2      */
     Word16 t0_fr1,                        /* (i)     : minimum value for resolution 1        */
     Word16 L_subfr                        /* (i)     : Length of subframe                    */
);
void Pred_lt4(
     Word16 exc[],                         /* in/out: excitation buffer */
     Word16 T0,                            /* input : integer pitch lag */
     Word16 frac,                          /* input : fraction of lag   */
     Word16 L_subfr                        /* input : subframe size     */
);

void pred_lt4_asm(
     Word16 exc[],                         /* in/out: excitation buffer */
     Word16 T0,                            /* input : integer pitch lag */
     Word16 frac,                          /* input : fraction of lag   */
     Word16 L_subfr                        /* input : subframe size     */
);

/*-----------------------------------------------------------------*
 *                       gain prototypes                           *
 *-----------------------------------------------------------------*/

Word16 G_pitch(                            /* (o) Q14 : Gain of pitch lag saturated to 1.2   */
     Word16 xn[],                          /* (i)     : Pitch target.                        */
     Word16 y1[],                          /* (i)     : filtered adaptive codebook.          */
     Word16 g_coeff[],                     /* : Correlations need for gain quantization. */
     Word16 L_subfr                        /* : Length of subframe.                  */
);
void Init_Q_gain2(
     Word16 * mem                          /* output  :static memory (2 words)      */
);
Word16 Q_gain2(                            /* Return index of quantization.        */
     Word16 xn[],                          /* (i) Q_xn:Target vector.               */
     Word16 y1[],                          /* (i) Q_xn:Adaptive codebook.           */
     Word16 Q_xn,                          /* (i)     :xn and y1 format             */
     Word16 y2[],                          /* (i) Q9  :Filtered innovative vector.  */
     Word16 code[],                        /* (i) Q9  :Innovative vector.           */
     Word16 g_coeff[],                     /* (i)     :Correlations <xn y1> <y1 y1> */
/* Compute in G_pitch().        */
     Word16 L_subfr,                       /* (i)     :Subframe lenght.             */
     Word16 nbits,                         /* (i)     : number of bits (6 or 7)     */
     Word16 * gain_pit,                    /* (i/o)Q14:Pitch gain.                  */
     Word32 * gain_cod,                    /* (o) Q16 :Code gain.                   */
     Word16 gp_clip,                       /* (i)     : Gp Clipping flag            */
     Word16 * mem                          /* (i/o)   :static memory (2 words)      */
);

void Init_D_gain2(
     Word16 * mem                          /* output  :static memory (4 words)      */
);
void D_gain2(
     Word16 index,                         /* (i)     :index of quantization.       */
     Word16 nbits,                         /* (i)     : number of bits (6 or 7)     */
     Word16 code[],                        /* (i) Q9  :Innovative vector.           */
     Word16 L_subfr,                       /* (i)     :Subframe lenght.             */
     Word16 * gain_pit,                    /* (o) Q14 :Pitch gain.                  */
     Word32 * gain_cod,                    /* (o) Q16 :Code gain.                   */
     Word16 bfi,                           /* (i)     :bad frame indicator          */
     Word16 prev_bfi,                      /* (i) : Previous BF indicator      */
     Word16 state,                         /* (i) : State of BFH               */
     Word16 unusable_frame,                /* (i) : UF indicator            */
     Word16 vad_hist,                      /* (i)         :number of non-speech frames  */
     Word16 * mem                          /* (i/o)   :static memory (4 words)      */
);

/*-----------------------------------------------------------------*
 *                       acelp prototypes                          *
 *-----------------------------------------------------------------*/

void cor_h_x(
     Word16 h[],                           /* (i) Q12 : impulse response of weighted synthesis filter */
     Word16 x[],                           /* (i) Q0  : target vector                                 */
     Word16 dn[]                           /* (o) <12bit : correlation between target and h[]         */
);
void ACELP_2t64_fx(
     Word16 dn[],                          /* (i) <12b : correlation between target x[] and H[]      */
     Word16 cn[],                          /* (i) <12b : residual after long term prediction         */
     Word16 H[],                           /* (i) Q12: impulse response of weighted synthesis filter */
     Word16 code[],                        /* (o) Q9 : algebraic (fixed) codebook excitation         */
     Word16 y[],                           /* (o) Q9 : filtered fixed codebook excitation            */
     Word16 * index                        /* (o) : index (12): 5+1+5+1 = 11 bits.                     */
);

void ACELP_4t64_fx(
     Word16 dn[],                          /* (i) <12b : correlation between target x[] and H[]      */
     Word16 cn[],                          /* (i) <12b : residual after long term prediction         */
     Word16 H[],                           /* (i) Q12: impulse response of weighted synthesis filter */
     Word16 code[],                        /* (o) Q9 : algebraic (fixed) codebook excitation         */
     Word16 y[],                           /* (o) Q9 : filtered fixed codebook excitation            */
     Word16 nbbits,                        /* (i) : 20, 36, 44, 52, 64, 72 or 88 bits                */
     Word16 ser_size,                      /* (i) : bit rate                                         */
     Word16 _index[]                       /* (o) : index (20): 5+5+5+5 = 20 bits.                   */
                       /* (o) : index (36): 9+9+9+9 = 36 bits.                   */
                       /* (o) : index (44): 13+9+13+9 = 44 bits.                 */
                       /* (o) : index (52): 13+13+13+13 = 52 bits.               */
                       /* (o) : index (64): 2+2+2+2+14+14+14+14 = 64 bits.       */
                       /* (o) : index (72): 10+2+10+2+10+14+10+14 = 72 bits.     */
                       /* (o) : index (88): 11+11+11+11+11+11+11+11 = 88 bits.   */
);

void Pit_shrp(
     Word16 * x,                           /* in/out: impulse response (or algebraic code) */
     Word16 pit_lag,                       /* input : pitch lag                            */
     Word16 sharp,                         /* input : pitch sharpening factor (Q15)        */
     Word16 L_subfr                        /* input : subframe size                        */
);


/*-----------------------------------------------------------------*
 *                        others prototypes                        *
 *-----------------------------------------------------------------*/

void Copy(
     Word16 x[],                           /* (i)   : input vector   */
     Word16 y[],                           /* (o)   : output vector  */
     Word16 L                              /* (i)   : vector length  */
);
void Set_zero(
     Word16 x[],                           /* (o)    : vector to clear     */
     Word16 L                              /* (i)    : length of vector    */
);
void Updt_tar(
     Word16 * x,                           /* (i) Q0  : old target (for pitch search)     */
     Word16 * x2,                          /* (o) Q0  : new target (for codebook search)  */
     Word16 * y,                           /* (i) Q0  : filtered adaptive codebook vector */
     Word16 gain,                          /* (i) Q14 : adaptive codebook gain            */
     Word16 L                              /* (i)     : subframe size                     */
);
Word16 voice_factor(                       /* (o) Q15 : factor (-1=unvoiced to 1=voiced) */
     Word16 exc[],                         /* (i) Q_exc: pitch excitation                */
     Word16 Q_exc,                         /* (i)     : exc format                       */
     Word16 gain_pit,                      /* (i) Q14 : gain of pitch                    */
     Word16 code[],                        /* (i) Q9  : Fixed codebook excitation        */
     Word16 gain_code,                     /* (i) Q0  : gain of code                     */
     Word16 L_subfr                        /* (i)     : subframe length                  */
);
void Scale_sig(
     Word16 x[],                           /* (i/o) : signal to scale               */
     Word16 lg,                            /* (i)   : size of x[]                   */
     Word16 exp                            /* (i)   : exponent: x = round(x << exp) */
);

void Scale_sig_opt(
     Word16 x[],                           /* (i/o) : signal to scale               */
     Word16 lg,                            /* (i)   : size of x[]                   */
     Word16 exp                            /* (i)   : exponent: x = round(x << exp) */
);

Word16 Random(Word16 * seed);

void Init_gp_clip(
     Word16 mem[]                          /* (o) : memory of gain of pitch clipping algorithm */
);
Word16 Gp_clip(
     Word16 mem[]                          /* (i/o) : memory of gain of pitch clipping algorithm */
);
void Gp_clip_test_isf(
     Word16 isf[],                         /* (i)   : isf values (in frequency domain)           */
     Word16 mem[]                          /* (i/o) : memory of gain of pitch clipping algorithm */
);
void Gp_clip_test_gain_pit(
     Word16 gain_pit,                      /* (i)   : gain of quantized pitch                    */
     Word16 mem[]                          /* (i/o) : memory of gain of pitch clipping algorithm */
);


#endif   //__ACELP_H__