changeset 32:baf74dff5368

dhf: generate hex forms of EFR DHF
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 13 May 2024 06:26:22 +0000
parents dd9a9368009e
children c1aa6a4160f6
files .hgignore Makefile dhf/Makefile dhf/efr-dhf-hexout.c
diffstat 4 files changed, 57 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon May 13 05:56:13 2024 +0000
+++ b/.hgignore	Mon May 13 06:26:22 2024 +0000
@@ -6,6 +6,9 @@
 ^amrdiff/readone-amr$
 ^amrdiff/readone-efr$
 
+^dhf/efr-dhf-hex\.txt$
+^dhf/efr-dhf-hexout$
+
 ^dmw/gen-dmw-bin$
 ^dmw/dmw-[au]law\.
 
--- a/Makefile	Mon May 13 05:56:13 2024 +0000
+++ b/Makefile	Mon May 13 06:26:22 2024 +0000
@@ -1,4 +1,4 @@
-SUBDIR=	amrdiff dmw pcma2efr pcmu2efr ringing utils
+SUBDIR=	amrdiff dhf dmw pcma2efr pcmu2efr ringing utils
 
 all:	${SUBDIR}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dhf/Makefile	Mon May 13 06:26:22 2024 +0000
@@ -0,0 +1,15 @@
+CC=	gcc
+CFLAGS=	-O2
+PROG=	efr-dhf-hexout
+OUTFILE=efr-dhf-hex.txt
+
+all:	${PROG} ${OUTFILE}
+
+${PROG}:	${PROG}.c
+	${CC} ${CFLAGS} -o $@ $@.c -lgsmefr -ltwamr
+
+${OUTFILE}:	${PROG}
+	./${PROG} > $@
+
+clean:
+	rm -f *.o ${PROG} *.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dhf/efr-dhf-hexout.c	Mon May 13 06:26:22 2024 +0000
@@ -0,0 +1,38 @@
+/*
+ * This little program takes EFR and MR122 DHFs provided in array-of-params
+ * form by libtwamr, turns them into EFR RTP format using libgsmefr function,
+ * and emits those two RTP-encoded EFR frames in hex, for inclusion in other
+ * C sources.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <gsm_efr.h>
+#include <tw_amr.h>
+
+static void
+emit_one_frame(params, name)
+	const int16_t *params;
+	char *name;
+{
+	uint8_t efr_rtp[EFR_RTP_FRAME_LEN];
+	unsigned n;
+
+	EFR_params2frame(params, efr_rtp);
+	printf("%s:\n\n", name);
+	for (n = 0; n < EFR_RTP_FRAME_LEN; n++) {
+		printf("0x%02X,", efr_rtp[n]);
+		if (n == 15 || n == 30)
+			putchar('\n');
+	}
+	putchar('\n');
+}
+
+main(argc, argv)
+	char **argv;
+{
+	emit_one_frame(amr_dhf_gsmefr, "EFR DHF");
+	emit_one_frame(amr_dhf_mr122, "MR122 DHF");
+	exit(0);
+}