changeset 20:f5f541bc9415

pcmu2efr: check all generated frames against DHF
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 12 May 2024 03:06:12 +0000
parents 2bdcd2ed9a1c
children 3eb407b08b4c
files .hgignore pcmu2efr/Makefile pcmu2efr/dhf-check.c
diffstat 3 files changed, 53 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sun May 12 00:56:42 2024 +0000
+++ b/.hgignore	Sun May 12 03:06:12 2024 +0000
@@ -10,6 +10,7 @@
 ^dmw/dmw-[au]law\.
 
 ^pcmu2efr/amrefr-out$
+^pcmu2efr/dhf-check$
 ^pcmu2efr/stdefr-diff$
 ^pcmu2efr/stdefr-out$
 
--- a/pcmu2efr/Makefile	Sun May 12 00:56:42 2024 +0000
+++ b/pcmu2efr/Makefile	Sun May 12 03:06:12 2024 +0000
@@ -1,8 +1,10 @@
 CC=	gcc
 CFLAGS=	-O2
-PROGS=	amrefr-out stdefr-diff stdefr-out
+PROGS=	amrefr-out dhf-check stdefr-diff stdefr-out
 
 AMREFR_OBJS=	amrefr-out.o gen-amrefr.o gen160.o seqsyncu.o ulaw-expand.o
+DHF_CHECK_OBJS=	dhf-check.o gen-amrefr.o gen-efr.o gen160.o seqsyncu.o \
+		ulaw-expand.o
 STDEFR_OBJS=	gen-efr.o gen160.o seqsyncu.o stdefr-out.o ulaw-expand.o
 STDEFRD_OBJS=	gen-efr.o gen160.o seqsyncu.o stdefr-diff.o ulaw-expand.o
 
@@ -11,6 +13,9 @@
 amrefr-out:	${AMREFR_OBJS}
 	${CC} ${CFLAGS} -o $@ ${AMREFR_OBJS} -lgsmefr -ltwamr
 
+dhf-check:	${DHF_CHECK_OBJS}
+	${CC} ${CFLAGS} -o $@ ${DHF_CHECK_OBJS} -lgsmefr -ltwamr
+
 stdefr-diff:	${STDEFRD_OBJS}
 	${CC} ${CFLAGS} -o $@ ${STDEFRD_OBJS} -lgsmefr
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pcmu2efr/dhf-check.c	Sun May 12 03:06:12 2024 +0000
@@ -0,0 +1,46 @@
+/*
+ * This program generates both standard-EFR and AMR-EFR versions of
+ * sample-shifted first encoder frame, and checks them against
+ * both EFR and MR122 DHFs.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <gsm_efr.h>
+#include <tw_amr.h>
+
+extern uint8_t standard_efr[160][31];
+extern uint8_t amr_efr[160][31];
+
+static void
+check_for_dhf(efr_frame, name, num)
+	uint8_t *efr_frame;
+	char *name;
+	unsigned num;
+{
+	int16_t params[EFR_NUM_PARAMS];
+
+	EFR_frame2params(efr_frame, params);
+	if (!bcmp(params, amr_dhf_gsmefr, EFR_NUM_PARAMS * sizeof(int16_t)))
+		printf("%s frame %u matches EFR DHF\n", name, num);
+	else if (!bcmp(params, amr_dhf_mr122, EFR_NUM_PARAMS * sizeof(int16_t)))
+		printf("%s frame %u matches MR122 DHF\n", name, num);
+}
+
+main(argc, argv)
+	char **argv;
+{
+	unsigned n;
+
+	generate_linear_inputs();
+	generate_std_efr();
+	generate_amr_efr();
+	for (n = 0; n < 160; n++)
+		check_for_dhf(standard_efr[n], "std EFR", n);
+	for (n = 0; n < 120; n++)
+		check_for_dhf(amr_efr[n], "AMR-EFR", n);
+	exit(0);
+}