comparison libtwamr/lpc.c @ 386:9adfe3863a41

libtwamr: integrate lpc.c
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 06:24:26 +0000
parents
children
comparison
equal deleted inserted replaced
385:c713061b6edf 386:9adfe3863a41
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 : lpc.c
11 *
12 ********************************************************************************
13 */
14
15 /*
16 ********************************************************************************
17 * MODULE INCLUDE FILE AND VERSION ID
18 ********************************************************************************
19 */
20 #include "namespace.h"
21 #include "lpc.h"
22
23 /*
24 ********************************************************************************
25 * INCLUDE FILES
26 ********************************************************************************
27 */
28 #include "tw_amr.h"
29 #include "typedef.h"
30 #include "basic_op.h"
31 #include "oper_32b.h"
32 #include "autocorr.h"
33 #include "lag_wind.h"
34 #include "levinson.h"
35 #include "cnst.h"
36 #include "no_count.h"
37 #include "window.h"
38
39 /*
40 ********************************************************************************
41 * PUBLIC PROGRAM CODE
42 ********************************************************************************
43 */
44
45 /*************************************************************************
46 *
47 * Function: lpc_reset
48 *
49 **************************************************************************
50 */
51 void lpc_reset (lpcState *state)
52 {
53 Levinson_reset(&state->levinsonSt);
54 }
55
56 int lpc(
57 lpcState *st, /* i/o: State struct */
58 enum Mode mode, /* i : coder mode */
59 Word16 x[], /* i : Input signal Q15 */
60 Word16 x_12k2[], /* i : Input signal (EFR) Q15 */
61 Word16 a[] /* o : predictor coefficients Q12 */
62 )
63 {
64 Word16 rc[4]; /* First 4 reflection coefficients Q15 */
65 Word16 rLow[MP1], rHigh[MP1]; /* Autocorrelations low and hi */
66 /* No fixed Q value but normalized */
67 /* so that overflow is avoided */
68
69 test ();
70 if ( sub (mode, MR122) == 0)
71 {
72 /* Autocorrelations */
73 Autocorr(x_12k2, M, rHigh, rLow, window_160_80);
74 /* Lag windowing */
75 Lag_window(M, rHigh, rLow);
76 /* Levinson Durbin */
77 Levinson(&st->levinsonSt, rHigh, rLow, &a[MP1], rc);
78
79 /* Autocorrelations */
80 Autocorr(x_12k2, M, rHigh, rLow, window_232_8);
81 /* Lag windowing */
82 Lag_window(M, rHigh, rLow);
83 /* Levinson Durbin */
84 Levinson(&st->levinsonSt, rHigh, rLow, &a[MP1 * 3], rc);
85 }
86 else
87 {
88 /* Autocorrelations */
89 Autocorr(x, M, rHigh, rLow, window_200_40);
90 /* Lag windowing */
91 Lag_window(M, rHigh, rLow);
92 /* Levinson Durbin */
93 Levinson(&st->levinsonSt, rHigh, rLow, &a[MP1 * 3], rc);
94 }
95
96 return 0;
97 }