FreeCalypso > hg > gsm-codec-lib
annotate libgsmefr/vad.c @ 110:913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 29 Nov 2022 03:01:38 +0000 |
parents | |
children | 756605c4850f |
rev | line source |
---|---|
110
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /*************************************************************************** |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * File Name: vad.c |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * Purpose: Contains all functions for voice activity detection, as |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * described in the high level specification of VAD. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 * Below is a listing of all the functions appearing in the file. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * The functions are arranged according to their purpose. Under |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * each heading, the ordering is hierarchical. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * Resetting of static variables of VAD: |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 * reset_vad() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 * Main routine of VAD (called by the speech encoder): |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 * vad_computation() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 * Adaptive filtering and energy computation: |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 * energy_computation() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 * Averaging of autocorrelation function values: |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 * acf_averaging() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 * Computation of predictor values: |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 * predictor_values() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 * schur_recursion() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 * step_up() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 * compute_rav1() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 * Spectral comparison: |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 * spectral_comparison() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 * Information tone detection: |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 * tone_detection() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 * step_up() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 * Threshold adaptation: |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 * threshold_adaptation() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 * VAD decision: |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 * vad_decision() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 * VAD hangover addition: |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 * vad_hangover() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 * Periodicity detection routine (called by the speech encoder): |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 * periodicity_detection() |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 **************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 #include "typedef.h" |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 #include "cnst.h" |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 #include "basic_op.h" |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 #include "oper_32b.h" |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 #include "count.h" |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 #include "vad.h" |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 /* Constants of VAD hangover addition */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 #define HANGCONST 10 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 #define BURSTCONST 3 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 /* Constant of spectral comparison */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 #define STAT_THRESH 3670L /* 0.056 */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 /* Constants of periodicity detection */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 #define LTHRESH 2 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 #define NTHRESH 4 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 /* Pseudo floating point representations of constants |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 for threshold adaptation */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 #define M_PTH 32500 /*** 130000.0 ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 #define E_PTH 17 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 #define M_PLEV 21667 /*** 346666.7 ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 #define E_PLEV 19 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 #define M_MARGIN 16927 /*** 69333340 ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 #define E_MARGIN 27 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 #define FAC 17203 /* 2.1 */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 /* Constants of tone detection */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 #define FREQTH 3189 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 #define PREDTH 1464 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 /* Static variables of VAD */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 static Word16 rvad[9], scal_rvad; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 static Pfloat thvad; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 static Word32 L_sacf[27]; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 static Word32 L_sav0[36]; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 static Word16 pt_sacf, pt_sav0; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 static Word32 L_lastdm; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 static Word16 adaptcount; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 static Word16 burstcount, hangcount; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 static Word16 oldlagcount, veryoldlagcount, oldlag; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 Word16 ptch; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 /************************************************************************* |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 * FUNCTION NAME: vad_reset |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 * PURPOSE: Resets the static variables of the VAD to their |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 * initial values |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 *************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 void vad_reset () |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 Word16 i; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 /* Initialize rvad variables */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 rvad[0] = 0x6000; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 for (i = 1; i < 9; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 rvad[i] = 0; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 scal_rvad = 7; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 /* Initialize threshold level */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 thvad.e = 20; /*** exponent ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 thvad.m = 27083; /*** mantissa ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 /* Initialize ACF averaging variables */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 for (i = 0; i < 27; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 L_sacf[i] = 0L; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 for (i = 0; i < 36; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 L_sav0[i] = 0L; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 pt_sacf = 0; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 pt_sav0 = 0; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 /* Initialize spectral comparison variable */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 L_lastdm = 0L; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 /* Initialize threshold adaptation variable */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 adaptcount = 0; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 /* Initialize VAD hangover addition variables */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 burstcount = 0; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 hangcount = -1; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 /* Initialize periodicity detection variables */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 oldlagcount = 0; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 veryoldlagcount = 0; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 oldlag = 18; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 ptch = 1; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 /**************************************************************************** |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 * FUNCTION: vad_computation |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 * PURPOSE: Returns a decision as to whether the current frame being |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 * processed by the speech encoder contains speech or not. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 * INPUTS: r_h[0..8] autocorrelation of input signal frame (msb) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 * r_l[0..8] autocorrelation of input signal frame (lsb) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 * scal_acf scaling factor for the autocorrelations |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 * rc[0..3] speech encoder reflection coefficients |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 * ptch flag to indicate a periodic signal component |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 * OUTPUTS: none |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 * RETURN VALUE: vad decision |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 ***************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 Word16 vad_computation ( |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 Word16 r_h[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 Word16 r_l[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 Word16 scal_acf, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 Word16 rc[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 Word16 ptch |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 ) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 Word32 L_av0[9], L_av1[9]; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 Word16 vad, vvad, rav1[9], scal_rav1, stat, tone; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 Pfloat acf0, pvad; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 energy_computation (r_h, scal_acf, rvad, scal_rvad, &acf0, &pvad); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 acf_averaging (r_h, r_l, scal_acf, L_av0, L_av1); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 predictor_values (L_av1, rav1, &scal_rav1); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 stat = spectral_comparison (rav1, scal_rav1, L_av0); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 tone_detection (rc, &tone); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 threshold_adaptation (stat, ptch, tone, rav1, scal_rav1, pvad, acf0, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 rvad, &scal_rvad, &thvad); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 vvad = vad_decision (pvad, thvad); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 vad = vad_hangover (vvad); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 return vad; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 /**************************************************************************** |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 * FUNCTION: energy_computation |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 * PURPOSE: Computes the input and residual energies of the adaptive |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 * filter in a floating point representation. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 * INPUTS: r_h[0..8] autocorrelation of input signal frame (msb) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 * scal_acf scaling factor for the autocorrelations |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 * rvad[0..8] autocorrelated adaptive filter coefficients |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 * scal_rvad scaling factor for rvad[] |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 * OUTPUTS: *acf0 signal frame energy (mantissa+exponent) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 * *pvad filtered signal energy (mantissa+exponent) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 * RETURN VALUE: none |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 ***************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 void energy_computation ( |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 Word16 r_h[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 Word16 scal_acf, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 Word16 rvad[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 Word16 scal_rvad, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 Pfloat * acf0, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 Pfloat * pvad |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 ) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 Word16 i, temp, norm_prod; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 Word32 L_temp; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 /* r[0] is always greater than zero (no need to test for r[0] == 0) */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 /* Computation of acf0 (exponent and mantissa) */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 acf0->e = sub (32, scal_acf); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 acf0->m = r_h[0] & 0x7ff8; move16 (); logic16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 /* Computation of pvad (exponent and mantissa) */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 pvad->e = add (acf0->e, 14); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 pvad->e = sub (pvad->e, scal_rvad); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 L_temp = 0L; move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 for (i = 1; i <= 8; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 temp = shr (r_h[i], 3); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 L_temp = L_mac (L_temp, temp, rvad[i]); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 temp = shr (r_h[0], 3); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 L_temp = L_add (L_temp, L_shr (L_mult (temp, rvad[0]), 1)); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 if (L_temp <= 0L) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 L_temp = 1L; move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 norm_prod = norm_l (L_temp); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 pvad->e = sub (pvad->e, norm_prod); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 pvad->m = extract_h (L_shl (L_temp, norm_prod)); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 /**************************************************************************** |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 * FUNCTION: acf_averaging |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 * PURPOSE: Computes the arrays L_av0[0..8] and L_av1[0..8]. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 * INPUTS: r_h[0..8] autocorrelation of input signal frame (msb) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 * r_l[0..8] autocorrelation of input signal frame (lsb) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 * scal_acf scaling factor for the autocorrelations |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 * OUTPUTS: L_av0[0..8] ACF averaged over last four frames |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 * L_av1[0..8] ACF averaged over previous four frames |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 * RETURN VALUE: none |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 ***************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 void acf_averaging ( |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 Word16 r_h[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 Word16 r_l[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 Word16 scal_acf, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 Word32 L_av0[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 Word32 L_av1[] |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 ) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 Word32 L_temp; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 Word16 scale; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 Word16 i; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 scale = add (9, scal_acf); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 for (i = 0; i <= 8; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 L_temp = L_shr (L_Comp (r_h[i], r_l[i]), scale); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 L_av0[i] = L_add (L_sacf[i], L_temp); move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 L_av0[i] = L_add (L_sacf[i + 9], L_av0[i]); move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 L_av0[i] = L_add (L_sacf[i + 18], L_av0[i]); move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 L_sacf[pt_sacf + i] = L_temp; move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 L_av1[i] = L_sav0[pt_sav0 + i]; move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 L_sav0[pt_sav0 + i] = L_av0[i]; move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 /* Update the array pointers */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 if (sub (pt_sacf, 18) == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 pt_sacf = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 pt_sacf = add (pt_sacf, 9); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 if (sub (pt_sav0, 27) == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 pt_sav0 = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 pt_sav0 = add (pt_sav0, 9); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 /**************************************************************************** |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 * FUNCTION: predictor_values |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 * PURPOSE: Computes the array rav[0..8] needed for the spectral |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 * comparison and the threshold adaptation. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 * INPUTS: L_av1[0..8] ACF averaged over previous four frames |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 * OUTPUTS: rav1[0..8] ACF obtained from L_av1 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 * *scal_rav1 rav1[] scaling factor |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 * RETURN VALUE: none |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 ***************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 void predictor_values ( |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 Word32 L_av1[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 Word16 rav1[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 Word16 *scal_rav1 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 ) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 Word16 vpar[8], aav1[9]; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 schur_recursion (L_av1, vpar); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 step_up (8, vpar, aav1); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 compute_rav1 (aav1, rav1, scal_rav1); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
357 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
361 /**************************************************************************** |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
362 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 * FUNCTION: schur_recursion |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
364 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
365 * PURPOSE: Uses the Schur recursion to compute adaptive filter |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
366 * reflection coefficients from an autorrelation function. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
367 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
368 * INPUTS: L_av1[0..8] autocorrelation function |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
369 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 * OUTPUTS: vpar[0..7] reflection coefficients |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
371 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 * RETURN VALUE: none |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 ***************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 void schur_recursion ( |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 Word32 L_av1[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 Word16 vpar[] |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 ) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
380 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 Word16 acf[9], pp[9], kk[9], temp; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 Word16 i, k, m, n; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
383 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 /*** Schur recursion with 16-bit arithmetic ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 test (); move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 if (L_av1[0] == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 for (i = 0; i < 8; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 vpar[i] = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 temp = norm_l (L_av1[0]); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
396 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
397 for (k = 0; k <= 8; k++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
398 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
399 acf[k] = extract_h (L_shl (L_av1[k], temp)); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
400 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
401 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
402 /*** Initialize arrays pp[..] and kk[..] for the recursion: ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
403 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
404 for (i = 1; i <= 7; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
405 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
406 kk[9 - i] = acf[i]; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
407 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
408 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
409 for (i = 0; i <= 8; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
410 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
411 pp[i] = acf[i]; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
412 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
413 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
414 /*** Compute Parcor coefficients: ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
415 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
416 for (n = 0; n < 8; n++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
417 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
418 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
419 if ((pp[0] == 0) || |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
420 (sub (pp[0], abs_s (pp[1])) < 0)) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
421 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
422 for (i = n; i < 8; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
423 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
424 vpar[i] = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
425 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
426 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
427 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
428 vpar[n] = div_s (abs_s (pp[1]), pp[0]); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
429 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
430 test (); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
431 if (pp[1] > 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
432 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
433 vpar[n] = negate (vpar[n]); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
434 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
435 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
436 if (sub (n, 7) == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
437 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
438 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
439 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
440 /*** Schur recursion: ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
441 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
442 pp[0] = add (pp[0], mult_r (pp[1], vpar[n])); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
443 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
444 for (m = 1; m <= 7 - n; m++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
445 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
446 pp[m] = add (pp[1 + m], mult_r (kk[9 - m], vpar[n])); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
447 move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
448 kk[9 - m] = add (kk[9 - m], mult_r (pp[1 + m], vpar[n])); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
449 move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
450 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
451 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
452 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
453 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
454 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
455 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
456 /**************************************************************************** |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
457 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
458 * FUNCTION: step_up |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
459 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
460 * PURPOSE: Computes the transversal filter coefficients from the |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
461 * reflection coefficients. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
462 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
463 * INPUTS: np filter order (2..8) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
464 * vpar[0..np-1] reflection coefficients |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
465 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
466 * OUTPUTS: aav1[0..np] transversal filter coefficients |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
467 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
468 * RETURN VALUE: none |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
469 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
470 ***************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
471 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
472 void step_up ( |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
473 Word16 np, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
474 Word16 vpar[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
475 Word16 aav1[] |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
476 ) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
477 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
478 Word32 L_coef[9], L_work[9]; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
479 Word16 temp; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
480 Word16 i, m; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
481 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
482 /*** Initialization of the step-up recursion ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
483 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
484 L_coef[0] = 0x20000000L; move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
485 L_coef[1] = L_shl (L_deposit_l (vpar[0]), 14); move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
486 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
487 /*** Loop on the LPC analysis order: ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
488 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
489 for (m = 2; m <= np; m++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
490 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
491 for (i = 1; i < m; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
492 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
493 temp = extract_h (L_coef[m - i]); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
494 L_work[i] = L_mac (L_coef[i], vpar[m - 1], temp); move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
495 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
496 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
497 for (i = 1; i < m; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
498 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
499 L_coef[i] = L_work[i]; move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
500 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
501 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
502 L_coef[m] = L_shl (L_deposit_l (vpar[m - 1]), 14); move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
503 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
504 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
505 /*** Keep the aav1[0..np] in 15 bits ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
506 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
507 for (i = 0; i <= np; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
508 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
509 aav1[i] = extract_h (L_shr (L_coef[i], 3)); move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
510 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
511 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
512 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
513 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
514 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
515 /**************************************************************************** |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
516 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
517 * FUNCTION: compute_rav1 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
518 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
519 * PURPOSE: Computes the autocorrelation function of the adaptive |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
520 * filter coefficients. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
521 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
522 * INPUTS: aav1[0..8] adaptive filter coefficients |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
523 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
524 * OUTPUTS: rav1[0..8] ACF of aav1 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
525 * *scal_rav1 rav1[] scaling factor |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
526 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
527 * RETURN VALUE: none |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
528 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
529 ***************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
530 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
531 void compute_rav1 ( |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
532 Word16 aav1[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
533 Word16 rav1[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
534 Word16 *scal_rav1 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
535 ) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
536 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
537 Word32 L_work[9]; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
538 Word16 i, k; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
539 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
540 /*** Computation of the rav1[0..8] ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
541 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
542 for (i = 0; i <= 8; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
543 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
544 L_work[i] = 0L; move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
545 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
546 for (k = 0; k <= 8 - i; k++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
547 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
548 L_work[i] = L_mac (L_work[i], aav1[k], aav1[k + i]); move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
549 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
550 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
551 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
552 test (); move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
553 if (L_work[0] == 0L) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
554 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
555 *scal_rav1 = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
556 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
557 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
558 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
559 *scal_rav1 = norm_l (L_work[0]); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
560 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
561 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
562 for (i = 0; i <= 8; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
563 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
564 rav1[i] = extract_h (L_shl (L_work[i], *scal_rav1)); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
565 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
566 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
567 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
568 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
569 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
570 /**************************************************************************** |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
571 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
572 * FUNCTION: spectral_comparison |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
573 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
574 * PURPOSE: Computes the stat flag needed for the threshold |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
575 * adaptation decision. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
576 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
577 * INPUTS: rav1[0..8] ACF obtained from L_av1 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
578 * *scal_rav1 rav1[] scaling factor |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
579 * L_av0[0..8] ACF averaged over last four frames |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
580 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
581 * OUTPUTS: none |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
582 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
583 * RETURN VALUE: flag to indicate spectral stationarity |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
584 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
585 ***************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
586 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
587 Word16 spectral_comparison ( |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
588 Word16 rav1[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
589 Word16 scal_rav1, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
590 Word32 L_av0[] |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
591 ) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
592 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
593 Word32 L_dm, L_sump, L_temp; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
594 Word16 stat, sav0[9], shift, divshift, temp; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
595 Word16 i; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
596 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
597 /*** Re-normalize L_av0[0..8] ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
598 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
599 test (); move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
600 if (L_av0[0] == 0L) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
601 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
602 for (i = 0; i <= 8; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
603 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
604 sav0[i] = 0x0fff; /* 4095 */ move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
605 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
606 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
607 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
608 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
609 shift = sub (norm_l (L_av0[0]), 3); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
610 for (i = 0; i <= 8; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
611 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
612 sav0[i] = extract_h (L_shl (L_av0[i], shift)); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
613 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
614 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
615 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
616 /*** Compute partial sum of dm ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
617 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
618 L_sump = 0L; move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
619 for (i = 1; i <= 8; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
620 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
621 L_sump = L_mac (L_sump, rav1[i], sav0[i]); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
622 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
623 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
624 /*** Compute the division of the partial sum by sav0[0] ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
625 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
626 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
627 if (L_sump < 0L) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
628 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
629 L_temp = L_negate (L_sump); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
630 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
631 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
632 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
633 L_temp = L_sump; move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
634 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
635 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
636 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
637 if (L_temp == 0L) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
638 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
639 L_dm = 0L; move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
640 shift = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
641 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
642 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
643 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
644 sav0[0] = shl (sav0[0], 3); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
645 shift = norm_l (L_temp); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
646 temp = extract_h (L_shl (L_temp, shift)); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
647 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
648 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
649 if (sub (sav0[0], temp) >= 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
650 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
651 divshift = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
652 temp = div_s (temp, sav0[0]); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
653 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
654 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
655 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
656 divshift = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
657 temp = sub (temp, sav0[0]); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
658 temp = div_s (temp, sav0[0]); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
659 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
660 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
661 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
662 if (sub (divshift, 1) == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
663 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
664 L_dm = 0x8000L; move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
665 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
666 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
667 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
668 L_dm = 0L; move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
669 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
670 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
671 L_dm = L_shl (L_add (L_dm, L_deposit_l (temp)), 1); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
672 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
673 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
674 if (L_sump < 0L) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
675 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
676 L_dm = L_negate (L_dm); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
677 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
678 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
679 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
680 /*** Re-normalization and final computation of L_dm ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
681 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
682 L_dm = L_shl (L_dm, 14); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
683 L_dm = L_shr (L_dm, shift); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
684 L_dm = L_add (L_dm, L_shl (L_deposit_l (rav1[0]), 11)); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
685 L_dm = L_shr (L_dm, scal_rav1); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
686 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
687 /*** Compute the difference and save L_dm ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
688 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
689 L_temp = L_sub (L_dm, L_lastdm); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
690 L_lastdm = L_dm; move32 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
691 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
692 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
693 if (L_temp < 0L) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
694 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
695 L_temp = L_negate (L_temp); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
696 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
697 /*** Evaluation of the stat flag ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
698 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
699 L_temp = L_sub (L_temp, STAT_THRESH); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
700 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
701 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
702 if (L_temp < 0L) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
703 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
704 stat = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
705 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
706 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
707 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
708 stat = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
709 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
710 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
711 return stat; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
712 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
713 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
714 /**************************************************************************** |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
715 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
716 * FUNCTION: threshold_adaptation |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
717 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
718 * PURPOSE: Evaluates the secondary VAD decision. If speech is not |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
719 * present then the noise model rvad and adaptive threshold |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
720 * thvad are updated. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
721 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
722 * INPUTS: stat flag to indicate spectral stationarity |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
723 * ptch flag to indicate a periodic signal component |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
724 * tone flag to indicate a tone signal component |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
725 * rav1[0..8] ACF obtained from L_av1 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
726 * scal_rav1 rav1[] scaling factor |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
727 * pvad filtered signal energy (mantissa+exponent) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
728 * acf0 signal frame energy (mantissa+exponent) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
729 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
730 * OUTPUTS: rvad[0..8] autocorrelated adaptive filter coefficients |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
731 * *scal_rvad rvad[] scaling factor |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
732 * *thvad decision threshold (mantissa+exponent) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
733 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
734 * RETURN VALUE: none |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
735 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
736 ***************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
737 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
738 void threshold_adaptation ( |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
739 Word16 stat, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
740 Word16 ptch, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
741 Word16 tone, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
742 Word16 rav1[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
743 Word16 scal_rav1, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
744 Pfloat pvad, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
745 Pfloat acf0, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
746 Word16 rvad[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
747 Word16 *scal_rvad, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
748 Pfloat * thvad |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
749 ) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
750 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
751 Word16 comp, comp2; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
752 Word32 L_temp; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
753 Word16 temp; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
754 Pfloat p_temp; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
755 Word16 i; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
756 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
757 comp = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
758 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
759 /*** Test if acf0 < pth; if yes set thvad to plev ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
760 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
761 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
762 if (sub (acf0.e, E_PTH) < 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
763 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
764 comp = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
765 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
766 test (); test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
767 if ((sub (acf0.e, E_PTH) == 0) && (sub (acf0.m, M_PTH) < 0)) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
768 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
769 comp = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
770 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
771 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
772 if (sub (comp, 1) == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
773 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
774 thvad->e = E_PLEV; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
775 thvad->m = M_PLEV; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
776 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
777 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
778 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
779 /*** Test if an adaption is required ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
780 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
781 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
782 if (sub (ptch, 1) == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
783 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
784 comp = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
785 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
786 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
787 if (stat == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
788 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
789 comp = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
790 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
791 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
792 if (sub (tone, 1) == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
793 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
794 comp = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
795 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
796 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
797 if (sub (comp, 1) == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
798 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
799 adaptcount = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
800 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
801 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
802 /*** Increment adaptcount ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
803 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
804 adaptcount = add (adaptcount, 1); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
805 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
806 if (sub (adaptcount, 8) <= 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
807 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
808 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
809 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
810 /*** computation of thvad-(thvad/dec) ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
811 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
812 thvad->m = sub (thvad->m, shr (thvad->m, 5)); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
813 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
814 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
815 if (sub (thvad->m, 0x4000) < 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
816 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
817 thvad->m = shl (thvad->m, 1); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
818 thvad->e = sub (thvad->e, 1); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
819 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
820 /*** computation of pvad*fac ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
821 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
822 L_temp = L_mult (pvad.m, FAC); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
823 L_temp = L_shr (L_temp, 15); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
824 p_temp.e = add (pvad.e, 1); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
825 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
826 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
827 if (L_temp > 0x7fffL) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
828 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
829 L_temp = L_shr (L_temp, 1); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
830 p_temp.e = add (p_temp.e, 1); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
831 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
832 p_temp.m = extract_l (L_temp); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
833 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
834 /*** test if thvad < pvad*fac ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
835 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
836 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
837 if (sub (thvad->e, p_temp.e) < 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
838 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
839 comp = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
840 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
841 test (); test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
842 if ((sub (thvad->e, p_temp.e) == 0) && |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
843 (sub (thvad->m, p_temp.m) < 0)) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
844 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
845 comp = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
846 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
847 /*** compute minimum(thvad+(thvad/inc), pvad*fac) when comp = 1 ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
848 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
849 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
850 if (sub (comp, 1) == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
851 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
852 /*** compute thvad + (thvad/inc) ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
853 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
854 L_temp = L_add (L_deposit_l (thvad->m), |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
855 L_deposit_l (shr (thvad->m, 4))); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
856 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
857 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
858 if (L_sub (L_temp, 0x7fffL) > 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
859 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
860 thvad->m = extract_l (L_shr (L_temp, 1)); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
861 thvad->e = add (thvad->e, 1); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
862 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
863 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
864 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
865 thvad->m = extract_l (L_temp); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
866 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
867 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
868 comp2 = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
869 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
870 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
871 if (sub (p_temp.e, thvad->e) < 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
872 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
873 comp2 = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
874 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
875 test (); test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
876 if ((sub (p_temp.e, thvad->e) == 0) && |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
877 (sub (p_temp.m, thvad->m) < 0)) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
878 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
879 comp2 = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
880 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
881 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
882 if (sub (comp2, 1) == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
883 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
884 thvad->e = p_temp.e;move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
885 thvad->m = p_temp.m;move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
886 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
887 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
888 /*** compute pvad + margin ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
889 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
890 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
891 if (sub (pvad.e, E_MARGIN) == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
892 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
893 L_temp = L_add (L_deposit_l (pvad.m), L_deposit_l (M_MARGIN)); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
894 p_temp.m = extract_l (L_shr (L_temp, 1)); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
895 p_temp.e = add (pvad.e, 1); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
896 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
897 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
898 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
899 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
900 if (sub (pvad.e, E_MARGIN) > 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
901 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
902 temp = sub (pvad.e, E_MARGIN); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
903 temp = shr (M_MARGIN, temp); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
904 L_temp = L_add (L_deposit_l (pvad.m), L_deposit_l (temp)); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
905 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
906 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
907 if (L_sub (L_temp, 0x7fffL) > 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
908 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
909 p_temp.e = add (pvad.e, 1); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
910 p_temp.m = extract_l (L_shr (L_temp, 1)); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
911 move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
912 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
913 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
914 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
915 p_temp.e = pvad.e; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
916 p_temp.m = extract_l (L_temp); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
917 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
918 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
919 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
920 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
921 temp = sub (E_MARGIN, pvad.e); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
922 temp = shr (pvad.m, temp); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
923 L_temp = L_add (L_deposit_l (M_MARGIN), L_deposit_l (temp)); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
924 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
925 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
926 if (L_sub (L_temp, 0x7fffL) > 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
927 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
928 p_temp.e = add (E_MARGIN, 1); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
929 p_temp.m = extract_l (L_shr (L_temp, 1)); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
930 move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
931 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
932 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
933 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
934 p_temp.e = E_MARGIN; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
935 p_temp.m = extract_l (L_temp); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
936 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
937 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
938 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
939 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
940 /*** Test if thvad > pvad + margin ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
941 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
942 comp = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
943 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
944 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
945 if (sub (thvad->e, p_temp.e) > 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
946 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
947 comp = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
948 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
949 test (); test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
950 if ((sub (thvad->e, p_temp.e) == 0) && |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
951 (sub (thvad->m, p_temp.m) > 0)) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
952 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
953 comp = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
954 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
955 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
956 if (sub (comp, 1) == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
957 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
958 thvad->e = p_temp.e; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
959 thvad->m = p_temp.m; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
960 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
961 /*** Normalise and retain rvad[0..8] in memory ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
962 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
963 *scal_rvad = scal_rav1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
964 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
965 for (i = 0; i <= 8; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
966 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
967 rvad[i] = rav1[i]; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
968 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
969 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
970 /*** Set adaptcount to adp + 1 ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
971 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
972 adaptcount = 9; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
973 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
974 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
975 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
976 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
977 /**************************************************************************** |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
978 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
979 * FUNCTION: tone_detection |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
980 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
981 * PURPOSE: Computes the tone flag needed for the threshold |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
982 * adaptation decision. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
983 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
984 * INPUTS: rc[0..3] reflection coefficients calculated in the |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
985 * speech encoder short term predictor |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
986 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
987 * OUTPUTS: *tone flag to indicate a periodic signal component |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
988 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
989 * RETURN VALUE: none |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
990 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
991 ***************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
992 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
993 void tone_detection ( |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
994 Word16 rc[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
995 Word16 *tone |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
996 ) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
997 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
998 Word32 L_num, L_den, L_temp; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
999 Word16 temp, prederr, a[3]; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1000 Word16 i; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1001 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1002 *tone = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1003 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1004 /*** Calculate filter coefficients ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1005 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1006 step_up (2, rc, a); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1007 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1008 /*** Calculate ( a[1] * a[1] ) ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1009 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1010 temp = shl (a[1], 3); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1011 L_den = L_mult (temp, temp); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1012 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1013 /*** Calculate ( 4*a[2] - a[1]*a[1] ) ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1014 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1015 L_temp = L_shl (L_deposit_h (a[2]), 3); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1016 L_num = L_sub (L_temp, L_den); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1017 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1018 /*** Check if pole frequency is less than 385 Hz ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1019 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1020 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1021 if (L_num <= 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1022 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1023 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1024 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1025 test (); move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1026 if (a[1] < 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1027 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1028 temp = extract_h (L_den); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1029 L_den = L_mult (temp, FREQTH); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1030 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1031 L_temp = L_sub (L_num, L_den); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1032 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1033 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1034 if (L_temp < 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1035 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1036 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1037 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1038 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1039 /*** Calculate normalised prediction error ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1040 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1041 prederr = 0x7fff; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1042 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1043 for (i = 0; i < 4; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1044 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1045 temp = mult (rc[i], rc[i]); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1046 temp = sub (0x7fff, temp); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1047 prederr = mult (prederr, temp); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1048 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1049 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1050 /*** Test if prediction error is smaller than threshold ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1051 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1052 temp = sub (prederr, PREDTH); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1053 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1054 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1055 if (temp < 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1056 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1057 *tone = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1058 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1059 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1060 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1061 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1062 /**************************************************************************** |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1063 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1064 * FUNCTION: vad_decision |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1065 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1066 * PURPOSE: Computes the VAD decision based on the comparison of the |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1067 * floating point representations of pvad and thvad. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1068 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1069 * INPUTS: pvad filtered signal energy (mantissa+exponent) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1070 * thvad decision threshold (mantissa+exponent) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1071 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1072 * OUTPUTS: none |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1073 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1074 * RETURN VALUE: vad decision before hangover is added |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1075 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1076 ***************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1077 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1078 Word16 vad_decision ( |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1079 Pfloat pvad, |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1080 Pfloat thvad |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1081 ) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1082 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1083 Word16 vvad; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1084 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1085 test (); test (); test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1086 if (sub (pvad.e, thvad.e) > 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1087 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1088 vvad = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1089 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1090 else if ((sub (pvad.e, thvad.e) == 0) && |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1091 (sub (pvad.m, thvad.m) > 0)) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1092 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1093 vvad = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1094 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1095 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1096 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1097 vvad = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1098 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1099 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1100 return vvad; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1101 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1102 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1103 /**************************************************************************** |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1104 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1105 * FUNCTION: vad_hangover |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1106 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1107 * PURPOSE: Computes the final VAD decision for the current frame |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1108 * being processed. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1109 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1110 * INPUTS: vvad vad decision before hangover is added |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1111 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1112 * OUTPUTS: none |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1113 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1114 * RETURN VALUE: vad decision after hangover is added |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1115 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1116 ***************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1117 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1118 Word16 vad_hangover ( |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1119 Word16 vvad |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1120 ) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1121 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1122 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1123 if (sub (vvad, 1) == 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1124 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1125 burstcount = add (burstcount, 1); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1126 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1127 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1128 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1129 burstcount = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1130 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1131 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1132 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1133 if (sub (burstcount, BURSTCONST) >= 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1134 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1135 hangcount = HANGCONST; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1136 burstcount = BURSTCONST;move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1137 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1138 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1139 if (hangcount >= 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1140 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1141 hangcount = sub (hangcount, 1); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1142 return 1; /* vad = 1 */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1143 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1144 return vvad; /* vad = vvad */ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1145 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1146 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1147 /**************************************************************************** |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1148 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1149 * FUNCTION: periodicity_update |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1150 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1151 * PURPOSE: Computes the ptch flag needed for the threshold |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1152 * adaptation decision for the next frame. |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1153 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1154 * INPUTS: lags[0..1] speech encoder long term predictor lags |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1155 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1156 * OUTPUTS: *ptch Boolean voiced / unvoiced decision |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1157 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1158 * RETURN VALUE: none |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1159 * |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1160 ***************************************************************************/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1161 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1162 void periodicity_update ( |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1163 Word16 lags[], |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1164 Word16 *ptch |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1165 ) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1166 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1167 Word16 minlag, maxlag, lagcount, temp; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1168 Word16 i; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1169 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1170 /*** Run loop for the two halves in the frame ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1171 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1172 lagcount = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1173 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1174 for (i = 0; i <= 1; i++) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1175 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1176 /*** Search the maximum and minimum of consecutive lags ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1177 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1178 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1179 if (sub (oldlag, lags[i]) > 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1180 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1181 minlag = lags[i]; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1182 maxlag = oldlag; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1183 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1184 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1185 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1186 minlag = oldlag; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1187 maxlag = lags[i]; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1188 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1189 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1190 temp = sub (maxlag, minlag); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1191 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1192 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1193 if (sub (temp, LTHRESH) < 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1194 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1195 lagcount = add (lagcount, 1); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1196 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1197 /*** Save the current LTP lag ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1198 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1199 oldlag = lags[i]; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1200 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1201 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1202 /*** Update the veryoldlagcount and oldlagcount ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1203 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1204 veryoldlagcount = oldlagcount; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1205 move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1206 oldlagcount = lagcount; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1207 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1208 /*** Make ptch decision ready for next frame ***/ |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1209 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1210 temp = add (oldlagcount, veryoldlagcount); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1211 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1212 test (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1213 if (sub (temp, NTHRESH) >= 0) |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1214 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1215 *ptch = 1; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1216 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1217 else |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1218 { |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1219 *ptch = 0; move16 (); |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1220 } |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1221 |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1222 return; |
913fe3c11890
libgsmefr/vad.c: initial import from ETSI code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1223 } |