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 ¶
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).
const ( EightTap uint8 = iota EightTapSmooth EightTapSharp Bilinear Switchable )
The interpolation filters, numbered as interp_filter is (and as StdVideoVP9InterpolationFilter numbers them).
const MaxFrames = 8
MaxFrames is how many frames a superframe holds at most.
Variables ¶
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 ¶
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 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 ¶
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 leaves as it was; Update takes the frame into the state once it is decoded.
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.
func (*Stream) Update ¶
func (s *Stream) Update(h *FrameHeader)
Update takes the frame h heads, decoded, into the stream's state: the slots its refresh_frame_flags name (8.10), its loop filter deltas and segmentation, its colour config when it is intra, the frame contexts it resets and saves, and it as the frame decoded before the next. A frame that shows another changes nothing.
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. |