bits

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: MIT, MIT Imports: 4 Imported by: 0

Documentation

Overview

Package bits implements bit reading and writing including EBSP.

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

Index

Constants

This section is empty.

Variables

View Source
var ErrNotReedSeeker = errors.New("Reader does not support Seek")

Functions

func EBSP2rbsp

func EBSP2rbsp(ebsp []byte) []byte

EBSP2rbsp - convert from EBSP to RBSP by removing start code emulation prevention bytes

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) IsSeeker added in v0.12.0

func (r *EBSPReader) IsSeeker() bool

IsSeeker - does reader support Seek

func (*EBSPReader) MoreRbspData added in v0.12.0

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

MoreRbspData - false if next bit is 1 and last 1 in fullSlice Underlying reader must support ReadSeeker interface to reset after check

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. Panic if not possible

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. Panic if not possible

func (*EBSPReader) NrBitsReadInCurrentByte added in v0.12.0

func (r *EBSPReader) NrBitsReadInCurrentByte() int

NrBitsReadInCurrentByte - how many bits have been read

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) ReadRbspTrailingBits added in v0.12.0

func (r *EBSPReader) ReadRbspTrailingBits() error

ReadRbspTrailingBits - read rbsp_traling_bits. Return false if wrong pattern

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 and panic if not possible

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 writing at first error. Errors that have occured can later be checked with 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