FreeCalypso > hg > vband-misc
view amrdiff/etsi-bit-rd.c @ 24:c52fb8080faf
pcmu2efr: emit all 320 computed frames
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 12 May 2024 04:28:49 +0000 |
parents | a03c87a2abc6 |
children |
line wrap: on
line source
/* * The utility function in this module reads the bits from ETSI *.cod * files, both AMR and EFR versions, either LE or BE. */ #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "etsi.h" #include "amr_defs.h" read_etsi_bits(inf, big_endian, bitvec, nwords, filename_for_errs) FILE *inf; uint8_t *bitvec; unsigned nwords; char *filename_for_errs; { uint8_t file_bytes[COD_FORMAT_NWORDS * 2], *sp; int cc; unsigned n, upper; cc = fread(file_bytes, 2, nwords, inf); if (cc == 0) return 0; if (cc != nwords) { fprintf(stderr, "error: short read from %s\n", filename_for_errs); exit(1); } sp = file_bytes; for (n = 0; n < nwords; n++) { if (big_endian) { upper = sp[0]; bitvec[n] = sp[1]; } else { bitvec[n] = sp[0]; upper = sp[1]; } if (upper && (sp[0] != 0xFF || sp[1] != 0xFF)) { fprintf(stderr, "error in %s: non-zero in what should be %s upper byte\n", filename_for_errs, big_endian ? "BE" : "LE"); exit(1); } sp += 2; } return 1; }