changeset 34:69b9cbca075b

libgsmefr: implement frame unpacking
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 24 Nov 2022 02:02:28 +0000
parents 88468d5b3590
children 3b5958f28a40
files libgsmefr/Makefile libgsmefr/frame2params.c
diffstat 2 files changed, 94 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libgsmefr/Makefile	Thu Nov 24 01:57:57 2022 +0000
+++ b/libgsmefr/Makefile	Thu Nov 24 02:02:28 2022 +0000
@@ -1,6 +1,6 @@
 CC=	gcc
 CFLAGS=	-O2
-OBJS=	params2frame.o sidclass.o
+OBJS=	frame2params.o params2frame.o sidclass.o
 LIB=	libgsmefr.a
 
 INSTALL_PREFIX=	/usr/local
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgsmefr/frame2params.c	Thu Nov 24 02:02:28 2022 +0000
@@ -0,0 +1,93 @@
+/*
+ * In this module we implement our EFR_frame2params() unpacking function.
+ */
+
+#include "gsm_efr.h"
+
+void EFR_frame2params(const uint8_t *frame, int16_t *params)
+{
+	const uint8_t *c;
+
+	/* EFR_MAGIC  = (*c >> 4) & 0xF; */
+	params[0]  = (*c++ & 0xF) << 3;
+	params[0] |= (*c >> 5) & 0x7;
+	params[1]  = (*c++ & 0x1F) << 3;
+	params[1] |= (*c >> 5) & 0x7;
+	params[2]  = (*c++ & 0x1F) << 4;
+	params[2] |= (*c >> 4) & 0xF;
+	params[3]  = (*c++ & 0xF) << 4;
+	params[3] |= (*c >> 4) & 0xF;
+	params[4]  = (*c++ & 0xF) << 2;
+	params[4] |= (*c >> 6) & 0x3;
+	params[5]  = (*c++ & 0x3F) << 3;
+	params[5] |= (*c >> 5) & 0x7;
+	params[6]  = (*c >> 1) & 0xF;
+	params[7]  = (*c++ & 0x1) << 3;
+	params[7] |= (*c >> 5) & 0x7;
+	params[8]  = (*c >> 1) & 0xF;
+	params[9]  = (*c++ & 0x1) << 3;
+	params[9] |= (*c >> 5) & 0x7;
+	params[10]  = (*c >> 1) & 0xF;
+	params[11]  = (*c++ & 0x1) << 3;
+	params[11] |= (*c >> 5) & 0x7;
+	params[12]  = (*c >> 2) & 0x7;
+	params[13]  = (*c++ & 0x3) << 1;
+	params[13] |= (*c >> 7) & 0x1;
+	params[14]  = (*c >> 4) & 0x7;
+	params[15]  = (*c >> 1) & 0x7;
+	params[16]  = (*c++ & 0x1) << 2;
+	params[16] |= (*c >> 6) & 0x3;
+	params[17]  = (*c >> 1) & 0x1F;
+	params[18]  = (*c++ & 0x1) << 5;
+	params[18] |= (*c >> 3) & 0x1F;
+	params[19]  = (*c++ & 0x7) << 1;
+	params[19] |= (*c >> 7) & 0x1;
+	params[20]  = (*c >> 3) & 0xF;
+	params[21]  = (*c++ & 0x7) << 1;
+	params[21] |= (*c >> 7) & 0x1;
+	params[22]  = (*c >> 3) & 0xF;
+	params[23]  = (*c++ & 0x7) << 1;
+	params[23] |= (*c >> 7) & 0x1;
+	params[24]  = (*c >> 3) & 0xF;
+	params[25]  = *c++ & 0x7;
+	params[26]  = (*c >> 5) & 0x7;
+	params[27]  = (*c >> 2) & 0x7;
+	params[28]  = (*c++ & 0x3) << 1;
+	params[28] |= (*c >> 7) & 0x1;
+	params[29]  = (*c >> 4) & 0x7;
+	params[30]  = (*c++ & 0xF) << 1;
+	params[30] |= (*c >> 7) & 0x1;
+	params[31]  = (*c++ & 0x7F) << 2;
+	params[31] |= (*c >> 6) & 0x3;
+	params[32]  = (*c >> 2) & 0xF;
+	params[33]  = (*c++ & 0x3) << 2;
+	params[33] |= (*c >> 6) & 0x3;
+	params[34]  = (*c >> 2) & 0xF;
+	params[35]  = (*c++ & 0x3) << 2;
+	params[35] |= (*c >> 6) & 0x3;
+	params[36]  = (*c >> 2) & 0xF;
+	params[37]  = (*c++ & 0x3) << 2;
+	params[37] |= (*c >> 6) & 0x3;
+	params[38]  = (*c >> 3) & 0x7;
+	params[39]  = *c++ & 0x7;
+	params[40]  = (*c >> 5) & 0x7;
+	params[41]  = (*c >> 2) & 0x7;
+	params[42]  = (*c++ & 0x3) << 1;
+	params[42] |= (*c >> 7) & 0x1;
+	params[43]  = (*c >> 2) & 0x1F;
+	params[44]  = (*c++ & 0x3) << 4;
+	params[44] |= (*c >> 4) & 0xF;
+	params[45]  = *c++ & 0xF;
+	params[46]  = (*c >> 4) & 0xF;
+	params[47]  = *c++ & 0xF;
+	params[48]  = (*c >> 4) & 0xF;
+	params[49]  = *c++ & 0xF;
+	params[50]  = (*c >> 4) & 0xF;
+	params[51]  = (*c >> 1) & 0x7;
+	params[52]  = (*c++ & 0x1) << 2;
+	params[52] |= (*c >> 6) & 0x3;
+	params[53]  = (*c >> 3) & 0x7;
+	params[54]  = *c++ & 0x7;
+	params[55]  = (*c >> 5) & 0x7;
+	params[56]  = *c++ & 0x1F;
+}