changeset 148:bbe5669f0f29

gsmefr-cod-parse: add BE support
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 14 Dec 2022 17:21:05 +0000
parents 90b9c7c3fa3b
children 95d47a34070a
files efrtest/cod-parse.c
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/efrtest/cod-parse.c	Wed Dec 14 08:09:52 2022 +0000
+++ b/efrtest/cod-parse.c	Wed Dec 14 17:21:05 2022 +0000
@@ -16,27 +16,35 @@
 main(argc, argv)
 	char **argv;
 {
+	char *infname;
 	FILE *inf;
+	int big_endian;
 	unsigned frame_no;
 	uint8_t input_bits[ETSI_ENC_NWORDS], frame[EFR_RTP_FRAME_LEN];
 	int16_t params[EFR_NUM_PARAMS];
 	int rc, i, j, n;
 
-	if (argc != 2) {
-		fprintf(stderr, "usage: %s file.cod\n", argv[0]);
+	if (argc == 2 && argv[1][0] != '-') {
+		big_endian = 0;
+		infname = argv[1];
+	} else if (argc == 3 && !strcmp(argv[1], "-b")) {
+		big_endian = 1;
+		infname = argv[2];
+	} else {
+		fprintf(stderr, "usage: %s [-b] file.cod\n", argv[0]);
 		exit(1);
 	}
-	inf = fopen(argv[1], "r");
+	inf = fopen(infname, "r");
 	if (!inf) {
-		perror(argv[1]);
+		perror(infname);
 		exit(1);
 	}
 	for (frame_no = 0; ; frame_no++) {
-		rc = read_etsi_bits(inf, 0, input_bits, ETSI_ENC_NWORDS,
-				    argv[1]);
+		rc = read_etsi_bits(inf, big_endian, input_bits,
+				    ETSI_ENC_NWORDS, infname);
 		if (!rc)
 			break;
-		bits2frame(input_bits, frame, argv[1], frame_no);
+		bits2frame(input_bits, frame, infname, frame_no);
 		printf("#%u: VAD=%u SP=%u SID=%d LPC", frame_no,
 			input_bits[244], input_bits[245],
 			EFR_sid_classify(frame));