cannam@125
|
1 The files in this directory comprise ANSI-C language reference implementations
|
cannam@125
|
2 of the CCITT (International Telegraph and Telephone Consultative Committee)
|
cannam@125
|
3 G.711, G.721 and G.723 voice compressions. They have been tested on Sun
|
cannam@125
|
4 SPARCstations and passed 82 out of 84 test vectors published by CCITT
|
cannam@125
|
5 (Dec. 20, 1988) for G.721 and G.723. [The two remaining test vectors,
|
cannam@125
|
6 which the G.721 decoder implementation for u-law samples did not pass,
|
cannam@125
|
7 may be in error because they are identical to two other vectors for G.723_40.]
|
cannam@125
|
8
|
cannam@125
|
9 This source code is released by Sun Microsystems, Inc. to the public domain.
|
cannam@125
|
10 Please give your acknowledgement in product literature if this code is used
|
cannam@125
|
11 in your product implementation.
|
cannam@125
|
12
|
cannam@125
|
13 Sun Microsystems supports some CCITT audio formats in Solaris 2.0 system
|
cannam@125
|
14 software. However, Sun's implementations have been optimized for higher
|
cannam@125
|
15 performance on SPARCstations.
|
cannam@125
|
16
|
cannam@125
|
17
|
cannam@125
|
18 The source files for CCITT conversion routines in this directory are:
|
cannam@125
|
19
|
cannam@125
|
20 g72x.h header file for g721.c, g723_24.c and g723_40.c
|
cannam@125
|
21 g711.c CCITT G.711 u-law and A-law compression
|
cannam@125
|
22 g72x.c common denominator of G.721 and G.723 ADPCM codes
|
cannam@125
|
23 g721.c CCITT G.721 32Kbps ADPCM coder (with g72x.c)
|
cannam@125
|
24 g723_24.c CCITT G.723 24Kbps ADPCM coder (with g72x.c)
|
cannam@125
|
25 g723_40.c CCITT G.723 40Kbps ADPCM coder (with g72x.c)
|
cannam@125
|
26
|
cannam@125
|
27
|
cannam@125
|
28 Simple conversions between u-law, A-law, and 16-bit linear PCM are invoked
|
cannam@125
|
29 as follows:
|
cannam@125
|
30
|
cannam@125
|
31 unsigned char ucode, acode;
|
cannam@125
|
32 short pcm_val;
|
cannam@125
|
33
|
cannam@125
|
34 ucode = linear2ulaw(pcm_val);
|
cannam@125
|
35 ucode = alaw2ulaw(acode);
|
cannam@125
|
36
|
cannam@125
|
37 acode = linear2alaw(pcm_val);
|
cannam@125
|
38 acode = ulaw2alaw(ucode);
|
cannam@125
|
39
|
cannam@125
|
40 pcm_val = ulaw2linear(ucode);
|
cannam@125
|
41 pcm_val = alaw2linear(acode);
|
cannam@125
|
42
|
cannam@125
|
43
|
cannam@125
|
44 The other CCITT compression routines are invoked as follows:
|
cannam@125
|
45
|
cannam@125
|
46 #include "g72x.h"
|
cannam@125
|
47
|
cannam@125
|
48 struct g72x_state state;
|
cannam@125
|
49 int sample, code;
|
cannam@125
|
50
|
cannam@125
|
51 g72x_init_state(&state);
|
cannam@125
|
52 code = {g721,g723_24,g723_40}_encoder(sample, coding, &state);
|
cannam@125
|
53 sample = {g721,g723_24,g723_40}_decoder(code, coding, &state);
|
cannam@125
|
54
|
cannam@125
|
55 where
|
cannam@125
|
56 coding = AUDIO_ENCODING_ULAW for 8-bit u-law samples
|
cannam@125
|
57 AUDIO_ENCODING_ALAW for 8-bit A-law samples
|
cannam@125
|
58 AUDIO_ENCODING_LINEAR for 16-bit linear PCM samples
|
cannam@125
|
59
|
cannam@125
|
60
|
cannam@125
|
61
|
cannam@125
|
62 This directory also includes the following sample programs:
|
cannam@125
|
63
|
cannam@125
|
64 encode.c CCITT ADPCM encoder
|
cannam@125
|
65 decode.c CCITT ADPCM decoder
|
cannam@125
|
66 Makefile makefile for the sample programs
|
cannam@125
|
67
|
cannam@125
|
68
|
cannam@125
|
69 The sample programs contain examples of how to call the various compression
|
cannam@125
|
70 routines and pack/unpack the bits. The sample programs read byte streams from
|
cannam@125
|
71 stdin and write to stdout. The input/output data is raw data (no file header
|
cannam@125
|
72 or other identifying information is embedded). The sample programs are
|
cannam@125
|
73 invoked as follows:
|
cannam@125
|
74
|
cannam@125
|
75 encode [-3|4|5] [-a|u|l] <infile >outfile
|
cannam@125
|
76 decode [-3|4|5] [-a|u|l] <infile >outfile
|
cannam@125
|
77 where:
|
cannam@125
|
78 -3 encode to (decode from) G.723 24kbps (3-bit) data
|
cannam@125
|
79 -4 encode to (decode from) G.721 32kbps (4-bit) data [the default]
|
cannam@125
|
80 -5 encode to (decode from) G.723 40kbps (5-bit) data
|
cannam@125
|
81 -a encode from (decode to) A-law data
|
cannam@125
|
82 -u encode from (decode to) u-law data [the default]
|
cannam@125
|
83 -l encode from (decode to) 16-bit linear data
|
cannam@125
|
84
|
cannam@125
|
85 Examples:
|
cannam@125
|
86 # Read 16-bit linear and output G.721
|
cannam@125
|
87 encode -4 -l <pcmfile >g721file
|
cannam@125
|
88
|
cannam@125
|
89 # Read 40Kbps G.723 and output A-law
|
cannam@125
|
90 decode -5 -a <g723file >alawfile
|
cannam@125
|
91
|
cannam@125
|
92 # Compress and then decompress u-law data using 24Kbps G.723
|
cannam@125
|
93 encode -3 <ulawin | deoced -3 >ulawout
|
cannam@125
|
94
|