changeset 233:bbdefd2ef950

dev: new program mk-256bytes
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 07 May 2023 21:19:30 +0000
parents 8710c94df334
children c7f02428bda6
files .hgignore dev/Makefile dev/mk-256bytes.c
diffstat 3 files changed, 36 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sun May 07 19:03:36 2023 +0000
+++ b/.hgignore	Sun May 07 21:19:30 2023 +0000
@@ -19,6 +19,7 @@
 ^dev/efr-tidsp\.out$
 ^dev/gsm0611-silence-fr$
 ^dev/gsm0611-silence-fr\.out$
+^dev/mk-256bytes$
 ^dev/s2a-regen$
 ^dev/s2a-regen\.out$
 ^dev/s2u-regen$
--- a/dev/Makefile	Sun May 07 19:03:36 2023 +0000
+++ b/dev/Makefile	Sun May 07 21:19:30 2023 +0000
@@ -1,7 +1,7 @@
 CC=	gcc
 CFLAGS=	-O2
 PROGS=	a2s-regen efr-bit-packing efr-sid-insert efr-tidsp gsm0611-silence-fr \
-	s2a-regen s2u-regen s2u-regen-plus4 u2s-regen
+	mk-256bytes s2a-regen s2u-regen s2u-regen-plus4 u2s-regen
 DATAOUT=a2s-regen.out efr-bit-packing.out efr-sid-insert.out efr-tidsp.out \
 	gsm0611-silence-fr.out s2a-regen.out s2u-regen.out s2u-regen-plus4.out \
 	u2s-regen.out
@@ -38,6 +38,9 @@
 gsm0611-silence-fr.out:	gsm0611-silence-fr
 	./gsm0611-silence-fr > $@
 
+mk-256bytes:	mk-256bytes.c
+	${CC} ${CFLAGS} -o $@ $@.c
+
 s2a-regen:	s2a-regen.c
 	${CC} ${CFLAGS} -o $@ $@.c
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/mk-256bytes.c	Sun May 07 21:19:30 2023 +0000
@@ -0,0 +1,31 @@
+/*
+ * This program generates a binary file of 256 bytes, containing every
+ * possible octet value in linearly increasing order.  The purpose of this
+ * datum is testing of A-linear-A and mu-linear-mu PCM conversions: we need
+ * to ensure that each of those sequences is an identity transform for all
+ * possible PCM octet values.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+main(argc, argv)
+	char **argv;
+{
+	FILE *outf;
+	unsigned val;
+
+	if (argc != 2) {
+		fprintf(stderr, "usage: %s output-bin-file\n", argv[0]);
+		exit(1);
+	}
+	outf = fopen(argv[1], "w");
+	if (!outf) {
+		perror(argv[1]);
+		exit(1);
+	}
+	for (val = 0; val < 256; val++)
+		putc(val, outf);
+	fclose(outf);
+	exit(0);
+}