Adaptive pictures in QLX
Inside QLX adaptive packets: exact straight alpha, bilinear grids, Tag 8 cosine frames (OBMC, IBC, CCC, CfL, 5-level AQ, Wiener filter), piecewise planar regions, and scratch bounds.
Adaptive picture payloads follow the adaptive packet header (see Bitstream spec). Every RGB operation strictly preserves straight alpha at destination coordinates; RGB code values span 0..M (255 for SDR8, 1023 for 10-bit HDR).
Exact straight alpha & bilinear grids (Tag 5)
Every adaptive frame first reconstructs exact per-pixel straight alpha (unchanged delta ref, constant fill, ≤ 4096-sample literal/LZ4 blocks, top-predicted run replacements, or ref-preserving run replacements).
Tag 5 encodes sparse color grid anchors along causal row/temporal predictors and applies fixed-point separable bilinear interpolation (floor((4096a + 2048 + i × trunc(4096(b - a)/d)) / 4096)), representing smooth gradient backdrops in a few hundred bytes.
Cosine picture (Tag 8)
Reads base step S ∈ 2..16384 (quarter code units) followed by a flags byte:
- bits 0–1: Prediction mode (
0black key / zero-MV ref,1local motion field from ref,2delta scene-cut black reset) - bit 2 (
4): Boundary deblocking filter - bit 3 (
8): Rectangular scroll copy(x, y, width, height)by signed(dx, dy)before motion compensation (preserving destination alpha) - bit 4 (
16): Per-macroblock 5-level Adaptive Quantization (AQ) ([0.75×, 0.875×, 1.00×, 1.125×, 1.25×]) - bit 5 (
32): Separable symmetric 5-tap edge-clamped Wiener filter (t0 ∈ -24..24,t1 ∈ -32..32, ,thresh ≥ 1) - bit 6 (
64): Linear Chroma-from-Luma (CfL) AC prediction (α ∈ ±1..8× 1/8) - bit 7 (
128): Causal single-canvas Intra Block Copy (IBC) and 8×8 Color-Cell Compression (CCC)
Sub-pixel motion & causal 2-pixel OBMC
Prediction mode 1 selects adaptive precision shift prec ∈ 0..3 (1/8, 1/4, 1/2, or 1-pel step) within ±96 × ±48 pixels using separable Q7 cubic interpolation, plus a causal 2-pixel Overlapped Block Motion Compensation ([1/4, 1/8] blending across interior left and top boundaries) with zero additional frame buffer overhead.
Arithmetic coding, multi-scale transforms & loop filters
- Arithmetic stream: 32-bit range coding (
0xffffffffinitial range) over 512 12-bit adaptive contexts (>> 4general update,>> 5coefficient contexts forsig,gt1,gt2,rem). - Multi-scale YCoCg-R:
16×16(BASIS16),8×8(BASIS8), and fine-detail4×4(BASIS4_ODD = [669, 277]) luma splits alongside2..4-color CCC UI cells and causal IBC. - Dual-stage loop filter: Interior 8×8 vertical-then-horizontal deblocking (skipping boundaries inside
16×16transforms) followed by separable 5-tap edge-clamped Wiener filtering over a 5-row rolling buffer.
Decoder storage & scratch formula {#decoder-storage}
Reconstruction occurs on one single packed surface acting simultaneously as temporal reference. Motion compensation's 115-row circular backup stripe, 8×8 loop-filter flags, 5-row rolling Wiener buffer, and region boundary lists share a single reusable scratch region:
Textadaptive_scratch = max( 4 * width * min(height, 115) + 8 * ceil(width / 16), 13 * ceil(width / 8) + ceil(width / 16) + ceil(width / 8) * ceil(height / 8), 20 * width)
Added to the single width × height × 4 canvas, 8-byte-per-group seek table, ~2 KiB arithmetic context state, and fixed block buffers, total memory is validated upfront by budget on Decoder::open.