Documentation
¶
Overview ¶
Package loopfilter implements the VP9 deblocking loop filter (spec §8.8). All filter kernels operate on byte slices addressed via a step parameter, which allows the same code to handle both horizontal and vertical edges:
- horizontal edge: step = 1 (consecutive bytes in a row)
- vertical edge: step = stride (bytes to the next row)
The four filter widths:
filter4 – 4-tap narrow (inner 4×4 sub-block edges) filter8 – 8-tap wide (TX-block edges, luma/chroma) filter16 – 14-tap (super-block / large TX edges)
Index ¶
- func FilterEdge4(buf []byte, q0, step, width int, p Params)
- func FilterPlane(buf []byte, stride, width, height, bsLog2 int, p Params)
- func FilterPlaneWithLevels(buf []byte, stride, width, height, bsLog2 int, ...)
- func LevelForBlock(baseLevel int, segLFActive bool, segLFDelta int16, deltaEnabled bool, ...) int
- type Params
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterEdge4 ¶
FilterEdge4 filters a single 4-sample edge in buf at position q0 (index of the first sample on the "right/below" side of the edge). step is the address step between consecutive samples (1 for horizontal, stride for vertical). Requires buf[q0-4*step..q0+3*step] to be valid. width (flat filter) and wide (flat2 filter) select the kernel:
width=4: 4-tap narrow only width=8: 8-tap if flat, else 4-tap narrow width=16: 14-tap if flat2, 8-tap if flat, else 4-tap narrow
func FilterPlane ¶
FilterPlane applies the VP9 loop filter to one luma or chroma plane.
Each 4x4 block's edge is filtered with the given Params. For simplicity this API takes a uniform Params for the whole plane; a full implementation would supply per-block params derived from filter_level, ref_delta, etc.
The filter visits:
- All vertical edges (column boundaries at multiples of 4, left to right).
- All horizontal edges (row boundaries at multiples of 4, top to bottom).
For each 4-pixel column/row along an edge the EdgeWidth function determines which kernel to apply (4, 8, or 16 wide) based on the block size at that edge (bsLog2: 1=8px, 2=16px, 3=32/64px boundary).
buf – plane pixel data, row-major. stride – row stride in bytes (may be > width). width, height – plane dimensions in pixels. bsLog2 – log2 of the superblock size in pixels (2=4px blocks, 3=8px…).
Controls whether the wider 8/14-tap filters are engaged. Pass 2 for chroma or for simple filter mode.
func FilterPlaneWithLevels ¶
func FilterPlaneWithLevels(buf []byte, stride, width, height, bsLog2 int, paramsAt func(row4, col4 int) Params)
FilterPlaneWithLevels applies the VP9 loop filter with per-4×4-block level lookup. paramsAt(row4, col4) returns the Params for the block at that 4×4 grid position. Blocks with level=0 produce Params{} from paramsAt; FilterEdge4 no-ops when BLimit=0.
func LevelForBlock ¶
func LevelForBlock( baseLevel int, segLFActive bool, segLFDelta int16, deltaEnabled bool, refFrame int, isInter bool, isZeroMV bool, refDeltas [4]int, modeDeltas [2]int, ) int
LevelForBlock computes the per-block loop filter level (spec §8.8.1 / libvpx vp9_loop_filter.c).
segLFActive: SEG_LVL_ALT_LF is enabled for this block's segment. segLFDelta: the segment's LF delta (always additive, never absolute). deltaEnabled: frame-level mode_ref_delta_enabled flag. refFrame: 0=INTRA, 1=LAST, 2=GOLDEN, 3=ALTREF. isZeroMV: inter block with zero MV (uses modeDeltas[0], else modeDeltas[1]).
Types ¶
type Params ¶
type Params struct {
Limit uint8 // interior flatness threshold (lim_lut)
BLimit uint8 // block-edge threshold (2*limit + level)
Thresh uint8 // HEV threshold (thresh_lut)
}
Params holds the per-edge filter thresholds derived from a filter level.
func ParamsForLevel ¶
ParamsForLevel returns filter thresholds for level ∈ [0,63] and sharpness ∈ [0,7] (spec §8.8.3).