FreeCalypso > hg > vband-misc
changeset 2:75ba83624a29
readone-amr program written
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 03 Apr 2024 19:41:45 +0000 |
parents | 33eeeff6ae88 |
children | 82c2d1a2f608 |
files | .hgignore amrdiff/Makefile amrdiff/readone-amr.c amrdiff/readone-common.c |
diffstat | 4 files changed, 83 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Wed Apr 03 19:10:09 2024 +0000 +++ b/.hgignore Wed Apr 03 19:41:45 2024 +0000 @@ -3,3 +3,4 @@ \.[oa]$ ^amrdiff/amrdiff$ +^amrdiff/readone-amr$
--- a/amrdiff/Makefile Wed Apr 03 19:10:09 2024 +0000 +++ b/amrdiff/Makefile Wed Apr 03 19:41:45 2024 +0000 @@ -1,12 +1,17 @@ CC= gcc CFLAGS= -O2 -PROG= amrdiff -OBJS= amrdiff.o etsi-bit-rd.o +PROGS= amrdiff readone-amr + +AMRDIFF_OBJS= amrdiff.o etsi-bit-rd.o +RD_AMR_OBJS= etsi-bit-rd.o readone-amr.o readone-common.o -all: ${PROG} +all: ${PROGS} -${PROG}: ${OBJS} - ${CC} ${CFLAGS} -o $@ ${OBJS} +amrdiff: ${AMRDIFF_OBJS} + ${CC} ${CFLAGS} -o $@ ${AMRDIFF_OBJS} + +readone-amr: ${RD_AMR_OBJS} + ${CC} ${CFLAGS} -o $@ ${RD_AMR_OBJS} clean: - rm -f *.o ${PROG} + rm -f *.o ${PROGS}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/amrdiff/readone-amr.c Wed Apr 03 19:41:45 2024 +0000 @@ -0,0 +1,50 @@ +/* + * This program reads a single frame (the first one) from an AMR *.cod file, + * enforces that this frame is MR122 speech, and emits the frame of 244 bits + * as comma-separated ASCII. The intent is to extract the DHF in a form + * convenient for inclusion in amrdiff source. + */ + +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include "amr_defs.h" + +main(argc, argv) + char **argv; +{ + char *filename; + int bigend, rc; + FILE *inf; + uint8_t amr_bits[COD_FORMAT_NWORDS]; + + if (argc != 3) { +usage: fprintf(stderr, "usage: %s amr-cod-file be|le\n", argv[0]); + exit(1); + } + filename = argv[1]; + if (!strcmp(argv[2], "be")) + bigend = 1; + else if (!strcmp(argv[2], "le")) + bigend = 0; + else + goto usage; + inf = fopen(filename, "r"); + if (!inf) { + perror(filename); + exit(1); + } + rc = read_etsi_bits(inf, bigend, amr_bits, COD_FORMAT_NWORDS, filename); + if (!rc) { + fprintf(stderr, "error: %s is empty\n", filename); + exit(1); + } + if (amr_bits[0] != TX_SPEECH_GOOD || amr_bits[245] != MR122) { + fprintf(stderr, "error: frame type is wrong\n"); + exit(1); + } + emit_frame244(amr_bits + 1); + exit(0); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/amrdiff/readone-common.c Wed Apr 03 19:41:45 2024 +0000 @@ -0,0 +1,21 @@ +/* + * The function in this module is common between readone-amr and readone-efr. + */ + +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> + +emit_frame244(bits) + uint8_t *bits; +{ + unsigned n; + + for (n = 0; n < 244; n++) { + printf("%u,", bits[n]); + if (n % 40 == 39 || n == 243) + putchar('\n'); + } +}