net.java.sip.communicator.impl.media.codec.audio
Class Utils
java.lang.Object
net.java.sip.communicator.impl.media.codec.audio.Utils
public class Utils
- extends java.lang.Object
- Author:
- Damian Minkov
Constructor Summary |
Utils()
|
Method Summary |
static short[] |
byteToShortArray(byte[] byteArray,
int offset,
int length,
boolean little)
Converts a byte array into a short array. |
static void |
shortArrToByteArr(short[] in,
byte[] res,
boolean little)
The result array must be twice as the input one. |
static byte[] |
shortToBytes(short v,
boolean little)
Get a pair of bytes representing a short value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Utils
public Utils()
byteToShortArray
public static short[] byteToShortArray(byte[] byteArray,
int offset,
int length,
boolean little)
throws java.lang.ArrayIndexOutOfBoundsException
- Converts a byte array into a short array. Since a byte is 8-bits,
and a short is 16-bits, the returned short array will be half in
length than the byte array. If the length of the byte array is odd,
the length of the short array will be
(byteArray.length - 1)/2
, i.e., the last byte is
discarded.
- Parameters:
byteArray
- a byte arrayoffset
- which byte to start fromlength
- how many bytes to convert
- Returns:
- a short array, or
null
if byteArray is of zero
length
- Throws:
java.lang.ArrayIndexOutOfBoundsException
shortArrToByteArr
public static void shortArrToByteArr(short[] in,
byte[] res,
boolean little)
- The result array must be twice as the input one. Since a byte is 8-bits,
and a short is 16-bits.
shortToBytes
public static byte[] shortToBytes(short v,
boolean little)
- Get a pair of bytes representing a short value.
- Parameters:
v
- shortlittle
- boolean
- Returns:
- byte[]