78 for (i = 0; i < 3; i++)
82 wd2 = (s->
band[band].
sg[0] == s->
band[band].
sg[1]) ? -wd1 : wd1;
85 wd3 = (s->
band[band].
sg[0] == s->
band[band].
sg[2]) ? 128 : -128;
87 wd3 += (s->
band[band].
a[2]*32512) >> 15;
90 else if (wd3 < -12288)
97 wd1 = (s->
band[band].
sg[0] == s->
band[band].
sg[1]) ? 192 : -192;
98 wd2 = (s->
band[band].
a[1]*32640) >> 15;
102 if (s->
band[band].
ap[1] > wd3)
103 s->
band[band].
ap[1] = wd3;
104 else if (s->
band[band].
ap[1] < -wd3)
105 s->
band[band].
ap[1] = -wd3;
108 wd1 = (d == 0) ? 0 : 128;
109 s->
band[band].
sg[0] = d >> 15;
110 for (i = 1; i < 7; i++)
113 wd2 = (s->
band[band].
sg[i] == s->
band[band].
sg[0]) ? wd1 : -wd1;
114 wd3 = (s->
band[band].
b[i]*32640) >> 15;
119 for (i = 6; i > 0; i--)
125 for (i = 2; i > 0; i--)
134 wd1 = (s->
band[band].
a[1]*wd1) >> 15;
136 wd2 = (s->
band[band].
a[2]*wd2) >> 15;
141 for (i = 6; i > 0; i--)
144 s->
band[band].
sz += (s->
band[band].
b[i]*wd1) >> 15;
160 memset(s, 0,
sizeof(*s));
163 else if (rate == 56000)
188 static const int wl[8] = {-60, -30, 58, 172, 334, 538, 1198, 3042 };
189 static const int rl42[16] = {0, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 0 };
190 static const int ilb[32] =
192 2048, 2093, 2139, 2186, 2233, 2282, 2332,
193 2383, 2435, 2489, 2543, 2599, 2656, 2714,
194 2774, 2834, 2896, 2960, 3025, 3091, 3158,
195 3228, 3298, 3371, 3444, 3520, 3597, 3676,
196 3756, 3838, 3922, 4008
198 static const int wh[3] = {0, -214, 798};
199 static const int rh2[4] = {2, 1, 2, 1};
200 static const int qm2[4] = {-7408, -1616, 7408, 1616};
201 static const int qm4[16] =
203 0, -20456, -12896, -8968,
204 -6288, -4240, -2584, -1200,
205 20456, 12896, 8968, 6288,
208 static const int qm5[32] =
210 -280, -280, -23352, -17560,
211 -14120, -11664, -9752, -8184,
212 -6864, -5712, -4696, -3784,
213 -2960, -2208, -1520, -880,
214 23352, 17560, 14120, 11664,
215 9752, 8184, 6864, 5712,
216 4696, 3784, 2960, 2208,
219 static const int qm6[64] =
221 -136, -136, -136, -136,
222 -24808, -21904, -19008, -16704,
223 -14984, -13512, -12280, -11192,
224 -10232, -9360, -8576, -7856,
225 -7192, -6576, -6000, -5456,
226 -4944, -4464, -4008, -3576,
227 -3168, -2776, -2400, -2032,
228 -1688, -1360, -1040, -728,
229 24808, 21904, 19008, 16704,
230 14984, 13512, 12280, 11192,
231 10232, 9360, 8576, 7856,
232 7192, 6576, 6000, 5456,
233 4944, 4464, 4008, 3576,
234 3168, 2776, 2400, 2032,
235 1688, 1360, 1040, 728,
238 static const int qmf_coeffs[12] =
240 3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11,
260 for (j = 0; j <
len; )
276 code = g722_data[j++];
284 ihigh = (code >> 6) & 0x03;
290 ihigh = (code >> 5) & 0x03;
296 ihigh = (code >> 4) & 0x03;
301 wd2 = (s->
band[0].
det*wd2) >> 15;
303 rlow = s->
band[0].
s + wd2;
307 else if (rlow < -16384)
312 dlowt = (s->
band[0].
det*wd2) >> 15;
316 wd1 = (s->
band[0].
nb*127) >> 7;
320 else if (wd1 > 18432)
325 wd1 = (s->
band[0].
nb >> 6) & 31;
326 wd2 = 8 - (s->
band[0].
nb >> 11);
327 wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2);
336 dhigh = (s->
band[1].
det*wd2) >> 15;
338 rhigh = dhigh + s->
band[1].
s;
342 else if (rhigh < -16384)
347 wd1 = (s->
band[1].
nb*127) >> 7;
351 else if (wd1 > 22528)
356 wd1 = (s->
band[1].
nb >> 6) & 31;
357 wd2 = 10 - (s->
band[1].
nb >> 11);
358 wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2);
366 amp[outlen++] = (
int16_t) (rlow << 1);
367 amp[outlen++] = (
int16_t) (rhigh << 1);
373 amp[outlen++] = (
int16_t) (rlow << 1);
378 for (i = 0; i < 22; i++)
379 s->
x[i] = s->
x[i + 2];
380 s->
x[22] = rlow + rhigh;
381 s->
x[23] = rlow - rhigh;
385 for (i = 0; i < 12; i++)
387 xout2 += s->
x[2*i]*qmf_coeffs[i];
388 xout1 += s->
x[2*i + 1]*qmf_coeffs[11 - i];
390 amp[outlen++] = (
int16_t) (xout1 >> 11);
391 amp[outlen++] = (
int16_t) (xout2 >> 11);
int g722_decode_release(g722_decode_state_t *s)
static __inline__ int16_t saturate(int32_t amp)
int g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[], int len)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static void block4(g722_decode_state_t *s, int band, int d)
g722_decode_state_t * g722_decode_init(g722_decode_state_t *s, int rate, int options)
struct g722_decode_state_t::@186 band[2]