clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name g722.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-eagerly-assume -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -menable-no-infs -menable-no-nans -menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math -fno-trapping-math -ffp-contract=fast -ffast-math -ffinite-math-only -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-feature +sse2 -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib/llvm-7/lib/clang/7.0.1 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/libxml2 -D NDEBUG -D HAVE_VISIBILITY=1 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-7/lib/clang/7.0.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wwrite-strings -std=gnu99 -fconst-strings -fdebug-compilation-dir /drone/src/src -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -fobjc-runtime=gcc -fdiagnostics-show-option -analyzer-output=html -o /drone/src/scan-build/2021-05-27-190700-749-1 -x c g722.c -faddrsig
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | #if defined(HAVE_CONFIG_H1) |
29 | #include "config.h" |
30 | #endif |
31 | |
32 | #include <inttypes.h> |
33 | #include <memory.h> |
34 | #include <stdlib.h> |
35 | #include <string.h> |
36 | #if defined(HAVE_TGMATH_H1) |
37 | #include <tgmath.h> |
38 | #endif |
39 | #if defined(HAVE_MATH_H1) |
40 | #include <math.h> |
41 | #endif |
42 | #if defined(HAVE_STDBOOL_H1) |
43 | #include <stdbool.h> |
44 | #else |
45 | #include "spandsp/stdbool.h" |
46 | #endif |
47 | #include "floating_fudge.h" |
48 | |
49 | #include "spandsp/telephony.h" |
50 | #include "spandsp/alloc.h" |
51 | #include "spandsp/fast_convert.h" |
52 | #include "spandsp/saturated.h" |
53 | #include "spandsp/vector_int.h" |
54 | #include "spandsp/g722.h" |
55 | |
56 | #include "spandsp/private/g722.h" |
57 | |
58 | static const int16_t qmf_coeffs_fwd[12] = |
59 | { |
60 | 3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11, |
61 | }; |
62 | |
63 | static const int16_t qmf_coeffs_rev[12] = |
64 | { |
65 | -11, 53, -156, 362, -805, 3876, 951, -210, 32, 12, -11, 3 |
66 | }; |
67 | |
68 | static const int16_t qm2[4] = |
69 | { |
70 | -7408, -1616, 7408, 1616 |
71 | }; |
72 | |
73 | static const int16_t qm4[16] = |
74 | { |
75 | 0, -20456, -12896, -8968, |
76 | -6288, -4240, -2584, -1200, |
77 | 20456, 12896, 8968, 6288, |
78 | 4240, 2584, 1200, 0 |
79 | }; |
80 | |
81 | static const int16_t qm5[32] = |
82 | { |
83 | -280, -280, -23352, -17560, |
84 | -14120, -11664, -9752, -8184, |
85 | -6864, -5712, -4696, -3784, |
86 | -2960, -2208, -1520, -880, |
87 | 23352, 17560, 14120, 11664, |
88 | 9752, 8184, 6864, 5712, |
89 | 4696, 3784, 2960, 2208, |
90 | 1520, 880, 280, -280 |
91 | }; |
92 | |
93 | static const int16_t qm6[64] = |
94 | { |
95 | -136, -136, -136, -136, |
96 | -24808, -21904, -19008, -16704, |
97 | -14984, -13512, -12280, -11192, |
98 | -10232, -9360, -8576, -7856, |
99 | -7192, -6576, -6000, -5456, |
100 | -4944, -4464, -4008, -3576, |
101 | -3168, -2776, -2400, -2032, |
102 | -1688, -1360, -1040, -728, |
103 | 24808, 21904, 19008, 16704, |
104 | 14984, 13512, 12280, 11192, |
105 | 10232, 9360, 8576, 7856, |
106 | 7192, 6576, 6000, 5456, |
107 | 4944, 4464, 4008, 3576, |
108 | 3168, 2776, 2400, 2032, |
109 | 1688, 1360, 1040, 728, |
110 | 432, 136, -432, -136 |
111 | }; |
112 | |
113 | static const int16_t q6[32] = |
114 | { |
115 | 0, 35, 72, 110, |
116 | 150, 190, 233, 276, |
117 | 323, 370, 422, 473, |
118 | 530, 587, 650, 714, |
119 | 786, 858, 940, 1023, |
120 | 1121, 1219, 1339, 1458, |
121 | 1612, 1765, 1980, 2195, |
122 | 2557, 2919, 0, 0 |
123 | }; |
124 | |
125 | static const int16_t ilb[32] = |
126 | { |
127 | 2048, 2093, 2139, 2186, |
128 | 2233, 2282, 2332, 2383, |
129 | 2435, 2489, 2543, 2599, |
130 | 2656, 2714, 2774, 2834, |
131 | 2896, 2960, 3025, 3091, |
132 | 3158, 3228, 3298, 3371, |
133 | 3444, 3520, 3597, 3676, |
134 | 3756, 3838, 3922, 4008 |
135 | }; |
136 | |
137 | static const int16_t iln[32] = |
138 | { |
139 | 0, 63, 62, 31, 30, 29, 28, 27, |
140 | 26, 25, 24, 23, 22, 21, 20, 19, |
141 | 18, 17, 16, 15, 14, 13, 12, 11, |
142 | 10, 9, 8, 7, 6, 5, 4, 0 |
143 | }; |
144 | |
145 | static const int16_t ilp[32] = |
146 | { |
147 | 0, 61, 60, 59, 58, 57, 56, 55, |
148 | 54, 53, 52, 51, 50, 49, 48, 47, |
149 | 46, 45, 44, 43, 42, 41, 40, 39, |
150 | 38, 37, 36, 35, 34, 33, 32, 0 |
151 | }; |
152 | |
153 | static const int16_t ihn[3] = |
154 | { |
155 | 0, 1, 0 |
156 | }; |
157 | |
158 | static const int16_t ihp[3] = |
159 | { |
160 | 0, 3, 2 |
161 | }; |
162 | |
163 | static const int16_t wl[8] = |
164 | { |
165 | -60, -30, 58, 172, 334, 538, 1198, 3042 |
166 | }; |
167 | |
168 | static const int16_t rl42[16] = |
169 | { |
170 | 0, 7, 6, 5, 4, 3, 2, 1, |
171 | 7, 6, 5, 4, 3, 2, 1, 0 |
172 | }; |
173 | |
174 | static const int16_t wh[3] = |
175 | { |
176 | 0, -214, 798 |
177 | }; |
178 | |
179 | static const int16_t rh2[4] = |
180 | { |
181 | 2, 1, 2, 1 |
182 | }; |
183 | |
184 | static void block4(g722_band_t *s, int16_t dx) |
185 | { |
186 | int16_t wd1; |
187 | int16_t wd2; |
188 | int16_t wd3; |
189 | int16_t sp; |
190 | int16_t r; |
191 | int16_t p; |
192 | int16_t ap[2]; |
193 | int32_t wd32; |
194 | int32_t sz; |
195 | int i; |
196 | |
197 | |
198 | r = sat_add16(s->s, dx); |
199 | |
200 | p = sat_add16(s->sz, dx); |
201 | |
202 | |
203 | wd1 = saturate16((int32_t) s->a[0] << 2); |
204 | wd32 = ((p ^ s->p[0]) & 0x8000) ? wd1 : -wd1; |
205 | if (wd32 > 32767) |
206 | wd32 = 32767; |
207 | wd3 = (int16_t) ((((p ^ s->p[1]) & 0x8000) ? -128 : 128) |
208 | + (wd32 >> 7) |
209 | + (((int32_t) s->a[1]*32512) >> 15)); |
210 | if (abs(wd3) > 12288) |
211 | wd3 = (wd3 < 0) ? -12288 : 12288; |
212 | ap[1] = wd3; |
213 | |
214 | |
215 | wd1 = ((p ^ s->p[0]) & 0x8000) ? -192 : 192; |
216 | wd2 = (int16_t) (((int32_t) s->a[0]*32640) >> 15); |
217 | ap[0] = sat_add16(wd1, wd2); |
218 | |
219 | wd3 = sat_sub16(15360, ap[1]); |
220 | if (abs(ap[0]) > wd3) |
221 | ap[0] = (ap[0] < 0) ? -wd3 : wd3; |
222 | |
223 | |
224 | wd1 = sat_add16(r, r); |
225 | wd1 = (int16_t) (((int32_t) ap[0]*wd1) >> 15); |
226 | wd2 = sat_add16(s->r, s->r); |
227 | wd2 = (int16_t) (((int32_t) ap[1]*wd2) >> 15); |
228 | sp = sat_add16(wd1, wd2); |
229 | s->r = r; |
230 | s->a[1] = ap[1]; |
231 | s->a[0] = ap[0]; |
232 | s->p[1] = s->p[0]; |
233 | s->p[0] = p; |
234 | |
235 | |
236 | |
237 | |
238 | wd1 = (dx == 0) ? 0 : 128; |
239 | s->d[0] = dx; |
240 | sz = 0; |
241 | for (i = 5; i >= 0; i--) |
242 | { |
243 | wd2 = ((s->d[i + 1] ^ dx) & 0x8000) ? -wd1 : wd1; |
244 | wd3 = (int16_t) (((int32_t) s->b[i]*32640) >> 15); |
245 | s->b[i] = sat_add16(wd2, wd3); |
246 | wd3 = sat_add16(s->d[i], s->d[i]); |
247 | sz += ((int32_t) s->b[i]*wd3) >> 15; |
248 | s->d[i + 1] = s->d[i]; |
249 | } |
250 | s->sz = saturate16(sz); |
251 | |
252 | |
253 | s->s = sat_add16(sp, s->sz); |
254 | } |
255 | |
256 | |
257 | SPAN_DECLARE(g722_decode_state_t *)__attribute__((visibility("default"))) g722_decode_state_t * g722_decode_init(g722_decode_state_t *s, int rate, int options) |
258 | { |
259 | if (s == NULL((void*)0)) |
260 | { |
261 | if ((s = (g722_decode_state_t *) span_alloc(sizeof(*s))) == NULL((void*)0)) |
262 | return NULL((void*)0); |
263 | } |
264 | memset(s, 0, sizeof(*s)); |
265 | if (rate == 48000) |
266 | s->bits_per_sample = 6; |
267 | else if (rate == 56000) |
268 | s->bits_per_sample = 7; |
269 | else |
270 | s->bits_per_sample = 8; |
271 | if ((options & G722_SAMPLE_RATE_8000)) |
272 | s->eight_k = true1; |
273 | if ((options & G722_PACKED) && s->bits_per_sample != 8) |
274 | s->packed = true1; |
275 | else |
276 | s->packed = false0; |
277 | s->band[0].det = 32; |
278 | s->band[1].det = 8; |
279 | return s; |
280 | } |
281 | |
282 | |
283 | SPAN_DECLARE(int)__attribute__((visibility("default"))) int g722_decode_release(g722_decode_state_t *s) |
284 | { |
285 | return 0; |
286 | } |
287 | |
288 | |
289 | SPAN_DECLARE(int)__attribute__((visibility("default"))) int g722_decode_free(g722_decode_state_t *s) |
290 | { |
291 | span_free(s); |
292 | return 0; |
293 | } |
294 | |
295 | |
296 | SPAN_DECLARE(int)__attribute__((visibility("default"))) int g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[], int len) |
297 | { |
298 | int rlow; |
299 | int ihigh; |
300 | int16_t dlow; |
301 | int16_t dhigh; |
302 | int rhigh; |
303 | int wd1; |
304 | int wd2; |
305 | int wd3; |
306 | int code; |
307 | int outlen; |
308 | int j; |
309 | |
310 | outlen = 0; |
311 | rhigh = 0; |
312 | for (j = 0; j < len; ) |
| |
| 2 | | Loop condition is true. Entering loop body | |
|
313 | { |
314 | if (s->packed) |
| 3 | | Assuming the condition is false | |
|
| |
315 | { |
316 | |
317 | if (s->in_bits < s->bits_per_sample) |
318 | { |
319 | s->in_buffer |= (g722_data[j++] << s->in_bits); |
320 | s->in_bits += 8; |
321 | } |
322 | code = s->in_buffer & ((1 << s->bits_per_sample) - 1); |
323 | s->in_buffer >>= s->bits_per_sample; |
324 | s->in_bits -= s->bits_per_sample; |
325 | } |
326 | else |
327 | { |
328 | code = g722_data[j++]; |
329 | } |
330 | |
331 | switch (s->bits_per_sample) |
| 5 | | Control jumps to 'case 6:' at line 346 | |
|
332 | { |
333 | default: |
334 | case 8: |
335 | wd1 = code & 0x3F; |
336 | ihigh = (code >> 6) & 0x03; |
337 | wd2 = qm6[wd1]; |
338 | wd1 >>= 2; |
339 | break; |
340 | case 7: |
341 | wd1 = code & 0x1F; |
342 | ihigh = (code >> 5) & 0x03; |
343 | wd2 = qm5[wd1]; |
344 | wd1 >>= 1; |
345 | break; |
346 | case 6: |
347 | wd1 = code & 0x0F; |
348 | ihigh = (code >> 4) & 0x03; |
349 | wd2 = qm4[wd1]; |
350 | break; |
| 6 | | Execution continues on line 353 | |
|
351 | } |
352 | |
353 | wd2 = ((int32_t) s->band[0].det*wd2) >> 15; |
354 | |
355 | |
356 | rlow = saturate15(s->band[0].s + wd2); |
357 | |
358 | |
359 | wd2 = qm4[wd1]; |
360 | dlow = (int16_t) (((int32_t) s->band[0].det*wd2) >> 15); |
361 | |
362 | |
363 | wd2 = rl42[wd1]; |
364 | wd1 = ((int32_t) s->band[0].nb*127) >> 7; |
365 | wd1 += wl[wd2]; |
366 | if (wd1 < 0) |
| |
| |
367 | wd1 = 0; |
368 | else if (wd1 > 18432) |
| 9 | | Assuming 'wd1' is <= 18432 | |
|
| |
369 | wd1 = 18432; |
370 | s->band[0].nb = (int16_t) wd1; |
371 | |
372 | |
373 | wd1 = (s->band[0].nb >> 6) & 31; |
374 | wd2 = 8 - (s->band[0].nb >> 11); |
375 | wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); |
| |
| |
376 | s->band[0].det = (int16_t) (wd3 << 2); |
377 | |
378 | block4(&s->band[0], dlow); |
379 | |
380 | if (!s->eight_k) |
| 13 | | Assuming the condition is false | |
|
| |
381 | { |
382 | |
383 | wd2 = qm2[ihigh]; |
384 | dhigh = (int16_t) (((int32_t) s->band[1].det*wd2) >> 15); |
385 | |
386 | |
387 | rhigh = saturate15(dhigh + s->band[1].s); |
388 | |
389 | |
390 | wd2 = rh2[ihigh]; |
391 | wd1 = ((int32_t) s->band[1].nb*127) >> 7; |
392 | wd1 += wh[wd2]; |
393 | if (wd1 < 0) |
394 | wd1 = 0; |
395 | else if (wd1 > 22528) |
396 | wd1 = 22528; |
397 | s->band[1].nb = (int16_t) wd1; |
398 | |
399 | |
400 | wd1 = (s->band[1].nb >> 6) & 31; |
401 | wd2 = 10 - (s->band[1].nb >> 11); |
402 | wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); |
403 | s->band[1].det = (int16_t) (wd3 << 2); |
404 | |
405 | block4(&s->band[1], dhigh); |
406 | } |
407 | |
408 | if (s->itu_test_mode) |
| 15 | | Assuming the condition is false | |
|
| |
409 | { |
410 | amp[outlen++] = (int16_t) (rlow << 1); |
411 | amp[outlen++] = (int16_t) (rhigh << 1); |
412 | } |
413 | else |
414 | { |
415 | if (s->eight_k) |
| |
416 | { |
417 | |
418 | amp[outlen++] = (int16_t) (rlow << 1); |
| 18 | | The result of the left shift is undefined because the left operand is negative |
|
419 | } |
420 | else |
421 | { |
422 | |
423 | s->x[s->ptr] = (int16_t) (rlow + rhigh); |
424 | s->y[s->ptr] = (int16_t) (rlow - rhigh); |
425 | if (++s->ptr >= 12) |
426 | s->ptr = 0; |
427 | |
428 | |
429 | amp[outlen++] = saturate16(vec_circular_dot_prodi16(s->y, qmf_coeffs_rev, 12, s->ptr) >> 11); |
430 | amp[outlen++] = saturate16(vec_circular_dot_prodi16(s->x, qmf_coeffs_fwd, 12, s->ptr) >> 11); |
431 | } |
432 | } |
433 | } |
434 | return outlen; |
435 | } |
436 | |
437 | |
438 | SPAN_DECLARE(g722_encode_state_t *)__attribute__((visibility("default"))) g722_encode_state_t * g722_encode_init(g722_encode_state_t *s, int rate, int options) |
439 | { |
440 | if (s == NULL((void*)0)) |
441 | { |
442 | if ((s = (g722_encode_state_t *) span_alloc(sizeof(*s))) == NULL((void*)0)) |
443 | return NULL((void*)0); |
444 | } |
445 | memset(s, 0, sizeof(*s)); |
446 | if (rate == 48000) |
447 | s->bits_per_sample = 6; |
448 | else if (rate == 56000) |
449 | s->bits_per_sample = 7; |
450 | else |
451 | s->bits_per_sample = 8; |
452 | if ((options & G722_SAMPLE_RATE_8000)) |
453 | s->eight_k = true1; |
454 | if ((options & G722_PACKED) && s->bits_per_sample != 8) |
455 | s->packed = true1; |
456 | else |
457 | s->packed = false0; |
458 | s->band[0].det = 32; |
459 | s->band[1].det = 8; |
460 | return s; |
461 | } |
462 | |
463 | |
464 | SPAN_DECLARE(int)__attribute__((visibility("default"))) int g722_encode_release(g722_encode_state_t *s) |
465 | { |
466 | return 0; |
467 | } |
468 | |
469 | |
470 | SPAN_DECLARE(int)__attribute__((visibility("default"))) int g722_encode_free(g722_encode_state_t *s) |
471 | { |
472 | span_free(s); |
473 | return 0; |
474 | } |
475 | |
476 | |
477 | SPAN_DECLARE(int)__attribute__((visibility("default"))) int g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[], int len) |
478 | { |
479 | int16_t dlow; |
480 | int16_t dhigh; |
481 | int el; |
482 | int wd; |
483 | int wd1; |
484 | int ril; |
485 | int wd2; |
486 | int il4; |
487 | int ih2; |
488 | int wd3; |
489 | int eh; |
490 | int g722_bytes; |
491 | int ihigh; |
492 | int ilow; |
493 | int code; |
494 | |
495 | int16_t xlow; |
496 | int16_t xhigh; |
497 | int32_t sumeven; |
498 | int32_t sumodd; |
499 | int mih; |
500 | int i; |
501 | int j; |
502 | |
503 | g722_bytes = 0; |
504 | xhigh = 0; |
505 | for (j = 0; j < len; ) |
506 | { |
507 | if (s->itu_test_mode) |
508 | { |
509 | xlow = |
510 | xhigh = amp[j++] >> 1; |
511 | } |
512 | else |
513 | { |
514 | if (s->eight_k) |
515 | { |
516 | |
517 | xlow = amp[j++] >> 1; |
518 | } |
519 | else |
520 | { |
521 | |
522 | s->x[s->ptr] = amp[j++]; |
523 | s->y[s->ptr] = amp[j++]; |
524 | if (++s->ptr >= 12) |
525 | s->ptr = 0; |
526 | sumodd = vec_circular_dot_prodi16(s->x, qmf_coeffs_fwd, 12, s->ptr); |
527 | sumeven = vec_circular_dot_prodi16(s->y, qmf_coeffs_rev, 12, s->ptr); |
528 | |
529 | |
530 | |
531 | xlow = (int16_t) ((sumeven + sumodd) >> 14); |
532 | xhigh = (int16_t) ((sumeven - sumodd) >> 14); |
533 | } |
534 | } |
535 | |
536 | el = sat_sub16(xlow, s->band[0].s); |
537 | |
538 | |
539 | wd = (el >= 0) ? el : ~el; |
540 | |
541 | for (i = 1; i < 30; i++) |
542 | { |
543 | wd1 = ((int32_t) q6[i]*s->band[0].det) >> 12; |
544 | if (wd < wd1) |
545 | break; |
546 | } |
547 | ilow = (el < 0) ? iln[i] : ilp[i]; |
548 | |
549 | |
550 | ril = ilow >> 2; |
551 | wd2 = qm4[ril]; |
552 | dlow = (int16_t) (((int32_t) s->band[0].det*wd2) >> 15); |
553 | |
554 | |
555 | il4 = rl42[ril]; |
556 | wd = ((int32_t) s->band[0].nb*127) >> 7; |
557 | s->band[0].nb = (int16_t) (wd + wl[il4]); |
558 | if (s->band[0].nb < 0) |
559 | s->band[0].nb = 0; |
560 | else if (s->band[0].nb > 18432) |
561 | s->band[0].nb = 18432; |
562 | |
563 | |
564 | wd1 = (s->band[0].nb >> 6) & 31; |
565 | wd2 = 8 - (s->band[0].nb >> 11); |
566 | wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); |
567 | s->band[0].det = (int16_t) (wd3 << 2); |
568 | |
569 | block4(&s->band[0], dlow); |
570 | |
571 | if (s->eight_k) |
572 | { |
573 | |
574 | code = (0xC0 | ilow) >> (8 - s->bits_per_sample); |
575 | } |
576 | else |
577 | { |
578 | |
579 | eh = sat_sub16(xhigh, s->band[1].s); |
580 | |
581 | |
582 | wd = (eh >= 0) ? eh : ~eh; |
583 | wd1 = (564*s->band[1].det) >> 12; |
584 | mih = (wd >= wd1) ? 2 : 1; |
585 | ihigh = (eh < 0) ? ihn[mih] : ihp[mih]; |
586 | |
587 | |
588 | wd2 = qm2[ihigh]; |
589 | dhigh = (int16_t) (((int32_t) s->band[1].det*wd2) >> 15); |
590 | |
591 | |
592 | ih2 = rh2[ihigh]; |
593 | wd = ((int32_t) s->band[1].nb*127) >> 7; |
594 | s->band[1].nb = (int16_t) (wd + wh[ih2]); |
595 | if (s->band[1].nb < 0) |
596 | s->band[1].nb = 0; |
597 | else if (s->band[1].nb > 22528) |
598 | s->band[1].nb = 22528; |
599 | |
600 | |
601 | wd1 = (s->band[1].nb >> 6) & 31; |
602 | wd2 = 10 - (s->band[1].nb >> 11); |
603 | wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); |
604 | s->band[1].det = (int16_t) (wd3 << 2); |
605 | |
606 | block4(&s->band[1], dhigh); |
607 | code = ((ihigh << 6) | ilow) >> (8 - s->bits_per_sample); |
608 | } |
609 | |
610 | if (s->packed) |
611 | { |
612 | |
613 | s->out_buffer |= (code << s->out_bits); |
614 | s->out_bits += s->bits_per_sample; |
615 | if (s->out_bits >= 8) |
616 | { |
617 | g722_data[g722_bytes++] = (uint8_t) (s->out_buffer & 0xFF); |
618 | s->out_bits -= 8; |
619 | s->out_buffer >>= 8; |
620 | } |
621 | } |
622 | else |
623 | { |
624 | g722_data[g722_bytes++] = (uint8_t) code; |
625 | } |
626 | } |
627 | return g722_bytes; |
628 | } |
629 | |
630 | |