FreeCalypso > hg > gsm-codec-lib
comparison libgsmefr/inter_6.c @ 53:49dd1ac8e75b
libgsmefr: import most *.c files from ETSI source
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Fri, 25 Nov 2022 16:18:21 +0000 |
| parents | |
| children | 63ad83f3d821 |
comparison
equal
deleted
inserted
replaced
| 52:988fd7ff514f | 53:49dd1ac8e75b |
|---|---|
| 1 /************************************************************************* | |
| 2 * | |
| 3 * FUNCTION: Interpol_6() | |
| 4 * | |
| 5 * PURPOSE: Interpolating the normalized correlation with 1/6 resolution. | |
| 6 * | |
| 7 *************************************************************************/ | |
| 8 | |
| 9 #include "typedef.h" | |
| 10 #include "basic_op.h" | |
| 11 #include "count.h" | |
| 12 | |
| 13 #define UP_SAMP 6 | |
| 14 #define L_INTERPOL 4 | |
| 15 #define FIR_SIZE (UP_SAMP*L_INTERPOL+1) | |
| 16 | |
| 17 /* 1/6 resolution interpolation filter (-3 dB at 3600 Hz) */ | |
| 18 | |
| 19 static const Word16 inter_6[FIR_SIZE] = | |
| 20 { | |
| 21 29519, | |
| 22 28316, 24906, 19838, 13896, 7945, 2755, | |
| 23 -1127, -3459, -4304, -3969, -2899, -1561, | |
| 24 -336, 534, 970, 1023, 823, 516, | |
| 25 220, 0, -131, -194, -215, 0 | |
| 26 }; | |
| 27 | |
| 28 Word16 Interpol_6 ( /* (o) : interpolated value */ | |
| 29 Word16 *x, /* (i) : input vector */ | |
| 30 Word16 frac /* (i) : fraction */ | |
| 31 ) | |
| 32 { | |
| 33 Word16 i, k; | |
| 34 Word16 *x1, *x2; | |
| 35 const Word16 *c1, *c2; | |
| 36 Word32 s; | |
| 37 | |
| 38 test (); | |
| 39 if (frac < 0) | |
| 40 { | |
| 41 frac = add (frac, UP_SAMP); | |
| 42 x--; | |
| 43 } | |
| 44 x1 = &x[0]; move16 (); | |
| 45 x2 = &x[1]; move16 (); | |
| 46 c1 = &inter_6[frac]; move16 (); | |
| 47 c2 = &inter_6[sub (UP_SAMP, frac)]; move16 (); | |
| 48 | |
| 49 s = 0; move32 (); | |
| 50 for (i = 0, k = 0; i < L_INTERPOL; i++, k += UP_SAMP) | |
| 51 { | |
| 52 s = L_mac (s, x1[-i], c1[k]); | |
| 53 s = L_mac (s, x2[i], c2[k]); | |
| 54 } | |
| 55 | |
| 56 return round (s); | |
| 57 } |
