|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcz.cuni.jagrlib.DefaultProperty
cz.cuni.jagrlib.Piece
cz.cuni.jagrlib.piece.HuffmanCodec
public class HuffmanCodec
Adaptive Huffman codec.
| Nested Class Summary | |
|---|---|
protected static class |
HuffmanCodec.HuffNode
Node of the Huffman tree. |
protected static class |
HuffmanCodec.HuffTree
Huffman tree (used as EntropyCodec-context). |
| Field Summary | |
|---|---|
protected static java.lang.String |
CATEGORY
Object category. |
protected HuffmanCodec.HuffTree |
context
Current context (accelerator). |
protected IntMap<HuffmanCodec.HuffTree> |
contexts
Map of contexts. |
protected int |
currentContext
Id of the current context. |
protected int |
maxSymbol
Max-symbol used only for creating of new contexts! |
protected boolean |
output
Opened for output (encoding)? |
protected long |
position
Actual position in original (logical) stream. |
static RegPiece |
reg
Static registration instance for this class. |
protected BitStream |
stream
Associated I/O stream. |
protected static java.lang.String |
TEMPLATE_NAME
Object template identifier. |
| Fields inherited from class cz.cuni.jagrlib.Piece |
|---|
channels, info, pl, plugs, TEMPLATE_TYPE, userBreak |
| Fields inherited from interface cz.cuni.jagrlib.iface.Property |
|---|
LOGGING, STATISTICS, TEXT_DESCRIPTION |
| Constructor Summary | |
|---|---|
HuffmanCodec()
|
|
| Method Summary | |
|---|---|
boolean |
available()
Are they any input symbols (bits) available? |
protected void |
clearContexts()
Discards all contexts. |
void |
close()
Codec close. |
long |
compressed()
Actual codec compressed position in bits (total amount in all contexts). |
void |
flush()
Codec flush. |
int |
get()
Decodes one symbol (using the current context). |
int |
get(WheelOfFortune wheel)
Decodes one subinterval from the given WheelOfFortune. |
long |
getBits(int length)
Reads the given amount of "raw" bits (by-passes the entropy decoder). |
int |
getMaxSymbol()
Retrieves maximal symbol value for the actual context. |
protected void |
initContexts(int ctx)
[Re-]initializes context set, creates the given solo context. |
void |
open(boolean output,
int dCtx)
Codec initialization. |
long |
position()
Actual codec external position in symbols (total amount in all contexts). |
void |
put(int symbol)
Encodes the given symbol (in the current context). |
void |
put(WheelOfFortune wheel,
int s)
Encodes one subinterval from the given WheelOfFortune. |
void |
putBits(long bits,
int length)
Writes the given "raw" bits (by-passes the entropy encoder). |
int |
setContext(int ctx)
Sets the given context as current. |
void |
setMaxSymbol(int maxSym)
Sets maximal symbol value for the actual context. |
static int |
setTemplate(Template t,
int ord)
General-purpose registration routine. |
| Methods inherited from class cz.cuni.jagrlib.Piece |
|---|
className, connect, findPlug, findPlug, getInfo, getInterface, getInterface, getPlug, getReg, init, isCompatible, isCompatible, isConnected, logError, logWarning, myInterface, newInputPlug, newOptOutputPlug, newOutputPlug, newPlug, noTemplates, propBegin, propBounds, propDefault, propEnd, propEnum, propManipulator, propManipulator, setProgressListener, setRegStrings, setTemplateDynamic, stop |
| Methods inherited from class cz.cuni.jagrlib.DefaultProperty |
|---|
booleanProperty, booleanProperty, colorDoubleProperty, colorProperty, commit, doubleProperty, doubleProperty, doubleProperty, enumProperty, floatProperty, floatProperty, floatProperty, get, intProperty, intProperty, intProperty, longProperty, longProperty, longProperty, set, set, stringProperty |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface cz.cuni.jagrlib.iface.Property |
|---|
commit, get, set |
| Field Detail |
|---|
protected BitStream stream
null if the codec is not opened.
protected IntMap<HuffmanCodec.HuffTree> contexts
protected int currentContext
protected HuffmanCodec.HuffTree context
protected int maxSymbol
protected boolean output
protected long position
protected static final java.lang.String TEMPLATE_NAME
protected static final java.lang.String CATEGORY
public static final RegPiece reg
| Constructor Detail |
|---|
public HuffmanCodec()
| Method Detail |
|---|
protected void clearContexts()
protected void initContexts(int ctx)
public boolean available()
throws java.io.IOException
available in interface EntropyCodecjava.io.IOExceptionposition,
compressed()
public void close()
throws java.io.IOException
close in interface EntropyCodecjava.io.IOExceptionopen(boolean, int),
flush()
public long compressed()
throws java.io.IOException
compressed in interface EntropyCodecjava.io.IOExceptionposition
public void flush()
throws java.io.IOException
flush in interface EntropyCodecjava.io.IOExceptionopen(boolean, int),
close()
public int get()
throws java.io.IOException
get in interface EntropyCodec-1 if no symbol is available).
java.io.IOExceptiongetBits(int),
put(int),
available()
public int get(WheelOfFortune wheel)
throws java.io.IOException
WheelOfFortune.
Uses the actual context!
get in interface EntropyCodecwheel - Set of intervals (wheel of fortune).
java.io.IOException
public long getBits(int length)
throws java.io.IOException
getBits in interface EntropyCodeclength - Number of bits to read.
-1 if no bits are available).
java.io.IOExceptionget(),
putBits(long, int),
available()
public void open(boolean output,
int dCtx)
throws java.io.IOException
open in interface EntropyCodecoutput - Open for output?dCtx - Initial context.
java.io.IOExceptionBitStream,
setContext(int)public int getMaxSymbol()
getMaxSymbol in interface EntropyCodecpublic void setMaxSymbol(int maxSym)
setMaxSymbol in interface EntropyCodecmaxSym - New maximal symbol value.
public long position()
throws java.io.IOException
position in interface EntropyCodecjava.io.IOExceptioncompressed()
public void put(int symbol)
throws java.io.IOException
put in interface EntropyCodecsymbol - Symbol to encode.
java.io.IOExceptionputBits(long, int),
get()
public void put(WheelOfFortune wheel,
int s)
throws java.io.IOException
WheelOfFortune.
Uses the actual context!
put in interface EntropyCodecwheel - Set of intervals (wheel of fortune).s - Index of an interval to encode.
java.io.IOException
public void putBits(long bits,
int length)
throws java.io.IOException
putBits in interface EntropyCodecbits - Bits to be written ("MSB first" order).length - Number of bits to write.
java.io.IOExceptionput(int),
getBits(int)
public int setContext(int ctx)
throws java.io.IOException
setContext in interface EntropyCodecctx - Id of the new context.
java.io.IOException
public static int setTemplate(Template t,
int ord)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||