(Metux) autogen.sh: not running ./configure anymore (breaks certain distro builders)
[mirror-ossqm-audiofile.git] / libaudiofile / g711.h
blob0423ffe0e9049daf256599c87b8f684f856a3d87
1 /*
2 * This source code is a product of Sun Microsystems, Inc. and is provided
3 * for unrestricted use. Users may copy or modify this source code without
4 * charge.
6 * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING
7 * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
8 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
10 * Sun source code is provided with no support and without any obligation on
11 * the part of Sun Microsystems, Inc. to assist in its use, correction,
12 * modification or enhancement.
14 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
15 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE
16 * OR ANY PART THEREOF.
18 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
19 * or profits or other special, indirect and consequential damages, even if
20 * Sun has been advised of the possibility of such damages.
22 * Sun Microsystems, Inc.
23 * 2550 Garcia Avenue
24 * Mountain View, California 94043
28 * g711.h
30 * u-law, A-law and linear PCM conversions.
33 #ifndef G711_H
34 #define G711_H
37 * linear2alaw() - Convert a 16-bit linear PCM value to 8-bit A-law
39 * linear2alaw() accepts an 16-bit integer and encodes it as A-law data.
41 * Linear Input Code Compressed Code
42 * ------------------------ ---------------
43 * 0000000wxyza 000wxyz
44 * 0000001wxyza 001wxyz
45 * 000001wxyzab 010wxyz
46 * 00001wxyzabc 011wxyz
47 * 0001wxyzabcd 100wxyz
48 * 001wxyzabcde 101wxyz
49 * 01wxyzabcdef 110wxyz
50 * 1wxyzabcdefg 111wxyz
52 * For further information see John C. Bellamy's Digital Telephony, 1982,
53 * John Wiley & Sons, pps 98-111 and 472-476.
56 /* pcm_val is 2's complement (16-bit range) */
57 unsigned char _af_linear2alaw (int pcm_val);
60 * alaw2linear() - Convert an A-law value to 16-bit linear PCM
64 int _af_alaw2linear (unsigned char a_val);
67 * linear2ulaw() - Convert a linear PCM value to u-law
69 * In order to simplify the encoding process, the original linear magnitude
70 * is biased by adding 33 which shifts the encoding range from (0 - 8158) to
71 * (33 - 8191). The result can be seen in the following encoding table:
73 * Biased Linear Input Code Compressed Code
74 * ------------------------ ---------------
75 * 00000001wxyza 000wxyz
76 * 0000001wxyzab 001wxyz
77 * 000001wxyzabc 010wxyz
78 * 00001wxyzabcd 011wxyz
79 * 0001wxyzabcde 100wxyz
80 * 001wxyzabcdef 101wxyz
81 * 01wxyzabcdefg 110wxyz
82 * 1wxyzabcdefgh 111wxyz
84 * Each biased linear code has a leading 1 which identifies the segment
85 * number. The value of the segment number is equal to 7 minus the number
86 * of leading 0's. The quantization interval is directly available as the
87 * four bits wxyz. * The trailing bits (a - h) are ignored.
89 * Ordinarily the complement of the resulting code word is used for
90 * transmission, and so the code word is complemented before it is returned.
92 * For further information see John C. Bellamy's Digital Telephony, 1982,
93 * John Wiley & Sons, pps 98-111 and 472-476.
96 /* pcm_val is 2's complement (16-bit range) */
97 unsigned char _af_linear2ulaw (int pcm_val);
100 * ulaw2linear() - Convert a u-law value to 16-bit linear PCM
102 * First, a biased linear code is derived from the code word. An unbiased
103 * output can then be obtained by subtracting 33 from the biased code.
105 * Note that this function expects to be passed the complement of the
106 * original code word. This is in keeping with ISDN conventions.
109 int _af_ulaw2linear (unsigned char u_val);
111 #endif /* G711_H */