static int repack_gsm0610_wav49_to_voip(uint8_t d[], const uint8_t c[]) { gsm0610_frame_t frame[2]; int n[2]; gsm0610_unpack_wav49(frame, c); n[0] = gsm0610_pack_voip(d, &frame[0]); n[1] = gsm0610_pack_voip(d + n[0], &frame[1]); return n[0] + n[1]; }
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; }