huffman

package
v0.0.0-...-90a1d6d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2020 License: AGPL-3.0, AGPL-3.0-only Imports: 5 Imported by: 0

Documentation

Overview

Package huffman contains jbig2 huffman tables used to decode jbig2 encoded data segments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicTabler

type BasicTabler interface {
	HtHigh() int32
	HtLow() int32
	StreamReader() reader.StreamReader
	HtPS() int32
	HtRS() int32
	HtOOB() int32
}

BasicTabler is the interface common for the huffman tables.

type Code

type Code struct {
	// contains filtered or unexported fields
}

Code is the model for the huffman table code.

func NewCode

func NewCode(prefixLength, rangeLength, rangeLow int32, isLowerRange bool) *Code

NewCode creates new huffman code.

func (*Code) String

func (c *Code) String() string

String implements Stringer interface.

type EncodedTable

type EncodedTable struct {
	BasicTabler
	// contains filtered or unexported fields
}

EncodedTable is a model for the encoded huffman table.

func NewEncodedTable

func NewEncodedTable(table BasicTabler) (*EncodedTable, error)

NewEncodedTable creates new encoded table from the provided 'table' argument.

func (*EncodedTable) Decode

func (e *EncodedTable) Decode(r reader.StreamReader) (int64, error)

Decode implenets Node interface.

func (*EncodedTable) InitTree

func (e *EncodedTable) InitTree(codeTable []*Code) error

InitTree implements Tabler interface.

func (*EncodedTable) RootNode

func (e *EncodedTable) RootNode() *InternalNode

RootNode Implements Tabler interface.

func (*EncodedTable) String

func (e *EncodedTable) String() string

String implements Stringer interface.

type FixedSizeTable

type FixedSizeTable struct {
	// contains filtered or unexported fields
}

FixedSizeTable defines the table with the fixed size.

func NewFixedSizeTable

func NewFixedSizeTable(codeTable []*Code) (*FixedSizeTable, error)

NewFixedSizeTable creates new fixedSizeTable.

func (*FixedSizeTable) Decode

func (f *FixedSizeTable) Decode(r reader.StreamReader) (int64, error)

Decode implements Tabler interface.

func (*FixedSizeTable) InitTree

func (f *FixedSizeTable) InitTree(codeTable []*Code) error

InitTree implements Tabler interface.

func (*FixedSizeTable) RootNode

func (f *FixedSizeTable) RootNode() *InternalNode

RootNode implements Tabler interface.

func (*FixedSizeTable) String

func (f *FixedSizeTable) String() string

String implements Stringer interface.

type InternalNode

type InternalNode struct {
	// contains filtered or unexported fields
}

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.

func (*InternalNode) Decode

func (i *InternalNode) Decode(r reader.StreamReader) (int64, error)

Decode implements Node interface.

func (*InternalNode) String

func (i *InternalNode) String() string

String implements the Stringer interface.

type Node

type Node interface {
	Decode(r reader.StreamReader) (int64, error)
	String() string
}

Node is the interface defined for all huffman tree nodes.

type OutOfBandNode

type OutOfBandNode struct{}

OutOfBandNode represents an out of band node in a huffman tree.

func (*OutOfBandNode) Decode

func (o *OutOfBandNode) Decode(r reader.StreamReader) (int64, error)

Decode implements Node interface. Decodes the out of band node by returning max int64 value.

func (*OutOfBandNode) String

func (o *OutOfBandNode) String() string

String implements the Stringer interface returns the max int binary value.

type StandardTable

type StandardTable struct {
	// contains filtered or unexported fields
}

StandardTable is the structure that defines standard jbig2 table.

func (*StandardTable) Decode

func (s *StandardTable) Decode(r reader.StreamReader) (int64, error)

Decode implements Node interface.

func (*StandardTable) InitTree

func (s *StandardTable) InitTree(codeTable []*Code) error

InitTree implements Tabler interface.

func (*StandardTable) RootNode

func (s *StandardTable) RootNode() *InternalNode

RootNode implements Tabler interface.

func (*StandardTable) String

func (s *StandardTable) String() string

String implements Stringer interface.

type Tabler

type Tabler interface {
	Decode(r reader.StreamReader) (int64, error)
	InitTree(codeTable []*Code) error
	String() string
	RootNode() *InternalNode
}

Tabler is the interface for all types of the huffman tables.

func GetStandardTable

func GetStandardTable(number int) (Tabler, error)

GetStandardTable gets the standard table for the given 'number'.

type ValueNode

type ValueNode struct {
	// contains filtered or unexported fields
}

ValueNode represents a value node in a huffman tree. It is a leaf of a tree.

func (*ValueNode) Decode

func (v *ValueNode) Decode(r reader.StreamReader) (int64, error)

Decode implements Node interface.

func (*ValueNode) String

func (v *ValueNode) String() string

String implements Stringer interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL