Mercurial > mplayer.hg
comparison alaw.c @ 756:b562c8bcf704
uLaw support
author | arpi_esp |
---|---|
date | Fri, 11 May 2001 01:20:22 +0000 |
parents | 3b5f5d1c5041 |
children |
comparison
equal
deleted
inserted
replaced
755:0d15358b0319 | 756:b562c8bcf704 |
---|---|
4 #define xaLONG long | 4 #define xaLONG long |
5 #define xaULONG unsigned long | 5 #define xaULONG unsigned long |
6 #define xaBYTE char | 6 #define xaBYTE char |
7 #define xaUBYTE unsigned char | 7 #define xaUBYTE unsigned char |
8 | 8 |
9 xaULONG long xa_alaw_2_sign[256]; | 9 //xaULONG long xa_alaw_2_sign[256]; |
10 xaULONG xa_alaw_2_sign[256]; | |
11 xaULONG xa_ulaw_2_sign[256]; | |
12 | |
13 /* | |
14 ** This routine converts from ulaw to 16 bit linear. | |
15 ** | |
16 ** Craig Reese: IDA/Supercomputing Research Center | |
17 ** 29 September 1989 | |
18 ** | |
19 ** References: | |
20 ** 1) CCITT Recommendation G.711 (very difficult to follow) | |
21 ** 2) MIL-STD-188-113,"Interoperability and Performance Standards | |
22 ** for Analog-to_Digital Conversion Techniques," | |
23 ** 17 February 1987 | |
24 ** | |
25 ** Input: 8 bit ulaw sample | |
26 ** Output: signed 16 bit linear sample | |
27 */ | |
28 | |
29 xaLONG XA_uLaw_to_Signed( ulawbyte ) | |
30 xaUBYTE ulawbyte; | |
31 { | |
32 static int exp_lut[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 }; | |
33 int sign, exponent, mantissa, sample; | |
34 | |
35 ulawbyte = ~ ulawbyte; | |
36 sign = ( ulawbyte & 0x80 ); | |
37 exponent = ( ulawbyte >> 4 ) & 0x07; | |
38 mantissa = ulawbyte & 0x0F; | |
39 sample = exp_lut[exponent] + ( mantissa << ( exponent + 3 ) ); | |
40 if ( sign != 0 ) sample = -sample; | |
41 | |
42 return sample; | |
43 } | |
44 | |
45 void Gen_uLaw_2_Signed() | |
46 { xaULONG i; | |
47 for(i=0;i<256;i++) | |
48 { xaUBYTE data = (xaUBYTE)(i); | |
49 xaLONG d = XA_uLaw_to_Signed( data ); | |
50 xa_ulaw_2_sign[i] = (xaULONG)((xaULONG)(d) & 0xffff); | |
51 } | |
52 } | |
53 | |
54 | |
10 | 55 |
11 void Gen_aLaw_2_Signed() | 56 void Gen_aLaw_2_Signed() |
12 { xaULONG i; | 57 { xaULONG i; |
13 for(i=0;i<256;i++) | 58 for(i=0;i<256;i++) |
14 { xaUBYTE data = (xaUBYTE)(i); | 59 { xaUBYTE data = (xaUBYTE)(i); |