changeset 102:dd88f9312170

gsm-amr2efr: forgot about AMR file header
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 27 Nov 2022 05:20:08 +0000
parents d86f866489e9
children 0123ca1f1402
files miscutil/amr2efr.c
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/miscutil/amr2efr.c	Sun Nov 27 05:15:39 2022 +0000
+++ b/miscutil/amr2efr.c	Sun Nov 27 05:20:08 2022 +0000
@@ -13,6 +13,8 @@
 
 extern const uint8_t amr_122_bit_order[244];
 
+static const char amr_file_hdr[] = "#!AMR\n";
+
 main(argc, argv)
 	char **argv;
 {
@@ -30,6 +32,10 @@
 		perror(argv[1]);
 		exit(1);
 	}
+	if (fread(frm_in, 1, 6, inf) != 6 || bcmp(frm_in, amr_file_hdr, 6)) {
+		fprintf(stderr, "error: %s is not in AMR format\n", argv[1]);
+		exit(1);
+	}
 	outf = fopen(argv[2], "w");
 	if (!outf) {
 		perror(argv[2]);