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