FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/ph_disp.c @ 395:8c7d5eec544c
libtwamr: integrate weight_a.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 06 May 2024 18:52:57 +0000 |
parents | bde9f5804670 |
children |
rev | line source |
---|---|
390
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : ph_disp.c |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : Perform adaptive phase dispersion of the excitation |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * signal. |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 /* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 * MODULE INCLUDE FILE AND VERSION ID |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "namespace.h" |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "ph_disp.h" |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 /* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 * INCLUDE FILES |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "typedef.h" |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "basic_op.h" |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "no_count.h" |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "cnst.h" |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #include "memops.h" |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 /* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 * LOCAL VARIABLES AND TABLES |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 #include "ph_disp.tab" |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 /* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 * PUBLIC PROGRAM CODE |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 /************************************************************************* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 * Function: ph_disp_reset |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 ************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 void ph_disp_reset (ph_dispState *state) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 Word16 i; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 for (i=0; i<PHDGAINMEMSIZE; i++) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 state->gainMem[i] = 0; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 state->prevState = 0; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 state->prevCbGain = 0; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 state->lockFull = 0; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 state->onset = 0; /* assume no onset in start */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 /************************************************************************* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 * Function: ph_disp_lock |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 ************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 void ph_disp_lock (ph_dispState *state) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 state->lockFull = 1; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 return; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 /************************************************************************* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 * Function: ph_disp_release |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 ************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 void ph_disp_release (ph_dispState *state) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 state->lockFull = 0; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 return; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 /************************************************************************* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 * Function: ph_disp |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 * Adaptive phase dispersion; forming of total excitation |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 * (for synthesis part of decoder) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 ************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 void ph_disp ( |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 ph_dispState *state, /* i/o : State struct */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 enum Mode mode, /* i : codec mode */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 Word16 x[], /* i/o Q0 : in: LTP excitation signal */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 /* out: total excitation signal */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 Word16 cbGain, /* i Q1 : Codebook gain */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 Word16 ltpGain, /* i Q14 : LTP gain */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 Word16 inno[], /* i/o Q13 : Innovation vector (Q12 for 12.2) */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 Word16 pitch_fac, /* i Q14 : pitch factor used to scale the |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 LTP excitation (Q13 for 12.2) */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 Word16 tmp_shift /* i Q0 : shift factor applied to sum of |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 scaled LTP ex & innov. before |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 rounding */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 ) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 Word16 i, i1; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 Word16 tmp1; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 Word32 L_temp; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 Word16 impNr; /* indicator for amount of disp./filter used */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 Word16 inno_sav[L_SUBFR]; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 Word16 ps_poss[L_SUBFR]; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 Word16 j, nze, nPulse, ppos; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 const Word16 *ph_imp; /* Pointer to phase dispersion filter */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 /* Update LTP gain memory */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 for (i = PHDGAINMEMSIZE-1; i > 0; i--) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 state->gainMem[i] = state->gainMem[i-1]; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 state->gainMem[0] = ltpGain; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 /* basic adaption of phase dispersion */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 test (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 if (sub(ltpGain, PHDTHR2LTP) < 0) { /* if (ltpGain < 0.9) */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 test (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 if (sub(ltpGain, PHDTHR1LTP) > 0) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 { /* if (ltpGain > 0.6 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 impNr = 1; /* medium dispersion */ move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 else |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 impNr = 0; /* maximum dispersion */ move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 else |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 impNr = 2; /* no dispersion */ move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 /* onset indicator */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 /* onset = (cbGain > onFact * cbGainMem[0]) */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 move32 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 tmp1 = round(L_shl(L_mult(state->prevCbGain, ONFACTPLUS1), 2)); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 test (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 if (sub(cbGain, tmp1) > 0) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 state->onset = ONLENGTH; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 else |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 test (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 if (state->onset > 0) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 state->onset = sub (state->onset, 1); move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 /* if not onset, check ltpGain buffer and use max phase dispersion if |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 half or more of the ltpGain-parameters say so */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 test (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 if (state->onset == 0) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 /* Check LTP gain memory and set filter accordingly */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 i1 = 0; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 for (i = 0; i < PHDGAINMEMSIZE; i++) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 test (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 if (sub(state->gainMem[i], PHDTHR1LTP) < 0) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 i1 = add (i1, 1); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 test (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 if (sub(i1, 2) > 0) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 impNr = 0; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 /* Restrict decrease in phase dispersion to one step if not onset */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 test (); test (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 if ((sub(impNr, add(state->prevState, 1)) > 0) && (state->onset == 0)) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 impNr = sub (impNr, 1); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 /* if onset, use one step less phase dispersion */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 test (); test (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 if((sub(impNr, 2) < 0) && (state->onset > 0)) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 impNr = add (impNr, 1); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 /* disable for very low levels */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 test (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 if(sub(cbGain, 10) < 0) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 impNr = 2; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 test (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 if(sub(state->lockFull, 1) == 0) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 impNr = 0; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 /* update static memory */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 state->prevState = impNr; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 state->prevCbGain = cbGain; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 /* do phase dispersion for all modes but 12.2 and 7.4; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 don't modify the innovation if impNr >=2 (= no phase disp) */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 test (); test (); test(); test(); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 if (sub(mode, MR122) != 0 && |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 sub(mode, MR102) != 0 && |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 sub(mode, MR74) != 0 && |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 sub(impNr, 2) < 0) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 /* track pulse positions, save innovation, |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 and initialize new innovation */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 nze = 0; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 for (i = 0; i < L_SUBFR; i++) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 move16 (); test(); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 if (inno[i] != 0) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 ps_poss[nze] = i; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 nze = add (nze, 1); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 inno_sav[i] = inno[i]; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 inno[i] = 0; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 /* Choose filter corresponding to codec mode and dispersion criterium */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 test (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 if (sub (mode, MR795) == 0) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 test (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 if (impNr == 0) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 ph_imp = ph_imp_low_MR795; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 else |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 ph_imp = ph_imp_mid_MR795; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 else |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 test (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 if (impNr == 0) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 ph_imp = ph_imp_low; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 else |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 ph_imp = ph_imp_mid; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 /* Do phase dispersion of innovation */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 for (nPulse = 0; nPulse < nze; nPulse++) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 ppos = ps_poss[nPulse]; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 /* circular convolution with impulse response */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 j = 0; move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 for (i = ppos; i < L_SUBFR; i++) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 /* inno[i1] += inno_sav[ppos] * ph_imp[i1-ppos] */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 tmp1 = mult(inno_sav[ppos], ph_imp[j++]); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 inno[i] = add(inno[i], tmp1); move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 for (i = 0; i < ppos; i++) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 /* inno[i] += inno_sav[ppos] * ph_imp[L_SUBFR-ppos+i] */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 tmp1 = mult(inno_sav[ppos], ph_imp[j++]); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 inno[i] = add(inno[i], tmp1); move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 /* compute total excitation for synthesis part of decoder |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 (using modified innovation if phase dispersion is active) */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 for (i = 0; i < L_SUBFR; i++) |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 /* x[i] = gain_pit*x[i] + cbGain*code[i]; */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 L_temp = L_mult ( x[i], pitch_fac); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 /* 12.2: Q0 * Q13 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 /* 7.4: Q0 * Q14 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 L_temp = L_mac (L_temp, inno[i], cbGain); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 /* 12.2: Q12 * Q1 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 /* 7.4: Q13 * Q1 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 L_temp = L_shl (L_temp, tmp_shift); /* Q16 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 x[i] = round (L_temp); move16 (); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 } |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 return; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 } |