entropy

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LINEAR_APM        = 0
	LOGISTIC_APM      = 1
	FAST_LOGISTIC_APM = 2
)
View Source
const (
	NONE_TYPE    = uint32(0)  // No compression
	HUFFMAN_TYPE = uint32(1)  // Huffman
	FPAQ_TYPE    = uint32(2)  // Fast PAQ (order 0)
	PAQ_TYPE     = uint32(3)  // Obsolete
	RANGE_TYPE   = uint32(4)  // Range
	ANS0_TYPE    = uint32(5)  // Asymmetric Numerical System order 0
	CM_TYPE      = uint32(6)  // Context Model
	TPAQ_TYPE    = uint32(7)  // Tangelo PAQ
	ANS1_TYPE    = uint32(8)  // Asymmetric Numerical System order 1
	TPAQX_TYPE   = uint32(9)  // Tangelo PAQ Extra
	RESERVED1    = uint32(10) // Reserved
	RESERVED2    = uint32(11) // Reserved
	RESERVED3    = uint32(12) // Reserved
	RESERVED4    = uint32(13) // Reserved
	RESERVED5    = uint32(14) // Reserved
	RESERVED6    = uint32(15) // Reserved
)
View Source
const (
	// INCOMPRESSIBLE_THRESHOLD Any block with entropy*1024 greater than this threshold is considered incompressible
	INCOMPRESSIBLE_THRESHOLD = 973
)

Variables

This section is empty.

Functions

func DecodeAlphabet

func DecodeAlphabet(ibs kanzi.InputBitStream, alphabet []int) (int, error)

DecodeAlphabet reads the alphabet from the bitstream and return the number of symbols read or an error

func EncodeAlphabet

func EncodeAlphabet(obs kanzi.OutputBitStream, alphabet []int) (int, error)

EncodeAlphabet writes the alphabet to the bitstream and return the number of symbols written or an error. alphabet must be sorted in increasing order alphabet size must be a power of 2 up to 256

func GetName

func GetName(entropyType uint32) (string, error)

GetName returns the name of the entropy codec given its type

func GetType

func GetType(entropyName string) (uint32, error)

GetType returns the type of the entropy codec given its name

func NewEntropyDecoder

func NewEntropyDecoder(ibs kanzi.InputBitStream, ctx map[string]interface{},
	entropyType uint32) (kanzi.EntropyDecoder, error)

NewEntropyDecoder creates a new entropy decoder using the provided type and bitstream

func NewEntropyEncoder

func NewEntropyEncoder(obs kanzi.OutputBitStream, ctx map[string]interface{},
	entropyType uint32) (kanzi.EntropyEncoder, error)

NewEntropyEncoder creates a new entropy encoder using the provided type and bitstream

func NormalizeFrequencies

func NormalizeFrequencies(freqs []int, alphabet []int, totalFreq, scale int) (int, error)

NormalizeFrequencies scales the frequencies so that their sum equals 'scale'. Returns the size of the alphabet or an error. The alphabet and freqs parameters are updated.

func ReadVarInt

func ReadVarInt(bs kanzi.InputBitStream) uint32

ReadVarInt reads a VarInt from the bitstream and returns it as an uint32.

func WriteVarInt

func WriteVarInt(bs kanzi.OutputBitStream, value uint32) int

WriteVarInt writes the provided value to the bitstream as a VarInt. Returns the number of bytes written.

Types

type ANSRangeDecoder

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

ANSRangeDecoder Asymmetric Numeral System Decoder

func NewANSRangeDecoder

func NewANSRangeDecoder(bs kanzi.InputBitStream, args ...uint) (*ANSRangeDecoder, error)

NewANSRangeDecoder creates an instance of ANS decoder. The chunk size indicates how many bytes are encoded (per block) before resetting the frequency stats. Since the number of args is variable, this function can be called like this: NewANSRangeDecoder(bs) or NewANSRangeDecoder(bs, 0, 16384, 12) Arguments are order and chunk size chunkSize = 0 means 'use input buffer length' during decoding

func NewANSRangeDecoderWithCtx

func NewANSRangeDecoderWithCtx(bs kanzi.InputBitStream, ctx *map[string]interface{}, args ...uint) (*ANSRangeDecoder, error)

NewANSRangeDecoderWithCtx creates a new instance of ANSRangeDecoder providing a context map.

func (*ANSRangeDecoder) BitStream

func (this *ANSRangeDecoder) BitStream() kanzi.InputBitStream

BitStream returns the underlying bitstream

func (*ANSRangeDecoder) Dispose

func (this *ANSRangeDecoder) Dispose()

Dispose this implementation does nothing

func (*ANSRangeDecoder) Read

func (this *ANSRangeDecoder) Read(block []byte) (int, error)

Decode data from the bitstream and write them, chunk by chunk, into the block.

type ANSRangeEncoder

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

ANSRangeEncoder Asymmetric Numeral System Encoder

func NewANSRangeEncoder

func NewANSRangeEncoder(bs kanzi.OutputBitStream, args ...uint) (*ANSRangeEncoder, error)

NewANSRangeEncoder creates an instance of ANS encoder. The chunk size indicates how many bytes are encoded (per block) before resetting the frequency stats. 0 means that frequencies calculated at the beginning of the block apply to the whole block Since the number of args is variable, this function can be called like this: NewANSRangeEncoder(bs) or NewANSRangeEncoder(bs, 0, 16384, 12) Arguments are order, chunk size and log range. chunkSize = 0 means 'use input buffer length' during decoding

func NewANSRangeEncoderWithCtx

func NewANSRangeEncoderWithCtx(bs kanzi.OutputBitStream, ctx *map[string]interface{}, args ...uint) (*ANSRangeEncoder, error)

NewANSRangeEncoderWithCtx creates a new instance of ANSRangeEncoder providing a context map.

func (*ANSRangeEncoder) BitStream

func (this *ANSRangeEncoder) BitStream() kanzi.OutputBitStream

BitStream returns the underlying bitstream

func (*ANSRangeEncoder) Dispose

func (this *ANSRangeEncoder) Dispose()

Dispose this implementation does nothing

func (*ANSRangeEncoder) Write

func (this *ANSRangeEncoder) Write(block []byte) (int, error)

Write Dynamically compute the frequencies for every chunk of data in the block and encode each chunk of the block sequentially

type AdaptiveProbMap

type AdaptiveProbMap interface {
	Get(bit int, pr int, ctx int) int
}

func NewAdaptiveProbMap

func NewAdaptiveProbMap(mapType int, n, rate uint) (AdaptiveProbMap, error)

NewBinaryEntropyEncoder creates an instance of AdaptiveProbMap given the provided type of APM.

type BinaryEntropyDecoder

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

BinaryEntropyDecoder entropy decoder based on arithmetic coding and using an external probability predictor.

func NewBinaryEntropyDecoder

func NewBinaryEntropyDecoder(bs kanzi.InputBitStream, predictor kanzi.Predictor) (*BinaryEntropyDecoder, error)

NewBinaryEntropyDecoder creates an instance of BinaryEntropyDecoder using the given predictor to predict the probability of the next bit to be one. It outputs to the given OutputBitstream

func (*BinaryEntropyDecoder) BitStream

func (this *BinaryEntropyDecoder) BitStream() kanzi.InputBitStream

BitStream returns the underlying bitstream

func (*BinaryEntropyDecoder) DecodeBit

func (this *BinaryEntropyDecoder) DecodeBit(pred int) byte

DecodeBit decodes one bit from the bitstream using arithmetic coding and the probability predictor provided at creation time.

func (*BinaryEntropyDecoder) DecodeByte

func (this *BinaryEntropyDecoder) DecodeByte() byte

DecodeByte decodes the given value from the bitstream bit by bit

func (*BinaryEntropyDecoder) Dispose

func (this *BinaryEntropyDecoder) Dispose()

Dispose must be called before getting rid of the entropy decoder This implementation does nothing.

func (*BinaryEntropyDecoder) Read

func (this *BinaryEntropyDecoder) Read(block []byte) (int, error)

Read decodes data from the bitstream and return it in the provided buffer. Return the number of bytes read from the bitstream. Splits big blocks into chunks and decode the chunks byte by byte sequentially from the bitstream.

type BinaryEntropyEncoder

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

BinaryEntropyEncoder entropy encoder based on arithmetic coding and using an external probability predictor.

func NewBinaryEntropyEncoder

func NewBinaryEntropyEncoder(bs kanzi.OutputBitStream, predictor kanzi.Predictor) (*BinaryEntropyEncoder, error)

NewBinaryEntropyEncoder creates an instance of BinaryEntropyEncoder using the given predictor to predict the probability of the next bit to be one. It outputs to the given OutputBitstream

func (*BinaryEntropyEncoder) BitStream

func (this *BinaryEntropyEncoder) BitStream() kanzi.OutputBitStream

BitStream returns the underlying bitstream

func (*BinaryEntropyEncoder) Dispose

func (this *BinaryEntropyEncoder) Dispose()

Dispose must be called before getting rid of the entropy encoder This idempotent implementation writes the last buffered bits into the bitstream.

func (*BinaryEntropyEncoder) EncodeBit

func (this *BinaryEntropyEncoder) EncodeBit(bit byte, pred int)

EncodeBit encodes one bit into the bitstream using arithmetic coding and the probability predictor provided at creation time.

func (*BinaryEntropyEncoder) EncodeByte

func (this *BinaryEntropyEncoder) EncodeByte(val byte)

EncodeByte encodes the given value into the bitstream bit by bit

func (*BinaryEntropyEncoder) Write

func (this *BinaryEntropyEncoder) Write(block []byte) (int, error)

Write encodes the data provided into the bitstream. Return the number of byte written to the bitstream. Splits big blocks into chunks and encode the chunks byte by byte sequentially into the bitstream.

type CMPredictor

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

func NewCMPredictor

func NewCMPredictor(ctx *map[string]interface{}) (*CMPredictor, error)

NewCMPredictor creates a new instance of CMPredictor

func (*CMPredictor) Get

func (this *CMPredictor) Get() int

Get returns the value representing the probability of the next bit being 1 in the [0..4095] range. The probability is computed from the internal bit counters.

func (*CMPredictor) Update

func (this *CMPredictor) Update(bit byte)

Update updates the probability model based on the internal bit counters

type ExpGolombDecoder

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

ExpGolombDecoder Exponential Golomb Entropy Decoder

func NewExpGolombDecoder

func NewExpGolombDecoder(bs kanzi.InputBitStream, sgn bool) (*ExpGolombDecoder, error)

NewExpGolombDecoder creates a new instance of ExpGolombDecoder If sgn is true, values from the bitstream will be decoded as signed (int8)

func (*ExpGolombDecoder) BitStream

func (this *ExpGolombDecoder) BitStream() kanzi.InputBitStream

BitStream returns the underlying bitstream

func (*ExpGolombDecoder) DecodeByte

func (this *ExpGolombDecoder) DecodeByte() byte

DecodeByte decodes one byte from the bitstream If the decoder is sign aware, the returned value is an int8 cast to a byte

func (*ExpGolombDecoder) Dispose

func (this *ExpGolombDecoder) Dispose()

Dispose this implementation does nothing

func (*ExpGolombDecoder) Read

func (this *ExpGolombDecoder) Read(block []byte) (int, error)

Read decodes data from the bitstream and return it in the provided buffer. Return the number of bytes read from the bitstream

func (*ExpGolombDecoder) Signed

func (this *ExpGolombDecoder) Signed() bool

Signed returns true if this decoder is sign aware

type ExpGolombEncoder

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

ExpGolombEncoder Exponential Golomb Entropy Encoder

func NewExpGolombEncoder

func NewExpGolombEncoder(bs kanzi.OutputBitStream, sgn bool) (*ExpGolombEncoder, error)

NewExpGolombEncoder creates a new instance of ExpGolombEncoder If sgn is true, values will be encoded as signed (int8) in the bitstream. Using a sign improves compression ratio for distributions centered on 0 (E.G. Gaussian) Example: -1 is better compressed as -1 (1 followed by '-') than as 255

func (*ExpGolombEncoder) BitStream

func (this *ExpGolombEncoder) BitStream() kanzi.OutputBitStream

BitStream returns the underlying bitstream

func (*ExpGolombEncoder) Dispose

func (this *ExpGolombEncoder) Dispose()

Dispose this implementation does nothing

func (*ExpGolombEncoder) EncodeByte

func (this *ExpGolombEncoder) EncodeByte(val byte)

EncodeByte encodes the given value into the bitstream

func (*ExpGolombEncoder) Signed

func (this *ExpGolombEncoder) Signed() bool

Signed returns true if this encoder is sign aware

func (*ExpGolombEncoder) Write

func (this *ExpGolombEncoder) Write(block []byte) (int, error)

Write encodes the data provided into the bitstream. Return the number of byte written to the bitstream

type FPAQDecoder

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

FPAQDecoder entropy decoder derived from fpaq0r by Matt Mahoney & Alexander Ratushnyak. See http://mattmahoney.net/dc/#fpaq0. Simple (and fast) adaptive entropy bit decoder

func NewFPAQDecoder

func NewFPAQDecoder(bs kanzi.InputBitStream) (*FPAQDecoder, error)

NewFPAQDecoder creates an instance of FPAQDecoder

func NewFPAQDecoderWithCtx

func NewFPAQDecoderWithCtx(bs kanzi.InputBitStream, ctx *map[string]interface{}) (*FPAQDecoder, error)

NewFPAQDecoderWithCtx creates an instance of FPAQDecoder providing a context map.

func (*FPAQDecoder) BitStream

func (this *FPAQDecoder) BitStream() kanzi.InputBitStream

BitStream returns the underlying bitstream

func (*FPAQDecoder) Dispose

func (this *FPAQDecoder) Dispose()

Dispose must be called before getting rid of the entropy decoder This implementation does nothing.

func (*FPAQDecoder) Read

func (this *FPAQDecoder) Read(block []byte) (int, error)

Read decodes data from the bitstream and return it in the provided buffer. Return the number of bytes read from the bitstream. Splits big blocks into chunks and decode the chunks byte by byte sequentially from the bitstream.

type FPAQEncoder

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

FPAQEncoder entropy encoder derived from fpaq0r by Matt Mahoney & Alexander Ratushnyak. See http://mattmahoney.net/dc/#fpaq0. Simple (and fast) adaptive entropy bit encoder

func NewFPAQEncoder

func NewFPAQEncoder(bs kanzi.OutputBitStream) (*FPAQEncoder, error)

NewFPAQEncoder creates an instance of FPAQEncoder providing a context map.

func NewFPAQEncoderWithCtx

func NewFPAQEncoderWithCtx(bs kanzi.OutputBitStream, ctx *map[string]interface{}) (*FPAQEncoder, error)

NewFPAQEncoderWithCtx creates an instance of FPAQEncoder

func (*FPAQEncoder) BitStream

func (this *FPAQEncoder) BitStream() kanzi.OutputBitStream

BitStream returns the underlying bitstream

func (*FPAQEncoder) Dispose

func (this *FPAQEncoder) Dispose()

Dispose must be called before getting rid of the entropy encoder This idempotent implmentation writes the last buffered bits into the bitstream.

func (*FPAQEncoder) Write

func (this *FPAQEncoder) Write(block []byte) (int, error)

Write encodes the data provided into the bitstream. Return the number of byte written to the bitstream. Splits big blocks into chunks and encode the chunks byte by byte sequentially into the bitstream.

type FastLogisticAdaptiveProbMap

type FastLogisticAdaptiveProbMap adaptiveProbMapData

FastLogisticAdaptiveProbMap is similar to LogisticAdaptiveProbMap but works faster at the expense of some accuracy

func (*FastLogisticAdaptiveProbMap) Get

func (this *FastLogisticAdaptiveProbMap) Get(bit int, pr int, ctx int) int

get returns improved prediction given current bit, prediction and context

type HuffmanDecoder

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

HuffmanDecoder Implementation of a static Huffman decoder. Uses tables to decode symbols

func NewHuffmanDecoder

func NewHuffmanDecoder(bs kanzi.InputBitStream, args ...uint) (*HuffmanDecoder, error)

NewHuffmanDecoder creates an instance of HuffmanDecoder. Since the number of args is variable, this function can be called like this: NewHuffmanDecoder(bs) or NewHuffmanDecoder(bs, 16384) (the second argument being the chunk size)

func NewHuffmanDecoderWithCtx

func NewHuffmanDecoderWithCtx(bs kanzi.InputBitStream, ctx *map[string]interface{}) (*HuffmanDecoder, error)

NewHuffmanDecoderWithCtx creates an instance of HuffmanDecoder providing a context map.

func (*HuffmanDecoder) BitStream

func (this *HuffmanDecoder) BitStream() kanzi.InputBitStream

BitStream returns the underlying bitstream

func (*HuffmanDecoder) Dispose

func (this *HuffmanDecoder) Dispose()

Dispose this implementation does nothing

func (*HuffmanDecoder) Read

func (this *HuffmanDecoder) Read(block []byte) (int, error)

Read decodes data from the bitstream and return it in the provided buffer. Return the number of bytes read from the bitstream

type HuffmanEncoder

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

HuffmanEncoder Implementation of a static Huffman encoder. Uses in place generation of canonical codes instead of a tree

func NewHuffmanEncoder

func NewHuffmanEncoder(bs kanzi.OutputBitStream, args ...uint) (*HuffmanEncoder, error)

NewHuffmanEncoder creates an instance of HuffmanEncoder. Since the number of args is variable, this function can be called like this: NewHuffmanEncoder(bs) or NewHuffmanEncoder(bs, 16384) (the second argument being the chunk size)

func (*HuffmanEncoder) BitStream

func (this *HuffmanEncoder) BitStream() kanzi.OutputBitStream

BitStream returns the underlying bitstream

func (*HuffmanEncoder) Dispose

func (this *HuffmanEncoder) Dispose()

Dispose this implementation does nothing

func (*HuffmanEncoder) Write

func (this *HuffmanEncoder) Write(block []byte) (int, error)

Write encodes the data provided into the bitstream. Return the number of byte written to the bitstream. Dynamically compute the frequencies for every chunk of data in the block

type LinearAdaptiveProbMap

type LinearAdaptiveProbMap adaptiveProbMapData

LinearAdaptiveProbMap maps a probability and a context into a new probability using linear interpolation of probabilities

func (*LinearAdaptiveProbMap) Get

func (this *LinearAdaptiveProbMap) Get(bit int, pr int, ctx int) int

get returns improved prediction given current bit, prediction and context

type LogisticAdaptiveProbMap

type LogisticAdaptiveProbMap adaptiveProbMapData

LogisticAdaptiveProbMap maps a probability and a context into a new probability using interpolation in the logistic domain

func (*LogisticAdaptiveProbMap) Get

func (this *LogisticAdaptiveProbMap) Get(bit int, pr int, ctx int) int

get returns improved prediction given current bit, prediction and context

type NullEntropyDecoder

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

NullEntropyDecoder pass through entropy decoder (reads the input bytes directly from the bitstream)

func NewNullEntropyDecoder

func NewNullEntropyDecoder(bs kanzi.InputBitStream) (*NullEntropyDecoder, error)

NewNullEntropyDecoder creates a new instance of NullEntropyDecoder

func (*NullEntropyDecoder) BitStream

func (this *NullEntropyDecoder) BitStream() kanzi.InputBitStream

BitStream returns the underlying bitstream

func (*NullEntropyDecoder) Dispose

func (this *NullEntropyDecoder) Dispose()

Dispose this implementation does nothing

func (*NullEntropyDecoder) Read

func (this *NullEntropyDecoder) Read(block []byte) (int, error)

Read decodes data from the bitstream and return it in the provided buffer. Return the number of bytes read from the bitstream

type NullEntropyEncoder

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

NullEntropyEncoder pass through entropy encoder (writes the input bytes directly to the bitstream)

func NewNullEntropyEncoder

func NewNullEntropyEncoder(bs kanzi.OutputBitStream) (*NullEntropyEncoder, error)

NewNullEntropyEncoder creates a new instance of NullEntropyEncoder

func (*NullEntropyEncoder) BitStream

func (this *NullEntropyEncoder) BitStream() kanzi.OutputBitStream

BitStream returns the underlying bitstream

func (*NullEntropyEncoder) Dispose

func (this *NullEntropyEncoder) Dispose()

Dispose this implementation does nothing

func (*NullEntropyEncoder) Write

func (this *NullEntropyEncoder) Write(block []byte) (int, error)

Write encodes the data provided into the bitstream. Return the number of byte written to the bitstream

type RangeDecoder

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

RangeDecoder Order 0 Range Entropy Decoder

func NewRangeDecoder

func NewRangeDecoder(bs kanzi.InputBitStream, args ...uint) (*RangeDecoder, error)

NewRangeDecoder creates a new instance of RangeDecoder The given arguments are either empty or containing a chunk size. EG: call NewRangeDecoder(bs) or NewRangeDecoder(bs, 16384) The default chunk size is 65536 bytes.

func (*RangeDecoder) BitStream

func (this *RangeDecoder) BitStream() kanzi.InputBitStream

BitStream returns the underlying bitstream

func (*RangeDecoder) Dispose

func (this *RangeDecoder) Dispose()

Dispose this implementation does nothing

func (*RangeDecoder) Read

func (this *RangeDecoder) Read(block []byte) (int, error)

Read decodes data from the bitstream and return it in the provided buffer. Decode the data chunk by chunk sequentially. Return the number of bytes read from the bitstream.

type RangeEncoder

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

RangeEncoder a Order 0 Range Entropy Encoder

func NewRangeEncoder

func NewRangeEncoder(bs kanzi.OutputBitStream, args ...uint) (*RangeEncoder, error)

NewRangeEncoder creates a new instance of RangeEncoder The given arguments are either empty or containing a chunk size and a log range (to specify the precision of the encoding). EG: call NewRangeEncoder(bs) or NewRangeEncoder(bs, 16384, 14) The default chunk size is 65536 bytes.

func (*RangeEncoder) BitStream

func (this *RangeEncoder) BitStream() kanzi.OutputBitStream

BitStream returns the underlying bitstream

func (*RangeEncoder) Dispose

func (this *RangeEncoder) Dispose()

Dispose this implementation does nothing

func (*RangeEncoder) Write

func (this *RangeEncoder) Write(block []byte) (int, error)

Write encodes the data provided into the bitstream. Return the number of byte written to the bitstream. Splits the input into chunks and encode chunks sequentially based on local statistics.

type RiceGolombDecoder

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

RiceGolombDecoder Exponential Golomb Entropy Decoder

func NewRiceGolombDecoder

func NewRiceGolombDecoder(bs kanzi.InputBitStream, sgn bool, logBase uint) (*RiceGolombDecoder, error)

NewRiceGolombDecoder creates a new instance of ExpGolombDecoder If sgn is true, values from the bitstream will be decoded as signed (int8)

func (*RiceGolombDecoder) BitStream

func (this *RiceGolombDecoder) BitStream() kanzi.InputBitStream

BitStream returns the underlying bitstream

func (*RiceGolombDecoder) DecodeByte

func (this *RiceGolombDecoder) DecodeByte() byte

DecodeByte decodes one byte from the bitstream If the decoder is sign aware, the returned value is an int8 cast to a byte

func (*RiceGolombDecoder) Dispose

func (this *RiceGolombDecoder) Dispose()

Dispose this implementation does nothing

func (*RiceGolombDecoder) Read

func (this *RiceGolombDecoder) Read(block []byte) (int, error)

Read decodes data from the bitstream and return it in the provided buffer. Return the number of bytes read from the bitstream

func (*RiceGolombDecoder) Signed

func (this *RiceGolombDecoder) Signed() bool

Signed returns true if this decoder is sign aware

type RiceGolombEncoder

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

RiceGolombEncoder a Rice Golomb Entropy Encoder

func NewRiceGolombEncoder

func NewRiceGolombEncoder(bs kanzi.OutputBitStream, sgn bool, logBase uint) (*RiceGolombEncoder, error)

NewRiceGolombEncoder creates a new instance of RiceGolombEncoder If sgn is true, values will be encoded as signed (int8) in the bitstream. Using a sign improves compression ratio for distributions centered on 0 (E.G. Gaussian) Example: -1 is better compressed as -1 (1 followed by '-') than as 255

func (*RiceGolombEncoder) BitStream

func (this *RiceGolombEncoder) BitStream() kanzi.OutputBitStream

BitStream returns the underlying bitstream

func (*RiceGolombEncoder) Dispose

func (this *RiceGolombEncoder) Dispose()

Dispose this implementation does nothing

func (*RiceGolombEncoder) EncodeByte

func (this *RiceGolombEncoder) EncodeByte(val byte)

EncodeByte encodes the given value into the bitstream

func (*RiceGolombEncoder) Signed

func (this *RiceGolombEncoder) Signed() bool

Signed returns true if this encoder is sign aware

func (*RiceGolombEncoder) Write

func (this *RiceGolombEncoder) Write(block []byte) (int, error)

Write encodes the data provided into the bitstream. Return the number of byte written to the bitstream

type TPAQMixer

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

TPAQMixer a mixer that combines models using neural networks with 8 inputs.

type TPAQPredictor

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

TPAQPredictor bit predictor for binary entropy codecs. It uses a mixer to combine initial predictions derived for several local contexts and a secondary symbol estimation to improve the prediction from the mixer. Initially based on Tangelo 2.4 (by Jan Ondrus). PAQ8 is written by Matt Mahoney. See http://encode.su/threads/1738-TANGELO-new-compressor-(derived-from-PAQ8-FP8)

func NewTPAQPredictor

func NewTPAQPredictor(ctx *map[string]interface{}) (*TPAQPredictor, error)

NewTPAQPredictor creates a new instance of TPAQPredictor using the provided map of options to select the sizes of internal structures.

func (*TPAQPredictor) Get

func (this *TPAQPredictor) Get() int

Get returns the value representing the probability of the next bit being 1 (in the [0..4095] range).

func (*TPAQPredictor) Update

func (this *TPAQPredictor) Update(bit byte)

Update updates the internal probability model based on the observed bit

Jump to

Keyboard shortcuts

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