Documentation
¶
Overview ¶
Package refbuf manages VP9 reference frame buffers (spec §8.9.1).
VP9 maintains 8 named reference frame slots (indices 0..7). Each frame header carries a refresh_frame_flags bitmask that tells the decoder which slots to overwrite with the just-decoded frame. Three of the 8 slots have special names used during prediction:
LAST_FRAME = slot pointed to by ref_frame_idx[0] GOLDEN_FRAME = slot pointed to by ref_frame_idx[1] ALTREF_FRAME = slot pointed to by ref_frame_idx[2]
The three per-frame indices are decoded from the frame header; this package stores them in Refs and exposes accessor methods.
Frame layout ¶
Each Frame stores one luma (Y) plane and two chroma (U, V) planes. All planes have an BORDER-pixel border on every side (VP9 requires ≥ 8 pixels; we use 8). The pixel at position (row, col) of an N-wide plane is at:
buf[BORDER*stride + BORDER + row*stride + col]
where stride = width + 2*BORDER.
Index ¶
Constants ¶
const BORDER = 96
BORDER is the number of pixels added on every side of each plane for sub-pixel filter access. The 8-tap filter needs ±3..+4, but inter motion vectors point past the frame edge, and the MC reads the reference's border there. libvpx's decoder carries a 32-pixel border and falls back to an on-demand edge-replicating copy (extend_and_predict) for reads beyond it. We instead carry a wide border (replicating the frame edge, identical result to extend_and_predict) so any MV within BORDER pixels of the edge is exact.
Variables ¶
This section is empty.
Functions ¶
func ExtendBorders ¶
func ExtendBorders(f *Frame)
ExtendBorders replicates the edge pixels of each plane into the border region so that sub-pixel filters always have valid data to read.
func ExtendBorders16 ¶ added in v0.2.0
func ExtendBorders16(f *Frame16)
ExtendBorders16 replicates each visible edge into the border (see Frame).
Types ¶
type Buffer ¶
type Buffer struct {
// Refs[0..2] are the slot indices for LAST, GOLDEN, ALTREF respectively.
// Values are in [0,7]; default to 0 before any frame is decoded.
Refs [3]int
// contains filtered or unexported fields
}
Buffer holds VP9's 8 named reference frame slots. Slot indices 0..7 correspond to the hardware frame buffer pool. The three active reference frames are identified by Refs[0..2].
func (*Buffer) Get ¶
Get returns the frame currently stored in the given slot index (0..7). Returns nil if the slot has not been filled yet.
type Buffer16 ¶ added in v0.2.0
type Buffer16 struct {
Refs [3]int
// contains filtered or unexported fields
}
Buffer16 holds VP9's 8 reference-frame slots for 16-bit frames.
type Frame ¶
type Frame struct {
// Y, U, V are the luma and chroma planes including their borders.
Y, U, V []byte
// Stride is the row stride (in bytes) of each plane.
// For Y: stride = width + 2*BORDER
// For U/V: stride = width/2 + 2*BORDER (4:2:0)
YStride, UVStride int
// Width and height of the visible picture in pixels.
Width, Height int
}
Frame is one decoded reference frame (4:2:0 planar, 8-bit).
type Frame16 ¶ added in v0.2.0
type Frame16 struct {
Y, U, V []uint16
YStride, UVStride int
Width, Height int
BitDepth int // 10 or 12
}
Frame16 is one decoded reference frame with 16-bit samples (VP9 profile 2/3, 10/12-bit). It mirrors Frame but stores []uint16 planes; the 8-bit Frame is left untouched so its bit-exact pipeline is unaffected.
func NewFrame16 ¶ added in v0.2.0
NewFrame16 allocates a zero-initialised 16-bit 4:2:0 frame.