comparison libgsmefr/c1035pf.c @ 57:e005e7b91f3c

libgsmefr: c1035pf.c compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 25 Nov 2022 17:24:48 +0000
parents 49dd1ac8e75b
children 12d9d3649232
comparison
equal deleted inserted replaced
56:902bc4b64cc6 57:e005e7b91f3c
1 #include "gsm_efr.h"
1 #include "typedef.h" 2 #include "typedef.h"
3 #include "namespace.h"
2 #include "basic_op.h" 4 #include "basic_op.h"
5 #include "no_count.h"
3 #include "sig_proc.h" 6 #include "sig_proc.h"
4 #include "count.h" 7 #include "codec.h"
5 8
6 #define L_CODE 40 9 #define L_CODE 40
7 #define NB_TRACK 5 10 #define NB_TRACK 5
8 #define NB_PULSE 10 11 #define NB_PULSE 10
9 #define STEP 5 12 #define STEP 5
10 13
11 /* local functions */ 14 /* local functions */
12 15
13 void cor_h_x ( 16 static void cor_h_x (
14 Word16 h[], /* (i) : impulse response of weighted synthesis filter */ 17 Word16 h[], /* (i) : impulse response of weighted synthesis filter */
15 Word16 x[], /* (i) : target */ 18 Word16 x[], /* (i) : target */
16 Word16 dn[] /* (o) : correlation between target and h[] */ 19 Word16 dn[] /* (o) : correlation between target and h[] */
17 ); 20 );
18 21
19 void set_sign ( 22 static void set_sign (
20 Word16 dn[], /* (i/o) : correlation between target and h[] */ 23 Word16 dn[], /* (i/o) : correlation between target and h[] */
21 Word16 cn[], /* (i) : residual after long term prediction */ 24 Word16 cn[], /* (i) : residual after long term prediction */
22 Word16 sign[], /* (o) : sign of d[n] */ 25 Word16 sign[], /* (o) : sign of d[n] */
23 Word16 pos_max[], /* (o) : position of maximum of dn[] */ 26 Word16 pos_max[], /* (o) : position of maximum of dn[] */
24 Word16 ipos[] /* (o) : starting position for each pulse */ 27 Word16 ipos[] /* (o) : starting position for each pulse */
25 ); 28 );
26 29
27 void cor_h ( 30 static void cor_h (
28 Word16 h[], /* (i) : impulse response of weighted synthesis 31 Word16 h[], /* (i) : impulse response of weighted synthesis
29 filter */ 32 filter */
30 Word16 sign[], /* (i) : sign of d[n] */ 33 Word16 sign[], /* (i) : sign of d[n] */
31 Word16 rr[][L_CODE] /* (o) : matrix of autocorrelation */ 34 Word16 rr[][L_CODE] /* (o) : matrix of autocorrelation */
32 ); 35 );
33 void search_10i40 ( 36 static void search_10i40 (
34 Word16 dn[], /* (i) : correlation between target and h[] */ 37 Word16 dn[], /* (i) : correlation between target and h[] */
35 Word16 rr[][L_CODE], /* (i) : matrix of autocorrelation */ 38 Word16 rr[][L_CODE], /* (i) : matrix of autocorrelation */
36 Word16 ipos[], /* (i) : starting position for each pulse */ 39 Word16 ipos[], /* (i) : starting position for each pulse */
37 Word16 pos_max[], /* (i) : position of maximum of dn[] */ 40 Word16 pos_max[], /* (i) : position of maximum of dn[] */
38 Word16 codvec[] /* (o) : algebraic codebook vector */ 41 Word16 codvec[] /* (o) : algebraic codebook vector */
39 ); 42 );
40 void build_code ( 43 static void build_code (
41 Word16 codvec[], /* (i) : algebraic codebook vector */ 44 Word16 codvec[], /* (i) : algebraic codebook vector */
42 Word16 sign[], /* (i) : sign of dn[] */ 45 Word16 sign[], /* (i) : sign of dn[] */
43 Word16 cod[], /* (o) : algebraic (fixed) codebook excitation */ 46 Word16 cod[], /* (o) : algebraic (fixed) codebook excitation */
44 Word16 h[], /* (i) : impulse response of weighted synthesis filter*/ 47 Word16 h[], /* (i) : impulse response of weighted synthesis filter*/
45 Word16 y[], /* (o) : filtered fixed codebook excitation */ 48 Word16 y[], /* (o) : filtered fixed codebook excitation */
46 Word16 indx[] /* (o) : index of 10 pulses (position+sign+ampl)*10 */ 49 Word16 indx[] /* (o) : index of 10 pulses (position+sign+ampl)*10 */
47 ); 50 );
48 51
49 void q_p ( 52 static void q_p (
50 Word16 *ind, /* Pulse position */ 53 Word16 *ind, /* Pulse position */
51 Word16 n /* Pulse number */ 54 Word16 n /* Pulse number */
52 ); 55 );
53 56
54 /************************************************************************* 57 /*************************************************************************
117 * 120 *
118 * d[n] is normalized such that the sum of 5 maxima of d[n] corresponding 121 * d[n] is normalized such that the sum of 5 maxima of d[n] corresponding
119 * to each position track does not saturate. 122 * to each position track does not saturate.
120 * 123 *
121 *************************************************************************/ 124 *************************************************************************/
122 void cor_h_x ( 125 static void cor_h_x (
123 Word16 h[], /* (i) : impulse response of weighted synthesis filter */ 126 Word16 h[], /* (i) : impulse response of weighted synthesis filter */
124 Word16 x[], /* (i) : target */ 127 Word16 x[], /* (i) : target */
125 Word16 dn[] /* (o) : correlation between target and h[] */ 128 Word16 dn[] /* (o) : correlation between target and h[] */
126 ) 129 )
127 { 130 {
168 * Also finds the position of maximum of correlation in each track 171 * Also finds the position of maximum of correlation in each track
169 * and the starting position for each pulse. 172 * and the starting position for each pulse.
170 * 173 *
171 *************************************************************************/ 174 *************************************************************************/
172 175
173 void set_sign ( 176 static void set_sign (
174 Word16 dn[], /* (i/o): correlation between target and h[] */ 177 Word16 dn[], /* (i/o): correlation between target and h[] */
175 Word16 cn[], /* (i) : residual after long term prediction */ 178 Word16 cn[], /* (i) : residual after long term prediction */
176 Word16 sign[], /* (o) : sign of d[n] */ 179 Word16 sign[], /* (o) : sign of d[n] */
177 Word16 pos_max[], /* (o) : position of maximum correlation */ 180 Word16 pos_max[], /* (o) : position of maximum correlation */
178 Word16 ipos[] /* (o) : starting position for each pulse */ 181 Word16 ipos[] /* (o) : starting position for each pulse */
267 ipos[i] = pos; move16 (); 270 ipos[i] = pos; move16 ();
268 ipos[i + 5] = pos; move16 (); 271 ipos[i + 5] = pos; move16 ();
269 } 272 }
270 } 273 }
271 274
272 void q_p ( 275 static void q_p (
273 Word16 *ind, /* Pulse position */ 276 Word16 *ind, /* Pulse position */
274 Word16 n /* Pulse number */ 277 Word16 n /* Pulse number */
275 ) 278 )
276 { 279 {
277 static const Word16 gray[8] = {0, 1, 3, 2, 6, 4, 5, 7}; 280 static const Word16 gray[8] = {0, 1, 3, 2, 6, 4, 5, 7};
306 * and the sign information is included by 309 * and the sign information is included by
307 * rr[i][j] = rr[i][j]*sign[i]*sign[j] 310 * rr[i][j] = rr[i][j]*sign[i]*sign[j]
308 * 311 *
309 *************************************************************************/ 312 *************************************************************************/
310 313
311 void cor_h ( 314 static void cor_h (
312 Word16 h[], /* (i) : impulse response of weighted synthesis 315 Word16 h[], /* (i) : impulse response of weighted synthesis
313 filter */ 316 filter */
314 Word16 sign[], /* (i) : sign of d[n] */ 317 Word16 sign[], /* (i) : sign of d[n] */
315 Word16 rr[][L_CODE] /* (o) : matrix of autocorrelation */ 318 Word16 rr[][L_CODE] /* (o) : matrix of autocorrelation */
316 ) 319 )
385 #define _1_16 (Word16)(32768L/16) 388 #define _1_16 (Word16)(32768L/16)
386 #define _1_32 (Word16)(32768L/32) 389 #define _1_32 (Word16)(32768L/32)
387 #define _1_64 (Word16)(32768L/64) 390 #define _1_64 (Word16)(32768L/64)
388 #define _1_128 (Word16)(32768L/128) 391 #define _1_128 (Word16)(32768L/128)
389 392
390 void search_10i40 ( 393 static void search_10i40 (
391 Word16 dn[], /* (i) : correlation between target and h[] */ 394 Word16 dn[], /* (i) : correlation between target and h[] */
392 Word16 rr[][L_CODE], /* (i) : matrix of autocorrelation */ 395 Word16 rr[][L_CODE], /* (i) : matrix of autocorrelation */
393 Word16 ipos[], /* (i) : starting position for each pulse */ 396 Word16 ipos[], /* (i) : starting position for each pulse */
394 Word16 pos_max[], /* (i) : position of maximum of dn[] */ 397 Word16 pos_max[], /* (i) : position of maximum of dn[] */
395 Word16 codvec[] /* (o) : algebraic codebook vector */ 398 Word16 codvec[] /* (o) : algebraic codebook vector */
770 * PURPOSE: Builds the codeword, the filtered codeword and index of the 773 * PURPOSE: Builds the codeword, the filtered codeword and index of the
771 * codevector, based on the signs and positions of 10 pulses. 774 * codevector, based on the signs and positions of 10 pulses.
772 * 775 *
773 *************************************************************************/ 776 *************************************************************************/
774 777
775 void build_code ( 778 static void build_code (
776 Word16 codvec[], /* (i) : position of pulses */ 779 Word16 codvec[], /* (i) : position of pulses */
777 Word16 sign[], /* (i) : sign of d[n] */ 780 Word16 sign[], /* (i) : sign of d[n] */
778 Word16 cod[], /* (o) : innovative code vector */ 781 Word16 cod[], /* (o) : innovative code vector */
779 Word16 h[], /* (i) : impulse response of weighted synthesis filter*/ 782 Word16 h[], /* (i) : impulse response of weighted synthesis filter*/
780 Word16 y[], /* (o) : filtered innovative code */ 783 Word16 y[], /* (o) : filtered innovative code */