FreeCalypso > hg > vband-misc
comparison amrdiff/etsi-bit-rd.c @ 0:a03c87a2abc6
amrdiff program written
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 03 Apr 2024 18:44:27 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a03c87a2abc6 |
---|---|
1 /* | |
2 * The utility function in this module reads the bits from ETSI *.cod | |
3 * files, both AMR and EFR versions, either LE or BE. | |
4 */ | |
5 | |
6 #include <stdio.h> | |
7 #include <stdint.h> | |
8 #include <stdlib.h> | |
9 #include <string.h> | |
10 #include <strings.h> | |
11 #include "etsi.h" | |
12 #include "amr_defs.h" | |
13 | |
14 read_etsi_bits(inf, big_endian, bitvec, nwords, filename_for_errs) | |
15 FILE *inf; | |
16 uint8_t *bitvec; | |
17 unsigned nwords; | |
18 char *filename_for_errs; | |
19 { | |
20 uint8_t file_bytes[COD_FORMAT_NWORDS * 2], *sp; | |
21 int cc; | |
22 unsigned n, upper; | |
23 | |
24 cc = fread(file_bytes, 2, nwords, inf); | |
25 if (cc == 0) | |
26 return 0; | |
27 if (cc != nwords) { | |
28 fprintf(stderr, "error: short read from %s\n", | |
29 filename_for_errs); | |
30 exit(1); | |
31 } | |
32 sp = file_bytes; | |
33 for (n = 0; n < nwords; n++) { | |
34 if (big_endian) { | |
35 upper = sp[0]; | |
36 bitvec[n] = sp[1]; | |
37 } else { | |
38 bitvec[n] = sp[0]; | |
39 upper = sp[1]; | |
40 } | |
41 if (upper && (sp[0] != 0xFF || sp[1] != 0xFF)) { | |
42 fprintf(stderr, | |
43 "error in %s: non-zero in what should be %s upper byte\n", | |
44 filename_for_errs, big_endian ? "BE" : "LE"); | |
45 exit(1); | |
46 } | |
47 sp += 2; | |
48 } | |
49 return 1; | |
50 } |