BasicTabler is the interface common for the huffman tables.
type BasicTabler interface { HtHigh() int32 HtLow() int32 StreamReader() bitwise.StreamReader HtPS() int32 HtRS() int32 HtOOB() int32 }
Code is the model for the huffman table code.
type Code struct {
// contains filtered or unexported fields
}
func NewCode(prefixLength, rangeLength, rangeLow int32, isLowerRange bool) *Code
NewCode creates new huffman code.
func (c *Code) String() string
String implements Stringer interface.
EncodedTable is a model for the encoded huffman table.
type EncodedTable struct { BasicTabler // contains filtered or unexported fields }
func NewEncodedTable(table BasicTabler) (*EncodedTable, error)
NewEncodedTable creates new encoded table from the provided 'table' argument.
func (e *EncodedTable) Decode(r bitwise.StreamReader) (int64, error)
Decode implenets Node interface.
func (e *EncodedTable) InitTree(codeTable []*Code) error
InitTree implements Tabler interface.
func (e *EncodedTable) RootNode() *InternalNode
RootNode Implements Tabler interface.
func (e *EncodedTable) String() string
String implements Stringer interface.
FixedSizeTable defines the table with the fixed size.
type FixedSizeTable struct {
// contains filtered or unexported fields
}
func NewFixedSizeTable(codeTable []*Code) (*FixedSizeTable, error)
NewFixedSizeTable creates new fixedSizeTable.
func (f *FixedSizeTable) Decode(r bitwise.StreamReader) (int64, error)
Decode implements Tabler interface.
func (f *FixedSizeTable) InitTree(codeTable []*Code) error
InitTree implements Tabler interface.
func (f *FixedSizeTable) RootNode() *InternalNode
RootNode implements Tabler interface.
func (f *FixedSizeTable) String() string
String implements Stringer interface.
InternalNode represents an internal node of a huffman tree. It is defined as a pair of two child nodes 'zero' and 'one' and a 'depth' level. Implements Node interface.
type InternalNode struct {
// contains filtered or unexported fields
}
func (i *InternalNode) Decode(r bitwise.StreamReader) (int64, error)
Decode implements Node interface.
func (i *InternalNode) String() string
String implements the Stringer interface.
Node is the interface defined for all huffman tree nodes.
type Node interface { Decode(r bitwise.StreamReader) (int64, error) String() string }
OutOfBandNode represents an out of band node in a huffman tree.
type OutOfBandNode struct{}
func (o *OutOfBandNode) Decode(r bitwise.StreamReader) (int64, error)
Decode implements Node interface. Decodes the out of band node by returning max int64 value.
func (o *OutOfBandNode) String() string
String implements the Stringer interface returns the max int binary value.
StandardTable is the structure that defines standard jbig2 table.
type StandardTable struct {
// contains filtered or unexported fields
}
func (s *StandardTable) Decode(r bitwise.StreamReader) (int64, error)
Decode implements Node interface.
func (s *StandardTable) InitTree(codeTable []*Code) error
InitTree implements Tabler interface.
func (s *StandardTable) RootNode() *InternalNode
RootNode implements Tabler interface.
func (s *StandardTable) String() string
String implements Stringer interface.
Tabler is the interface for all types of the huffman tables.
type Tabler interface { Decode(r bitwise.StreamReader) (int64, error) InitTree(codeTable []*Code) error String() string RootNode() *InternalNode }
func GetStandardTable(number int) (Tabler, error)
GetStandardTable gets the standard table for the given 'number'.
ValueNode represents a value node in a huffman tree. It is a leaf of a tree.
type ValueNode struct {
// contains filtered or unexported fields
}
func (v *ValueNode) Decode(r bitwise.StreamReader) (int64, error)
Decode implements Node interface.
func (v *ValueNode) String() string
String implements Stringer interface.