bitreader

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 1 Imported by: 0

README

Test Coverage CI Go Report Card

Bitreader

Go module to read bits

Sample usage

data := []byte{0x1a, 0xfc, 0xda}

br := New(data)

br.Skip(8) // allow skipping of bits
r, err := br.ReadUint16()

Supported Types

The following types are allowed

uint8, uint16, uint32, uint64, int8, int16, int32, int64

Supported Functions

  1. Allows to read signed and unsigned Exp-Golomb codes through ReadUev() and ReadEv() functions
  2. Allows to Skip Bits via Skip(bits int)
  3. Allows appending to the backing byte array with Append(data []byte)

Documentation

Overview

Package bitreader takes byte array and provides abilitiy to read bits and various bit encoding

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitReader

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

func New

func New(data []byte) *BitReader

func (*BitReader) Append

func (b *BitReader) Append(data []byte)

func (*BitReader) CurrentIndex

func (b *BitReader) CurrentIndex() int

func (*BitReader) ReadBit

func (b *BitReader) ReadBit() (uint8, error)

func (*BitReader) ReadBits

func (b *BitReader) ReadBits(count int) (uint64, error)

func (*BitReader) ReadEv

func (reader *BitReader) ReadEv() (int64, error)

ReadEv reads signed exp-golomb codes

func (*BitReader) ReadFlag

func (b *BitReader) ReadFlag() (bool, error)

func (*BitReader) ReadInt8

func (b *BitReader) ReadInt8() (int8, error)

func (*BitReader) ReadInt16

func (b *BitReader) ReadInt16() (int16, error)

func (*BitReader) ReadInt32

func (b *BitReader) ReadInt32() (int32, error)

func (*BitReader) ReadInt64

func (b *BitReader) ReadInt64() (int64, error)

func (*BitReader) ReadUev

func (reader *BitReader) ReadUev() (uint64, error)

ReadUev reads unsigned exp-golomb codes

func (*BitReader) ReadUint8

func (b *BitReader) ReadUint8() (uint8, error)

func (*BitReader) ReadUint16

func (b *BitReader) ReadUint16() (uint16, error)

func (*BitReader) ReadUint32

func (b *BitReader) ReadUint32() (uint32, error)

func (*BitReader) ReadUint64

func (b *BitReader) ReadUint64() (uint64, error)

func (*BitReader) Reverse

func (b *BitReader) Reverse(count int) error

func (*BitReader) Skip

func (b *BitReader) Skip(bits int) error

func (*BitReader) Trim

func (b *BitReader) Trim()

Trims the underlying slice by removing the read bytes

Jump to

Keyboard shortcuts

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