diff efr-sid/mk-sid-test.c @ 43:8bfc517fda3b

efr-sid: hack created
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 09 Jun 2024 05:57:48 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/efr-sid/mk-sid-test.c	Sun Jun 09 05:57:48 2024 +0000
@@ -0,0 +1,55 @@
+/*
+ * This program generates a sequence of 95 EFR codec frames that starts
+ * with a perfect SID and is degraded by one bit in the SID field
+ * on every output frame.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <gsm_efr.h>
+#include "etsi.h"
+
+extern const uint8_t SID_codeword_bit_idx[95];
+
+static void
+read_input_file(filename, cod_frame)
+	char *filename;
+	uint8_t *cod_frame;
+{
+	FILE *inf;
+
+	inf = fopen(filename, "r");
+	if (!inf) {
+		perror(filename);
+		exit(1);
+	}
+	read_etsi_bits(inf, 0, cod_frame, ETSI_ENC_NWORDS, filename);
+	fclose(inf);
+}
+
+main(argc, argv)
+	char **argv;
+{
+	uint8_t cod_frame[ETSI_ENC_NWORDS], packed_frame[EFR_RTP_FRAME_LEN];
+	FILE *outf;
+	unsigned nf;
+
+	if (argc != 3) {
+		fprintf(stderr, "usage: %s input.cod output.gsmx\n", argv[0]);
+		exit(1);
+	}
+	read_input_file(argv[1], cod_frame);
+	outf = fopen(argv[2], "w");
+	if (!outf) {
+		perror(argv[2]);
+		exit(1);
+	}
+	for (nf = 0; nf < 95; nf++) {
+		bits2frame(cod_frame, packed_frame, argv[1], 0);
+		fwrite(packed_frame, 1, EFR_RTP_FRAME_LEN, outf);
+		cod_frame[SID_codeword_bit_idx[nf]] = 0;
+	}
+	fclose(outf);
+	exit(0);
+}