FreeCalypso > hg > gsm-codec-lib
view libgsmfr2/unpack_frame.c @ 534:516e84085a15
libgsmfr2 is now at version 2.1.0
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 20 Sep 2024 00:17:35 +0000 |
parents | f0220c141d2c |
children |
line wrap: on
line source
/* * This module holds our gsmfr_unpack_frame() function: unpacking a single * GSM-FR frame from libgsm/RTP format into a broken-down struct of params. */ #include <stdint.h> #include "tw_gsmfr.h" void gsmfr_unpack_frame(const uint8_t *frame, struct gsmfr_param_frame *param) { const uint8_t *c = frame; unsigned sub; param->LARc[0] = (*c++ & 0xF) << 2; param->LARc[0] |= (*c >> 6) & 0x3; param->LARc[1] = *c++ & 0x3F; param->LARc[2] = (*c >> 3) & 0x1F; param->LARc[3] = (*c++ & 0x7) << 2; param->LARc[3] |= (*c >> 6) & 0x3; param->LARc[4] = (*c >> 2) & 0xF; param->LARc[5] = (*c++ & 0x3) << 2; param->LARc[5] |= (*c >> 6) & 0x3; param->LARc[6] = (*c >> 3) & 0x7; param->LARc[7] = *c++ & 0x7; for (sub = 0; sub < 4; sub++) { param->Nc[sub] = (*c >> 1) & 0x7F; param->bc[sub] = (*c++ & 0x1) << 1; param->bc[sub] |= (*c >> 7) & 0x1; param->Mc[sub] = (*c >> 5) & 0x3; param->xmaxc[sub] = (*c++ & 0x1F) << 1; param->xmaxc[sub] |= (*c >> 7) & 0x1; param->xMc[sub][0] = (*c >> 4) & 0x7; param->xMc[sub][1] = (*c >> 1) & 0x7; param->xMc[sub][2] = (*c++ & 0x1) << 2; param->xMc[sub][2] |= (*c >> 6) & 0x3; param->xMc[sub][3] = (*c >> 3) & 0x7; param->xMc[sub][4] = *c++ & 0x7; param->xMc[sub][5] = (*c >> 5) & 0x7; param->xMc[sub][6] = (*c >> 2) & 0x7; param->xMc[sub][7] = (*c++ & 0x3) << 1; param->xMc[sub][7] |= (*c >> 7) & 0x1; param->xMc[sub][8] = (*c >> 4) & 0x7; param->xMc[sub][9] = (*c >> 1) & 0x7; param->xMc[sub][10] = (*c++ & 0x1) << 2; param->xMc[sub][10] |= (*c >> 6) & 0x3; param->xMc[sub][11] = (*c >> 3) & 0x7; param->xMc[sub][12] = *c++ & 0x7; } }