changeset 149:95d47a34070a

gsmefr-dec-parse: add BE support
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 14 Dec 2022 18:12:55 +0000
parents bbe5669f0f29
children da17c7f02c6c
files efrtest/dec-parse.c
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/efrtest/dec-parse.c	Wed Dec 14 17:21:05 2022 +0000
+++ b/efrtest/dec-parse.c	Wed Dec 14 18:12:55 2022 +0000
@@ -15,27 +15,35 @@
 main(argc, argv)
 	char **argv;
 {
+	char *infname;
 	FILE *inf;
+	int big_endian;
 	unsigned frame_no;
 	uint8_t input_bits[ETSI_DEC_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.dec\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.dec\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_DEC_NWORDS,
-				    argv[1]);
+		rc = read_etsi_bits(inf, big_endian, input_bits,
+				    ETSI_DEC_NWORDS, infname);
 		if (!rc)
 			break;
-		bits2frame(input_bits + 1, frame, argv[1], frame_no);
+		bits2frame(input_bits + 1, frame, infname, frame_no);
 		printf("#%u: BFI=%u SID=%u TAF=%u LPC", frame_no,
 			input_bits[0], input_bits[245], input_bits[246]);
 		EFR_frame2params(frame, params);