static int repack_gsm0610_voip_to_wav49(uint8_t c[], const uint8_t d[]) { gsm0610_frame_t frame[2]; int n; n = gsm0610_unpack_voip(&frame[0], d); gsm0610_unpack_voip(&frame[1], d + n); n = gsm0610_pack_wav49(c, frame); return n; }
SPAN_DECLARE(int) gsm0610_decode(gsm0610_state_t *s, int16_t amp[], const uint8_t code[], int len) { gsm0610_frame_t frame[2]; int bytes; int samples; int i; samples = 0; for (i = 0; i < len; i += bytes) { switch (s->packing) { default: case GSM0610_PACKING_NONE: if ((bytes = gsm0610_unpack_none(frame, &code[i])) < 0) return 0; decode_a_frame(s, &[samples], frame); samples += GSM0610_FRAME_LEN; break; case GSM0610_PACKING_WAV49: if ((bytes = gsm0610_unpack_wav49(frame, &code[i])) < 0) return 0; decode_a_frame(s, &[samples], frame); samples += GSM0610_FRAME_LEN; decode_a_frame(s, &[samples], frame + 1); samples += GSM0610_FRAME_LEN; break; case GSM0610_PACKING_VOIP: if ((bytes = gsm0610_unpack_voip(frame, &code[i])) < 0) return 0; decode_a_frame(s, &[samples], frame); samples += GSM0610_FRAME_LEN; break; } /*endswitch*/ } /*endfor*/ return samples; }
int gsm0610_decode(gsm0610_state_t *s, int16_t amp[], const uint8_t code[], int quant) { gsm0610_frame_t frame; const uint8_t *c; int bytes; int i; if (s->packing == GSM0610_PACKING_WAV49) quant <<= 1; c = code; for (i = 0; i < quant; i++) { switch (s->packing) { default: case GSM0610_PACKING_NONE: bytes = gsm0610_unpack_none(&frame, c); break; case GSM0610_PACKING_WAV49: s->frame_index = !s->frame_index; bytes = gsm0610_unpack_wav49(&frame, c, s->frame_index); break; case GSM0610_PACKING_VOIP: bytes = gsm0610_unpack_voip(&frame, c); break; } /*endswitch*/ if (bytes < 0) return 0; decode_a_frame(s, amp, &frame); c += bytes; amp += GSM0610_FRAME_LEN; } /*endwhile*/ return quant*GSM0610_FRAME_LEN; }