liveMedia/uLawAudioFilter.cpp File Reference

#include "uLawAudioFilter.hh"

Include dependency graph for uLawAudioFilter.cpp:

Go to the source code of this file.

Defines

#define BIAS   0x84
#define CLIP   32635

Functions

static unsigned char uLawFrom16BitLinear (short sample)
static short linear16FromuLaw (unsigned char uLawByte)


Define Documentation

#define BIAS   0x84

Definition at line 71 of file uLawAudioFilter.cpp.

Referenced by uLawFrom16BitLinear().

#define CLIP   32635

Definition at line 72 of file uLawAudioFilter.cpp.

Referenced by uLawFrom16BitLinear().


Function Documentation

static short linear16FromuLaw ( unsigned char  uLawByte  )  [static]

Definition at line 188 of file uLawAudioFilter.cpp.

Referenced by PCMFromuLawAudioSource::afterGettingFrame1().

00188                                                       {
00189   static int const exp_lut[8] = {0,132,396,924,1980,4092,8316,16764};
00190   uLawByte = ~uLawByte;
00191 
00192   Boolean sign = (uLawByte & 0x80) != 0;
00193   unsigned char exponent = (uLawByte>>4) & 0x07;
00194   unsigned char mantissa = uLawByte & 0x0F;
00195 
00196   short result = exp_lut[exponent] + (mantissa << (exponent+3));
00197   if (sign) result = -result;
00198   return result;
00199 }

static unsigned char uLawFrom16BitLinear ( short  sample  )  [static]

Definition at line 74 of file uLawAudioFilter.cpp.

References BIAS, and CLIP.

Referenced by uLawFromPCMAudioSource::afterGettingFrame1().

00074                                                        {
00075   static int const exp_lut[256] = {0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
00076                                    4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
00077                                    5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
00078                                    5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
00079                                    6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
00080                                    6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
00081                                    6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
00082                                    6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
00083                                    7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
00084                                    7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
00085                                    7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
00086                                    7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
00087                                    7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
00088                                    7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
00089                                    7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
00090                                    7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
00091   unsigned char sign = (sample >> 8) & 0x80;
00092   if (sign != 0) sample = -sample; // get the magnitude
00093 
00094   if (sample > CLIP) sample = CLIP; // clip the magnitude
00095   sample += BIAS;
00096 
00097   unsigned char exponent = exp_lut[(sample>>7) & 0xFF];
00098   unsigned char mantissa = (sample >> (exponent+3)) & 0x0F;
00099   unsigned char result = ~(sign | (exponent << 4) | mantissa);
00100   if (result == 0 ) result = 0x02;  // CCITT trap
00101 
00102   return result;
00103 }


Generated on Thu May 17 07:14:24 2012 for live by  doxygen 1.5.2