bitter

package module
v0.0.0-...-5095b38 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: BSD-2-Clause Imports: 2 Imported by: 5

README

bitter

bit encoding and decoding for SCTE-35

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

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

Decoder converts bytes to a list of bits.

func (*Decoder) As90k

func (dec *Decoder) As90k(bitcount uint) float64

As90k is Float / 90000.00 rounded to six decimal places.

func (*Decoder) Ascii

func (dec *Decoder) Ascii(bitcount uint) string

Ascii returns the Ascii chars of Bytes

func (*Decoder) Bool

func (dec *Decoder) Bool() bool

func (*Decoder) Bytes

func (dec *Decoder) Bytes(bitcount uint) []byte

Bytes slices bitcount of bits and returns as []bytes

func (*Decoder) Chunk

func (dec *Decoder) Chunk(bitcount uint) *big.Int

Chunk slices bitcount of bits and returns it as a uint64

func (*Decoder) Flag

func (dec *Decoder) Flag() bool

Flag slices 1 bit and returns true for 1 , false for 0

func (*Decoder) Float

func (dec *Decoder) Float(bitcount uint) float64

Float slices bitcount of bits and returns float64

func (*Decoder) Forward

func (dec *Decoder) Forward(bitcount uint)

Forward advances g.idx by bitcount

func (*Decoder) Hex

func (dec *Decoder) Hex(bitcount uint) string

Hex slices bitcount of bits and returns as hex string

func (*Decoder) Load

func (dec *Decoder) Load(bites []byte)

Load raw bytes and convert to bits

func (*Decoder) UInt16

func (dec *Decoder) UInt16(bitcount uint) uint16

uint16 trims uint64 to 16 bits

func (*Decoder) UInt32

func (dec *Decoder) UInt32(bitcount uint) uint32

uint32 trims uint64 to 32 bits

func (*Decoder) UInt64

func (dec *Decoder) UInt64(bitcount uint) uint64

uint64 is a wrapper for Chunk

func (*Decoder) UInt8

func (dec *Decoder) UInt8(bitcount uint) uint8

uint8 trims uint64 to 8 bits

type Encoder

type Encoder struct {
	Bites big.Int
}

Encoder packs data as bits for encoding.

func (*Encoder) Add

func (enc *Encoder) Add(val interface{}, nbits uint)

Add left shifts Encoder.Bites by nbits and add val interface{} as bits. Supports val as bool, float64, int, uint8, uint16, uint32,or uint64.

func (*Encoder) AddBytes

func (enc *Encoder) AddBytes(bites []byte, nbits uint)

Append a []byte as bits

func (*Encoder) AddHex64

func (enc *Encoder) AddHex64(val string, nbits uint)

AddHex64 append a hex string as uint64 in bits

func (*Encoder) Reserve

func (enc *Encoder) Reserve(num int)

Reserve left shifts Encoder.Bites by num and adds num bits set to 1

Jump to

Keyboard shortcuts

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