FreeCalypso > hg > gsm-codec-lib
annotate libgsmhr1/dtx_dec.c @ 598:5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Thu, 04 Dec 2025 09:51:11 +0000 |
| parents | |
| children | c7c03231002d |
| rev | line source |
|---|---|
|
598
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /*************************************************************************** |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * File Name: dtx_dec.c |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * Derivation: this module is the subset of GSM 06.06 dtx.c |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * reduced to decoder functions that aren't in dtx_rxfe.c, i.e., |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * apply only to the full decoder and not the TFO transform. |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 **************************************************************************/ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 /*________________________________________________________________________ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 | | |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 | Include Files | |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |________________________________________________________________________| |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include <string.h> |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include "typedefs.h" |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #include "namespace.h" |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #include "mathhalf.h" |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "mathdp31.h" |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "dec_func.h" |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 #include "dec_state.h" |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include "dtx_const.h" |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 #include "dtx_dec.h" |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 /*________________________________________________________________________ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 | | |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 | Defines | |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 |________________________________________________________________________| |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #define ASHIFT 4 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 #define ASCALE 0x0800 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 /*________________________________________________________________________ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 | | |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 | DTX Rom Tables | |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 |________________________________________________________________________| |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 /* interpolation curve for comfort noise (i*1/12) i=1..12 */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 static const Shortword psrCNNewFactor[12] = { |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 0x0aaa, 0x1554, 0x1ffe, 0x2aa8, 0x3552, |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 0x3ffc, 0x4aa6, 0x5550, 0x5ffa, 0x6aa4, |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 0x754e, 0x7fff |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 }; |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 /* |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 * This function is a fragment from original rxInterpR0Lpc(): |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 * init or update CN interpolation endpoints on CNIFIRSTSID |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 * or CNICONT. |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 void Init_CN_interpolation(struct gsmhr_decoder_state *st, Shortword deco_mode, |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 Shortword new_R0, const Shortword *pswNewKs) |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 { |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 st->swR0OldCN = st->swOldR0Dec; |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 st->swR0NewCN = new_R0; |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 if (deco_mode == CNIFIRSTSID) { |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 rcToCorrDpL(ASHIFT, ASCALE, st->pswOldFrmKsDec, |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 st->pL_OldCorrSeq); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 } else { |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 memcpy(st->pL_OldCorrSeq, st->pL_CorrSeq, |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 sizeof(st->pL_CorrSeq)); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 } |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 rcToCorrDpL(ASHIFT, ASCALE, pswNewKs, st->pL_NewCorrSeq); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 } |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 /* |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 * This function is a fragment from original rxInterpR0Lpc(): |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 * interpolate R0 for CN output. |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 Shortword CN_Interpolate_R0(struct gsmhr_decoder_state *st) |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 { |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 return linInterpSidShort(st->swR0NewCN, st->swR0OldCN, |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 st->swRxDTXState); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 } |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 /* |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 * This function is a fragment from original rxInterpR0Lpc(): |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 * interpolate LPC for CN output. |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 void CN_Interpolate_LPC(struct gsmhr_decoder_state *st, Shortword *pswNewKs) |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 { |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 int i; |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 /* linearly interpolate between the two sets of correlation coefs */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 /* -------------------------------------------------------------- */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 for (i = 0; i < NP + 1; i++) |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 { |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 st->pL_CorrSeq[i] = linInterpSid(st->pL_NewCorrSeq[i], |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 st->pL_OldCorrSeq[i], |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 st->swRxDTXState); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 } |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 /* Generate this frames K's (overwrite input) */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 /* ------------------------------------------ */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 aFlatRcDp(st->pL_CorrSeq, pswNewKs); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 } |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 /************************************************************************* |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 * FUNCTION NAME: linInterpSid |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 * PURPOSE: |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 * Linearly interpolate between two input numbers based on what the |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 * current DtxState is. |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 * INPUTS: |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 * L_New - longword more current value |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 * L_Old - longword oldest value |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 * swDtxState - state is 0 at the transmitted SID Frame. |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 * OUTPUTS: |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 * none |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 * RETURN VALUE: |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 * A value between old and new inputs with dtxState+1/12 of the new |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 * (dtxState+1)-12/12 of the old |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 *************************************************************************/ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 Longword linInterpSid(Longword L_New, Longword L_Old, Shortword swDtxState) |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 { |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 /*_________________________________________________________________________ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 | | |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 | Automatic Variables | |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 |_________________________________________________________________________| |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 Shortword swOldFactor; |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 /*_________________________________________________________________________ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 | | |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 | Executable Code | |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 |_________________________________________________________________________| |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 /* old factor = (1.0 - newFactor) */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 /* ------------------------------ */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 swOldFactor = sub(0x7fff, psrCNNewFactor[swDtxState]); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 swOldFactor = add(0x1, swOldFactor); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 /* contributions from new and old */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 /* ------------------------------ */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 L_New = L_mpy_ls(L_New, psrCNNewFactor[swDtxState]); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 L_Old = L_mpy_ls(L_Old, swOldFactor); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 return (L_add(L_New, L_Old)); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 } |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 /************************************************************************* |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 * FUNCTION NAME: linInterpSidShort |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 * PURPOSE: |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 * Linearly interpolate between two input numbers based on what |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 * the current DtxState is. |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 * INPUTS: |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 * swNew - 16 bit, more current value |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 * swOld - 16 bit, oldest value |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 * swDtxState - state is 0 at the transmitted SID Frame. |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 * OUTPUTS: |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 * none |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 * RETURN VALUE: |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 * A value between old and new inputs with dtxState+1/12 of the new |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 * (dtxState+1)-12/12 of the old |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 * |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 *************************************************************************/ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 Shortword linInterpSidShort(Shortword swNew, Shortword swOld, |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 Shortword swDtxState) |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 { |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 /*_________________________________________________________________________ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 | | |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 | Automatic Variables | |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 |_________________________________________________________________________| |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 Shortword swOldFactor; |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 Longword L_New, |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 L_Old; |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 /*_________________________________________________________________________ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 | | |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 | Executable Code | |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 |_________________________________________________________________________| |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 /* old factor = (1.0 - newFactor) */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 /* ------------------------------ */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 swOldFactor = sub(0x7fff, psrCNNewFactor[swDtxState]); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 swOldFactor = add(0x1, swOldFactor); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 /* contributions from new and old */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 /* ------------------------------ */ |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 L_New = L_mult(swNew, psrCNNewFactor[swDtxState]); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 L_Old = L_mult(swOld, swOldFactor); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 return (round(L_add(L_New, L_Old))); |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 |
|
5809165fb140
libgsmhr1: integrate DTX functions for speech decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 } |
