net.sf.fmj.media.codec.audio.ulaw
Class MuLawDecoderUtil

java.lang.Object
  extended by net.sf.fmj.media.codec.audio.ulaw.MuLawDecoderUtil

public class MuLawDecoderUtil
extends java.lang.Object

Turns 8-bit mu-law bytes back into 16-bit PCM values. Adapted from code by Marc Sweetgall at http://www.codeproject.com/csharp/g711audio.asp Note: in .Net, a byte is unsigned, hence the need to always do byte & 0xff - this converts an unsigned byte to the corresponding (nonnegative) int value.


Constructor Summary
MuLawDecoderUtil()
           
 
Method Summary
static void muLawDecode(boolean bigEndian, byte[] data, int offset, int len, byte[] decoded)
           
static short muLawDecode(byte mulaw)
          Decode one mu-law byte
static void muLawDecodeBigEndian(byte[] data, int offset, int len, byte[] decoded)
           
static void muLawDecodeLittleEndian(byte[] data, int offset, int len, byte[] decoded)
          Decode an array of mu-law encoded bytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MuLawDecoderUtil

public MuLawDecoderUtil()
Method Detail

muLawDecode

public static short muLawDecode(byte mulaw)
Decode one mu-law byte

Parameters:
mulaw - The encoded mu-law byte
Returns:
A short containing the 16-bit result

muLawDecodeLittleEndian

public static void muLawDecodeLittleEndian(byte[] data,
                                           int offset,
                                           int len,
                                           byte[] decoded)
Decode an array of mu-law encoded bytes

Parameters:
data - An array of mu-law encoded bytes
decoded - An array of bytes in Little-Endian format containing the results, must be twice as big as data.

muLawDecodeBigEndian

public static void muLawDecodeBigEndian(byte[] data,
                                        int offset,
                                        int len,
                                        byte[] decoded)

muLawDecode

public static void muLawDecode(boolean bigEndian,
                               byte[] data,
                               int offset,
                               int len,
                               byte[] decoded)