Package ej.audio.util
Class G711
java.lang.Object
ej.audio.util.G711
G.711 codec. This class provides methods for u-law, A-law and linear PCM
conversions.
From
https://www.javatips.net/api/OpenComm-master/sipvoip/src/org/hsc/media/G711.java
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intBias for linear code.static final int -
Method Summary
Modifier and TypeMethodDescriptionstatic intalaw2linear(int aVal) Converts an A-law value to 16-bit linear PCMstatic intalaw2ulaw(int aval) A-law to u-law conversion.static intlinear2alaw(int pcmVal) Converts a 16-bit linear PCM value to 8-bit A-law.static intlinear2ulaw(int pcmVal) 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 intulaw2alaw(int uval) u-law to A-law conversion.static intulaw2linear(int uVal) ConvertS a u-law value to 16-bit linear PCM.
-
Field Details
-
ULAW_ALGORITHM
public static final int ULAW_ALGORITHM- See Also:
-
ALAW_ALGORITHM
public static final int ALAW_ALGORITHM- See Also:
-
BIAS
public static final int BIASBias for linear code.- See Also:
-
-
Method Details
-
linear2alaw
public static int linear2alaw(int pcmVal) 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 aVal) Converts an A-law value to 16-bit linear PCM -
linear2ulaw
public static int linear2ulaw(int pcmVal) 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 uVal) 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.
-