vp9

package
v0.3.20 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package vp9 reads the VP9 bitstream (VP9 Bitstream & Decoding Process Specification, version 0.6) as far as a decoder that keeps its own reference state needs: superframes and the uncompressed header, with the state its syntax and semantics predict from (the reference frames' sizes, the loop filter deltas, the segmentation features, whether a frame reuses the previous frame's motion vectors and which frame contexts hold probabilities frames saved). Decoding the compressed header and the tiles is the hardware's (Vulkan Video's).

Index

Constants

View Source
const (
	NumRefFrames = 8
	RefsPerFrame = 3
	// ResetOneContext and ResetAllContexts are the reset_frame_context
	// values that reset the frame context the header names and every
	// frame context.
	ResetOneContext  = 2
	ResetAllContexts = 3
	MaxSegments      = 8
	SegLvlMax        = 4
	// MaxRefFrames counts the reference names, intra included: the loop
	// filter's reference deltas are by them.
	MaxRefFrames = 4
	// LastFrame is the first reference name of an inter frame, the one
	// ref_frame_idx[0] names.
	LastFrame = 1
)

The constants of the syntax (3).

View Source
const (
	EightTap uint8 = iota
	EightTapSmooth
	EightTapSharp
	Bilinear
	Switchable
)

The interpolation filters, numbered as interp_filter is (and as StdVideoVP9InterpolationFilter numbers them).

View Source
const MaxFrames = 8

MaxFrames is how many frames a superframe holds at most.

Variables

View Source
var ErrSyntax = errors.New("vp9: stream")

ErrSyntax is a VP9 stream a decoder cannot read: malformed, or using syntax outside what it reads. Errors wrap it with what was read.

Functions

func Frames

func Frames(b []byte, frames *[MaxFrames][]byte) ([][]byte, error)

Frames splits b, a packet, into its frames (Annex B): a superframe's by its index, else b whole. The frames are slices of b in frames.

Types

type ColorConfig

type ColorConfig struct {
	BitDepth                   int
	ColorSpace                 ColorSpace
	FullRange                  bool
	SubsamplingX, SubsamplingY bool
}

ColorConfig is a color_config(), or what a frame that codes none takes from the frames before it.

type ColorSpace

type ColorSpace uint8

ColorSpace is a color_space.

const (
	CSUnknown ColorSpace = iota
	CSBT601
	CSBT709
	CSSMPTE170
	CSSMPTE240
	CSBT2020
	CSReserved
	CSRGB
)

The colour spaces.

type FrameHeader

type FrameHeader struct {
	Profile           uint8
	ShowExistingFrame bool
	FrameToShowMapIdx uint8

	FrameType          FrameType
	ShowFrame          bool
	ErrorResilientMode bool
	IntraOnly          bool
	ResetFrameContext  uint8
	Color              ColorConfig
	RefreshFrameFlags  uint8
	// RefFrameIdx is ref_frame_idx: the slot of each reference name
	// from LastFrame on. RefFrameSignBias is by reference name.
	RefFrameIdx      [RefsPerFrame]uint8
	RefFrameSignBias [MaxRefFrames]bool

	FrameWidth, FrameHeight     int
	RenderAndFrameSizeDifferent bool
	RenderWidth, RenderHeight   int

	AllowHighPrecisionMV      bool
	InterpolationFilter       uint8
	RefreshFrameContext       bool
	FrameParallelDecodingMode bool
	// FrameContextIdx is the frame context the frame decodes from and,
	// with RefreshFrameContext, saves to: the frame_context_idx coded,
	// but 0 for an intra or error resilient frame, whose coded one is
	// ResetContextIdx, the context a ResetFrameContext of
	// ResetOneContext resets.
	FrameContextIdx uint8
	ResetContextIdx uint8
	// SavedContexts has bit i set where a frame since the last reset of
	// frame context i saved to it, before this frame resets and saves
	// any: the contexts that may not be the default one.
	SavedContexts uint8

	LoopFilter LoopFilter
	Quant      Quantization
	Seg        Segmentation

	TileColsLog2, TileRowsLog2 uint8

	// UsePrevFrameMVs is UsePrevFrameMvs: whether the frame predicts
	// motion vectors from the frame decoded before it.
	UsePrevFrameMVs bool

	// HeaderBytes is the uncompressed header's size, its trailing bits
	// included: where the compressed header starts. CompressedBytes is
	// the compressed header's, header_size_in_bytes; the tiles follow.
	HeaderBytes, CompressedBytes int
}

FrameHeader is an uncompressed_header() (6.2), its values as its semantics (7.2) and the decoding process define them.

func (*FrameHeader) FrameIsIntra

func (h *FrameHeader) FrameIsIntra() bool

FrameIsIntra is FrameIsIntra.

type FrameType

type FrameType uint8

FrameType is a frame's frame_type.

const (
	KeyFrame FrameType = iota
	NonKeyFrame
)

The frame types.

func (FrameType) String

func (t FrameType) String() string

type LoopFilter

type LoopFilter struct {
	Level, Sharpness uint8
	DeltaEnabled     bool
	DeltaUpdate      bool
	UpdateRefDelta   uint8
	RefDeltas        [MaxRefFrames]int8
	UpdateModeDelta  uint8
	ModeDeltas       [2]int8
}

LoopFilter is a loop_filter_params(), the deltas it leaves out kept from the frames before. UpdateRefDelta and UpdateModeDelta have bit i set for each delta i coded.

type Quantization

type Quantization struct {
	BaseQIdx                          uint8
	DeltaQYDc, DeltaQUVDc, DeltaQUVAc int8
}

Quantization is a quantization_params().

type Segmentation

type Segmentation struct {
	Enabled, UpdateMap, TemporalUpdate bool
	UpdateData, AbsOrDeltaUpdate       bool
	TreeProbs                          [7]uint8
	PredProbs                          [3]uint8
	FeatureEnabled                     [MaxSegments][SegLvlMax]bool
	FeatureData                        [MaxSegments][SegLvlMax]int16
}

Segmentation is a segmentation_params(), the features it leaves out kept from the frames before. The probabilities are 255 where not coded.

type Stream

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

Stream is the state a stream's frame headers are read with.

func (*Stream) ParseFrame

func (s *Stream) ParseFrame(h *FrameHeader, b []byte) error

ParseFrame reads the uncompressed header of b, a frame, into h with the stream's state, which it moves on as decoding the frame does.

func (*Stream) Reset

func (s *Stream) Reset()

Reset forgets the reference frames and the frame decoded before: what decoding from a key frame after a seek does.

Directories

Path Synopsis
Package vp9test makes the VP9 frames libvpx codes none of, out of the ones it does, for tests of what reads and decodes them: frames that show a frame again, hidden intra-only frames, and key frames that code a frame context of their own.
Package vp9test makes the VP9 frames libvpx codes none of, out of the ones it does, for tests of what reads and decodes them: frames that show a frame again, hidden intra-only frames, and key frames that code a frame context of their own.

Jump to

Keyboard shortcuts

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