view libgsmfr2/unpack_frame.c @ 602:72cdae602d6e

libgsmhr1/dec_func.c: rm unused static functions In the original code, sp_dec.c held two kinds of functions: those needed only as part of the decoder, and those used by both decoder and encoder engines. In this library, we have moved the latter class of functions to dec_func.c module. Almost all static functions from the original sp_dec.c, with the exception of aToRc(), are needed only on sp_dec.c side of the new divide - remove them from dec_func.c, where they became dead code.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 04 Dec 2025 18:58:22 +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;
	}
}