obu

package
v1.8.21 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 2 Imported by: 4

Documentation

Overview

Package obu implements tools for working with the Open Bitstream Unit.

Index

Constants

View Source
const (
	// OBUSequenceHeader av1 sequence_header_obu.
	OBUSequenceHeader = Type(1)
	// OBUTemporalDelimiter av1 temporal_delimiter_obu.
	OBUTemporalDelimiter = Type(2)
	// OBUFrameHeader av1 frame_header_obu.
	OBUFrameHeader = Type(3)
	// OBUTileGroup av1 tile_group_obu.
	OBUTileGroup = Type(4)
	// OBUMetadata av1 metadata_obu.
	OBUMetadata = Type(5)
	// OBUFrame av1 frame_obu.
	OBUFrame = Type(6)
	// OBURedundantFrameHeader av1 redundant_frame_header_obu.
	OBURedundantFrameHeader = Type(7)
	// OBUTileList av1 tile_list_obu.
	OBUTileList = Type(8)
	// OBUPadding av1 padding_obu.
	OBUPadding = Type(15)
)

OBU types as defined in the AV1 specification. 5.3.1: https://aomediacodec.github.io/av1-spec/av1-spec.pdf#page=39

Variables

View Source
var (
	// ErrInvalidOBUHeader is returned when an OBU header has forbidden bits set.
	ErrInvalidOBUHeader = errors.New("invalid OBU header")
	// ErrShortHeader is returned when an OBU header is not large enough.
	// This can happen when an extension header is expected but not present.
	ErrShortHeader = errors.New("OBU header is not large enough")
)
View Source
var ErrFailedToReadLEB128 = errors.New("payload ended before LEB128 was finished")

ErrFailedToReadLEB128 indicates that a buffer ended before a LEB128 value could be successfully read.

Functions

func EncodeLEB128

func EncodeLEB128(in uint) (out uint)

EncodeLEB128 encodes a uint as LEB128.

func ReadLeb128

func ReadLeb128(in []byte) (uint, uint, error)

ReadLeb128 scans an buffer and decodes a Leb128 value. If the end of the buffer is reached and all MSB are set an error is returned.

func WriteToLeb128 added in v1.8.4

func WriteToLeb128(in uint) []byte

WriteToLeb128 writes a uint to a LEB128 encoded byte slice.

Types

type ExtensionHeader added in v1.8.12

type ExtensionHeader struct {
	TemporalID    uint8
	SpatialID     uint8
	Reserved3Bits uint8
}

ExtensionHeader represents an OBU extension header obu_extension_header(). 5.3.3 https://aomediacodec.github.io/av1-spec/av1-spec.pdf#page=40

func ParseOBUExtensionHeader added in v1.8.12

func ParseOBUExtensionHeader(headerData byte) ExtensionHeader

ParseOBUExtensionHeader parses an OBU extension header from the given data. 5.3.3 https://aomediacodec.github.io/av1-spec/av1-spec.pdf#page=40

obu_extension_header() { Type
	temporal_id                      f(3)
	spatial_id                       f(2)
	extension_header_reserved_3bits  f(3)
}

func (*ExtensionHeader) Marshal added in v1.8.12

func (o *ExtensionHeader) Marshal() byte

Marshal serializes the OBU extension header to a byte slice. 5.3.3 https://aomediacodec.github.io/av1-spec/av1-spec.pdf#page=40

obu_extension_header() { Type
	temporal_id                      f(3)
	spatial_id                       f(2)
	extension_header_reserved_3bits  f(3)
}
type Header struct {
	Type            Type
	ExtensionHeader *ExtensionHeader
	HasSizeField    bool
	Reserved1Bit    bool
}

Header represents the header of an OBU obu_header(). 5.3.2: https://aomediacodec.github.io/av1-spec/av1-spec.pdf#page=40

func ParseOBUHeader added in v1.8.12

func ParseOBUHeader(data []byte) (*Header, error)

ParseOBUHeader parses an OBU header from the given data. 5.3.2: https://aomediacodec.github.io/av1-spec/av1-spec.pdf#page=40

obu_header() { Type
	obu_forbidden_bit     f(1)
	obu_type              f(4)
	obu_extension_flag    f(1)
	obu_has_size_field    f(1)
	obu_reserved_1bit     f(1)
	if ( obu_extension_flag == 1 )
		obu_extension_header()
	}
}

func (*Header) Marshal added in v1.8.12

func (o *Header) Marshal() []byte

Marshal serializes the OBU header to a byte slice. If the OBU has an extension header, the extension header is serialized as well. 5.3.2: https://aomediacodec.github.io/av1-spec/av1-spec.pdf#page=40

obu_header() { Type
	obu_forbidden_bit     f(1)
	obu_type              f(4)
	obu_extension_flag    f(1)
	obu_has_size_field    f(1)
	obu_reserved_1bit     f(1)
	if ( obu_extension_flag == 1 )
		obu_extension_header()
	}
}

func (*Header) Size added in v1.8.12

func (o *Header) Size() int

Size returns the size of the OBU header in bytes.

type OBU added in v1.8.12

type OBU struct {
	Header  Header
	Payload []byte
}

OBU represents an AV1 OBU. 5.1 https://aomediacodec.github.io/av1-spec/av1-spec.pdf#page=39

func (*OBU) Marshal added in v1.8.12

func (o *OBU) Marshal() []byte

Marshal serializes the OBU to low-overhead bitstream format. 5.2 https://aomediacodec.github.io/av1-spec/av1-spec.pdf#page=40

type Type added in v1.8.12

type Type uint8

Type represents the type of an AV1 OBU.

func (Type) String added in v1.8.12

func (o Type) String() string

Jump to

Keyboard shortcuts

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