changeset 835:516066ac5bc1

tiaud-decomp: support both old-AEC and new-AEC mode files
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 30 Jul 2021 00:23:05 +0000
parents c458e33060bf
children f7e946389f8b
files ffstools/tiaud/decomp.c
diffstat 1 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ffstools/tiaud/decomp.c	Fri Jul 30 00:10:13 2021 +0000
+++ b/ffstools/tiaud/decomp.c	Fri Jul 30 00:23:05 2021 +0000
@@ -14,6 +14,7 @@
 #include "binstruct.h"
 
 struct audio_cfg_bin bin;
+int is_new_aec;
 FILE *outf;
 
 read_bin_file(filename)
@@ -32,11 +33,15 @@
 		fprintf(stderr, "%s is not a regular file\n", filename);
 		exit(1);
 	}
-	if (st.st_size != MODE_FILE_SIZE_OLDAEC) {
+	if (st.st_size == MODE_FILE_SIZE_OLDAEC)
+		is_new_aec = 0;
+	else if (st.st_size == MODE_FILE_SIZE_NEWAEC)
+		is_new_aec = 1;
+	else {
 		fprintf(stderr, "%s has the wrong length\n", filename);
 		exit(1);
 	}
-	read(fd, &bin, MODE_FILE_SIZE_OLDAEC);
+	read(fd, &bin, st.st_size);
 	close(fd);
 }
 
@@ -56,7 +61,7 @@
 
 emit_ascii()
 {
-	int i;
+	int i, num_aec;
 
 	fprintf(outf, "voice-path %u\n", bin.voice_path);
 
@@ -114,8 +119,14 @@
 	fputs("}\n", outf);
 
 	fprintf(outf, "sidetone %d\n", bin.sidetone_gain);
-	fputs("aec", outf);
-	for (i = 0; i < 5; i++) {
+	if (is_new_aec) {
+		fputs("aec-new", outf);
+		num_aec = 12;
+	} else {
+		fputs("aec", outf);
+		num_aec = 5;
+	}
+	for (i = 0; i < num_aec; i++) {
 		putc(' ', outf);
 		if (bin.aec_words[i])
 			fprintf(outf, "0x%X", le16toh(bin.aec_words[i]));