annotate src/dtx.c @ 0:56410792419a

src: original EFR source from ETSI
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 03 Apr 2024 05:31:37 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /***************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * File Name: dtx.c
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * Purpose: Contains functions for performing DTX operation and comfort
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * noise generation.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 * Below is a listing of all the functions appearing in the file.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 * The functions are arranged according to their purpose. Under
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * each heading, the ordering is hierarchical.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 * Resetting of static variables of TX DTX:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 * reset_tx_dtx()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 * Resetting of static variables of RX DTX:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 * reset_rx_dtx()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 * TX DTX handler (called by the speech encoder):
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 * tx_dtx()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 * RX DTX handler (called by the speech decoder):
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 * rx_dtx()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 * Encoding of comfort noise parameters into SID frame:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 * CN_encoding()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 * Encoding of SID codeword into SID frame:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 * sid_codeword_encoding()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 * Detecting of SID codeword from a frame:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 * sid_frame_detection()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 * Update the LSF parameter history:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 * update_lsf_history()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 * Update the reference LSF parameter vector:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 * update_lsf_p_CN()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 * Compute the averaged LSF parameter vector:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 * aver_lsf_history()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 * Update the fixed codebook gain parameter history of the encoder:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 * update_gain_code_history_tx()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 * Update the fixed codebook gain parameter history of the decoder:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 * update_gain_code_history_rx()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 * Compute the unquantized fixed codebook gain:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 * compute_CN_excitation_gain()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 * Update the reference fixed codebook gain:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 * update_gcode0_CN()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 * Compute the averaged fixed codebook gain:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 * aver_gain_code_history()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 * Compute the comfort noise fixed codebook excitation:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 * build_CN_code()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 * Generate a random integer value:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 * pseudonoise()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 * Interpolate a comfort noise parameter value over the comfort noise
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 * update period:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 * interpolate_CN_param()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 * Interpolate comfort noise LSF pparameter values over the comfort
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 * noise update period:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 * interpolate_CN_lsf()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 * interpolate_CN_param()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 **************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 #include "typedef.h"
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 #include "basic_op.h"
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 #include "cnst.h"
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 #include "sig_proc.h"
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 #include "count.h"
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 #include "dtx.h"
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 /* Inverse values of DTX hangover period and DTX hangover period + 1 */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 #define INV_DTX_HANGOVER (0x7fff / DTX_HANGOVER)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 #define INV_DTX_HANGOVER_P1 (0x7fff / (DTX_HANGOVER+1))
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 #define NB_PULSE 10 /* Number of pulses in fixed codebook excitation */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 /* SID frame classification thresholds */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 #define VALID_SID_THRESH 2
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 #define INVALID_SID_THRESH 16
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 /* Constant DTX_ELAPSED_THRESHOLD is used as threshold for allowing
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 SID frame updating without hangover period in case when elapsed
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 time measured from previous SID update is below 24 */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 #define DTX_ELAPSED_THRESHOLD (24 + DTX_HANGOVER - 1)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 /* Index map for encoding and detecting SID codeword */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 static const Word16 SID_codeword_bit_idx[95] =
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 45, 46, 48, 49, 50, 51, 52, 53, 54, 55,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 66, 67, 68, 94, 95, 96, 98, 99, 100, 101,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 112, 113, 114, 115, 116, 117, 118, 148, 149, 150,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 161, 162, 163, 164, 165, 166, 167, 168, 169, 170,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 171, 196, 197, 198, 199, 200, 201, 202, 203, 204,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 205, 206, 207, 208, 209, 212, 213, 214, 215, 216,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 217, 218, 219, 220, 221
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 };
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 Word16 txdtx_ctrl; /* Encoder DTX control word */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 Word16 rxdtx_ctrl; /* Decoder DTX control word */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 Word16 CN_excitation_gain; /* Unquantized fixed codebook gain */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 Word32 L_pn_seed_tx; /* PN generator seed (encoder) */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 Word32 L_pn_seed_rx; /* PN generator seed (decoder) */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 Word16 rx_dtx_state; /* State of comfort noise insertion period */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 static Word16 txdtx_hangover; /* Length of hangover period (VAD=0, SP=1) */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 static Word16 rxdtx_aver_period;/* Length of hangover period (VAD=0, SP=1) */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 static Word16 txdtx_N_elapsed; /* Measured time from previous SID frame */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 static Word16 rxdtx_N_elapsed; /* Measured time from previous SID frame */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 static Word16 old_CN_mem_tx[6]; /* The most recent CN parameters are stored*/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 static Word16 prev_SID_frames_lost; /* Counter for lost SID frames */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 static Word16 buf_p_tx; /* Circular buffer pointer for gain code
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 history update in tx */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 static Word16 buf_p_rx; /* Circular buffer pointer for gain code
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 history update in rx */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 Word16 lsf_old_tx[DTX_HANGOVER][M]; /* Comfort noise LSF averaging buffer */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 Word16 lsf_old_rx[DTX_HANGOVER][M]; /* Comfort noise LSF averaging buffer */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 Word16 gain_code_old_tx[4 * DTX_HANGOVER]; /* Comfort noise gain averaging
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 buffer */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 Word16 gain_code_old_rx[4 * DTX_HANGOVER]; /* Comfort noise gain averaging
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 buffer */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 * FUNCTION NAME: reset_tx_dtx
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 * PURPOSE: Resets the static variables of the TX DTX handler to their
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 * initial values
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 void reset_tx_dtx ()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 Word16 i;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 /* suppose infinitely long speech period before start */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 txdtx_hangover = DTX_HANGOVER;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 txdtx_N_elapsed = 0x7fff;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 txdtx_ctrl = TX_SP_FLAG | TX_VAD_FLAG;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 for (i = 0; i < 6; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 old_CN_mem_tx[i] = 0;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 for (i = 0; i < DTX_HANGOVER; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 lsf_old_tx[i][0] = 1384;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 lsf_old_tx[i][1] = 2077;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 lsf_old_tx[i][2] = 3420;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 lsf_old_tx[i][3] = 5108;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 lsf_old_tx[i][4] = 6742;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 lsf_old_tx[i][5] = 8122;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 lsf_old_tx[i][6] = 9863;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 lsf_old_tx[i][7] = 11092;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 lsf_old_tx[i][8] = 12714;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 lsf_old_tx[i][9] = 13701;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 for (i = 0; i < 4 * DTX_HANGOVER; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 gain_code_old_tx[i] = 0;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 L_pn_seed_tx = PN_INITIAL_SEED;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 buf_p_tx = 0;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 return;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 * FUNCTION NAME: reset_rx_dtx
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 * PURPOSE: Resets the static variables of the RX DTX handler to their
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 * initial values
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 void reset_rx_dtx ()
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 Word16 i;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 /* suppose infinitely long speech period before start */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 rxdtx_aver_period = DTX_HANGOVER;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 rxdtx_N_elapsed = 0x7fff;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 rxdtx_ctrl = RX_SP_FLAG;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 for (i = 0; i < DTX_HANGOVER; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 lsf_old_rx[i][0] = 1384;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 lsf_old_rx[i][1] = 2077;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 lsf_old_rx[i][2] = 3420;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 lsf_old_rx[i][3] = 5108;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 lsf_old_rx[i][4] = 6742;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 lsf_old_rx[i][5] = 8122;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 lsf_old_rx[i][6] = 9863;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 lsf_old_rx[i][7] = 11092;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 lsf_old_rx[i][8] = 12714;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 lsf_old_rx[i][9] = 13701;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 for (i = 0; i < 4 * DTX_HANGOVER; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 gain_code_old_rx[i] = 0;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 L_pn_seed_rx = PN_INITIAL_SEED;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 rx_dtx_state = CN_INT_PERIOD - 1;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 prev_SID_frames_lost = 0;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 buf_p_rx = 0;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 return;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 * FUNCTION NAME: tx_dtx
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 * PURPOSE: DTX handler of the speech encoder. Determines when to add
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 * the hangover period to the end of the speech burst, and
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 * also determines when to use old SID parameters, and when
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 * to update the SID parameters. This function also initializes
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 * the pseudo noise generator shift register.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 * Operation of the TX DTX handler is based on the VAD flag
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 * given as input from the speech encoder.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 * INPUTS: VAD_flag Voice activity decision
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 * *txdtx_ctrl Old encoder DTX control word
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 * OUTPUTS: *txdtx_ctrl Updated encoder DTX control word
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 * L_pn_seed_tx Initialized pseudo noise generator shift
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 * register (global variable)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 * RETURN VALUE: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 void tx_dtx (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 Word16 VAD_flag,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 Word16 *txdtx_ctrl
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
249
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250 /* N_elapsed (frames since last SID update) is incremented. If SID
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251 is updated N_elapsed is cleared later in this function */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253 txdtx_N_elapsed = add (txdtx_N_elapsed, 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255 /* If voice activity was detected, reset hangover counter */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
257 test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
258 if (sub (VAD_flag, 1) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
260 txdtx_hangover = DTX_HANGOVER; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 *txdtx_ctrl = TX_SP_FLAG | TX_VAD_FLAG; move16 (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 if (txdtx_hangover == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 /* Hangover period is over, SID should be updated */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270 txdtx_N_elapsed = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 /* Check if this is the first frame after hangover period */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 test (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274 if ((*txdtx_ctrl & TX_HANGOVER_ACTIVE) != 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 *txdtx_ctrl = TX_PREV_HANGOVER_ACTIVE
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277 | TX_SID_UPDATE; move16 (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278 L_pn_seed_tx = PN_INITIAL_SEED; move32 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 *txdtx_ctrl = TX_SID_UPDATE; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287 /* Hangover period is not over, update hangover counter */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288 txdtx_hangover = sub (txdtx_hangover, 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 /* Check if elapsed time from last SID update is greater than
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 threshold. If not, set SP=0 (although hangover period is not
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292 over) and use old SID parameters for new SID frame.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
293 N_elapsed counter must be summed with hangover counter in order
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 to avoid erroneus SP=1 decision in case when N_elapsed is grown
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295 bigger than threshold and hangover period is still active */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
296
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298 if (sub (add (txdtx_N_elapsed, txdtx_hangover),
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
299 DTX_ELAPSED_THRESHOLD) < 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
300 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
301 /* old SID frame should be used */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
302 *txdtx_ctrl = TX_USE_OLD_SID; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
303 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
305 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306 test (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 if ((*txdtx_ctrl & TX_HANGOVER_ACTIVE) != 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
308 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
309 *txdtx_ctrl = TX_PREV_HANGOVER_ACTIVE
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310 | TX_HANGOVER_ACTIVE
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
311 | TX_SP_FLAG; move16 (); logic16 (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
313 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
314 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
315 *txdtx_ctrl = TX_HANGOVER_ACTIVE
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
316 | TX_SP_FLAG; move16 (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
317 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
318 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
319 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
320 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
321
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
322 return;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
323 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
324
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
325 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
326 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
327 * FUNCTION NAME: rx_dtx
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
328 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
329 * PURPOSE: DTX handler of the speech decoder. Determines when to update
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
330 * the reference comfort noise parameters (LSF and gain) at the
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
331 * end of the speech burst. Also classifies the incoming frames
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
332 * according to SID flag and BFI flag
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
333 * and determines when the transmission is active during comfort
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
334 * noise insertion. This function also initializes the pseudo
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
335 * noise generator shift register.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
336 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
337 * Operation of the RX DTX handler is based on measuring the
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
338 * lengths of speech bursts and the lengths of the pauses between
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
339 * speech bursts to determine when there exists a hangover period
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
340 * at the end of a speech burst. The idea is to keep in sync with
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
341 * the TX DTX handler to be able to update the reference comfort
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
342 * noise parameters at the same time instances.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
343 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
344 * INPUTS: *rxdtx_ctrl Old decoder DTX control word
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
345 * TAF Time alignment flag
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
346 * bfi Bad frame indicator flag
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
347 * SID_flag Silence descriptor flag
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
348 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
349 * OUTPUTS: *rxdtx_ctrl Updated decoder DTX control word
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
350 * rx_dtx_state Updated state of comfort noise interpolation
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
351 * period (global variable)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
352 * L_pn_seed_rx Initialized pseudo noise generator shift
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
353 * register (global variable)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
354 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
355 * RETURN VALUE: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
356 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
357 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
358
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
359 void rx_dtx (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
360 Word16 *rxdtx_ctrl,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
361 Word16 TAF,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
362 Word16 bfi,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
363 Word16 SID_flag
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
364 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
365 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
366 Word16 frame_type;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
367
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
368 /* Frame classification according to bfi-flag and ternary-valued
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
369 SID flag. The frames between SID updates (not actually trans-
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
370 mitted) are also classified here; they will be discarded later
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
371 and provided with "NO TRANSMISSION"-flag */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
372
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
373 test (); test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
374 test (); test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
375 test (); test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
376 if ((sub (SID_flag, 2) == 0) && (bfi == 0))
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
377 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
378 frame_type = VALID_SID_FRAME; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
379 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
380 else if ((SID_flag == 0) && (bfi == 0))
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
381 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
382 frame_type = GOOD_SPEECH_FRAME; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
383 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
384 else if ((SID_flag == 0) && (bfi != 0))
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
385 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
386 frame_type = UNUSABLE_FRAME; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
387 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
388 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
389 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
390 frame_type = INVALID_SID_FRAME; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
391 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
392
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
393 /* Update of decoder state */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
394 /* Previous frame was classified as a speech frame */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
395 test (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
396 if ((*rxdtx_ctrl & RX_SP_FLAG) != 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
397 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
398 test (); test (); test (); test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
399 if (sub (frame_type, VALID_SID_FRAME) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
400 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
401 *rxdtx_ctrl = RX_FIRST_SID_UPDATE; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
402 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
403 else if (sub (frame_type, INVALID_SID_FRAME) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
404 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
405 *rxdtx_ctrl = RX_FIRST_SID_UPDATE
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
406 | RX_INVALID_SID_FRAME; move16 (); logic16();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
407 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
408 else if (sub (frame_type, UNUSABLE_FRAME) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
409 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
410 *rxdtx_ctrl = RX_SP_FLAG; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
411 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
412 else if (sub (frame_type, GOOD_SPEECH_FRAME) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
413 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
414 *rxdtx_ctrl = RX_SP_FLAG; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
415 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
416 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
417 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
418 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
419 test (); test (); test (); test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
420 if (sub (frame_type, VALID_SID_FRAME) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
421 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
422 *rxdtx_ctrl = RX_CONT_SID_UPDATE; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
423 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
424 else if (sub (frame_type, INVALID_SID_FRAME) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
425 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
426 *rxdtx_ctrl = RX_CONT_SID_UPDATE
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
427 | RX_INVALID_SID_FRAME; move16 (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
428 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
429 else if (sub (frame_type, UNUSABLE_FRAME) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
430 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
431 *rxdtx_ctrl = RX_CNI_BFI; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
432 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
433 else if (sub (frame_type, GOOD_SPEECH_FRAME) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
434 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
435 /* If the previous frame (during CNI period) was muted,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
436 raise the RX_PREV_DTX_MUTING flag */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
437 test (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
438 if ((*rxdtx_ctrl & RX_DTX_MUTING) != 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
439 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
440 *rxdtx_ctrl = RX_SP_FLAG | RX_FIRST_SP_FLAG
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
441 | RX_PREV_DTX_MUTING; move16 (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
442 logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
443 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
444 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
445 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
446 *rxdtx_ctrl = RX_SP_FLAG | RX_FIRST_SP_FLAG; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
447 logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
448 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
449 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
450 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
451
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
452
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
453 test (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
454 if ((*rxdtx_ctrl & RX_SP_FLAG) != 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
455 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
456 prev_SID_frames_lost = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
457 rx_dtx_state = CN_INT_PERIOD - 1; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
458 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
459 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
460 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
461 /* First SID frame */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
462 test (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
463 if ((*rxdtx_ctrl & RX_FIRST_SID_UPDATE) != 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
464 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
465 prev_SID_frames_lost = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
466 rx_dtx_state = CN_INT_PERIOD - 1; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
467 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
468
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
469 /* SID frame detected, but not the first SID */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
470 test (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
471 if ((*rxdtx_ctrl & RX_CONT_SID_UPDATE) != 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
472 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
473 prev_SID_frames_lost = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
474
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
475 test (); test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
476 if (sub (frame_type, VALID_SID_FRAME) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
477 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
478 rx_dtx_state = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
479 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
480 else if (sub (frame_type, INVALID_SID_FRAME) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
481 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
482 test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
483 if (sub(rx_dtx_state, (CN_INT_PERIOD - 1)) < 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
484 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
485 rx_dtx_state = add(rx_dtx_state, 1); move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
486 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
487 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
488 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
489
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
490 /* Bad frame received in CNI mode */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
491 test (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
492 if ((*rxdtx_ctrl & RX_CNI_BFI) != 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
493 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
494 test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
495 if (sub (rx_dtx_state, (CN_INT_PERIOD - 1)) < 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
496 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
497 rx_dtx_state = add (rx_dtx_state, 1); move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
498 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
499
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
500 /* If an unusable frame is received during CNI period
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
501 when TAF == 1, the frame is classified as a lost
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
502 SID frame */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
503 test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
504 if (sub (TAF, 1) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
505 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
506 *rxdtx_ctrl = *rxdtx_ctrl | RX_LOST_SID_FRAME;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
507 move16 (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
508 prev_SID_frames_lost = add (prev_SID_frames_lost, 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
509 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
510 else /* No transmission occurred */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
511 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
512 *rxdtx_ctrl = *rxdtx_ctrl | RX_NO_TRANSMISSION;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
513 move16 (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
514 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
515
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
516 test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
517 if (sub (prev_SID_frames_lost, 1) > 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
518 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
519 *rxdtx_ctrl = *rxdtx_ctrl | RX_DTX_MUTING;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
520 move16 (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
521 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
522 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
523 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
524
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
525 /* N_elapsed (frames since last SID update) is incremented. If SID
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
526 is updated N_elapsed is cleared later in this function */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
527
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
528 rxdtx_N_elapsed = add (rxdtx_N_elapsed, 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
529
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
530 test (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
531 if ((*rxdtx_ctrl & RX_SP_FLAG) != 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
532 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
533 rxdtx_aver_period = DTX_HANGOVER; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
534 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
535 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
536 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
537 test (); test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
538 if (sub (rxdtx_N_elapsed, DTX_ELAPSED_THRESHOLD) > 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
539 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
540 *rxdtx_ctrl |= RX_UPD_SID_QUANT_MEM; move16 (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
541 rxdtx_N_elapsed = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
542 rxdtx_aver_period = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
543 L_pn_seed_rx = PN_INITIAL_SEED; move32 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
544 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
545 else if (rxdtx_aver_period == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
546 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
547 rxdtx_N_elapsed = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
548 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
549 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
550 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
551 rxdtx_aver_period = sub (rxdtx_aver_period, 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
552 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
553 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
554
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
555 return;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
556 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
557
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
558 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
559 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
560 * FUNCTION NAME: CN_encoding
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
561 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
562 * PURPOSE: Encoding of the comfort noise parameters into a SID frame.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
563 * Use old SID parameters if necessary. Set the parameter
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
564 * indices not used by comfort noise parameters to zero.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
565 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
566 * INPUTS: params[0..56] Comfort noise parameter frame from the
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
567 * speech encoder
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
568 * txdtx_ctrl TX DTX handler control word
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
569 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
570 * OUTPUTS: params[0..56] Comfort noise encoded parameter frame
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
571 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
572 * RETURN VALUE: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
573 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
574 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
575
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
576 void CN_encoding (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
577 Word16 params[],
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
578 Word16 txdtx_ctrl
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
579 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
580 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
581 Word16 i;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
582
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
583 test (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
584 if ((txdtx_ctrl & TX_SID_UPDATE) != 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
585 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
586 /* Store new CN parameters in memory to be used later as old
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
587 CN parameters */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
588
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
589 /* LPC parameter indices */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
590 for (i = 0; i < 5; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
591 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
592 old_CN_mem_tx[i] = params[i]; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
593 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
594 /* Codebook index computed in last subframe */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
595 old_CN_mem_tx[5] = params[56]; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
596 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
597 test (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
598 if ((txdtx_ctrl & TX_USE_OLD_SID) != 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
599 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
600 /* Use old CN parameters previously stored in memory */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
601 for (i = 0; i < 5; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
602 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
603 params[i] = old_CN_mem_tx[i]; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
604 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
605 params[17] = old_CN_mem_tx[5]; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
606 params[30] = old_CN_mem_tx[5]; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
607 params[43] = old_CN_mem_tx[5]; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
608 params[56] = old_CN_mem_tx[5]; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
609 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
610 /* Set all the rest of the parameters to zero (SID codeword will
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
611 be written later) */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
612 for (i = 0; i < 12; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
613 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
614 params[i + 5] = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
615 params[i + 18] = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
616 params[i + 31] = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
617 params[i + 44] = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
618 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
619
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
620 return;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
621 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
622
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
623 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
624 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
625 * FUNCTION NAME: sid_codeword_encoding
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
626 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
627 * PURPOSE: Encoding of the SID codeword into the SID frame. The SID
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
628 * codeword consists of 95 bits, all set to '1'.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
629 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
630 * INPUTS: ser2[0..243] Serial-mode speech parameter frame before
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
631 * writing SID codeword into it
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
632 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
633 * OUTPUTS: ser2[0..243] Serial-mode speech parameter frame with
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
634 * SID codeword written into it
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
635 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
636 * RETURN VALUE: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
637 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
638 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
639
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
640 void sid_codeword_encoding (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
641 Word16 ser2[]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
642 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
643 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
644 Word16 i;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
645
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
646 for (i = 0; i < 95; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
647 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
648 ser2[SID_codeword_bit_idx[i]] = 1; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
649 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
650
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
651 return;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
652 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
653
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
654 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
655 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
656 * FUNCTION NAME: sid_frame_detection
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
657 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
658 * PURPOSE: Detecting of SID codeword from a received frame. The frames
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
659 * are classified into three categories based on how many bit
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
660 * errors occur in the SID codeword:
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
661 * - VALID SID FRAME
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
662 * - INVALID SID FRAME
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
663 * - SPEECH FRAME
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
664 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
665 * INPUTS: ser2[0..243] Received serial-mode speech parameter frame
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
666 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
667 * OUTPUTS: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
668 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
669 * RETURN VALUE: Ternary-valued SID classification flag
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
670 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
671 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
672
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
673 Word16 sid_frame_detection (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
674 Word16 ser2[]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
675 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
676 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
677 Word16 i, nbr_errors, sid;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
678
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
679 /* Search for bit errors in SID codeword */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
680 nbr_errors = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
681 for (i = 0; i < 95; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
682 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
683 test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
684 if (ser2[SID_codeword_bit_idx[i]] == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
685 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
686 nbr_errors = add (nbr_errors, 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
687 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
688 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
689
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
690 /* Frame classification */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
691 test (); test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
692 if (sub (nbr_errors, VALID_SID_THRESH) < 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
693 { /* Valid SID frame */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
694 sid = 2; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
695 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
696 else if (sub (nbr_errors, INVALID_SID_THRESH) < 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
697 { /* Invalid SID frame */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
698 sid = 1; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
699 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
700 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
701 { /* Speech frame */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
702 sid = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
703 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
704
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
705 return sid;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
706 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
707
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
708 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
709 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
710 * FUNCTION NAME: update_lsf_history
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
711 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
712 * PURPOSE: Update the LSF parameter history. The LSF parameters kept
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
713 * in the buffer are used later for computing the reference
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
714 * LSF parameter vector and the averaged LSF parameter vector.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
715 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
716 * INPUTS: lsf1[0..9] LSF vector of the 1st half of the frame
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
717 * lsf2[0..9] LSF vector of the 2nd half of the frame
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
718 * lsf_old[0..DTX_HANGOVER-1][0..M-1]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
719 * Old LSF history
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
720 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
721 * OUTPUTS: lsf_old[0..DTX_HANGOVER-1][0..M-1]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
722 * Updated LSF history
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
723 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
724 * RETURN VALUE: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
725 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
726 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
727
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
728 void update_lsf_history (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
729 Word16 lsf1[M],
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
730 Word16 lsf2[M],
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
731 Word16 lsf_old[DTX_HANGOVER][M]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
732 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
733 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
734 Word16 i, j, temp;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
735
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
736 /* shift LSF data to make room for LSFs from current frame */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
737 /* This can also be implemented by using circular buffering */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
738
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
739 for (i = DTX_HANGOVER - 1; i > 0; i--)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
740 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
741 for (j = 0; j < M; j++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
742 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
743 lsf_old[i][j] = lsf_old[i - 1][j]; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
744 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
745 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
746
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
747 /* Store new LSF data to lsf_old buffer */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
748
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
749 for (i = 0; i < M; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
750 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
751 temp = add (shr (lsf1[i], 1), shr (lsf2[i], 1));
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
752 lsf_old[0][i] = temp; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
753 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
754
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
755 return;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
756 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
757
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
758 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
759 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
760 * FUNCTION NAME: update_lsf_p_CN
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
761 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
762 * PURPOSE: Update the reference LSF parameter vector. The reference
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
763 * vector is computed by averaging the quantized LSF parameter
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
764 * vectors which exist in the LSF parameter history.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
765 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
766 * INPUTS: lsf_old[0..DTX_HANGOVER-1][0..M-1]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
767 * LSF parameter history
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
768 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
769 * OUTPUTS: lsf_p_CN[0..9] Computed reference LSF parameter vector
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
770 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
771 * RETURN VALUE: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
772 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
773 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
774
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
775 void update_lsf_p_CN (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
776 Word16 lsf_old[DTX_HANGOVER][M],
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
777 Word16 lsf_p_CN[M]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
778 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
779 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
780 Word16 i, j;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
781 Word32 L_temp;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
782
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
783 for (j = 0; j < M; j++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
784 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
785 L_temp = L_mult (INV_DTX_HANGOVER, lsf_old[0][j]);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
786 for (i = 1; i < DTX_HANGOVER; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
787 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
788 L_temp = L_mac (L_temp, INV_DTX_HANGOVER, lsf_old[i][j]);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
789 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
790 lsf_p_CN[j] = round (L_temp); move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
791 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
792
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
793 return;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
794 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
795
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
796 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
797 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
798 * FUNCTION NAME: aver_lsf_history
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
799 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
800 * PURPOSE: Compute the averaged LSF parameter vector. Computation is
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
801 * performed by averaging the LSF parameter vectors which exist
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
802 * in the LSF parameter history, together with the LSF
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
803 * parameter vectors of the current frame.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
804 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
805 * INPUTS: lsf_old[0..DTX_HANGOVER-1][0..M-1]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
806 * LSF parameter history
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
807 * lsf1[0..M-1] LSF vector of the 1st half of the frame
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
808 * lsf2[0..M-1] LSF vector of the 2nd half of the frame
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
809 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
810 * OUTPUTS: lsf_aver[0..M-1] Averaged LSF parameter vector
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
811 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
812 * RETURN VALUE: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
813 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
814 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
815
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
816 void aver_lsf_history (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
817 Word16 lsf_old[DTX_HANGOVER][M],
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
818 Word16 lsf1[M],
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
819 Word16 lsf2[M],
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
820 Word16 lsf_aver[M]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
821 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
822 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
823 Word16 i, j;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
824 Word32 L_temp;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
825
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
826 for (j = 0; j < M; j++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
827 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
828 L_temp = L_mult (0x3fff, lsf1[j]);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
829 L_temp = L_mac (L_temp, 0x3fff, lsf2[j]);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
830 L_temp = L_mult (INV_DTX_HANGOVER_P1, extract_h (L_temp));
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
831
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
832 for (i = 0; i < DTX_HANGOVER; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
833 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
834 L_temp = L_mac (L_temp, INV_DTX_HANGOVER_P1, lsf_old[i][j]);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
835 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
836
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
837 lsf_aver[j] = extract_h (L_temp); move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
838 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
839
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
840 return;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
841 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
842
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
843 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
844 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
845 * FUNCTION NAME: update_gain_code_history_tx
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
846 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
847 * PURPOSE: Update the fixed codebook gain parameter history of the
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
848 * encoder. The fixed codebook gain parameters kept in the buffer
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
849 * are used later for computing the reference fixed codebook
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
850 * gain parameter value and the averaged fixed codebook gain
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
851 * parameter value.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
852 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
853 * INPUTS: new_gain_code New fixed codebook gain value
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
854 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
855 * gain_code_old_tx[0..4*DTX_HANGOVER-1]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
856 * Old fixed codebook gain history of encoder
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
857 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
858 * OUTPUTS: gain_code_old_tx[0..4*DTX_HANGOVER-1]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
859 * Updated fixed codebook gain history of encoder
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
860 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
861 * RETURN VALUE: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
862 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
863 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
864
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
865 void update_gain_code_history_tx (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
866 Word16 new_gain_code,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
867 Word16 gain_code_old_tx[4 * DTX_HANGOVER]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
868 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
869 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
870
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
871 /* Circular buffer */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
872 gain_code_old_tx[buf_p_tx] = new_gain_code; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
873
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
874 test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
875 if (sub (buf_p_tx, (4 * DTX_HANGOVER - 1)) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
876 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
877 buf_p_tx = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
878 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
879 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
880 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
881 buf_p_tx = add (buf_p_tx, 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
882 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
883
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
884 return;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
885 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
886
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
887 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
888 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
889 * FUNCTION NAME: update_gain_code_history_rx
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
890 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
891 * PURPOSE: Update the fixed codebook gain parameter history of the
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
892 * decoder. The fixed codebook gain parameters kept in the buffer
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
893 * are used later for computing the reference fixed codebook
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
894 * gain parameter value.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
895 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
896 * INPUTS: new_gain_code New fixed codebook gain value
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
897 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
898 * gain_code_old_tx[0..4*DTX_HANGOVER-1]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
899 * Old fixed codebook gain history of decoder
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
900 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
901 * OUTPUTS: gain_code_old_tx[0..4*DTX_HANGOVER-1]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
902 * Updated fixed codebk gain history of decoder
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
903 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
904 * RETURN VALUE: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
905 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
906 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
907
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
908 void update_gain_code_history_rx (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
909 Word16 new_gain_code,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
910 Word16 gain_code_old_rx[4 * DTX_HANGOVER]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
911 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
912 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
913
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
914 /* Circular buffer */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
915 gain_code_old_rx[buf_p_rx] = new_gain_code; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
916
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
917 test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
918 if (sub (buf_p_rx, (4 * DTX_HANGOVER - 1)) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
919 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
920 buf_p_rx = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
921 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
922 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
923 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
924 buf_p_rx = add (buf_p_rx, 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
925 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
926
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
927 return;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
928 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
929
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
930 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
931 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
932 * FUNCTION NAME: compute_CN_excitation_gain
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
933 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
934 * PURPOSE: Compute the unquantized fixed codebook gain. Computation is
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
935 * based on the energy of the Linear Prediction residual signal.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
936 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
937 * INPUTS: res2[0..39] Linear Prediction residual signal
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
938 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
939 * OUTPUTS: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
940 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
941 * RETURN VALUE: Unquantized fixed codebook gain
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
942 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
943 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
944
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
945 Word16 compute_CN_excitation_gain (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
946 Word16 res2[L_SUBFR]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
947 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
948 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
949 Word16 i, norm, norm1, temp, overfl;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
950 Word32 L_temp;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
951
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
952 /* Compute the energy of the LP residual signal */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
953
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
954 norm = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
955 do
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
956 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
957 overfl = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
958
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
959 L_temp = 0L; move32 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
960 for (i = 0; i < L_SUBFR; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
961 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
962 temp = shr (res2[i], norm);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
963 L_temp = L_mac (L_temp, temp, temp);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
964 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
965
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
966 test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
967 if (L_sub (L_temp, MAX_32) == 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
968 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
969 norm = add (norm, 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
970 overfl = 1; move16 (); /* Set the overflow flag */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
971 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
972 test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
973 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
974 while (overfl != 0);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
975
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
976 L_temp = L_add (L_temp, 1L); /* Avoid the case of all zeros */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
977
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
978 /* Take the square root of the obtained energy value (sqroot is a 2nd
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
979 order Taylor series approximation) */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
980
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
981 norm1 = norm_l (L_temp);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
982 temp = extract_h (L_shl (L_temp, norm1));
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
983 L_temp = L_mult (temp, temp);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
984 L_temp = L_sub (805306368L, L_shr (L_temp, 3));
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
985 L_temp = L_add (L_temp, L_mult (24576, temp));
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
986
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
987 temp = extract_h (L_temp);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
988 test (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
989 if ((norm1 & 0x0001) != 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
990 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
991 temp = mult_r (temp, 23170);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
992 norm1 = sub (norm1, 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
993 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
994 /* Divide the result of sqroot operation by sqroot(10) */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
995
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
996 temp = mult_r (temp, 10362);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
997
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
998 /* Re-scale to get the final value */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
999
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1000 norm1 = shr (norm1, 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1001 norm1 = sub (norm1, norm);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1002
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1003 test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1004 if (norm1 >= 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1005 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1006 temp = shr (temp, norm1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1007 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1008 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1009 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1010 temp = shl (temp, abs_s (norm1));
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1011 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1012
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1013 return temp;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1014 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1015
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1016 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1017 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1018 * FUNCTION NAME: update_gcode0_CN
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1019 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1020 * PURPOSE: Update the reference fixed codebook gain parameter value.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1021 * The reference value is computed by averaging the quantized
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1022 * fixed codebook gain parameter values which exist in the
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1023 * fixed codebook gain parameter history.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1024 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1025 * INPUTS: gain_code_old[0..4*DTX_HANGOVER-1]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1026 * fixed codebook gain parameter history
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1027 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1028 * OUTPUTS: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1029 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1030 * RETURN VALUE: Computed reference fixed codebook gain
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1031 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1032 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1033
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1034 Word16 update_gcode0_CN (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1035 Word16 gain_code_old[4 * DTX_HANGOVER]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1036 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1037 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1038 Word16 i, j;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1039 Word32 L_temp, L_ret;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1040
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1041 L_ret = 0L; move32 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1042 for (i = 0; i < DTX_HANGOVER; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1043 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1044 L_temp = L_mult (0x1fff, gain_code_old[4 * i]);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1045 for (j = 1; j < 4; j++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1046 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1047 L_temp = L_mac (L_temp, 0x1fff, gain_code_old[4 * i + j]);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1048 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1049 L_ret = L_mac (L_ret, INV_DTX_HANGOVER, extract_h (L_temp));
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1050 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1051
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1052 return extract_h (L_ret);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1053 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1054
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1055 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1056 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1057 * FUNCTION NAME: aver_gain_code_history
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1058 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1059 * PURPOSE: Compute the averaged fixed codebook gain parameter value.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1060 * Computation is performed by averaging the fixed codebook
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1061 * gain parameter values which exist in the fixed codebook
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1062 * gain parameter history, together with the fixed codebook
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1063 * gain parameter value of the current subframe.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1064 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1065 * INPUTS: CN_excitation_gain
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1066 * Unquantized fixed codebook gain value
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1067 * of the current subframe
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1068 * gain_code_old[0..4*DTX_HANGOVER-1]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1069 * fixed codebook gain parameter history
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1070 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1071 * OUTPUTS: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1072 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1073 * RETURN VALUE: Averaged fixed codebook gain value
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1074 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1075 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1076
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1077 Word16 aver_gain_code_history (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1078 Word16 CN_excitation_gain,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1079 Word16 gain_code_old[4 * DTX_HANGOVER]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1080 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1081 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1082 Word16 i;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1083 Word32 L_ret;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1084
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1085 L_ret = L_mult (0x470, CN_excitation_gain);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1086
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1087 for (i = 0; i < (4 * DTX_HANGOVER); i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1088 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1089 L_ret = L_mac (L_ret, 0x470, gain_code_old[i]);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1090 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1091 return extract_h (L_ret);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1092 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1093
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1094 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1095 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1096 * FUNCTION NAME: build_CN_code
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1097 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1098 * PURPOSE: Compute the comfort noise fixed codebook excitation. The
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1099 * gains of the pulses are always +/-1.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1100 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1101 * INPUTS: *seed Old CN generator shift register state
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1102 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1103 * OUTPUTS: cod[0..39] Generated comfort noise fixed codebook vector
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1104 * *seed Updated CN generator shift register state
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1105 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1106 * RETURN VALUE: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1107 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1108 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1109
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1110 void build_CN_code (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1111 Word16 cod[],
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1112 Word32 *seed
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1113 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1114 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1115 Word16 i, j, k;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1116
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1117 for (i = 0; i < L_SUBFR; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1118 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1119 cod[i] = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1120 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1121
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1122 for (k = 0; k < NB_PULSE; k++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1123 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1124 i = pseudonoise (seed, 2); /* generate pulse position */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1125 i = shr (extract_l (L_mult (i, 10)), 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1126 i = add (i, k);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1127
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1128 j = pseudonoise (seed, 1); /* generate sign */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1129
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1130 test ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1131 if (j > 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1132 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1133 cod[i] = 4096; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1134 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1135 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1136 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1137 cod[i] = -4096; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1138 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1139 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1140
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1141 return;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1142 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1143
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1144 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1145 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1146 * FUNCTION NAME: pseudonoise
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1147 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1148 * PURPOSE: Generate a random integer value to use in comfort noise
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1149 * generation. The algorithm uses polynomial x^31 + x^3 + 1
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1150 * (length of PN sequence is 2^31 - 1).
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1151 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1152 * INPUTS: *shift_reg Old CN generator shift register state
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1153 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1154 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1155 * OUTPUTS: *shift_reg Updated CN generator shift register state
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1156 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1157 * RETURN VALUE: Generated random integer value
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1158 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1159 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1160
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1161 Word16 pseudonoise (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1162 Word32 *shift_reg,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1163 Word16 no_bits
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1164 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1165 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1166 Word16 noise_bits, Sn, i;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1167
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1168 noise_bits = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1169 for (i = 0; i < no_bits; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1170 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1171 /* State n == 31 */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1172 test (); logic32 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1173 if ((*shift_reg & 0x00000001L) != 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1174 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1175 Sn = 1; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1176 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1177 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1178 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1179 Sn = 0; move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1180 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1181
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1182 /* State n == 3 */
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1183 test (); logic32 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1184 if ((*shift_reg & 0x10000000L) != 0)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1185 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1186 Sn = Sn ^ 1; logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1187 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1188 else
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1189 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1190 Sn = Sn ^ 0; logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1191 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1192
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1193 noise_bits = shl (noise_bits, 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1194 noise_bits = noise_bits | (extract_l (*shift_reg) & 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1195 logic16 (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1196
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1197 *shift_reg = L_shr (*shift_reg, 1); move32 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1198 test (); logic16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1199 if (Sn & 1)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1200 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1201 *shift_reg = *shift_reg | 0x40000000L; move32 (); logic32 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1202 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1203 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1204
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1205 return noise_bits;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1206 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1207
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1208 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1209 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1210 * FUNCTION NAME: interpolate_CN_param
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1211 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1212 * PURPOSE: Interpolate a comfort noise parameter value over the comfort
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1213 * noise update period.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1214 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1215 * INPUTS: old_param The older parameter of the interpolation
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1216 * (the endpoint the interpolation is started
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1217 * from)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1218 * new_param The newer parameter of the interpolation
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1219 * (the endpoint the interpolation is ended to)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1220 * rx_dtx_state State of the comfort noise insertion period
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1221 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1222 * OUTPUTS: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1223 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1224 * RETURN VALUE: Interpolated CN parameter value
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1225 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1226 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1227
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1228 Word16 interpolate_CN_param (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1229 Word16 old_param,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1230 Word16 new_param,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1231 Word16 rx_dtx_state
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1232 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1233 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1234 static const Word16 interp_factor[CN_INT_PERIOD] =
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1235 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1236 0x0555, 0x0aaa, 0x1000, 0x1555, 0x1aaa, 0x2000,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1237 0x2555, 0x2aaa, 0x3000, 0x3555, 0x3aaa, 0x4000,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1238 0x4555, 0x4aaa, 0x5000, 0x5555, 0x5aaa, 0x6000,
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1239 0x6555, 0x6aaa, 0x7000, 0x7555, 0x7aaa, 0x7fff};
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1240 Word16 temp;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1241 Word32 L_temp;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1242
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1243 L_temp = L_mult (interp_factor[rx_dtx_state], new_param);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1244 temp = sub (0x7fff, interp_factor[rx_dtx_state]);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1245 temp = add (temp, 1);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1246 L_temp = L_mac (L_temp, temp, old_param);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1247 temp = round (L_temp);
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1248
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1249 return temp;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1250 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1251
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1252 /*************************************************************************
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1253 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1254 * FUNCTION NAME: interpolate_CN_lsf
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1255 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1256 * PURPOSE: Interpolate comfort noise LSF parameter vector over the comfort
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1257 * noise update period.
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1258 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1259 * INPUTS: lsf_old_CN[0..9]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1260 * The older LSF parameter vector of the
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1261 * interpolation (the endpoint the interpolation
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1262 * is started from)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1263 * lsf_new_CN[0..9]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1264 * The newer LSF parameter vector of the
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1265 * interpolation (the endpoint the interpolation
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1266 * is ended to)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1267 * rx_dtx_state State of the comfort noise insertion period
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1268 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1269 * OUTPUTS: lsf_interp_CN[0..9]
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1270 * Interpolated LSF parameter vector
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1271 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1272 * RETURN VALUE: none
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1273 *
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1274 *************************************************************************/
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1275
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1276 void interpolate_CN_lsf (
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1277 Word16 lsf_old_CN[M],
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1278 Word16 lsf_new_CN[M],
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1279 Word16 lsf_interp_CN[M],
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1280 Word16 rx_dtx_state
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1281 )
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1282 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1283 Word16 i;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1284
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1285 for (i = 0; i < M; i++)
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1286 {
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1287 lsf_interp_CN[i] = interpolate_CN_param (lsf_old_CN[i],
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1288 lsf_new_CN[i],
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1289 rx_dtx_state); move16 ();
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1290 }
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1291
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1292 return;
56410792419a src: original EFR source from ETSI
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1293 }