bits

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 License: MIT, MIT Imports: 2 Imported by: 0

README

This code is based on https://github.com/tcnksm/go-casper/tree/master/internal/bits

with the MIT license provided in the file LICENSE.md in this directory.

Documentation

Overview

Package bits implements bit reading and writing.

Beyond plain bit reading and writing, it includes reading of ebsp (Encapsulated Byte Sequence Packets) Golomb codes as usid in the AVC/H.264 video coding standard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EBSP2rbsp

func EBSP2rbsp(ebsp []byte) []byte

EBSP2rbsp - convert from EBSP to RBSP by removing escape 0x03 after two 0x00

Types

type EBSPReader

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

EBSPReader - Reader that drops start code emulation 0x03 after two bytes of 0x00

func NewEBSPReader

func NewEBSPReader(rd io.Reader) *EBSPReader

NewEBSPReader - return a new Reader.

func (*EBSPReader) MustRead

func (r *EBSPReader) MustRead(n int) uint

MustRead - read n bits and panic if not possible

func (*EBSPReader) MustReadExpGolomb

func (r *EBSPReader) MustReadExpGolomb() uint

MustReadExpGolomb - Read one unsigned exponential golomb code

func (*EBSPReader) MustReadFlag

func (r *EBSPReader) MustReadFlag() bool

MustReadFlag - read 1 bit into flag. Panic if not possible

func (*EBSPReader) MustReadSignedGolomb

func (r *EBSPReader) MustReadSignedGolomb() int

MustReadSignedGolomb - Read one signed exponential golomb code

func (*EBSPReader) NrBytesRead

func (r *EBSPReader) NrBytesRead() int

NrBytesRead - how many bytes read into parser

func (*EBSPReader) Read

func (r *EBSPReader) Read(n int) (uint, error)

Read - read n bits and return error if not possible

func (*EBSPReader) ReadExpGolomb

func (r *EBSPReader) ReadExpGolomb() (uint, error)

ReadExpGolomb - Read one unsigned exponential golomb code

func (*EBSPReader) ReadFlag

func (r *EBSPReader) ReadFlag() (bool, error)

ReadFlag - read 1 bit into flag. Return error if not possible

func (*EBSPReader) ReadSignedGolomb

func (r *EBSPReader) ReadSignedGolomb() (int, error)

ReadSignedGolomb - Read one signed exponential golomb code

type Reader

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

Reader - read bits from the given io.Reader

func NewReader

func NewReader(rd io.Reader) *Reader

NewReader - return a new Reader

func (*Reader) MustRead

func (r *Reader) MustRead(n int) uint

MustRead - Read bits and panic if not possible

func (*Reader) MustReadFlag

func (r *Reader) MustReadFlag() bool

MustReadFlag - read 1 bit into flag

func (*Reader) Read

func (r *Reader) Read(n int) (uint, error)

Read - read n bits

func (*Reader) ReadFlag

func (r *Reader) ReadFlag() (bool, error)

ReadFlag - read 1 bit into flag

type Writer

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

Writer writes bits into underlying io.Writer. Stops at first error

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter - returns a new Writer

func (*Writer) Error

func (w *Writer) Error() error

Error - error that has occured and stopped writing

func (*Writer) Flush

func (w *Writer) Flush()

Flush - write remaining bits to the underlying io.Writer. bits will be left-shifted.

func (*Writer) Write

func (w *Writer) Write(bits uint, n int)

Write - write n bits from bits and save error state

Jump to

Keyboard shortcuts

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