view libgsmefr/params2frame.c @ 546:b26df31124a4

frtest: new program gsmfr-tfo-xfrm
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 04 Oct 2024 19:07:52 +0000
parents 88468d5b3590
children
line wrap: on
line source

/*
 * In this module we implement our EFR_params2frame() packing function.
 */

#include "gsm_efr.h"

#define	EFR_MAGIC	0xC

void EFR_params2frame(const int16_t *params, uint8_t *frame)
{
	uint8_t *c = frame;

	*c++ =   ((EFR_MAGIC & 0xF) << 4)
	       | ((params[0] >> 3) & 0xF);
	*c++ =   ((params[0] & 0x7) << 5)
	       | ((params[1] >> 3) & 0x1F);
	*c++ =   ((params[1] & 0x7) << 5)
	       | ((params[2] >> 4) & 0x1F);
	*c++ =   ((params[2] & 0xF) << 4)
	       | ((params[3] >> 4) & 0xF);
	*c++ =   ((params[3] & 0xF) << 4)
	       | ((params[4] >> 2) & 0xF);
	*c++ =   ((params[4] & 0x3) << 6)
	       | ((params[5] >> 3) & 0x3F);
	*c++ =   ((params[5] & 0x7) << 5)
	       | ((params[6] & 0xF) << 1)
	       | ((params[7] >> 3) & 0x1);
	*c++ =   ((params[7] & 0x7) << 5)
	       | ((params[8] & 0xF) << 1)
	       | ((params[9] >> 3) & 0x1);
	*c++ =   ((params[9] & 0x7) << 5)
	       | ((params[10] & 0xF) << 1)
	       | ((params[11] >> 3) & 0x1);
	*c++ =   ((params[11] & 0x7) << 5)
	       | ((params[12] & 0x7) << 2)
	       | ((params[13] >> 1) & 0x3);
	*c++ =   ((params[13] & 0x1) << 7)
	       | ((params[14] & 0x7) << 4)
	       | ((params[15] & 0x7) << 1)
	       | ((params[16] >> 2) & 0x1);
	*c++ =   ((params[16] & 0x3) << 6)
	       | ((params[17] & 0x1F) << 1)
	       | ((params[18] >> 5) & 0x1);
	*c++ =   ((params[18] & 0x1F) << 3)
	       | ((params[19] >> 1) & 0x7);
	*c++ =   ((params[19] & 0x1) << 7)
	       | ((params[20] & 0xF) << 3)
	       | ((params[21] >> 1) & 0x7);
	*c++ =   ((params[21] & 0x1) << 7)
	       | ((params[22] & 0xF) << 3)
	       | ((params[23] >> 1) & 0x7);
	*c++ =   ((params[23] & 0x1) << 7)
	       | ((params[24] & 0xF) << 3)
	       | (params[25] & 0x7);
	*c++ =   ((params[26] & 0x7) << 5)
	       | ((params[27] & 0x7) << 2)
	       | ((params[28] >> 1) & 0x3);
	*c++ =   ((params[28] & 0x1) << 7)
	       | ((params[29] & 0x7) << 4)
	       | ((params[30] >> 1) & 0xF);
	*c++ =   ((params[30] & 0x1) << 7)
	       | ((params[31] >> 2) & 0x7F);
	*c++ =   ((params[31] & 0x3) << 6)
	       | ((params[32] & 0xF) << 2)
	       | ((params[33] >> 2) & 0x3);
	*c++ =   ((params[33] & 0x3) << 6)
	       | ((params[34] & 0xF) << 2)
	       | ((params[35] >> 2) & 0x3);
	*c++ =   ((params[35] & 0x3) << 6)
	       | ((params[36] & 0xF) << 2)
	       | ((params[37] >> 2) & 0x3);
	*c++ =   ((params[37] & 0x3) << 6)
	       | ((params[38] & 0x7) << 3)
	       | (params[39] & 0x7);
	*c++ =   ((params[40] & 0x7) << 5)
	       | ((params[41] & 0x7) << 2)
	       | ((params[42] >> 1) & 0x3);
	*c++ =   ((params[42] & 0x1) << 7)
	       | ((params[43] & 0x1F) << 2)
	       | ((params[44] >> 4) & 0x3);
	*c++ =   ((params[44] & 0xF) << 4)
	       | (params[45] & 0xF);
	*c++ =   ((params[46] & 0xF) << 4)
	       | (params[47] & 0xF);
	*c++ =   ((params[48] & 0xF) << 4)
	       | (params[49] & 0xF);
	*c++ =   ((params[50] & 0xF) << 4)
	       | ((params[51] & 0x7) << 1)
	       | ((params[52] >> 2) & 0x1);
	*c++ =   ((params[52] & 0x3) << 6)
	       | ((params[53] & 0x7) << 3)
	       | (params[54] & 0x7);
	*c++ =   ((params[55] & 0x7) << 5)
	       | (params[56] & 0x1F);
}