comparison ffstools/tiaud/decomp.c @ 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
comparison
equal deleted inserted replaced
834:c458e33060bf 835:516066ac5bc1
12 #include <stdlib.h> 12 #include <stdlib.h>
13 #include <unistd.h> 13 #include <unistd.h>
14 #include "binstruct.h" 14 #include "binstruct.h"
15 15
16 struct audio_cfg_bin bin; 16 struct audio_cfg_bin bin;
17 int is_new_aec;
17 FILE *outf; 18 FILE *outf;
18 19
19 read_bin_file(filename) 20 read_bin_file(filename)
20 char *filename; 21 char *filename;
21 { 22 {
30 fstat(fd, &st); 31 fstat(fd, &st);
31 if (!S_ISREG(st.st_mode)) { 32 if (!S_ISREG(st.st_mode)) {
32 fprintf(stderr, "%s is not a regular file\n", filename); 33 fprintf(stderr, "%s is not a regular file\n", filename);
33 exit(1); 34 exit(1);
34 } 35 }
35 if (st.st_size != MODE_FILE_SIZE_OLDAEC) { 36 if (st.st_size == MODE_FILE_SIZE_OLDAEC)
37 is_new_aec = 0;
38 else if (st.st_size == MODE_FILE_SIZE_NEWAEC)
39 is_new_aec = 1;
40 else {
36 fprintf(stderr, "%s has the wrong length\n", filename); 41 fprintf(stderr, "%s has the wrong length\n", filename);
37 exit(1); 42 exit(1);
38 } 43 }
39 read(fd, &bin, MODE_FILE_SIZE_OLDAEC); 44 read(fd, &bin, st.st_size);
40 close(fd); 45 close(fd);
41 } 46 }
42 47
43 emit_fir(table) 48 emit_fir(table)
44 uint16_t *table; 49 uint16_t *table;
54 } 59 }
55 } 60 }
56 61
57 emit_ascii() 62 emit_ascii()
58 { 63 {
59 int i; 64 int i, num_aec;
60 65
61 fprintf(outf, "voice-path %u\n", bin.voice_path); 66 fprintf(outf, "voice-path %u\n", bin.voice_path);
62 67
63 switch (bin.mic_mode) { 68 switch (bin.mic_mode) {
64 case AUDIO_MICROPHONE_HANDHELD: 69 case AUDIO_MICROPHONE_HANDHELD:
112 } else 117 } else
113 fprintf(outf, "\tactivate %d\n", bin.speaker_bytes[0]); 118 fprintf(outf, "\tactivate %d\n", bin.speaker_bytes[0]);
114 fputs("}\n", outf); 119 fputs("}\n", outf);
115 120
116 fprintf(outf, "sidetone %d\n", bin.sidetone_gain); 121 fprintf(outf, "sidetone %d\n", bin.sidetone_gain);
117 fputs("aec", outf); 122 if (is_new_aec) {
118 for (i = 0; i < 5; i++) { 123 fputs("aec-new", outf);
124 num_aec = 12;
125 } else {
126 fputs("aec", outf);
127 num_aec = 5;
128 }
129 for (i = 0; i < num_aec; i++) {
119 putc(' ', outf); 130 putc(' ', outf);
120 if (bin.aec_words[i]) 131 if (bin.aec_words[i])
121 fprintf(outf, "0x%X", le16toh(bin.aec_words[i])); 132 fprintf(outf, "0x%X", le16toh(bin.aec_words[i]));
122 else 133 else
123 putc('0', outf); 134 putc('0', outf);