FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/lsp_avg.c @ 485:751f06541fbb
doc/Codec-utils: clarify lack of DHF in gsmfr-decode-rb
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 20 May 2024 01:47:22 +0000 |
parents | 9cd332a94c97 |
children |
rev | line source |
---|---|
389
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ***************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ***************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : lsp_avg.c |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose: : LSP averaging and history |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 ***************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 */ |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 /* |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 ***************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 * MODULE INCLUDE FILE AND VERSION ID |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 ***************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 */ |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "namespace.h" |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "lsp_avg.h" |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 /* |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 ***************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 * INCLUDE FILES |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 ***************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 */ |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "basic_op.h" |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "oper_32b.h" |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "no_count.h" |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "q_plsf5_tab.h" |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #include "memops.h" |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 /* |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 ***************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 * LOCAL VARIABLES AND TABLES |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 ***************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 */ |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 /* |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 ***************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 * PUBLIC PROGRAM CODE |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 ***************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 */ |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 /* |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 ************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 * |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 * Function : lsp_avg_reset |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 * Purpose : Resets state memory |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 * |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 ************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 */ |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 void lsp_avg_reset (lsp_avgState *st) |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 { |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 Copy(mean_lsf, &st->lsp_meanSave[0], M); |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 /* |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 ************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 * |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 * Function : lsp_avg |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 * Purpose : Calculate the LSP averages |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 * |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 ************************************************************************** |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 */ |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 void lsp_avg ( |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 lsp_avgState *st, /* i/o : State struct Q15 */ |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 Word16 *lsp /* i : state of the state machine Q15 */ |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 ) |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 { |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 Word16 i; |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 Word32 L_tmp; /* Q31 */ |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 for (i = 0; i < M; i++) { |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 /* mean = 0.84*mean */ |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 L_tmp = L_deposit_h(st->lsp_meanSave[i]); |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 L_tmp = L_msu(L_tmp, EXPCONST, st->lsp_meanSave[i]); |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 /* Add 0.16 of newest LSPs to mean */ |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 L_tmp = L_mac(L_tmp, EXPCONST, lsp[i]); |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 /* Save means */ |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 st->lsp_meanSave[i] = round(L_tmp); move16(); /* Q15 */ |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 } |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 return; |
9cd332a94c97
libtwamr: integrate lsp_avg.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 } |