FreeCalypso > hg > gsm-codec-lib
comparison miscutil/amrts-pcm8-compact.c @ 469:7c50864deaff
amrts-pcm8-compact program written
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 13 May 2024 21:06:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
468:4104b0390fab | 469:7c50864deaff |
---|---|
1 /* | |
2 * The set of AMR test sequences shipped by 3GPP as TS 26.074 includes | |
3 * not only linear PCM (13-bit left-justified) and AMR-encoded files, | |
4 * but also 8-bit PCM sequences in both A-law and mu-law. However, | |
5 * those PCM8 sequences are shipped in a stupid and inconvenient format: | |
6 * each 8-bit PCM sample is expanded to a 16-bit word, written in LE | |
7 * byte order. This utility converts a PCM8 test sequence file | |
8 * from this weird format into sane PCM8 format with one byte per sample. | |
9 * For this conversion, it does not matter whether the PCM8 test sequence | |
10 * in question is A-law or mu-law. | |
11 */ | |
12 | |
13 #include <stdio.h> | |
14 #include <stdlib.h> | |
15 | |
16 main(argc, argv) | |
17 char **argv; | |
18 { | |
19 FILE *inf, *outf; | |
20 int cdat, cpad; | |
21 | |
22 if (argc != 3) { | |
23 fprintf(stderr, "usage: %s in-file out-file\n", argv[0]); | |
24 exit(1); | |
25 } | |
26 inf = fopen(argv[1], "r"); | |
27 if (!inf) { | |
28 perror(argv[1]); | |
29 exit(1); | |
30 } | |
31 outf = fopen(argv[2], "w"); | |
32 if (!outf) { | |
33 perror(argv[2]); | |
34 exit(1); | |
35 } | |
36 for (;;) { | |
37 cdat = getc(inf); | |
38 if (cdat < 0) | |
39 break; | |
40 cpad = getc(inf); | |
41 if (cpad < 0) { | |
42 fprintf(stderr, "error: %s has odd length\n", argv[1]); | |
43 exit(1); | |
44 } | |
45 if (cpad != 0) { | |
46 fprintf(stderr, | |
47 "error: presumed padding byte in %s is not 0\n", | |
48 argv[1]); | |
49 exit(1); | |
50 } | |
51 putc(cdat, outf); | |
52 } | |
53 fclose(outf); | |
54 exit(0); | |
55 } |