comparison amrdiff/readone-amr.c @ 2:75ba83624a29

readone-amr program written
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 03 Apr 2024 19:41:45 +0000
parents
children
comparison
equal deleted inserted replaced
1:33eeeff6ae88 2:75ba83624a29
1 /*
2 * This program reads a single frame (the first one) from an AMR *.cod file,
3 * enforces that this frame is MR122 speech, and emits the frame of 244 bits
4 * as comma-separated ASCII. The intent is to extract the DHF in a form
5 * convenient for inclusion in amrdiff source.
6 */
7
8 #include <stdio.h>
9 #include <stdint.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <strings.h>
13 #include "amr_defs.h"
14
15 main(argc, argv)
16 char **argv;
17 {
18 char *filename;
19 int bigend, rc;
20 FILE *inf;
21 uint8_t amr_bits[COD_FORMAT_NWORDS];
22
23 if (argc != 3) {
24 usage: fprintf(stderr, "usage: %s amr-cod-file be|le\n", argv[0]);
25 exit(1);
26 }
27 filename = argv[1];
28 if (!strcmp(argv[2], "be"))
29 bigend = 1;
30 else if (!strcmp(argv[2], "le"))
31 bigend = 0;
32 else
33 goto usage;
34 inf = fopen(filename, "r");
35 if (!inf) {
36 perror(filename);
37 exit(1);
38 }
39 rc = read_etsi_bits(inf, bigend, amr_bits, COD_FORMAT_NWORDS, filename);
40 if (!rc) {
41 fprintf(stderr, "error: %s is empty\n", filename);
42 exit(1);
43 }
44 if (amr_bits[0] != TX_SPEECH_GOOD || amr_bits[245] != MR122) {
45 fprintf(stderr, "error: frame type is wrong\n");
46 exit(1);
47 }
48 emit_frame244(amr_bits + 1);
49 exit(0);
50 }