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