summaryrefslogtreecommitdiffstats
path: root/alaw.c
diff options
context:
space:
mode:
authorarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-05-11 01:20:22 +0000
committerarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-05-11 01:20:22 +0000
commit0702a8bf1d124c32e4dbc6c72a514ea52a35f6de (patch)
tree96f3f8a6b01d6dfcefc761b63ca06b74bf4d1270 /alaw.c
parent2f3ad260a640f0408cd06f5a74273c3e8dee57cf (diff)
downloadmpv-0702a8bf1d124c32e4dbc6c72a514ea52a35f6de.tar.bz2
mpv-0702a8bf1d124c32e4dbc6c72a514ea52a35f6de.tar.xz
uLaw support
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@757 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'alaw.c')
-rw-r--r--alaw.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/alaw.c b/alaw.c
index de8c43962c..41a45d0267 100644
--- a/alaw.c
+++ b/alaw.c
@@ -6,7 +6,52 @@
#define xaBYTE char
#define xaUBYTE unsigned char
-xaULONG long xa_alaw_2_sign[256];
+//xaULONG long xa_alaw_2_sign[256];
+xaULONG xa_alaw_2_sign[256];
+xaULONG xa_ulaw_2_sign[256];
+
+/*
+** This routine converts from ulaw to 16 bit linear.
+**
+** Craig Reese: IDA/Supercomputing Research Center
+** 29 September 1989
+**
+** References:
+** 1) CCITT Recommendation G.711 (very difficult to follow)
+** 2) MIL-STD-188-113,"Interoperability and Performance Standards
+** for Analog-to_Digital Conversion Techniques,"
+** 17 February 1987
+**
+** Input: 8 bit ulaw sample
+** Output: signed 16 bit linear sample
+*/
+
+xaLONG XA_uLaw_to_Signed( ulawbyte )
+xaUBYTE ulawbyte;
+{
+ static int exp_lut[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 };
+ int sign, exponent, mantissa, sample;
+
+ ulawbyte = ~ ulawbyte;
+ sign = ( ulawbyte & 0x80 );
+ exponent = ( ulawbyte >> 4 ) & 0x07;
+ mantissa = ulawbyte & 0x0F;
+ sample = exp_lut[exponent] + ( mantissa << ( exponent + 3 ) );
+ if ( sign != 0 ) sample = -sample;
+
+ return sample;
+}
+
+void Gen_uLaw_2_Signed()
+{ xaULONG i;
+ for(i=0;i<256;i++)
+ { xaUBYTE data = (xaUBYTE)(i);
+ xaLONG d = XA_uLaw_to_Signed( data );
+ xa_ulaw_2_sign[i] = (xaULONG)((xaULONG)(d) & 0xffff);
+ }
+}
+
+
void Gen_aLaw_2_Signed()
{ xaULONG i;