local.media
Class G711
java.lang.Object
|
+--local.media.G711
- public class G711
- extends java.lang.Object
G.711 codec.
This class provides methods for u-law, A-law and linear PCM conversions.
|
Field Summary |
static int |
BIAS
Bias for linear code. |
|
Constructor Summary |
G711()
|
|
Method Summary |
static int |
alaw2linear(int a_val)
Converts an A-law value to 16-bit linear PCM |
static int |
alaw2ulaw(int aval)
A-law to u-law conversion. |
static int |
linear2alaw(int pcm_val)
Converts a 16-bit linear PCM value to 8-bit A-law.
|
static int |
linear2ulaw(int pcm_val)
Converts a linear PCM value to u-law
In order to simplify the encoding process, the original linear magnitude
is biased by adding 33 which shifts the encoding range from (0 - 8158) to
(33 - 8191). |
static int |
ulaw2alaw(int uval)
u-law to A-law conversion. |
static int |
ulaw2linear(int u_val)
ConvertS a u-law value to 16-bit linear PCM.
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BIAS
public static final int BIAS
- Bias for linear code.
G711
public G711()
linear2alaw
public static int linear2alaw(int pcm_val)
- Converts a 16-bit linear PCM value to 8-bit A-law.
It accepts an 16-bit integer and encodes it as A-law data.
Linear Input Code Compressed Code
----------------- ---------------
0000000wxyza 000wxyz
0000001wxyza 001wxyz
000001wxyzab 010wxyz
00001wxyzabc 011wxyz
0001wxyzabcd 100wxyz
001wxyzabcde 101wxyz
01wxyzabcdef 110wxyz
1wxyzabcdefg 111wxyz
For further information see John C. Bellamy's Digital Telephony, 1982,
John Wiley & Sons, pps 98-111 and 472-476.
alaw2linear
public static int alaw2linear(int a_val)
- Converts an A-law value to 16-bit linear PCM
linear2ulaw
public static int linear2ulaw(int pcm_val)
- Converts a linear PCM value to u-law
In order to simplify the encoding process, the original linear magnitude
is biased by adding 33 which shifts the encoding range from (0 - 8158) to
(33 - 8191). The result can be seen in the following encoding table:
Biased Linear Input Code Compressed Code
------------------------ ---------------
00000001wxyza 000wxyz
0000001wxyzab 001wxyz
000001wxyzabc 010wxyz
00001wxyzabcd 011wxyz
0001wxyzabcde 100wxyz
001wxyzabcdef 101wxyz
01wxyzabcdefg 110wxyz
1wxyzabcdefgh 111wxyz
Each biased linear code has a leading 1 which identifies the segment
number. The value of the segment number is equal to 7 minus the number
of leading 0's. The quantization interval is directly available as the
four bits wxyz. The trailing bits (a - h) are ignored.
Ordinarily the complement of the resulting code word is used for
transmission, and so the code word is complemented before it is returned.
For further information see John C. Bellamy's Digital Telephony, 1982,
John Wiley & Sons, pps 98-111 and 472-476.
ulaw2linear
public static int ulaw2linear(int u_val)
- ConvertS a u-law value to 16-bit linear PCM.
First, a biased linear code is derived from the code word. An unbiased
output can then be obtained by subtracting 33 from the biased code.
Note that this function expects to be passed the complement of the
original code word. This is in keeping with ISDN conventions.
alaw2ulaw
public static int alaw2ulaw(int aval)
- A-law to u-law conversion.
ulaw2alaw
public static int ulaw2alaw(int uval)
- u-law to A-law conversion.