FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/inter_36.c @ 468:4104b0390fab
efrtest: new program gsmefr-dlcap-sync
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 13 May 2024 07:21:09 +0000 |
parents | 838ed426bb76 |
children |
rev | line source |
---|---|
383
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : inter_36.c |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : Interpolating the normalized correlation |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * : with 1/3 or 1/6 resolution. |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 * |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 ******************************************************************************** |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 */ |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 /* |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 ******************************************************************************** |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 * MODULE INCLUDE FILE AND VERSION ID |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 ******************************************************************************** |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 */ |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "namespace.h" |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "inter_36.h" |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 /* |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 ******************************************************************************** |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 * INCLUDE FILES |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 ******************************************************************************** |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 */ |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "typedef.h" |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "basic_op.h" |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "no_count.h" |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "cnst.h" |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 /* |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 ******************************************************************************** |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 * LOCAL VARIABLES AND TABLES |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 ******************************************************************************** |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 */ |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 #define UP_SAMP_MAX 6 |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 #include "inter_36.tab" |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 /* |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 ******************************************************************************** |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 * PUBLIC PROGRAM CODE |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 ******************************************************************************** |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 */ |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 /************************************************************************* |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 * |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 * FUNCTION: Interpol_3or6() |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 * |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 * PURPOSE: Interpolating the normalized correlation with 1/3 or 1/6 |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 * resolution. |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 * |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 *************************************************************************/ |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 Word16 Interpol_3or6 ( /* o : interpolated value */ |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 Word16 *x, /* i : input vector */ |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 Word16 frac, /* i : fraction (-2..2 for 3*, -3..3 for 6*) */ |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 Word16 flag3 /* i : if set, upsampling rate = 3 (6 otherwise) */ |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 ) |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 { |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 Word16 i, k; |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 Word16 *x1, *x2; |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 const Word16 *c1, *c2; |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 Word32 s; |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 test(); |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 if (flag3 != 0) |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 { |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 frac = shl (frac, 1); /* inter_3[k] = inter_6[2*k] -> k' = 2*k */ |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 } |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 test (); |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 if (frac < 0) |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 { |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 frac = add (frac, UP_SAMP_MAX); |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 x--; |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 } |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 x1 = &x[0]; move16 (); |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 x2 = &x[1]; move16 (); |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 c1 = &inter_6[frac]; move16 (); |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 c2 = &inter_6[sub (UP_SAMP_MAX, frac)]; move16 (); |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 s = 0; move32 (); |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 for (i = 0, k = 0; i < L_INTER_SRCH; i++, k += UP_SAMP_MAX) |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 { |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 s = L_mac (s, x1[-i], c1[k]); |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 s = L_mac (s, x2[i], c2[k]); |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 } |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 return round (s); |
838ed426bb76
libtwamr: integrate inter_36.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 } |