FreeCalypso > hg > gsm-codec-lib
comparison efrtest/cod-parse.c @ 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 | 46a6e6b6841a |
comparison
equal
deleted
inserted
replaced
147:90b9c7c3fa3b | 148:bbe5669f0f29 |
---|---|
14 #include "etsi.h" | 14 #include "etsi.h" |
15 | 15 |
16 main(argc, argv) | 16 main(argc, argv) |
17 char **argv; | 17 char **argv; |
18 { | 18 { |
19 char *infname; | |
19 FILE *inf; | 20 FILE *inf; |
21 int big_endian; | |
20 unsigned frame_no; | 22 unsigned frame_no; |
21 uint8_t input_bits[ETSI_ENC_NWORDS], frame[EFR_RTP_FRAME_LEN]; | 23 uint8_t input_bits[ETSI_ENC_NWORDS], frame[EFR_RTP_FRAME_LEN]; |
22 int16_t params[EFR_NUM_PARAMS]; | 24 int16_t params[EFR_NUM_PARAMS]; |
23 int rc, i, j, n; | 25 int rc, i, j, n; |
24 | 26 |
25 if (argc != 2) { | 27 if (argc == 2 && argv[1][0] != '-') { |
26 fprintf(stderr, "usage: %s file.cod\n", argv[0]); | 28 big_endian = 0; |
29 infname = argv[1]; | |
30 } else if (argc == 3 && !strcmp(argv[1], "-b")) { | |
31 big_endian = 1; | |
32 infname = argv[2]; | |
33 } else { | |
34 fprintf(stderr, "usage: %s [-b] file.cod\n", argv[0]); | |
27 exit(1); | 35 exit(1); |
28 } | 36 } |
29 inf = fopen(argv[1], "r"); | 37 inf = fopen(infname, "r"); |
30 if (!inf) { | 38 if (!inf) { |
31 perror(argv[1]); | 39 perror(infname); |
32 exit(1); | 40 exit(1); |
33 } | 41 } |
34 for (frame_no = 0; ; frame_no++) { | 42 for (frame_no = 0; ; frame_no++) { |
35 rc = read_etsi_bits(inf, 0, input_bits, ETSI_ENC_NWORDS, | 43 rc = read_etsi_bits(inf, big_endian, input_bits, |
36 argv[1]); | 44 ETSI_ENC_NWORDS, infname); |
37 if (!rc) | 45 if (!rc) |
38 break; | 46 break; |
39 bits2frame(input_bits, frame, argv[1], frame_no); | 47 bits2frame(input_bits, frame, infname, frame_no); |
40 printf("#%u: VAD=%u SP=%u SID=%d LPC", frame_no, | 48 printf("#%u: VAD=%u SP=%u SID=%d LPC", frame_no, |
41 input_bits[244], input_bits[245], | 49 input_bits[244], input_bits[245], |
42 EFR_sid_classify(frame)); | 50 EFR_sid_classify(frame)); |
43 EFR_frame2params(frame, params); | 51 EFR_frame2params(frame, params); |
44 n = 0; | 52 n = 0; |