comparison libtwamr/lsp_avg.c @ 389:9cd332a94c97

libtwamr: integrate lsp_avg.c
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 06:49:54 +0000
parents
children
comparison
equal deleted inserted replaced
388:550d3594c878 389:9cd332a94c97
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 : lsp_avg.c
11 * Purpose: : LSP averaging and history
12 *
13 *****************************************************************************
14 */
15
16 /*
17 *****************************************************************************
18 * MODULE INCLUDE FILE AND VERSION ID
19 *****************************************************************************
20 */
21 #include "namespace.h"
22 #include "lsp_avg.h"
23
24 /*
25 *****************************************************************************
26 * INCLUDE FILES
27 *****************************************************************************
28 */
29 #include "basic_op.h"
30 #include "oper_32b.h"
31 #include "no_count.h"
32 #include "q_plsf5_tab.h"
33 #include "memops.h"
34
35 /*
36 *****************************************************************************
37 * LOCAL VARIABLES AND TABLES
38 *****************************************************************************
39 */
40 /*
41 *****************************************************************************
42 * PUBLIC PROGRAM CODE
43 *****************************************************************************
44 */
45
46 /*
47 **************************************************************************
48 *
49 * Function : lsp_avg_reset
50 * Purpose : Resets state memory
51 *
52 **************************************************************************
53 */
54 void lsp_avg_reset (lsp_avgState *st)
55 {
56 Copy(mean_lsf, &st->lsp_meanSave[0], M);
57 }
58
59 /*
60 **************************************************************************
61 *
62 * Function : lsp_avg
63 * Purpose : Calculate the LSP averages
64 *
65 **************************************************************************
66 */
67
68 void lsp_avg (
69 lsp_avgState *st, /* i/o : State struct Q15 */
70 Word16 *lsp /* i : state of the state machine Q15 */
71 )
72 {
73 Word16 i;
74 Word32 L_tmp; /* Q31 */
75
76 for (i = 0; i < M; i++) {
77
78 /* mean = 0.84*mean */
79 L_tmp = L_deposit_h(st->lsp_meanSave[i]);
80 L_tmp = L_msu(L_tmp, EXPCONST, st->lsp_meanSave[i]);
81
82 /* Add 0.16 of newest LSPs to mean */
83 L_tmp = L_mac(L_tmp, EXPCONST, lsp[i]);
84
85 /* Save means */
86 st->lsp_meanSave[i] = round(L_tmp); move16(); /* Q15 */
87 }
88
89 return;
90 }