FreeCalypso > hg > gsm-codec-lib
comparison libtwamr/pred_lt.c @ 398:df14b0c17e6d
libtwamr: integrate pred_lt.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 06 May 2024 19:07:10 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
397:9b699f30e6f3 | 398:df14b0c17e6d |
---|---|
1 /* | |
2 ******************************************************************************** | |
3 * | |
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 | |
5 * R99 Version 3.3.0 | |
6 * REL-4 Version 4.1.0 | |
7 * | |
8 ******************************************************************************** | |
9 * | |
10 * File : pred_lt.c | |
11 * Purpose : Compute the result of long term prediction | |
12 * | |
13 ******************************************************************************** | |
14 */ | |
15 | |
16 /* | |
17 ******************************************************************************** | |
18 * MODULE INCLUDE FILE AND VERSION ID | |
19 ******************************************************************************** | |
20 */ | |
21 #include "namespace.h" | |
22 #include "pred_lt.h" | |
23 | |
24 /* | |
25 ******************************************************************************** | |
26 * INCLUDE FILES | |
27 ******************************************************************************** | |
28 */ | |
29 #include "typedef.h" | |
30 #include "basic_op.h" | |
31 #include "no_count.h" | |
32 #include "cnst.h" | |
33 | |
34 /* | |
35 ******************************************************************************** | |
36 * LOCAL VARIABLES AND TABLES | |
37 ******************************************************************************** | |
38 */ | |
39 #define UP_SAMP_MAX 6 | |
40 #define L_INTER10 (L_INTERPOL-1) | |
41 #define FIR_SIZE (UP_SAMP_MAX*L_INTER10+1) | |
42 | |
43 /* 1/6 resolution interpolation filter (-3 dB at 3600 Hz) */ | |
44 /* Note: the 1/3 resolution filter is simply a subsampled | |
45 * version of the 1/6 resolution filter, i.e. it uses | |
46 * every second coefficient: | |
47 * | |
48 * inter_3l[k] = inter_6[2*k], 0 <= k <= 3*L_INTER10 | |
49 */ | |
50 static const Word16 inter_6[FIR_SIZE] = | |
51 { | |
52 29443, | |
53 28346, 25207, 20449, 14701, 8693, 3143, | |
54 -1352, -4402, -5865, -5850, -4673, -2783, | |
55 -672, 1211, 2536, 3130, 2991, 2259, | |
56 1170, 0, -1001, -1652, -1868, -1666, | |
57 -1147, -464, 218, 756, 1060, 1099, | |
58 904, 550, 135, -245, -514, -634, | |
59 -602, -451, -231, 0, 191, 308, | |
60 340, 296, 198, 78, -36, -120, | |
61 -163, -165, -132, -79, -19, 34, | |
62 73, 91, 89, 70, 38, 0 | |
63 }; | |
64 | |
65 /* | |
66 ******************************************************************************** | |
67 * PUBLIC PROGRAM CODE | |
68 ******************************************************************************** | |
69 */ | |
70 /************************************************************************* | |
71 * | |
72 * FUNCTION: Pred_lt_3or6() | |
73 * | |
74 * PURPOSE: Compute the result of long term prediction with fractional | |
75 * interpolation of resolution 1/3 or 1/6. (Interpolated past | |
76 * excitation). | |
77 * | |
78 * DESCRIPTION: | |
79 * The past excitation signal at the given delay is interpolated at | |
80 * the given fraction to build the adaptive codebook excitation. | |
81 * On return exc[0..L_subfr-1] contains the interpolated signal | |
82 * (adaptive codebook excitation). | |
83 * | |
84 *************************************************************************/ | |
85 void Pred_lt_3or6 ( | |
86 Word16 exc[], /* in/out: excitation buffer */ | |
87 Word16 T0, /* input : integer pitch lag */ | |
88 Word16 frac, /* input : fraction of lag */ | |
89 Word16 L_subfr, /* input : subframe size */ | |
90 Word16 flag3 /* input : if set, upsampling rate = 3 (6 otherwise) */ | |
91 ) | |
92 { | |
93 Word16 i, j, k; | |
94 Word16 *x0, *x1, *x2; | |
95 const Word16 *c1, *c2; | |
96 Word32 s; | |
97 | |
98 x0 = &exc[-T0]; move16 (); | |
99 | |
100 frac = negate (frac); | |
101 test(); | |
102 if (flag3 != 0) | |
103 { | |
104 frac = shl (frac, 1); /* inter_3l[k] = inter_6[2*k] -> k' = 2*k */ | |
105 } | |
106 | |
107 test (); | |
108 if (frac < 0) | |
109 { | |
110 frac = add (frac, UP_SAMP_MAX); | |
111 x0--; | |
112 } | |
113 | |
114 for (j = 0; j < L_subfr; j++) | |
115 { | |
116 x1 = x0++; move16 (); | |
117 x2 = x0; move16 (); | |
118 c1 = &inter_6[frac]; | |
119 c2 = &inter_6[sub (UP_SAMP_MAX, frac)]; | |
120 | |
121 s = 0; move32 (); | |
122 for (i = 0, k = 0; i < L_INTER10; i++, k += UP_SAMP_MAX) | |
123 { | |
124 s = L_mac (s, x1[-i], c1[k]); | |
125 s = L_mac (s, x2[i], c2[k]); | |
126 } | |
127 | |
128 exc[j] = round (s); move16 (); | |
129 } | |
130 | |
131 return; | |
132 } |