arith

package
v0.0.0-...-c98f1fc Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2018 License: Unlicense Imports: 1 Imported by: 0

Documentation

Overview

This package implements simple arithmetic coders based on code by https://github.com/rygorous/mini_arith

Index

Constants

View Source
const (
	MaxP = 1 << probBits
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

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

func NewDecoder

func NewDecoder(data []byte) *Decoder

func (*Decoder) Decode

func (dec *Decoder) Decode(prob P) (bit uint)

type Encoder

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

func NewEncoder

func NewEncoder() *Encoder

func (*Encoder) Bytes

func (enc *Encoder) Bytes() []byte

func (*Encoder) Close

func (enc *Encoder) Close()

func (*Encoder) Encode

func (enc *Encoder) Encode(bit uint, prob P)

type Model

type Model interface {
	NBits() uint
	Encode(enc *Encoder, value uint)
	Decode(dec *Decoder) (value uint)
}

type P

type P uint32

efficient representation of probability

func Prob

func Prob(p float64) P

type Reader

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

func NewReader

func NewReader(data []byte, model Model) *Reader

func (*Reader) Read

func (r *Reader) Read(data []byte) (int, error)

type Shift

type Shift struct {
	P P
	I byte
}

func (*Shift) Decode

func (m *Shift) Decode(dec *Decoder) (bit uint)

func (*Shift) Encode

func (m *Shift) Encode(enc *Encoder, bit uint)

func (*Shift) NBits

func (m *Shift) NBits() uint

type Shift2

type Shift2 struct {
	P0 P
	I0 byte

	P1 P
	I1 byte
}

func (*Shift2) Decode

func (m *Shift2) Decode(dec *Decoder) (bit uint)

func (*Shift2) Encode

func (m *Shift2) Encode(enc *Encoder, bit uint)

func (*Shift2) NBits

func (m *Shift2) NBits() uint

type Shift4

type Shift4 struct {
	P [4]P
	I [4]byte
}

func (*Shift4) Decode

func (m *Shift4) Decode(dec *Decoder) (bit uint)

func (*Shift4) Encode

func (m *Shift4) Encode(enc *Encoder, bit uint)

func (*Shift4) NBits

func (m *Shift4) NBits() uint

type Tree

type Tree []Model

func NewEmptyTree

func NewEmptyTree(nbits uint) Tree

func NewTree

func NewTree(nbits uint, model func() Model) Tree

func (Tree) Decode

func (tree Tree) Decode(dec *Decoder) (value uint)

func (Tree) Encode

func (tree Tree) Encode(enc *Encoder, value uint)

func (Tree) NBits

func (tree Tree) NBits() uint

type Writer

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

func NewWriter

func NewWriter(model Model) *Writer

func (*Writer) Bytes

func (w *Writer) Bytes() []byte

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Write

func (w *Writer) Write(data []byte) (int, error)

Jump to

Keyboard shortcuts

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