comparison libgsmefr/e_homing.c @ 53:49dd1ac8e75b

libgsmefr: import most *.c files from ETSI source
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 25 Nov 2022 16:18:21 +0000
parents
children aacdf352576c
comparison
equal deleted inserted replaced
52:988fd7ff514f 53:49dd1ac8e75b
1 /**************************************************************************
2 *
3 * File Name: e_homing.c
4 *
5 * Purpose:
6 * This file contains the following functions:
7 *
8 * encoder_homing_frame_test() checks if a frame of input samples
9 * matches the Encoder Homing Frame pattern.
10 *
11 * encoder_reset() called by reset_enc() to reset all
12 * the state variables for the encoder.
13 *
14 * reset_enc() calls functions to reset the state
15 * variables for the encoder and VAD, and
16 * for the transmit DTX and Comfort Noise.
17 *
18 **************************************************************************/
19
20 #include "typedef.h"
21 #include "cnst.h"
22 #include "vad.h"
23 #include "dtx.h"
24 #include "codec.h"
25 #include "sig_proc.h"
26 #include "e_homing.h"
27
28 /***************************************************************************
29 *
30 * FUNCTION NAME: encoder_homing_frame_test
31 *
32 * PURPOSE:
33 * Checks if a frame of input samples matches the Encoder Homing Frame
34 * pattern, which is 0x0008 for all 160 samples in the frame.
35 *
36 * INPUT:
37 * input_frame[] one frame of speech samples
38 *
39 * OUTPUT:
40 * None
41 *
42 * RETURN:
43 * 0 input frame does not match the Encoder Homing Frame pattern.
44 * 1 input frame matches the Encoder Homing Frame pattern.
45 *
46 **************************************************************************/
47
48 Word16 encoder_homing_frame_test (Word16 input_frame[])
49 {
50 Word16 i, j;
51
52 for (i = 0; i < L_FRAME; i++)
53 {
54 j = input_frame[i] ^ EHF_MASK;
55
56 if (j)
57 break;
58 }
59
60 return !j;
61 }
62
63 /***************************************************************************
64 *
65 * FUNCTION NAME: encoder_reset
66 *
67 * PURPOSE:
68 * resets all of the state variables for the encoder
69 *
70 * INPUT:
71 * None
72 *
73 * OUTPUT:
74 * None
75 *
76 * RETURN:
77 * None
78 *
79 **************************************************************************/
80
81 void encoder_reset (void)
82 {
83 /* External declarations for encoder variables which need to be reset */
84
85 /* Variables defined in levinson.c */
86 /* ------------------------------- */
87 extern Word16 old_A[M + 1]; /* Last A(z) for case of unstable filter */
88
89 /* Variables defined in q_gains.c */
90 /* ------------------------------- */
91 /* Memories of gain quantization: */
92 extern Word16 past_qua_en[4], pred[4];
93
94 /* Variables defined in q_plsf_5.c */
95 /* ------------------------------- */
96 /* Past quantized prediction error */
97 extern Word16 past_r2_q[M];
98
99 Word16 i;
100
101 /* reset all the encoder state variables */
102 /* ------------------------------------- */
103
104 /* Variables in cod_12k2.c: */
105 Init_Coder_12k2 ();
106
107 /* Variables in levinson.c: */
108 old_A[0] = 4096; /* Last A(z) for case of unstable filter */
109 for (i = 1; i < M + 1; i++)
110 {
111 old_A[i] = 0;
112 }
113
114 /* Variables in pre_proc.c: */
115 Init_Pre_Process ();
116
117 /* Variables in q_gains.c: */
118 for (i = 0; i < 4; i++)
119 {
120 past_qua_en[i] = -2381; /* past quantized energies */
121 }
122
123 pred[0] = 44; /* MA prediction coeff */
124 pred[1] = 37; /* MA prediction coeff */
125 pred[2] = 22; /* MA prediction coeff */
126 pred[3] = 12; /* MA prediction coeff */
127
128 /* Variables in q_plsf_5.c: */
129 for (i = 0; i < M; i++)
130 {
131 past_r2_q[i] = 0; /* Past quantized prediction error */
132 }
133
134 return;
135 }
136
137 /***************************************************************************
138 *
139 * FUNCTION NAME: reset_enc
140 *
141 * PURPOSE:
142 * resets all of the state variables for the encoder and VAD, and for
143 * the transmit DTX and Comfort Noise.
144 *
145 * INPUT:
146 * None
147 *
148 * OUTPUT:
149 * None
150 *
151 * RETURN:
152 * None
153 *
154 **************************************************************************/
155
156 void reset_enc (void)
157 {
158 encoder_reset (); /* reset all the state variables in the speech encoder*/
159 vad_reset (); /* reset all the VAD state variables */
160 reset_tx_dtx (); /* reset all the transmit DTX and CN variables */
161
162 return;
163 }