FreeCalypso > hg > gsm-codec-lib
annotate libgsmhr1/dtx_enc.c @ 613:7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Thu, 05 Mar 2026 07:53:49 +0000 |
| parents | |
| children | e6e9d5104503 |
| rev | line source |
|---|---|
|
613
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /*************************************************************************** |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * File Name: dtx_enc.c |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * Derivation: this module is the subset of GSM 06.06 dtx.c |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * reduced to those functions that are used only by the speech |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * encoder. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 **************************************************************************/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 /*________________________________________________________________________ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 | | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 | Include Files | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |________________________________________________________________________| |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "typedefs.h" |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include "namespace.h" |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #include "mathhalf.h" |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #include "mathdp31.h" |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "enc_state.h" |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "dtx_const.h" |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 #include "dtx_enc.h" |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include "dtx_rxfe.h" |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 /*________________________________________________________________________ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 | | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 | Defines | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |________________________________________________________________________| |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #define OH_SHIFT 3 /* shift corresponding to OVERHANG */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 #define NP_AFLAT 4 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 #define LPC_VQ_SEG 3 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 /************************************************************************* |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 * FUNCTION NAME: swComfortNoise |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 * PURPOSE: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 * This routine perform the following tasks: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 * - generation of the speech flag (swSP) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 * - averaging and encoding of the comfort noise parameters |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 * - randomization of the codebook indices |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 * INPUTS: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 * swVadFrmCnt (global) - swVadFlag=0 frame counter. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 * If swVadFlag=1 then this counter is 0, the first frame with |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 * swVadFlag=0 will set this counter to 1, with each additional |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 * swVadFlag=0 frame the counter is incremented. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 * swVadFlag - voise activity flag. swVadFlag=0 frame with |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 * no voice activity, swVadFlag=0 frame with voice activity |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 * L_UnqntzdR0 - unquantized R(0), 32 bit value, output of |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 * FLAT. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 * pL_UnqntzdCorr[NP+1] - unquantized correlation sequence, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 * also an output of FLAT. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 * OUTPUTS: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 * swCNR0 - global variable, the output quantized R0 index |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 * pswCNLpc[3] - global variable, the output quantized LPC to the |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 * transmitted in the SID frame |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 * pswCNGsp0Code[N_SUB] - global variable, the output quantized GSP0 indices |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 * pswCNVSCode1[N_SUB] - global variable, the output quantized codevector 1 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 * indices. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 * pswCNVSCode2[N_SUB] - global variable, the output quantized codevector 2 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 * indices. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 * RETURN VALUE: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 * swSP - speech flag, swSP=1 speech frames are generated, swSP=0 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 * SID frames are generated. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 *************************************************************************/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 Shortword swComfortNoise(struct gsmhr_encoder_state *st, Shortword swVadFlag, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 Longword L_UnqntzdR0, Longword *pL_UnqntzdCorr) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 /*_________________________________________________________________________ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 | | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 | Automatic Variables | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 |_________________________________________________________________________| |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 struct cn_state *cn_st = &st->cn_state; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 Shortword swSP; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 Shortword pswFinalRc[NP]; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 /* unquantized reference parameters */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 Longword L_RefR0; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 Longword pL_RefCorr[NP + 1]; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 Longword L_RefGs; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 int i; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 /*_________________________________________________________________________ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 | | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 | Executable Code | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 |_________________________________________________________________________| |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 swSP = 1; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 /* VadFrmCnt will indicate the number of sequential frames where */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 /* swVadFlag == 0 */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 /* ------------------------------------------------------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 if (swVadFlag) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 st->swVadFrmCnt = 0; /* Voice acitvity present */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 else |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 st->swVadFrmCnt = add(st->swVadFrmCnt, 1); /* no voice activity */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 /* swNElapsed will indicate the number of frames that have elapsed */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 /* since the last SID frame with updated comfort noise parameters */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 /* was generated */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 /* --------------------------------------------------------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 st->swNElapsed = add(st->swNElapsed, 1); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 /* If no voice activity was detected. */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 /* ----------------------------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 if (st->swVadFrmCnt) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 /* Short speech burst ? */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 /* -------------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 if (st->swVadFrmCnt == 1) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 if (sub(st->swNElapsed, 24) < 0) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 cn_st->swShortBurst = 1; /* short speech burst detected */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 else |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 cn_st->swShortBurst = 0; /* long speech burst detected */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 /* Update history, with this frames data */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 /* ------------------------------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 updateCNHist(st, L_UnqntzdR0, pL_UnqntzdCorr, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 cn_st->pL_R0Hist, cn_st->ppL_CorrHist); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 /* first SID frame */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 /* --------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 if (((cn_st->swShortBurst == 0) && (st->swVadFrmCnt == OVERHANG)) || |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 ((cn_st->swShortBurst == 1) && (st->swVadFrmCnt == 1))) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 /* init. random generator */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 /* ---------------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 cn_st->L_TxPNSeed = PN_INIT_SEED; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 /* average GS */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 /* ---------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 avgGsHistQntz(st->pL_GsHist, &L_RefGs); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 /* GS quantization */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 /* --------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 cn_st->swRefGsIndex = gsQuant(L_RefGs, 0); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 /* No Overhang in case of short speech bursts, */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 /* generate SID frames with repeated comfort noise parameters */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 /* ---------------------------------------------------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 if ((cn_st->swShortBurst == 1) && (st->swVadFrmCnt < OVERHANG)) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 /* generate a SID frame with repeated parameters */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 /* --------------------------------------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 swSP = 0; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 /* repeat data: r0, LPC, GS */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 /* ------------------------ */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 st->swCNR0 = cn_st->swQntRefR0; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 for (i = 0; i < 3; i++) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 st->pswCNLpc[i] = cn_st->piRefVqCodewds[i]; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 for (i = 0; i < N_SUB; i++) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 st->pswCNGsp0Code[i] = cn_st->swRefGsIndex; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 /* generate SID frames with updated comfort noise parameters */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 /* --------------------------------------------------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 if (st->swVadFrmCnt >= OVERHANG) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 /* A SID frame with updated parameters */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 /* ----------------------------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 swSP = 0; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 st->swNElapsed = 0; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 /* average R0 and correlation values */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 /* --------------------------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 avgCNHist(cn_st->pL_R0Hist, cn_st->ppL_CorrHist, &L_RefR0, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 pL_RefCorr); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 /* now quantize the averaged R(0) */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 /* ------------------------------ */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 cn_st->swQntRefR0 = r0Quant(L_RefR0); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 /* Quantize the averaged correlation */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 /* --------------------------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 lpcCorrQntz(pL_RefCorr, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 pswFinalRc, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 cn_st->piRefVqCodewds); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 /* update frame data: r0, LPC */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 /* -------------------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 st->swCNR0 = cn_st->swQntRefR0; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 for (i = 0; i < 3; i++) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 st->pswCNLpc[i] = cn_st->piRefVqCodewds[i]; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 /* update subframe data (unvoiced mode): GSP0 */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 /* ------------------------------------------ */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 for (i = 0; i < N_SUB; i++) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 st->pswCNGsp0Code[i] = cn_st->swRefGsIndex; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 /* random codevectors */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 /* ------------------ */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 if (swSP == 0) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 for (i = 0; i < N_SUB; i++) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 st->pswCNVSCode1[i] = getPnBits(7, &cn_st->L_TxPNSeed); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 st->pswCNVSCode2[i] = getPnBits(7, &cn_st->L_TxPNSeed); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 return (swSP); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 /************************************************************************* |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 * FUNCTION NAME: updateCNHist |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 * PURPOSE: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 * Add current frame's unquantized R(0) and LPC information to the |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 * comfort noise history, so that it will be available for |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 * averaging. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 * INPUTS: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 * Unquantized values from the coder: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 * L_UnqntzdR0 - unquantized frame energy R(0), an output of FLAT |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 * pL_UnqntzdCorr[NP+1] - unquantized correlation coefficient |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 * array. Also an output of FLAT. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 * siUpdPointer (global) - A modulo counter which counts up from |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 * 0 to OVERHANG-1. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 * OUTPUTS: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 * pL_R0History[OVERHANG] - history of the OVERHANG frames worth of |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 * R(0). |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 * ppL_CorrHistory[OVERHANG][NP+1] - - history of the OVERHANG |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 * frames worth of pL_UnqntzdCorr[]. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 * RETURN VALUE: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 * none |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 *************************************************************************/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 void updateCNHist(struct gsmhr_encoder_state *st, Longword L_UnqntzdR0, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 Longword *pL_UnqntzdCorr, Longword pL_R0Hist[], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 Longword ppL_CorrHist[OVERHANG][NP + 1]) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 /*_________________________________________________________________________ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 | | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 | Automatic Variables | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 |_________________________________________________________________________| |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 int i; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 /*_________________________________________________________________________ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 | | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 | Executable Code | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 |_________________________________________________________________________| |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 /* update */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 pL_R0Hist[st->siUpdPointer] = L_UnqntzdR0; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 for (i = 0; i < NP + 1; i++) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 ppL_CorrHist[st->siUpdPointer][i] = pL_UnqntzdCorr[i]; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 st->siUpdPointer = (st->siUpdPointer + 1) % OVERHANG; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 /************************************************************************* |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 * FUNCTION NAME: avgCNHist |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 * PURPOSE: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
357 * Average the unquantized R0 and LPC data stored at the encoder |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 * to arrive at an average R0 and LPC frame for use in a SID |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 * frame. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
361 * INPUTS: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
362 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 * pL_R0History[OVERHANG] - contains unquantized R(0) data from the |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
364 * most recent OVERHANG frame (including this one). |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
365 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
366 * ppL_CorrHistory[OVERHANG][NP+1] - Unquantized correlation |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
367 * coefficients from the most recent OVERHANG frame (including this |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
368 * one). The data stored here is an output of FLAT. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
369 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 * OUTPUTS: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
371 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 * *pL_AvgdR0 - the average of pL_R0History[] |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 * pL_AvgdCorrSeq[NP+1] - the average of ppL_CorrHistory[][]. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 * RETURN VALUE: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 * none |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
380 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 *************************************************************************/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
383 void avgCNHist(Longword pL_R0History[], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 Longword ppL_CorrHistory[OVERHANG][NP + 1], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 Longword *pL_AvgdR0, Longword pL_AvgdCorrSeq[]) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 /*_________________________________________________________________________ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 | | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 | Automatic Variables | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 |_________________________________________________________________________| |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 int i, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 j; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
396 Longword L_avg; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
397 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
398 /*_________________________________________________________________________ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
399 | | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
400 | Executable Code | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
401 |_________________________________________________________________________| |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
402 */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
403 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
404 /* R0 Averaging */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
405 /* ------------ */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
406 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
407 for (L_avg = 0, i = 0; i < OVERHANG; i++) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
408 L_avg = L_add(L_shr(pL_R0History[i], OH_SHIFT), L_avg); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
409 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
410 *pL_AvgdR0 = L_avg; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
411 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
412 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
413 /* LPC: average the last OVERHANG frames */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
414 /* ------------------------------------- */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
415 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
416 for (j = 0; j < NP + 1; j++) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
417 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
418 for (L_avg = 0, i = 0; i < OVERHANG; i++) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
419 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
420 L_avg = L_add(L_shift_r(ppL_CorrHistory[i][j], -OH_SHIFT), L_avg); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
421 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
422 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
423 pL_AvgdCorrSeq[j] = L_avg; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
424 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
425 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
426 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
427 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
428 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
429 /*************************************************************************** |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
430 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
431 * FUNCTION NAME: lpcCorrQntz |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
432 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
433 * PURPOSE: Quantize a correlation sequence |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
434 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
435 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
436 * INPUT: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
437 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
438 * pL_CorrelSeq[NP+1] |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
439 * Correlation sequence to quantize. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
440 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
441 * OUTPUTS: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
442 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
443 * pswFinalRc[0:NP-1] |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
444 * A quantized set of NP reflection coefficients. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
445 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
446 * piVQCodewds[0:2] |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
447 * An array containing the indices of the 3 reflection |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
448 * coefficient vectors selected from the three segment |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
449 * Rc-VQ. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
450 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
451 * RETURN: |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
452 * None. |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
453 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
454 * KEYWORDS: AFLAT,aflat,flat,vectorquantization, reflectioncoefficients |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
455 * |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
456 *************************************************************************/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
457 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
458 #if 0 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
459 void lpcCorrQntz(Longword pL_CorrelSeq[], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
460 Shortword pswFinalRc[], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
461 int piVQCodewds[]) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
462 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
463 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
464 /*_________________________________________________________________________ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
465 | | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
466 | Automatic Variables | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
467 |_________________________________________________________________________| |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
468 */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
469 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
470 Shortword pswPOldSpace[NP_AFLAT], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
471 pswPNewSpace[NP_AFLAT], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
472 pswVOldSpace[2 * NP_AFLAT - 1], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
473 pswVNewSpace[2 * NP_AFLAT - 1], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
474 *ppswPAddrs[2], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
475 *ppswVAddrs[2], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
476 *pswVBar, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
477 pswPBar[NP_AFLAT], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
478 pswVBarSpace[2 * NP_AFLAT - 1], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
479 pswFlatsRc[NP], /* Unquantized Rc's computed by FLAT */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
480 pswRc[NP + 1]; /* Temp list for the converted RC's */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
481 Longword *pL_VBarFull, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
482 pL_PBarFull[NP], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
483 pL_VBarFullSpace[2 * NP - 1]; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
484 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
485 int i, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
486 iVec, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
487 iSeg, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
488 iCnt; /* Loop counter */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
489 struct QuantList quantList, /* A list of vectors */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
490 bestPql[4]; /* The four best vectors from |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
491 * the PreQ */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
492 struct QuantList bestQl[LPC_VQ_SEG + 1]; /* Best vectors for each of |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
493 * the three segments */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
494 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
495 /*_________________________________________________________________________ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
496 | | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
497 | Executable Code | |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
498 |_________________________________________________________________________| |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
499 */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
500 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
501 /* Setup pointers temporary space */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
502 /*--------------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
503 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
504 pswVBar = pswVBarSpace + NP_AFLAT - 1; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
505 pL_VBarFull = pL_VBarFullSpace + NP - 1; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
506 ppswPAddrs[0] = pswPOldSpace; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
507 ppswPAddrs[1] = pswPNewSpace; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
508 ppswVAddrs[0] = pswVOldSpace + NP_AFLAT - 1; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
509 ppswVAddrs[1] = pswVNewSpace + NP_AFLAT - 1; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
510 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
511 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
512 /* Set up pL_PBarFull and pL_VBarFull initial conditions, using the */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
513 /* autocorrelation sequence derived from the optimal reflection */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
514 /* coefficients computed by FLAT. The initial conditions are shifted */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
515 /* right by RSHIFT bits. These initial conditions, stored as */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
516 /* Longwords, are used to initialize PBar and VBar arrays for the */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
517 /* next VQ segment. */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
518 /*--------------------------------------------------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
519 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
520 initPBarFullVBarFullL(pL_CorrelSeq, pL_PBarFull, pL_VBarFull); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
521 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
522 /* Set up initial PBar and VBar initial conditions, using pL_PBarFull */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
523 /* and pL_VBarFull arrays initialized above. These are the initial */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
524 /* PBar and VBar conditions to be used by the AFLAT recursion at the */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
525 /* 1-st Rc-VQ segment. */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
526 /*--------------------------------------------------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
527 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
528 initPBarVBarL(pL_PBarFull, pswPBar, pswVBar); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
529 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
530 for (iSeg = 1; iSeg <= LPC_VQ_SEG; iSeg++) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
531 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
532 /* initialize candidate list */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
533 /*---------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
534 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
535 quantList.iNum = psrPreQSz[iSeg - 1]; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
536 quantList.iRCIndex = 0; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
537 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
538 /* do aflat for all vectors in the list */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
539 /*--------------------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
540 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
541 setupPreQ(iSeg, quantList.iRCIndex); /* set up vector ptrs */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
542 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
543 for (iCnt = 0; iCnt < quantList.iNum; iCnt++) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
544 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
545 /* get a vector */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
546 /*--------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
547 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
548 getNextVec(pswRc); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
549 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
550 /* clear the limiter flag */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
551 /*------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
552 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
553 iLimit = 0; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
554 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
555 /* find the error values for each vector */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
556 /*---------------------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
557 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
558 quantList.pswPredErr[iCnt] = |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
559 aflatRecursion(&pswRc[psvqIndex[iSeg - 1].l], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
560 pswPBar, pswVBar, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
561 ppswPAddrs, ppswVAddrs, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
562 psvqIndex[iSeg - 1].len); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
563 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
564 /* check the limiter flag */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
565 /*------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
566 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
567 if (iLimit) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
568 quantList.pswPredErr[iCnt] = 0x7fff; /* set error to bad value */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
569 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
570 } /* done list loop */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
571 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
572 /* find 4 best prequantizer levels */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
573 /*---------------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
574 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
575 findBestInQuantList(quantList, 4, bestPql); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
576 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
577 for (iVec = 0; iVec < 4; iVec++) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
578 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
579 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
580 /* initialize quantizer list */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
581 /*---------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
582 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
583 quantList.iNum = psrQuantSz[iSeg - 1]; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
584 quantList.iRCIndex = bestPql[iVec].iRCIndex * psrQuantSz[iSeg - 1]; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
585 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
586 setupQuant(iSeg, quantList.iRCIndex); /* set up vector ptrs */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
587 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
588 /* do aflat recursion on each element of list */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
589 /*--------------------------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
590 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
591 for (iCnt = 0; iCnt < quantList.iNum; iCnt++) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
592 { |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
593 /* get a vector */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
594 /*--------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
595 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
596 getNextVec(pswRc); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
597 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
598 /* clear the limiter flag */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
599 /*------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
600 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
601 iLimit = 0; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
602 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
603 /* find the error values for each vector */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
604 /*---------------------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
605 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
606 quantList.pswPredErr[iCnt] = |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
607 aflatRecursion(&pswRc[psvqIndex[iSeg - 1].l], |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
608 pswPBar, pswVBar, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
609 ppswPAddrs, ppswVAddrs, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
610 psvqIndex[iSeg - 1].len); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
611 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
612 /* check the limiter flag */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
613 /*------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
614 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
615 if (iLimit) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
616 quantList.pswPredErr[iCnt] = 0x7fff; /* set error to the worst |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
617 * value */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
618 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
619 } /* done list loop */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
620 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
621 /* find best quantizer vector for this segment, and save it */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
622 /*----------------------------------------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
623 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
624 findBestInQuantList(quantList, 1, bestQl); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
625 if (iVec == 0) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
626 bestQl[iSeg] = bestQl[0]; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
627 else if (sub(bestQl[iSeg].pswPredErr[0], bestQl[0].pswPredErr[0]) > 0) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
628 bestQl[iSeg] = bestQl[0]; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
629 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
630 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
631 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
632 /* find the quantized reflection coefficients */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
633 /*--------------------------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
634 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
635 setupQuant(iSeg, bestQl[iSeg].iRCIndex); /* set up vector ptrs */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
636 getNextVec((Shortword *) (pswFinalRc - 1)); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
637 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
638 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
639 /* Update pBarFull and vBarFull for the next Rc-VQ segment, and */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
640 /* update the pswPBar and pswVBar for the next Rc-VQ segment */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
641 /*--------------------------------------------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
642 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
643 if (iSeg < LPC_VQ_SEG) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
644 aflatNewBarRecursionL(&pswFinalRc[psvqIndex[iSeg - 1].l - 1], iSeg, |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
645 pL_PBarFull, pL_VBarFull, pswPBar, pswVBar); |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
646 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
647 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
648 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
649 /* find the quantizer index (the values to be output in the symbol file) */ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
650 /*-----------------------------------------------------------------*/ |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
651 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
652 for (iSeg = 1; iSeg <= LPC_VQ_SEG; iSeg++) |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
653 piVQCodewds[iSeg - 1] = bestQl[iSeg].iRCIndex; |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
654 |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
655 } |
|
7ce83c70ec5f
libgsmhr1: integrate encoder DTX functions, first round
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
656 #endif |
