changeset 4:5aeebdcbddad

readone-efr program written
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 03 Apr 2024 20:07:50 +0000
parents 82c2d1a2f608
children 6ac30bef2b4b
files .hgignore amrdiff/Makefile amrdiff/readone-efr.c
diffstat 3 files changed, 51 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Wed Apr 03 19:45:29 2024 +0000
+++ b/.hgignore	Wed Apr 03 20:07:50 2024 +0000
@@ -4,3 +4,4 @@
 
 ^amrdiff/amrdiff$
 ^amrdiff/readone-amr$
+^amrdiff/readone-efr$
--- a/amrdiff/Makefile	Wed Apr 03 19:45:29 2024 +0000
+++ b/amrdiff/Makefile	Wed Apr 03 20:07:50 2024 +0000
@@ -1,9 +1,10 @@
 CC=	gcc
 CFLAGS=	-O2
-PROGS=	amrdiff readone-amr
+PROGS=	amrdiff readone-amr readone-efr
 
 AMRDIFF_OBJS=	amrdiff.o etsi-bit-rd.o
 RD_AMR_OBJS=	etsi-bit-rd.o readone-amr.o readone-common.o
+RD_EFR_OBJS=	etsi-bit-rd.o readone-common.o readone-efr.o
 
 all:	${PROGS}
 
@@ -13,5 +14,8 @@
 readone-amr:	${RD_AMR_OBJS}
 	${CC} ${CFLAGS} -o $@ ${RD_AMR_OBJS}
 
+readone-efr:	${RD_EFR_OBJS}
+	${CC} ${CFLAGS} -o $@ ${RD_EFR_OBJS}
+
 clean:
 	rm -f *.o ${PROGS}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/amrdiff/readone-efr.c	Wed Apr 03 20:07:50 2024 +0000
@@ -0,0 +1,45 @@
+/*
+ * This program reads a single frame (the first one) from an EFR *.cod file
+ * and emits this frame of 244 bits as comma-separated ASCII.  The intent is
+ * to extract the DHF in a form convenient for inclusion in amrdiff source.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include "etsi.h"
+
+main(argc, argv)
+	char **argv;
+{
+	char *filename;
+	int bigend, rc;
+	FILE *inf;
+	uint8_t efr_bits[ETSI_ENC_NWORDS];
+
+	if (argc != 3) {
+usage:		fprintf(stderr, "usage: %s efr-cod-file be|le\n", argv[0]);
+		exit(1);
+	}
+	filename = argv[1];
+	if (!strcmp(argv[2], "be"))
+		bigend = 1;
+	else if (!strcmp(argv[2], "le"))
+		bigend = 0;
+	else
+		goto usage;
+	inf = fopen(filename, "r");
+	if (!inf) {
+		perror(filename);
+		exit(1);
+	}
+	rc = read_etsi_bits(inf, bigend, efr_bits, ETSI_ENC_NWORDS, filename);
+	if (!rc) {
+		fprintf(stderr, "error: %s is empty\n", filename);
+		exit(1);
+	}
+	emit_frame244(efr_bits);
+	exit(0);
+}