public abstract class BytesIntConverter extends Object implements Converter<int[]>
Simple converter from bytes to ints and back, while taking into account the sign, bytes per int and byte order.
Specialized implementations (i.e. fast versions) are provided for signed 16bit and 24bit formats.
Constructor and Description |
---|
BytesIntConverter() |
Modifier and Type | Method and Description |
---|---|
abstract int |
decode(ByteBuffer source)
Reads bytes from the provided buffer and converts them into an int.
|
void |
decode(ByteBuffer source,
int[] ibuf)
Reads samples from the byte buffer and writes the resulting values to the
provided array.
|
void |
encode(int[] ibuf,
ByteBuffer target)
Writes the given array to the target byte buffer using the given
byte order, bytes per sample etc.
|
void |
encode(int[] ibuf,
int length,
ByteBuffer target)
Writes the given array to the target byte buffer using the given
byte order, bytes per sample etc.
|
abstract void |
encode(int value,
ByteBuffer target)
Writes the given value to the given buffer.
|
static BytesIntConverter |
getInstance(int bytesPerSample,
boolean bigEndian,
boolean signed)
Returns a suitable instance.
|
static int |
maxPossibleValue(int bitsPerSample,
boolean signed) |
static int |
minPossibleValue(int bitsPerSample,
boolean signed) |
public static int maxPossibleValue(int bitsPerSample, boolean signed)
public static int minPossibleValue(int bitsPerSample, boolean signed)
public static BytesIntConverter getInstance(int bytesPerSample, boolean bigEndian, boolean signed)
bytesPerSample
- bytes per samplebigEndian
- big endiansigned
- signedpublic abstract int decode(ByteBuffer source) throws IOException
source
- byte bufferIOException
- if the conversion failspublic void decode(ByteBuffer source, int[] ibuf) throws IOException
Converter
decode
in interface Converter<int[]>
source
- byte bufferibuf
- value array (output)IOException
- if the conversion failspublic abstract void encode(int value, ByteBuffer target)
value
- a integer valuetarget
- byte bufferpublic void encode(int[] ibuf, ByteBuffer target)
Converter
public void encode(int[] ibuf, int length, ByteBuffer target)
Converter
Copyright © 2011–2018 tagtraum industries incorporated. All rights reserved.