FreeCalypso > hg > gsm-codec-lib
annotate miscutil/pcm16-to-ulaw.c @ 585:3c6bf0d26ee7 default tip
TW-TS-005 reader: fix maximum line length bug
TW-TS-005 section 4.1 states:
The maximum allowed length of each line is 80 characters, not
including the OS-specific newline encoding.
The implementation of this line length limit in the TW-TS-005 hex file
reader function in the present suite was wrong, such that lines of
the full maximum length could not be read. Fix it.
Note that this bug affects comment lines too, not just actual RTP
payloads. Neither Annex A nor Annex B features an RTP payload format
that goes to the maximum of 40 bytes, but if a comment line goes to
the maximum allowed length of 80 characters not including the
terminating newline, the bug will be triggered, necessitating
the present fix.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 25 Feb 2025 07:49:28 +0000 |
parents | c7f02428bda6 |
children |
rev | line source |
---|---|
219
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This program reads a 16-bit PCM recording in raw format (robe by default, |
220
c4c45148cde1
miscutil: new program pcm16-to-ulaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
3 * or LE with -l option) and converts it to 8-bit PCM in North American |
229
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
4 * mu-law encoding. It is based on the ulaw_compress() function from ITU-T |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
5 * G.191 STL, using the most significant 14 bits of each input linear PCM |
234
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
6 * sample, rather than just 13. A command line option is also provided |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
7 * to truncate each input value to 13 bits prior to mu-law encoding, to |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
8 * replicate the effect of using a table lookup conversion method that |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
9 * only considers the upper 13 bits - specify -t option to select this mode. |
219
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 */ |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <stdio.h> |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <stdint.h> |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <stdlib.h> |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <string.h> |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include <strings.h> |
234
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
17 #include <unistd.h> |
219
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
229
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
19 static unsigned |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
20 ulaw_compress(input) |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
21 unsigned input; |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
22 { |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
23 short i; /* aux.var. */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
24 short absno; /* absolute value of linear (input) sample */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
25 short segno; /* segment (Table 2/G711, column 1) */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
26 short low_nibble; /* low nibble of log companded sample */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
27 short high_nibble; /* high nibble of log companded sample */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
28 unsigned output; |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
29 |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
30 /* -------------------------------------------------------------------- */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
31 /* Input is 14-bit right-justified in this version */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
32 /* Compute absolute value; adjust for easy processing */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
33 /* -------------------------------------------------------------------- */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
34 absno = input >= 0x2000 /* compute 1's complement in case of */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
35 ? (~input & 0x1FFF) + 33 /* negative samples */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
36 : input + 33; /* NB: 33 is the difference value */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
37 /* between the thresholds for */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
38 /* A-law and u-law. */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
39 if (absno > (0x1FFF)) /* limitation to "absno" < 8192 */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
40 absno = (0x1FFF); |
219
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 |
229
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
42 /* Determination of sample's segment */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
43 i = absno >> 6; |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
44 segno = 1; |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
45 while (i != 0) { |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
46 segno++; |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
47 i >>= 1; |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
48 } |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
49 |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
50 /* Mounting the high-nibble of the log-PCM sample */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
51 high_nibble = (0x0008) - segno; |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
52 |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
53 /* Mounting the low-nibble of the log PCM sample */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
54 low_nibble = (absno >> segno) /* right shift of mantissa and */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
55 &(0x000F); /* masking away leading '1' */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
56 low_nibble = (0x000F) - low_nibble; |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
57 |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
58 /* Joining the high-nibble and the low-nibble of the log PCM sample */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
59 output = (high_nibble << 4) | low_nibble; |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
60 |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
61 /* Add sign bit */ |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
62 if (input < 0x2000) |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
63 output = output | (0x0080); |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
64 |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
65 return output; |
f00bf3687286
pcm16-to-ulaw: replace toast table with STL function
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
66 } |
219
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 main(argc, argv) |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 char **argv; |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 { |
234
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
71 int opt, little_endian = 0, truncate = 0; |
219
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 char *infname, *outfname; |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 FILE *inf, *outf; |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 uint8_t inb[2]; |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 uint16_t ins; |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 int cc; |
234
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
77 extern int optind; |
219
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 |
234
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
79 while ((opt = getopt(argc, argv, "lt")) != EOF) { |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
80 switch (opt) { |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
81 case 'l': |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
82 little_endian = 1; |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
83 continue; |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
84 case 't': |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
85 truncate = 1; |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
86 continue; |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
87 default: |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
88 usage: |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
89 fprintf(stderr, |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
90 "usage: %s [-l] [-t] input.pcm16 output.ulaw\n", |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
91 argv[0]); |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
92 exit(1); |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
93 } |
219
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 } |
234
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
95 if (argc != optind + 2) |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
96 goto usage; |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
97 infname = argv[optind]; |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
98 outfname = argv[optind+1]; |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
99 |
219
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 inf = fopen(infname, "r"); |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 if (!inf) { |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 perror(infname); |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 exit(1); |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 } |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 outf = fopen(outfname, "w"); |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 if (!outf) { |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 perror(outfname); |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 exit(1); |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 } |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 for (;;) { |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 cc = fread(inb, 1, 2, inf); |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 if (cc <= 0) |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 break; |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 if (cc & 1) { |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 fprintf(stderr, "error: %s has odd number of bytes\n", |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 infname); |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 exit(1); |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 } |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 if (little_endian) |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 ins = ((uint16_t) inb[1] << 8) | ((uint16_t) inb[0]); |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 else |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 ins = ((uint16_t) inb[0] << 8) | ((uint16_t) inb[1]); |
234
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
123 ins >>= 2; |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
124 if (truncate) |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
125 ins &= ~1; |
c7f02428bda6
pcm16-to-ulaw: add -t option for 13-bit mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
231
diff
changeset
|
126 putc(ulaw_compress(ins), outf); |
219
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 } |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 fclose(outf); |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 exit(0); |
dc52c3857bf7
miscutil: new program pcm16-to-alaw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 } |