public abstract class G726
extends java.lang.Object
This implementation is based on the ANSI-C language reference implementations of the CCITT (International Telegraph and Telephone Consultative Committee) G.711, G.721 and G.723 voice compressions, provided by Sun Microsystems, Inc.
Acknowledgement to Sun Microsystems, Inc. for having released the original ANSI-C source code to the public domain.
Modifier and Type | Field and Description |
---|---|
static int |
AUDIO_ENCODING_ALAW
ISDN A-law
|
static int |
AUDIO_ENCODING_LINEAR
PCM 2's-complement (0-center)
|
static int |
AUDIO_ENCODING_ULAW
ISDN u-law
|
Constructor and Description |
---|
G726(javax.sound.sampled.AudioFormat.Encoding encoding)
Creates a new G726 processor, that can be used to encode from or decode do PCM audio data.
|
Modifier and Type | Method and Description |
---|---|
abstract int |
decode(byte[] in_buff,
int in_offset,
int in_len,
int out_coding,
byte[] out_buff,
int out_offset)
Decodes the input chunk in_buff of G726 encoded data and returns
the linear PCM, A-law or u-law chunk into out_buff.
|
abstract int |
decode(int i,
int out_coding)
Decodes a 4-bit code of G.72x encoded data of i and
returns the resulting linear PCM, A-law or u-law value.
|
abstract int |
encode(byte[] in_buff,
int in_offset,
int in_len,
int in_coding,
byte[] out_buff,
int out_offset)
Encodes the input chunk in_buff of linear PCM, A-law or u-law data and returns
the G726 encoded chuck into out_buff.
|
abstract int |
encode(int sl,
int in_coding)
Encodes the input vale of linear PCM, A-law or u-law data sl and returns
the resulting code. -1 is returned for unknown input coding value.
|
javax.sound.sampled.AudioFormat.Encoding |
getEncoding()
Gets the G726 encoding type.
|
protected static int |
quantize(int d,
int y,
int[] table,
int size)
Given a raw sample, 'd', of the difference signal and a
quantization step size scale factor, 'y', this routine returns the
ADPCM codeword to which that sample gets quantized.
|
protected static int |
reconstruct(int sign,
int dqln,
int y)
Returns reconstructed difference signal 'dq' obtained from
codeword 'i' and quantization step size scale factor 'y'.
|
static int |
signedIntLittleEndian(byte hi_b,
byte lo_b)
Converts 2 little-endian-bytes into a signed int.
|
protected static int |
tandem_adjust_alaw(int sr,
int se,
int y,
int i,
int sign,
int[] qtab)
At the end of ADPCM decoding, it simulates an encoder which may be receiving
the output of this decoder as a tandem process.
|
protected static int |
tandem_adjust_ulaw(int sr,
int se,
int y,
int i,
int sign,
int[] qtab) |
protected static int |
unsignedInt(byte b)
Converts a byte into an unsigned int.
|
static int |
unsignedIntLittleEndian(byte hi_b,
byte lo_b)
Converts 2 little-endian-bytes into an unsigned int.
|
protected static void |
update(int code_size,
int y,
int wi,
int fi,
int dq,
int sr,
int dqsez,
org.zoolu.sound.codec.G726State state)
updates the state variables for each output code
|
public static final int AUDIO_ENCODING_ULAW
public static final int AUDIO_ENCODING_ALAW
public static final int AUDIO_ENCODING_LINEAR
public G726(javax.sound.sampled.AudioFormat.Encoding encoding)
protected static int quantize(int d, int y, int[] table, int size)
d
- - Raw difference signal sampley
- - Step size multipliertable
- - Quantization tablesize
- - Table size of short integersprotected static int reconstruct(int sign, int dqln, int y)
sign
- - 0 for non-negative valuedqln
- - G.72x codewordy
- - Step size multiplierprotected static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, org.zoolu.sound.codec.G726State state)
code_size
- - distinguish 723_40 with othersy
- - quantizer step sizewi
- - scale factor multiplierfi
- - for long/short term energiesdq
- - quantized prediction differencesr
- - reconstructed signaldqsez
- - difference from 2-pole predictorstate
- - coder stateprotected static int tandem_adjust_alaw(int sr, int se, int y, int i, int sign, int[] qtab)
sr
- - decoder output linear PCM sample,se
- - predictor estimate sample,y
- - quantizer step size,i
- - decoder input code,sign
- - sign bit of code iprotected static int tandem_adjust_ulaw(int sr, int se, int y, int i, int sign, int[] qtab)
sr
- - decoder output linear PCM samplese
- - predictor estimate sampley
- - quantizer step sizei
- - decoder input codesign
- qtab
- protected static int unsignedInt(byte b)
public static int unsignedIntLittleEndian(byte hi_b, byte lo_b)
public static int signedIntLittleEndian(byte hi_b, byte lo_b)
public javax.sound.sampled.AudioFormat.Encoding getEncoding()
public abstract int encode(int sl, int in_coding)
public abstract int encode(byte[] in_buff, int in_offset, int in_len, int in_coding, byte[] out_buff, int out_offset)
public abstract int decode(int i, int out_coding)
public abstract int decode(byte[] in_buff, int in_offset, int in_len, int out_coding, byte[] out_buff, int out_offset)