comparison libtwamr/inter_36.c @ 383:838ed426bb76

libtwamr: integrate inter_36.c
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 05:49:47 +0000
parents
children
comparison
equal deleted inserted replaced
382:693ea1d5cf1e 383:838ed426bb76
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 : inter_36.c
11 * Purpose : Interpolating the normalized correlation
12 * : with 1/3 or 1/6 resolution.
13 *
14 ********************************************************************************
15 */
16 /*
17 ********************************************************************************
18 * MODULE INCLUDE FILE AND VERSION ID
19 ********************************************************************************
20 */
21 #include "namespace.h"
22 #include "inter_36.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
41 #include "inter_36.tab"
42
43 /*
44 ********************************************************************************
45 * PUBLIC PROGRAM CODE
46 ********************************************************************************
47 */
48 /*************************************************************************
49 *
50 * FUNCTION: Interpol_3or6()
51 *
52 * PURPOSE: Interpolating the normalized correlation with 1/3 or 1/6
53 * resolution.
54 *
55 *************************************************************************/
56 Word16 Interpol_3or6 ( /* o : interpolated value */
57 Word16 *x, /* i : input vector */
58 Word16 frac, /* i : fraction (-2..2 for 3*, -3..3 for 6*) */
59 Word16 flag3 /* i : if set, upsampling rate = 3 (6 otherwise) */
60 )
61 {
62 Word16 i, k;
63 Word16 *x1, *x2;
64 const Word16 *c1, *c2;
65 Word32 s;
66
67 test();
68 if (flag3 != 0)
69 {
70 frac = shl (frac, 1); /* inter_3[k] = inter_6[2*k] -> k' = 2*k */
71 }
72
73 test ();
74 if (frac < 0)
75 {
76 frac = add (frac, UP_SAMP_MAX);
77 x--;
78 }
79
80 x1 = &x[0]; move16 ();
81 x2 = &x[1]; move16 ();
82 c1 = &inter_6[frac]; move16 ();
83 c2 = &inter_6[sub (UP_SAMP_MAX, frac)]; move16 ();
84
85 s = 0; move32 ();
86 for (i = 0, k = 0; i < L_INTER_SRCH; i++, k += UP_SAMP_MAX)
87 {
88 s = L_mac (s, x1[-i], c1[k]);
89 s = L_mac (s, x2[i], c2[k]);
90 }
91
92 return round (s);
93 }