|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javaFlacEncoder.EncodedElement
public class EncodedElement
EncodedElement class provides is used to store data in the proper bitstream format for FLAC audio. Methods are provided to easily append values to the bitstream. Conceptually, an EncodedElement is a list structure, in which the encoded data is stored in a byte array. It is assumed that any data stored by objects of this class will be retrieved through direct access to the underlying byte array. This byte array is exposed to outside objects primarily to allow faster access than "proper" object-oriented design might allow.
Field Summary | |
---|---|
protected int |
offset
Used to signify the index of the first valid bit of the data array. |
Constructor Summary | |
---|---|
EncodedElement()
Constructor, creates an empty element with offset of zero and array size of 100. |
|
EncodedElement(byte[] array,
int off)
Constructor. |
|
EncodedElement(byte[] array,
int off,
int usedBits)
|
|
EncodedElement(int size,
int off)
Constructor. |
Method Summary | |
---|---|
EncodedElement |
addInt(int input,
int bitCount)
Add a number of bits from an int to the end of this list's data. |
static void |
addInt(int value,
int count,
int startPos,
byte[] dest)
This method adds a given number of bits of an int to a byte array. |
EncodedElement |
addLong(long input,
int bitCount)
Add a number of bits from a long to the end of this list's data. |
static void |
addLong(long input,
int count,
int startPos,
byte[] dest)
This method adds a given number of bits of a long to a byte array. |
boolean |
attachEnd(EncodedElement e)
Attach an element to the end of this list. |
void |
clear(int size,
int off)
Completely clear this element and use the given size and offset for the new data array. |
void |
clear(int size,
int off,
boolean keep)
Completely clear this element and use the given size and offset for the new data array. |
short |
getCRC16()
|
protected static EncodedElement |
getEnd_S(EncodedElement e)
Return the last element of the list given. |
EncodedElement |
getEnd()
Return the last element of the list given. |
int |
getTotalBits()
Total number of usable bits stored by this entire list. |
EncodedElement |
packInt(int[] inputArray,
int bitSize,
int start,
int skip,
int countA)
Append an equal number of bits from each int in an array within given limits to the end of this list. |
static void |
packInt(int[] inputArray,
int bitSize,
int startPosIn,
int start,
int skip,
int countA,
byte[] dest)
Append an equal number of bits from each int in an array within given limits to the given byte array. |
EncodedElement |
packIntByBits(int[] inputA,
int[] inputBits,
int inputOffset,
int countA)
Pack a number of bits from each int of an array(within given limits)to the end of this list. |
static void |
packIntByBits(int[] inputA,
int[] inputBits,
int inputOffset,
int countA,
int startPosIn,
byte[] dest)
Pack a number of bits from each int of an array(within given limits)to the end of this list. |
boolean |
padToByte()
Force the usable data stored in this list ends on a a byte boundary, by padding to the end with zeros. |
protected void |
print()
|
protected void |
print(int childCount)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int offset
Constructor Detail |
---|
public EncodedElement()
public EncodedElement(byte[] array, int off)
array
- Byte array to use for this element.off
- Offset to use for this element. Usablebits will also be set
to this value.public EncodedElement(byte[] array, int off, int usedBits)
public EncodedElement(int size, int off)
size
- Size of data array to use(in bytes)off
- Offset to use for this element. Usablebits will also be set
to this value.Method Detail |
---|
public void clear(int size, int off)
size
- Size of data array to use(in bytes)off
- Offset to use for this element. Usablebits will also be set to
this value.public void clear(int size, int off, boolean keep)
size
- Size of data array to use(in bytes)off
- Offset to use for this element. Usablebits will also be set to
this value.keep
- true to keep current backing array, false to create new one.protected static EncodedElement getEnd_S(EncodedElement e)
e
- EncodedElement list to find end of.
public EncodedElement getEnd()
public boolean attachEnd(EncodedElement e)
e
- Element to attach.
public EncodedElement addLong(long input, int bitCount)
input
- Long containing bits to append to end.bitCount
- Number of bits to append.
public EncodedElement addInt(int input, int bitCount)
input
- Int containing bits to append to end.bitCount
- Number of bits to append.
public EncodedElement packInt(int[] inputArray, int bitSize, int start, int skip, int countA)
inputArray
- Array storing input values.bitSize
- number of bits to store from each value.start
- index of first usable index.skip
- number of indices to skip between values(in case input data
is interleaved with non-desirable data).countA
- Number of total indices to store from.
public EncodedElement packIntByBits(int[] inputA, int[] inputBits, int inputOffset, int countA)
inputA
- Array containing input values.inputBits
- Array containing number of bits to use for each index
packed. This array should be equal in size to the inputA array.inputOffset
- Index of first usable index.countA
- Number of indices to pack.
public int getTotalBits()
public static void addInt(int value, int count, int startPos, byte[] dest)
value
- int to store bits fromcount
- number of low-order bits to storestartPos
- start bit location in array to begin writingdest
- array to store bits in. dest MUST have enough space to store
the given data, or this function will fail.public static void addLong(long input, int count, int startPos, byte[] dest)
input
- long to store bits fromcount
- number of low-order bits to storestartPos
- start bit location in array to begin writingdest
- array to store bits in. dest MUST have enough space to store
the given data, or this function will fail.public static void packInt(int[] inputArray, int bitSize, int startPosIn, int start, int skip, int countA, byte[] dest)
inputArray
- Array storing input values.bitSize
- number of bits to store from each value.start
- index of first usable index.skip
- number of indices to skip between values(in case input data
is interleaved with non-desirable data).countA
- Number of total indices to store from.startPosIn
- First usable index in destination array(byte
index = startPosIn/8, bit within that byte = startPosIn%8)dest
- Destination array to store input values in. This array *must*
be large enough to store all values or this method will fail in an
undefined manner.public static void packIntByBits(int[] inputA, int[] inputBits, int inputOffset, int countA, int startPosIn, byte[] dest)
inputA
- Array containing input values.inputBits
- Array containing number of bits to use for each index
packed. This array should be equal in size to the inputA array.inputOffset
- Index of first usable index.countA
- Number of indices to pack.startPosIn
- First usable bit-level index in destination array(byte
index = startPosIn/8, bit within that byte = startPosIn%8)dest
- Destination array to store input values in. This array *must*
be large enough to store all values or this method will fail in an
undefined manner.public boolean padToByte()
public short getCRC16()
protected void print()
protected void print(int childCount)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |