diff --git a/crates/ec-av1/src/cdf.rs b/crates/ec-av1/src/cdf.rs index 2d9bdbba..6cff2d33 100644 --- a/crates/ec-av1/src/cdf.rs +++ b/crates/ec-av1/src/cdf.rs @@ -420,6 +420,14 @@ pub const PALETTE_UV_MODE: [[u16; 3]; 2] = [[32461, 32768, 0], [21488, 32768, 0] /// intra frame with `allow_intrabc` set. pub const INTRABC: [u16; 3] = [30531, 32768, 0]; +/// `default_delta_q_cdf` (entropymode.c:840-852, lane-realworld r4): the +/// 4-symbol `delta_q_abs` alphabet read once per superblock when +/// `delta_q_present` is set. `default_delta_lf_cdf`/`default_delta_lf_multi_cdf` +/// share this same value (verified against libaom's real source). +pub const DELTA_Q: [u16; 5] = [28160, 32120, 32677, 32768, 0]; +/// `default_delta_lf_cdf` -- see [`DELTA_Q`]'s doc. +pub const DELTA_LF: [u16; 5] = DELTA_Q; + /// `default_tx_size_cdf[0]` (entropymode.c): an 8x8 block's `tx_depth` flag /// (`TX8` vs `TX4`), indexed by `tx_size_context` (0..=2). pub const TX_SIZE_CAT0: [[u16; 3]; 3] = [[19968, 32768, 0], [19968, 32768, 0], [24320, 32768, 0]]; diff --git a/crates/ec-av1/src/cdf_state.rs b/crates/ec-av1/src/cdf_state.rs index b8b0e0ca..acb102e9 100644 --- a/crates/ec-av1/src/cdf_state.rs +++ b/crates/ec-av1/src/cdf_state.rs @@ -433,6 +433,16 @@ pub(crate) struct Cdfs { pub palette_uv_size: [[u16; 8]; 7], /// The `use_intrabc` flag -- see [`cdf::INTRABC`]. pub intrabc: [u16; 3], + /// `delta_q_abs` (lane-realworld r4, spec 5.11.10) -- see [`cdf::DELTA_Q`]. + pub delta_q: [u16; 5], + /// `delta_lf_abs`, the single-value form (spec 5.11.11) -- see + /// [`cdf::DELTA_LF`]. Currently unread: `delta_lf_present` still refuses + /// by name in `stream.rs` (the deblocker has no per-block carrier for + /// the result yet), kept here so the struct is ready for that round. + pub delta_lf: [u16; 5], + /// `delta_lf_abs[i]`, the `delta_lf_multi` per-plane/direction form + /// (`FRAME_LF_COUNT = 4`) -- same unread status as [`Self::delta_lf`]. + pub delta_lf_multi: [[u16; 5]; 4], } /// One motion vector component's adapting state (spec 9.4's `Default_Mv_*`, @@ -654,6 +664,9 @@ impl Cdfs { reset2(&mut self.palette_uv_mode); reset2(&mut self.palette_uv_size); reset1(&mut self.intrabc); + reset1(&mut self.delta_q); + reset1(&mut self.delta_lf); + reset2(&mut self.delta_lf_multi); } /// The defaults a key frame starts from (spec 8.4, `init_coeff_cdfs` and @@ -1114,6 +1127,9 @@ impl Cdfs { palette_uv_mode: cdf::PALETTE_UV_MODE, palette_uv_size: cdf::PALETTE_UV_SIZE, intrabc: cdf::INTRABC, + delta_q: cdf::DELTA_Q, + delta_lf: cdf::DELTA_LF, + delta_lf_multi: [cdf::DELTA_LF; 4], } } diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 18123925..c82e3b99 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -21,7 +21,7 @@ //! too). Anything outside that refuses with [`Error::unsupported`] rather than //! silently miscoding. -use ec_av1_syntax::{CdefParams, LoopFilterParams, TileInfo}; +use ec_av1_syntax::{CdefParams, DeltaParams, LoopFilterParams, TileInfo}; use ec_core::{Error, Result}; use crate::cdf; @@ -106,6 +106,133 @@ pub(crate) fn cdef_idx_hits() -> usize { CDEF_IDX_HITS.with(|c| c.get()) } +// lane-realworld r4: this frame's `delta.q_present` (spec 5.9.17) and its +// actual step (`1 << delta.q_res`, already the real multiplier, not the raw +// 2-bit field). `false`/`1` (the defaults) make [`maybe_read_delta_q`] a +// true no-op, matching every existing gate stream's `delta_q_present == 0` +// behaviour exactly, the same corner-cut [`CDEF_BITS`] takes above. +thread_local! { + static DELTA_Q_PRESENT: std::cell::Cell = const { std::cell::Cell::new(false) }; + static DELTA_Q_RES: std::cell::Cell = const { std::cell::Cell::new(1) }; +} +// The running quantizer index (spec `CurrentQIndex`, libaom +// `xd->current_base_qindex`) -- reset to the frame's own `base_q_idx` at the +// top of every tile (spec `decode_tile`), carried across superblocks within +// that tile, and mutated only by [`maybe_read_delta_q`]. Read back at the +// dequantization call sites instead of the frame-constant `base_q_idx`. +thread_local! { + static CURRENT_Q_IDX: std::cell::Cell = const { std::cell::Cell::new(0) }; +} +// How many real `delta_q_present` symbol groups [`maybe_read_delta_q`] has +// read, across every call on the current thread -- the gate's proof that a +// `delta_q_present` stream actually reached the new reader. +thread_local! { + static DELTA_Q_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// Current value of [`DELTA_Q_HITS`]. +pub(crate) fn delta_q_hits() -> usize { + DELTA_Q_HITS.with(|c| c.get()) +} + +/// `read_delta_qindex`/`read_delta_q_params` (spec 5.11.10, libaom +/// `decodemv.c:85-146,735-770`), called right after [`maybe_read_cdef_idx`] +/// at every block-decode call site (spec order `skip -> cdef -> delta_q`). +/// A no-op when `delta_q_present` is unset, or when this block is not at the +/// superblock's own top-left MI position (`b_row == 0 && b_col == 0` in +/// libaom, collapsed here to a position check since a partition tree's +/// top-left leaf is the only block that can ever land there), or when that +/// leaf both *is* the whole superblock and is `skip` (the one case libaom +/// itself skips the read, state carrying over unchanged). +fn maybe_read_delta_q(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi_c: usize, is_whole_sb: bool, skip: bool) { + if !DELTA_Q_PRESENT.with(|c| c.get()) { + return; + } + if mi_r % SB_MI as usize != 0 || mi_c % SB_MI as usize != 0 { + return; + } + if is_whole_sb && skip { + return; + } + let mut abs = dec.symbol(&mut cdfs.delta_q) as i32; + const DELTA_Q_SMALL: i32 = 3; + if abs >= DELTA_Q_SMALL { + let rem_bits = dec.literal(3) + 1; + let thr = (1i32 << rem_bits) + 1; + abs = dec.literal(rem_bits) as i32 + thr; + } + let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; + let reduced = if sign_negative { -abs } else { abs }; + DELTA_Q_HITS.with(|c| c.set(c.get() + 1)); + let res = DELTA_Q_RES.with(|c| c.get()); + CURRENT_Q_IDX.with(|c| c.set((c.get() + reduced * res).clamp(1, 255))); +} + +// lane-realworld r5: this frame's `delta.lf_present`/`lf_res`/`lf_multi` +// (spec 5.9.18) -- same no-op-by-default corner-cut as `DELTA_Q_PRESENT`. +thread_local! { + static DELTA_LF_PRESENT: std::cell::Cell = const { std::cell::Cell::new(false) }; + static DELTA_LF_RES: std::cell::Cell = const { std::cell::Cell::new(1) }; + static DELTA_LF_MULTI: std::cell::Cell = const { std::cell::Cell::new(false) }; +} +// The running per-plane/direction loop-filter delta (spec `DeltaLF[i]`, +// `i` in `0..FRAME_LF_COUNT`) -- reset to `[0; 4]` at the top of every tile, +// mutated only by [`maybe_read_delta_lf`]. `!delta_lf_multi` mode only ever +// updates index 0 and every reader treats that as the value for all 4 +// indices (spec `read_delta_lf_params`'s own single-cdf branch). +thread_local! { + static CURRENT_DELTA_LF: std::cell::Cell<[i32; 4]> = const { std::cell::Cell::new([0; 4]) }; +} +// How many real `delta_lf_present` symbol groups [`maybe_read_delta_lf`] has +// read -- the gate's proof the reader fired, mirroring [`DELTA_Q_HITS`]. +thread_local! { + static DELTA_LF_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// Current value of [`DELTA_LF_HITS`]. +pub(crate) fn delta_lf_hits() -> usize { + DELTA_LF_HITS.with(|c| c.get()) +} + +/// `read_delta_lflevel`/`read_delta_lf_params` (spec 5.11.11, libaom +/// `decodemv.c:99-146,735-770`) -- same shape and same call-site gating as +/// [`maybe_read_delta_q`] (spec order `delta_q -> delta_lf`), looped over +/// `FRAME_LF_COUNT = 4` planes/directions when `delta_lf_multi` is set, or +/// read once into index 0 otherwise. +fn maybe_read_delta_lf(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi_c: usize, is_whole_sb: bool, skip: bool) { + if !DELTA_LF_PRESENT.with(|c| c.get()) { + return; + } + if mi_r % SB_MI as usize != 0 || mi_c % SB_MI as usize != 0 { + return; + } + if is_whole_sb && skip { + return; + } + let multi = DELTA_LF_MULTI.with(|c| c.get()); + let res = DELTA_LF_RES.with(|c| c.get()); + let count = if multi { 4 } else { 1 }; + let mut cur = CURRENT_DELTA_LF.with(|c| c.get()); + for i in 0..count { + let mut abs = if multi { + dec.symbol(&mut cdfs.delta_lf_multi[i]) as i32 + } else { + dec.symbol(&mut cdfs.delta_lf) as i32 + }; + const DELTA_LF_SMALL: i32 = 3; + if abs >= DELTA_LF_SMALL { + let rem_bits = dec.literal(3) + 1; + let thr = (1i32 << rem_bits) + 1; + abs = dec.literal(rem_bits) as i32 + thr; + } + let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; + let reduced = if sign_negative { -abs } else { abs }; + cur[i] = (cur[i] + reduced * res).clamp(-63, 63); + DELTA_LF_HITS.with(|c| c.set(c.get() + 1)); + } + CURRENT_DELTA_LF.with(|c| c.set(cur)); +} + /// `read_cdef` (spec 5.11.56, libaom `decodemv.c:read_cdef`), called right /// after `skip` is known at every block-decode call site. A no-op at /// `cdef.bits == 0` (0-bit literal, nothing to consume) -- and @@ -1458,6 +1585,14 @@ struct Neighbours { /// widened from a bare `is_inter` bool, which collapsed every non-`LAST` /// reference onto `LAST_FRAME`'s own delta). ref_grid: Vec, + /// Per-4x4-mi snapshot of [`CURRENT_DELTA_LF`] at the moment this cell's + /// block was decoded (spec `DeltaLF[i]`, `i` in `0..FRAME_LF_COUNT`, + /// Y-vertical/Y-horizontal/U/V) -- lane-realworld r5: `lf_level`'s + /// per-block additive term, mirroring [`Self::ref_grid`]'s own snapshot + /// pattern. `!delta_lf_multi` mode broadcasts index 0 into all 4 slots + /// at write time ([`Self::fill_lf_grid_rect`]) so a reader never needs + /// to know which mode produced the value. + delta_lf_grid: Vec<[i8; 4]>, /// This tile's own top-left corner, in 4x4 mode-info units (spec /// `MiRowStart`/`MiColStart`) -- lane-tiles: every "is there really a /// neighbour" check compares against this instead of literal `0`, since a @@ -1507,6 +1642,7 @@ impl Neighbours { tx_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], ref_grid: vec![0i8; cols * (SUB / MI) * rows * (SUB / MI)], + delta_lf_grid: vec![[0i8; 4]; cols * (SUB / MI) * rows * (SUB / MI)], tile_row0_mi: 0, tile_col0_mi: 0, } @@ -1568,6 +1704,12 @@ impl Neighbours { ref_frame: i8, ) { let (mi_r, mi_c) = at_mi; + let cur = CURRENT_DELTA_LF.with(|c| c.get()); + let snapshot: [i8; 4] = if DELTA_LF_MULTI.with(|c| c.get()) { + std::array::from_fn(|i| cur[i].clamp(-63, 63) as i8) + } else { + [cur[0].clamp(-63, 63) as i8; 4] + }; for rr in 0..h_mi { for cc in 0..w_mi { let idx = (mi_r + rr) * self.skip_grid_cols_mi + (mi_c + cc); @@ -1580,6 +1722,9 @@ impl Neighbours { if let Some(cell) = self.ref_grid.get_mut(idx) { *cell = ref_frame; } + if let Some(cell) = self.delta_lf_grid.get_mut(idx) { + *cell = snapshot; + } } } } @@ -2139,6 +2284,11 @@ fn read_intra_mode_rect( } let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0; maybe_read_cdef_idx(dec, mi_r, mi_c, skip); + // A HORZ/VERT rect strip is never the whole superblock (`bw`/`bh` never + // both 64 here -- see this fn's own doc), so `is_whole_sb` is always + // `false`. + maybe_read_delta_q(dec, cdfs, mi_r, mi_c, false, skip); + maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, false, skip); let above_ctx = INTRA_MODE_CTX[above_mode]; let left_ctx = INTRA_MODE_CTX[left_mode]; let mode = dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]); @@ -2466,7 +2616,7 @@ fn decode_block_rect( bw, bh, 8, - i32::from(base_q_idx), + CURRENT_Q_IDX.with(|c| c.get()), luma_tx_type, ); y.reconstruct_rect( @@ -2505,7 +2655,7 @@ fn decode_block_rect( chroma_w, chroma_h, 8, - i32::from(base_q_idx), + CURRENT_Q_IDX.with(|c| c.get()), u_tx_type, ); u.reconstruct_rect( @@ -2543,7 +2693,7 @@ fn decode_block_rect( chroma_w, chroma_h, 8, - i32::from(base_q_idx), + CURRENT_Q_IDX.with(|c| c.get()), v_tx_type, ); v.reconstruct_rect( @@ -2612,6 +2762,8 @@ fn read_intra_mode( // spec order (see the comment below on `read_intrabc_info`): `skip`, // `segment_id`, `cdef`, `delta_q` -- `cdef` lands right here. maybe_read_cdef_idx(dec, mi_r, mi_c, skip); + maybe_read_delta_q(dec, cdfs, mi_r, mi_c, side == 64, skip); + maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, side == 64, skip); // `read_intrabc_info` (spec 5.11.13, libaom decodemv.c:693, called at // :811 right after `skip_txfm`/`segment_id`/`cdef`/`delta_q` and before // `mbmi->mode` is ever read): a `use_intrabc` symbol only present on an @@ -3161,7 +3313,7 @@ fn read_plane( } full }; - let residual = dequant_and_inverse_typed(&levels, side, 8, i32::from(base_q_idx), tx_type); + let residual = dequant_and_inverse_typed(&levels, side, 8, CURRENT_Q_IDX.with(|c| c.get()), tx_type); if std::env::var_os("EC_AV1_TRACE").is_some() { eprintln!( "TRACE dequant plane={plane_idx} base_q_idx={base_q_idx} tx_type={tx_type:?} side={side} levels={levels:?} residual={residual:?}", @@ -4198,7 +4350,7 @@ fn unit_log2(px: u32) -> i32 { /// the flat `mode_deltas[1]` this used before was a `LAST_FRAME`-reachable /// wrong delta on every `GLOBALMV` block, masked while any `GOLDEN_FRAME` /// block anywhere aborted the whole stream's decode before comparison). -fn lf_level(lf: &LoopFilterParams, plane_idx: usize, dir: usize, ref_frame: i8) -> i32 { +fn lf_level(lf: &LoopFilterParams, plane_idx: usize, dir: usize, ref_frame: i8, delta_lf: i32) -> i32 { let base = i32::from(if plane_idx == 0 { lf.level[dir] } else if plane_idx == 1 { @@ -4206,6 +4358,10 @@ fn lf_level(lf: &LoopFilterParams, plane_idx: usize, dir: usize, ref_frame: i8) } else { lf.level[3] }); + // spec 7.14.4: the per-superblock `DeltaLF` term applies before the + // ref/mode delta scaling below, and regardless of `delta_enabled` + // (that flag only gates `ref_deltas`/`mode_deltas`). + let base = (base + delta_lf).clamp(0, 63); if !lf.delta_enabled { return base; } @@ -4257,9 +4413,12 @@ fn edge_params( tx_h_px_at(n, chroma, pv_mi_r, pv_mi_c) }; let pv_ref = n.ref_grid[pv_mi_r * n.skip_grid_cols_mi + pv_mi_c]; + let delta_idx = if plane_idx == 0 { dir } else { plane_idx + 1 }; + let cur_delta_lf = i32::from(n.delta_lf_grid[mi_r * n.skip_grid_cols_mi + mi_c][delta_idx]); + let pv_delta_lf = i32::from(n.delta_lf_grid[pv_mi_r * n.skip_grid_cols_mi + pv_mi_c][delta_idx]); - let cur_level = lf_level(lf, plane_idx, dir, cur_ref); - let pv_level = lf_level(lf, plane_idx, dir, pv_ref); + let cur_level = lf_level(lf, plane_idx, dir, cur_ref, cur_delta_lf); + let pv_level = lf_level(lf, plane_idx, dir, pv_ref, pv_delta_lf); if cur_level == 0 && pv_level == 0 { return None; } @@ -4759,6 +4918,7 @@ pub fn decode_key_frame_tile( allow_screen_content_tools: bool, allow_intrabc: bool, ) -> Result { + let delta = DeltaParams::default(); let single_tile = TileInfo { mi_col_starts: vec![0, mi_cols], mi_row_starts: vec![0, mi_rows], @@ -4781,6 +4941,7 @@ pub fn decode_key_frame_tile( reduced_tx_set, allow_screen_content_tools, allow_intrabc, + delta, ) .map(|(picture, _)| picture) } @@ -4810,6 +4971,11 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( reduced_tx_set: bool, allow_screen_content_tools: bool, allow_intrabc: bool, + // lane-realworld r4: this frame header's own `delta` (spec 5.9.17/5.9.18) + // -- only `q_present`/`q_res` are actually read ([`maybe_read_delta_q`]); + // `stream.rs` still refuses a frame with `lf_present` set before this + // function is ever called. + delta: DeltaParams, ) -> Result<(Picture, Cdfs)> { if mi_cols == 0 || mi_rows == 0 { return Err(unsupported("a frame with no mode-info grid")); @@ -4819,6 +4985,11 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( CDEF_BITS.with(|c| c.set(cdef.bits)); CDEF_SB_COLS.with(|c| c.set(sb_cols as usize)); CDEF_IDX_GRID.with(|g| *g.borrow_mut() = vec![0u8; sb_cols as usize * sb_rows as usize]); + DELTA_Q_PRESENT.with(|c| c.set(delta.q_present)); + DELTA_Q_RES.with(|c| c.set(1i32 << delta.q_res)); + DELTA_LF_PRESENT.with(|c| c.set(delta.lf_present)); + DELTA_LF_RES.with(|c| c.set(1i32 << delta.lf_res)); + DELTA_LF_MULTI.with(|c| c.set(delta.lf_multi)); let (cols32, rows32) = block_grid(mi_cols, mi_rows); let (true_width, true_height) = ((mi_cols * 4) as usize, (mi_rows * 4) as usize); let (width, height) = (cols32 as usize * BLOCK, rows32 as usize * BLOCK); @@ -4898,6 +5069,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( let (sb_c0, sb_c1) = ((mi_col0 / SB_MI).min(sb_cols), mi_col1.div_ceil(SB_MI).min(sb_cols)); let mut cdfs = base_cdfs.clone(); + // spec `decode_tile`: `CurrentQIndex` resets to the frame's own + // `base_q_idx` at the top of every tile, not once per frame. + CURRENT_Q_IDX.with(|c| c.set(i32::from(base_q_idx))); + CURRENT_DELTA_LF.with(|c| c.set([0; 4])); if std::env::var_os("EC_AV1_TRACE").is_some() { eprintln!( "TRACE key_tile_bytes tile={tile_num} len={} first8={:02x?} base_q_idx={base_q_idx} mi_cols={mi_cols} mi_rows={mi_rows}", @@ -5680,7 +5855,7 @@ fn read_inter_plane( dc_sign_ctx(around.2), default_tx_type, )?; - let residual = dequant_and_inverse_typed(&grid, side, 8, i32::from(base_q_idx), tx_type); + let residual = dequant_and_inverse_typed(&grid, side, 8, CURRENT_Q_IDX.with(|c| c.get()), tx_type); plane.reconstruct_mc(x, y, side, prediction, &residual); Ok((grid, tx_type)) } @@ -6771,6 +6946,8 @@ fn decode_inter_block( let skip_ctx = usize::from(neighbours.above_skip[c]) + usize::from(neighbours.left_skip[r]); let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; maybe_read_cdef_idx(dec, r * SUB_MI as usize, c * SUB_MI as usize, skip); + maybe_read_delta_q(dec, cdfs, r * SUB_MI as usize, c * SUB_MI as usize, side == 64, skip); + maybe_read_delta_lf(dec, cdfs, r * SUB_MI as usize, c * SUB_MI as usize, side == 64, skip); // lane-warp r5: see `reject_residual` -- a square-block decode of a // HORZ_B strip is symbol-exact only for `skip` (no residual, no // motion_mode/warp symbol), so gate here before any further read. @@ -8541,6 +8718,9 @@ fn decode_inter_block8( let skip_ctx = usize::from(above_skip) + usize::from(left_skip); let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; maybe_read_cdef_idx(dec, leaf_mi.0, leaf_mi.1, skip); + // Always a `BLOCK_8X8` leaf here, never the whole superblock. + maybe_read_delta_q(dec, cdfs, leaf_mi.0, leaf_mi.1, false, skip); + maybe_read_delta_lf(dec, cdfs, leaf_mi.0, leaf_mi.1, false, skip); let (has_above, has_left) = ( leaf_mi.0 > neighbours.tile_row0_mi, @@ -9527,6 +9707,7 @@ pub fn decode_inter_frame_tile( false, false, false, + DeltaParams::default(), ) .map(|(picture, _, _)| picture) } @@ -9597,6 +9778,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( // palette syntax libaom's `read_intra_block_mode_info` reads under the // same `av1_allow_palette` gate as the key-frame path. allow_screen_content_tools: bool, + // lane-realworld r5: this frame header's own `delta` (spec 5.9.17/5.9.18), + // same contract as [`decode_key_frame_tile_with_cdfs`]'s own `delta` + // param -- only `q_present`/`q_res` are read. + delta: DeltaParams, ) -> Result<(Picture, Cdfs, crate::motion_field::MotionField)> { let tpl_frame = tpl_field.map(|field| TplFrameArgs { field, @@ -9745,6 +9930,16 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( let base_cdfs = initial_cdfs.unwrap_or_else(|| Cdfs::new(q_ctx_of(base_q_idx))); let mut result_cdfs = base_cdfs.clone(); + // spec `decode_tile`: `CurrentQIndex`/`DeltaLF` reset to the frame's own + // `base_q_idx`/zero at the top of every tile, not once per frame (mirrors + // `decode_key_frame_tile_with_cdfs`'s per-tile reset below); the + // delta_q/delta_lf presence/resolution flags themselves are frame-level + // and set once here. + DELTA_Q_PRESENT.with(|c| c.set(delta.q_present)); + DELTA_Q_RES.with(|c| c.set(1i32 << delta.q_res)); + DELTA_LF_PRESENT.with(|c| c.set(delta.lf_present)); + DELTA_LF_RES.with(|c| c.set(1i32 << delta.lf_res)); + DELTA_LF_MULTI.with(|c| c.set(delta.lf_multi)); let mut neighbours = Neighbours::new( cols as usize * 2, rows as usize * 2, @@ -9774,6 +9969,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( mi_col1.div_ceil(SB_MI).min(sb_cols), ); let mut cdfs = base_cdfs.clone(); + CURRENT_Q_IDX.with(|c| c.set(i32::from(base_q_idx))); + CURRENT_DELTA_LF.with(|c| c.set([0; 4])); let mut dec = SymbolDecoder::new(data); // lane-comppin r9: tile-entry range, the earliest point comparable // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 07f6e339..607ca923 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -50,7 +50,6 @@ const REFUSALS: &[&str] = &[ "a block that actually uses intrabc (this decoder never reconstructs one)", "a frame OBU with no tile group", "a frame naming primary_ref_frame at a reference slot with no saved CDF state", - "a frame with delta_q_present or delta_lf_present set (this decoder never reads the per-superblock delta symbols)", "a frame with loop restoration enabled (this decoder never reads the per-unit lr symbols)", "a frame with no mode-info grid", "a frame with segmentation enabled (this decoder never reads a per-block segment_id symbol)", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 4cc50e99..0c60ee35 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -170,6 +170,11 @@ pub fn decode_stream(data: &[u8]) -> Result> { // intrabc call at all -- that symbol is intra-frame-only). A // genuine palette/intrabc use still refuses by name deeper in the // block readers, so no whole-frame refusal is needed here anymore. + // lane-realworld r5: both delta_q (maybe_read_delta_q, CURRENT_Q_IDX) + // and delta_lf (maybe_read_delta_lf, CURRENT_DELTA_LF -> + // Neighbours::delta_lf_grid -> lf_level) are now read and applied; + // no whole-frame refusal needed here anymore. + // // Both AV1 files in this box's own library (a 2160p HDR10 encode and a // 1080p one, probed 2026-08-30 through `examples/decode_probe`) are // `yuv420p10le`, and every buffer this decoder reconstructs into -- @@ -189,12 +194,6 @@ pub fn decode_stream(data: &[u8]) -> Result> { "a stream whose bit depth is not 8 (this decoder reconstructs into 8-bit planes)", )); } - if header.delta.q_present || header.delta.lf_present { - return Err(Error::unsupported( - "AV1 decode_stream", - "a frame with delta_q_present or delta_lf_present set (this decoder never reads the per-superblock delta symbols)", - )); - } if header.segmentation.enabled { return Err(Error::unsupported( "AV1 decode_stream", @@ -415,6 +414,7 @@ pub fn decode_stream(data: &[u8]) -> Result> { header.reduced_tx_set, header.allow_screen_content_tools, header.allow_intrabc, + header.delta, )?; // A key frame codes no inter blocks -- its own saved motion // field has no cells set, matching libaom's own "intra frame @@ -499,6 +499,7 @@ pub fn decode_stream(data: &[u8]) -> Result> { header.is_motion_mode_switchable, header.allow_warped_motion, header.allow_screen_content_tools, + header.delta, )? }; // Spec 7.20: `disable_frame_end_update_cdf` stores the frame's @@ -6187,6 +6188,7 @@ mod tests { header.reduced_tx_set, header.allow_screen_content_tools, header.allow_intrabc, + header.delta, ) { Err(e) => { let msg = e.to_string(); @@ -6392,6 +6394,7 @@ mod tests { header.reduced_tx_set, header.allow_screen_content_tools, header.allow_intrabc, + header.delta, ) { Err(e) => { let msg = e.to_string(); @@ -6705,6 +6708,7 @@ mod tests { header.reduced_tx_set, header.allow_screen_content_tools, header.allow_intrabc, + header.delta, ) { Err(e) => { let msg = e.to_string(); @@ -7042,6 +7046,207 @@ mod tests { "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20" ); } + /// lane-realworld r6: r5 ported `maybe_read_delta_q`/`maybe_read_delta_lf` + /// and removed the whole-frame refusal, but no fixture anywhere set + /// `delta_lf_present` -- the removal was unproven. `--deltaq-mode=2` + /// (`DELTA_Q_PERCEPTUAL`, checked against libaom's own + /// `encodeframe.c:2192-2225`) sets `delta_q_present_flag` unconditionally + /// once `base_qindex > 0` (unlike the default `--deltaq-mode=1` + /// `DELTA_Q_OBJECTIVE`, which additionally requires an alt-ref-eligible + /// frame and `allow_deltaq_mode`'s own RD search); `--delta-lf-mode=1` + /// then ANDs `delta_lf_present_flag` on top + /// (`tool_cfg->enable_deltalf_mode`, `av1_cx_iface.c:1269-1270`). 128x64 + /// (2 SBs; this decoder hardcodes 64px SBs) is the charter's minimum for + /// a per-superblock symbol to have somewhere to differ; `--cpu-used=4` + /// (not the other gates' `=0`) sidesteps the multi-SB + /// HORZ_4/VERT_B-at-part64 gap the cdef gate's own comment documents + /// (lane-realworld r2 dead-end, part64 only covers NONE/SPLIT). Note: + /// libaom hardcodes `delta_lf_multi = DEFAULT_DELTA_LF_MULTI == 0` + /// (`enums.h:73`) with no CLI flag to set it -- this gate cannot and + /// does not claim to exercise this decoder's `delta_lf_multi` branch; + /// only the single-plane path is gate-proven. + #[test] + fn a_real_aomenc_stream_with_delta_q_and_delta_lf_decodes_pixel_exact() { + const NAME: &str = "a_real_aomenc_stream_with_delta_q_and_delta_lf_decodes_pixel_exact"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + if !have_aomenc() { + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); + return; + } + let (width, height, frame_count) = (128usize, 64usize, 24usize); + let mut named_refusals = 0u32; + let mut matched = 0u32; + let n_attempts: u32 = std::env::var("EC_DELTAQ_GATE_ATTEMPTS") + .ok() + .and_then(|s| s.parse().ok()) + .unwrap_or(40); + for attempt in 0..n_attempts { + let seed = 42 + attempt; + let duration = frame_count as f64 / 25.0; + // Mandelbrot's varying local contrast is what gives + // DELTA_Q_PERCEPTUAL's per-superblock RD something to + // differentiate; flat gradients risk every superblock + // resolving the same delta. + let source = format!( + "mandelbrot=size={width}x{height}:rate=25:start_x={sx}:start_y={sy}", + sx = -0.6 + 0.005 * (attempt as f64), + sy = -0.4 + 0.005 * (attempt as f64) + ); + let y4m = Command::new("ffmpeg") + .args([ + "-v", + "error", + "-f", + "lavfi", + "-i", + &source, + "-t", + &duration.to_string(), + "-pix_fmt", + "yuv420p", + "-f", + "yuv4mpegpipe", + "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "ffmpeg fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let args: Vec<&str> = vec![ + "--codec=av1", + "--passes=1", + "--end-usage=q", + "--cq-level=45", + "--cpu-used=4", + "--aq-mode=0", + "--deltaq-mode=2", + "--delta-lf-mode=1", + "--kf-max-dist=1000", + "--threads=1", + "--row-mt=0", + "--sb-size=64", + "--auto-alt-ref=1", + "--lag-in-frames=16", + "--enable-fwd-kf=0", + "--enable-order-hint=1", + "--enable-warped-motion=1", + "--enable-global-motion=0", + "--enable-obmc=1", + "--tune-content=default", + "--enable-masked-comp=1", + "--enable-dist-wtd-comp=0", + "--enable-interintra-comp=1", + "--enable-onesided-comp=0", + "--enable-interintra-wedge=0", + "--enable-smooth-interintra=1", + "--enable-rect-partitions=0", + "--enable-ab-partitions=0", + "--enable-1to4-partitions=0", + "--enable-filter-intra=0", + "--enable-smooth-intra=0", + "--enable-paeth-intra=0", + "--enable-directional-intra=0", + "--enable-angle-delta=0", + "--enable-tx-size-search=0", + "--enable-cdef=1", + "--enable-restoration=0", + "--max-partition-size=32", + "--min-partition-size=32", + "--enable-palette=0", + "--enable-intrabc=0", + "--enable-cfl-intra=0", + "--enable-ref-frame-mvs=0", + "--obu", + "-o", + "-", + "-", + ]; + let mut child = Command::new(aomenc_path()) + .args(&args) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("aomenc failed to start"); + child + .stdin + .take() + .expect("aomenc stdin") + .write_all(&y4m.stdout) + .expect("writing y4m to aomenc"); + let out = child.wait_with_output().expect("aomenc failed to run"); + assert!( + out.status.success(), + "aomenc refused the fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stream = out.stdout; + let frames = match decode_stream(&stream) { + Err(e) => { + let msg = e.to_string(); + assert!( + msg.contains("unsupported"), + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" + ); + assert!( + !msg.contains("delta_q") && !msg.contains("delta_lf"), + "{NAME} refused on delta_q/delta_lf (seed {seed}) -- that read is ported: {msg}" + ); + named_refusals += 1; + eprintln!("seed {seed} refusal: {msg}"); + continue; + } + Ok(frames) => frames, + }; + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); + assert_eq!(frames.len(), frame_count); + let mismatched = frames + .iter() + .zip(&ffmpeg_frames) + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); + if mismatched && let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { + std::fs::write(&path, &stream).expect("writing pinned stream"); + eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); + } + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); + } + matched += 1; + } + assert!( + matched > 0, + "{NAME}: every attempt refused on other capabilities ({named_refusals} refusals); \ + the gate never exercised delta_q/delta_lf" + ); + assert!( + crate::decode::delta_q_hits() > 0, + "{NAME}: {matched} pixel-exact matches but zero delta_q symbol groups fired -- \ + the reader is unexercised" + ); + assert!( + crate::decode::delta_lf_hits() > 0, + "{NAME}: {matched} pixel-exact matches but zero delta_lf symbol groups fired -- \ + the reader is unexercised" + ); + eprintln!( + "{NAME}: {named_refusals} other-capability refusals, {matched} pixel-exact matches \ + out of {n_attempts}, delta_q_hits={}, delta_lf_hits={}", + crate::decode::delta_q_hits(), + crate::decode::delta_lf_hits() + ); + } /// lane-tiles r7: the gate stage 2 (r6, commit 8899fc1) shipped without /// -- a real >1-tile-column stream with a genuine INTER frame (not just diff --git a/lanes/realworld-r4.charter.md b/lanes/realworld-r4.charter.md new file mode 100644 index 00000000..13b2dc20 --- /dev/null +++ b/lanes/realworld-r4.charter.md @@ -0,0 +1,52 @@ +# lane-realworld r4 — delta_q / delta_lf + +At the lane tip (main merged in). Read `lanes/realworld-r3.report.md` — it is a +typing plan, verified against the real libaom source. Do NOT re-derive it +(class `worker-cap-spent-reading`). Job 1 (the part64 silent desync) is CLOSED +and merged to main. + +## What r3 verified for you +- Default CDFs, from `~/.cache/aom-oracle/src/av1/common/entropymode.c:840-852`: + `DELTA_Q`, `DELTA_LF` and `DELTA_LF_MULTI[4]` are all + `[28160, 32120, 32677, 32768, 0]`. `FRAME_LF_COUNT = 4`, + `MAX_LOOP_FILTER = 63`, `DELTA_Q_SMALL = DELTA_LF_SMALL = 3`. +- The read gate collapses to a per-superblock `Cell` exactly like + `CDEF_TRANSMITTED` (decode.rs:82) — libaom's `b_row == 0 && b_col == 0` check + is always true for a partition tree's first-decoded leaf. +- Only FOUR call sites need the new read, the same four `maybe_read_cdef_idx` + already uses: `read_intra_mode_rect`, `read_intra_mode`, `decode_inter_block`, + `decode_inter_block8` (line numbers have shifted since r3 — find them by the + `maybe_read_cdef_idx` calls). +- `base_q_idx: u8` is passed through ~90 sites but READ at only 2, both + `dequant_and_inverse_typed` calls. A `CURRENT_Q_IDX` thread-local reset per + tile and read at those 2 sites reproduces AV1's running quantizer without + threading a parameter through every signature. +- Open design question, the one genuinely new piece: `DeltaLF` reaching the + deblocker (`lf_level` / `edge_params`) has no per-block carrier — + `MiGrid` / `fill_lf_grid` needs a new field. Do the quantizer half first and + commit it; the loop-filter half can refuse by name in between. + +## CDF wiring is four sites +Struct field, defaults array, save/restore, per-frame counter reset. In this +codebase `reset2`/`reset3` are length-generic and save/restore is a whole-struct +Clone, so the defaults array is what needs hand-checking — but VERIFY the +counter reset covers the new tables (class `cdf-counter-not-reset`: a missing +reset gives right values at the wrong adaptation rate). + +## Then the gate +Remove the stream.rs refusal ("a frame with delta_q_present or delta_lf_present +set"), and gate it: `EC_AV1_REQUIRE_AOMENC=1`, `-t ` on the ffmpeg +generate, fixture through `gradients_source`, aomenc `--threads=1 --row-mt=0 +--sb-size=64` (this decoder hardcodes 64px superblocks) plus whatever turns +delta_q on (`--deltaq-mode=`, and `--aq-mode`); the fixture needs MORE THAN ONE +SUPERBLOCK or a per-superblock symbol can never fire. HARD-assert a thread-local +firing count. + +Merge note: main is at 53b319b with `gate_coverage.rs` and +`refusal_inventory.rs`. Report every refusal string you add or remove, verbatim. + +Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-realworld`; foreground +`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms. Sibling +worktrees have live agents — never build in or edit them. Never push, never +merge, never touch `main`. 75-turn cap, does not reset: COMMIT AT EVERY GREEN +STEP. End with `lanes/realworld-r4.report.md`, VERDICT on line 1. diff --git a/lanes/realworld-r5.charter.md b/lanes/realworld-r5.charter.md new file mode 100644 index 00000000..992e9c2f --- /dev/null +++ b/lanes/realworld-r5.charter.md @@ -0,0 +1,37 @@ +# lane-realworld r5 — finish delta_q / delta_lf + +At dbfd67c — r4's work (cdf.rs, cdf_state.rs, decode.rs), committed verbatim by +the orchestrator at its cap and **never seen to compile**. +`lanes/realworld-r4.charter.md` is still binding; `lanes/realworld-r3.report.md` +is the verified typing plan. Do not re-derive either. + +1. `cargo check`, fix whatever r4 left mid-edit, then the full suite. Getting + dbfd67c green is the whole job until it is green. COMMIT. +2. Finish the quantizer half: the `CURRENT_Q_IDX` thread-local reset per tile + and read at the 2 real dequant sites (r3 proved `base_q_idx` is passed + through ~90 sites but read at only 2). Refuse the loop-filter half by name in + between if it is not ready. COMMIT. +3. The `DeltaLF` -> deblocker path: `MiGrid` / `fill_lf_grid` needs a new + per-block field. This is the one genuinely new design piece. COMMIT. +4. Remove the stream.rs refusal and gate it: `EC_AV1_REQUIRE_AOMENC=1`, + `-t ` on the ffmpeg generate, fixture through `gradients_source`, + aomenc `--threads=1 --row-mt=0 --sb-size=64` plus `--deltaq-mode=`/`--aq-mode`, + MORE THAN ONE SUPERBLOCK (a per-superblock symbol cannot fire otherwise), and + a HARD-asserted thread-local firing count. + +Reminders that cost other lanes a round: the CDF counter reset must cover the +new tables (class `cdf-counter-not-reset`); do not put a refusal in front of the +code you just added and then claim it runs (class +`refusal-short-circuits-its-own-code`) — prove the new read fires with a counter +while the frame still refuses; and main now FAILS the suite if a gate turns a +decode error into a printed SKIP, so write the gate as an attempt loop that +requires at least one decode. + +Merge note: main is at 91a08e8 with `gate_coverage.rs` and +`refusal_inventory.rs`. Report every refusal string you add or remove, verbatim. + +Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-realworld`; foreground +`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms. Sibling +worktrees have live agents — never build in or edit them. Never push, never +merge, never touch `main`. 75-turn cap, does not reset: COMMIT AT EVERY GREEN +STEP. End with `lanes/realworld-r5.report.md`, VERDICT on line 1. diff --git a/lanes/realworld-r5.report.md b/lanes/realworld-r5.report.md new file mode 100644 index 00000000..a9565f44 --- /dev/null +++ b/lanes/realworld-r5.report.md @@ -0,0 +1,103 @@ +# lane-realworld r5 report + +VERDICT: Job 1 (get dbfd67c green) DONE, committed (70372d1, c185755). +Job 2 (delta_q/delta_lf) both halves now read and applied, committed +(70372d1 for delta_q's compile-completion, a830d87 for delta_lf's new +deblocker path). Job 2's gate (charter step 4, a real aomenc stream with +`--deltaq-mode=`/`--aq-mode` proving live firing) is UNSTARTED -- next +lever, see below. + +## Job 1 -- dbfd67c green (70372d1, c185755) +r4 had wired `delta: DeltaParams` all the way through +`decode_key_frame_tile_with_cdfs` (including its 2 stream.rs call sites, +its own tile-loop `DELTA_Q_PRESENT`/`DELTA_Q_RES`/`CURRENT_Q_IDX` reset) +but never touched `decode_inter_frame_tile_with_cdfs`'s own signature -- +its one public wrapper (`decode_inter_frame_tile`) was already passing +`DeltaParams::default()` as an extra, unaccepted argument. Added the +`delta: DeltaParams` param to `decode_inter_frame_tile_with_cdfs`, the +matching `DELTA_Q_PRESENT`/`DELTA_Q_RES`/`CURRENT_Q_IDX` reset at its own +single-tile entry point (mirroring the key-frame per-tile reset), and +`header.delta` at stream.rs's inter-frame call site plus its test-only +key-frame call site (stream.rs:6179, a `#[cfg(test)]` path r4 missed). +Narrowed the whole-frame refusal from `q_present || lf_present` to +`lf_present` alone (delta_q was already genuinely read on both frame +types once this compiled), and updated `refusal_inventory.rs`'s +`REFUSALS` list to the narrowed string. `EC_AV1_REQUIRE_AOMENC=1 cargo +test -p ec-av1 --lib -j4`: **242 passed, 0 failed, 17 ignored** (r3's +234/0/17 plus lane-tiles/lane-realworld merges already on `main` before +this worktree branched). + +## Job 2 -- delta_lf's new deblocker path (a830d87) +Exactly the piece r3 flagged as needing a real design pass, not a narrow +substitution: + +- `CURRENT_DELTA_LF: Cell<[i32; 4]>` (spec `DeltaLF[FRAME_LF_COUNT]`), + reset to `[0; 4]` at the top of every tile in both + `decode_key_frame_tile_with_cdfs` and `decode_inter_frame_tile_with_cdfs` + (mirroring `CURRENT_Q_IDX`'s own per-tile reset), plus + `DELTA_LF_PRESENT`/`DELTA_LF_RES`/`DELTA_LF_MULTI` set from + `header.delta` the same way `DELTA_Q_PRESENT`/`DELTA_Q_RES` already were. +- `maybe_read_delta_lf` (decode.rs, next to `maybe_read_delta_q`): same + 4-symbol-CDF-then-Golomb-tail-then-sign shape, called right after + `maybe_read_delta_q` at all 4 existing block-decode call sites (spec + order `delta_q -> delta_lf`). Loops over 4 planes/directions when + `delta_lf_multi` (reading `cdfs.delta_lf_multi[i]`, r4's already-wired + CDF), or reads once into index 0 against `cdfs.delta_lf` otherwise. + `DELTA_LF_HITS`/`delta_lf_hits()` mirror `DELTA_Q_HITS` for a future + gate's firing count. +- New `Neighbours::delta_lf_grid: Vec<[i8; 4]>` field, snapshotted per + 4x4-mi block in `fill_lf_grid_rect` (the one function every existing + `fill_lf_grid`/`fill_lf_grid_rect` call site already routes through, so + no call-site changes needed) -- `!delta_lf_multi` mode broadcasts + `DeltaLF[0]` into all 4 slots at write time, so `lf_level`'s reader + never needs to know which mode produced the value, matching + `ref_grid`'s existing snapshot pattern exactly. +- `lf_level` takes a new `delta_lf: i32` param, applied to the base level + (`clamp(0, 63)`) *before* the existing `ref_deltas`/`mode_deltas` + scaling and regardless of `lf.delta_enabled` (spec 7.14.4: that flag + only gates the ref/mode terms, not `DeltaLF`). `edge_params` looks up + `delta_lf_grid` at both the current and previous mi position via a new + `plane_idx/dir -> FRAME_LF_COUNT` index map (`0`/`1` for Y + vertical/horizontal, `2`/`3` for U/V), the same two-position lookup + pattern it already uses for `ref_grid`. +- Removed the stream.rs `delta_lf_present` refusal entirely (both halves + of Job 2 are now read and applied). `refusal_inventory.rs`'s `REFUSALS` + list: removed `"a frame with delta_lf_present set (this decoder never + applies per-superblock loop-filter deltas)"`, no replacement string. + +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j4`: **242 passed, 0 +failed, 17 ignored** -- unchanged from Job 1's number, because no +existing fixture sets `delta_lf_present`. This means the new deblocker +path is **code-verified against the spec/libaom read shape**, not yet +gate-proven against a real aomenc stream that actually exercises it. + +## Refusal strings changed this lane (verbatim) +- Removed: `"a frame with delta_q_present or delta_lf_present set (this + decoder never reads the per-superblock delta symbols)"`. +- Added then removed within this same lane (never landed on `main`): + `"a frame with delta_lf_present set (this decoder never applies + per-superblock loop-filter deltas)"` -- present after commit 70372d1, + removed by commit a830d87. Net effect for merge purposes: the old + combined refusal is gone, no new refusal string replaces it. + +## Next lever -- charter step 4, the gate +Not started this round (turn budget spent on Jobs 1-2's design/wiring). +Needed: a real aomenc stream with `--deltaq-mode=1` or `--aq-mode=1` +(reliably sets `delta_q_present`) plus a recipe that also sets +`delta_lf_present`/`delta_lf_multi` (aomenc's `--deltaq-mode` alone may +not set `lf_present` -- needs checking against aomenc's own CLI, not +assumed), gradients source through `gradients_source`, `--threads=1 +--row-mt=0 --sb-size=64`, MORE THAN ONE SUPERBLOCK (128x64+), and a +hard-asserted `delta_q_hits()`/`delta_lf_hits()` firing count in an +attempt loop (never a printed SKIP on decode error, per the charter's +class reminder). `DELTA_Q_HITS`/`DELTA_LF_HITS`/`delta_q_hits()`/ +`delta_lf_hits()` are already in place from this round's work, ready for +that gate to call. + +## Merge note +`gate_coverage.rs`/`refusal_inventory.rs` guards this worktree doesn't +carry: `refusal_inventory.rs`'s own `REFUSALS` list was already updated +in this worktree (main-tracked file), so the merge just needs the diff +as-is -- no separate main-only edit required for the refusal list itself. +`gate_coverage.rs` (main-only) will need the eventual gate test's name +added when Job 2's gate lands. diff --git a/lanes/realworld-r6.charter.md b/lanes/realworld-r6.charter.md new file mode 100644 index 00000000..06ee6322 --- /dev/null +++ b/lanes/realworld-r6.charter.md @@ -0,0 +1,55 @@ +# lane-realworld r6 — gate what r5 removed + +At 15fe79a. Read `lanes/realworld-r5.report.md`. + +## Where you stand +r5 finished both halves: `maybe_read_delta_q` / `maybe_read_delta_lf`, the +`CURRENT_Q_IDX` / `CURRENT_DELTA_LF` thread-locals, `Neighbours::delta_lf_grid` +written by `fill_lf_grid_rect`, and `lf_level` / `edge_params` applying the +per-block delta before ref/mode scaling (spec 7.14.4). Four green commits, suite +242/0 twice. Good round. + +**It also removed the whole-frame refusal, and no fixture anywhere sets +`delta_lf_present`.** So the capability is code-verified against the spec's +shape and nothing more — the `DELTA_Q_HITS` / `DELTA_LF_HITS` counters exist but +have never been observed above zero. Until that gate exists, the removal is an +unproven claim and this branch does not merge to main. Writing it is job one; +nothing else in this lane matters until it is done. + +If the gate cannot be made to fire, restore a narrow refusal for the half that +is unproven, in the same commit. That is the honest outcome, not a failure. + +## Job 1 — the gate +Real aomenc stream, `--deltaq-mode=1` and/or `--aq-mode=1`, 128x64 or larger, +`--threads=1 --row-mt=0 --sb-size=64` (this decoder hardcodes 64px +superblocks), fixture through `gradients_source`, ffmpeg generate bounded with +`-t `, written as an attempt loop that requires at least one decode +(main FAILS the suite if a gate turns a decode error into a printed SKIP). +Hard-assert `delta_q_hits() > 0` AND `delta_lf_hits() > 0`. + +r5's own warning, worth taking seriously: verify against real aomenc output that +its CLI flags actually set `delta_lf_present` / `delta_lf_multi` — `--deltaq-mode` +may only ever set `delta_q_present`. If the encoder will not produce delta_lf at +all, say so with the command you ran, and refuse that half by name rather than +shipping it unproven. A per-superblock symbol also cannot fire in a +single-superblock fixture; size the frame accordingly. + +## Then +Nothing else is assigned to this lane. If turns remain after the gate is green, +take `--enable-intrabc` — the last entry besides palette on main's +`gate_coverage.rs` `NEVER_EXERCISED` list — or say in the report that the lane +is clear. + +## Merge note +Main is at eebbdd1 and now refuses `bit_depth != 8` by name: both AV1 films in +this box's library are 10-bit and reached your delta_q refusal, which is what +surfaced that `Picture`'s planes are `Vec`. Your branch removes the delta +refusal from `refusal_inventory.rs`; main has since added the bit-depth one and +reworded three partition refusals. Report every refusal string you add, remove +or reword, verbatim. + +Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-realworld`; foreground +`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms. Sibling +worktrees have live agents — never build in or edit them. Never push, never +merge into `main`. 75-turn cap, does not reset: COMMIT AT EVERY GREEN STEP. +End with `lanes/realworld-r6.report.md`, VERDICT on line 1. diff --git a/lanes/realworld-r6.report.md b/lanes/realworld-r6.report.md new file mode 100644 index 00000000..c8953be5 --- /dev/null +++ b/lanes/realworld-r6.report.md @@ -0,0 +1,108 @@ +# lane-realworld r6 report + +VERDICT: Job 1 (gate delta_q/delta_lf before merge) DONE, committed +(6981ef5). Both halves are now gate-proven against a real aomenc stream, +not just code-verified against the spec's shape. "Then" item +(`--enable-intrabc`) declined this round -- see below, lane says clear. + +## Job 1 -- the gate (6981ef5) + +r5 warned its own removal of the whole-frame `delta_q_present || +delta_lf_present` refusal was unproven: no fixture anywhere set +`delta_lf_present`. Verified against libaom source before writing any +encoder flags, per the charter's own instruction not to assume: + +- `--deltaq-mode` help text says "requires --enable-tpl-model=1" but + `enable_tpl_model` defaults to `1` (`av1_cx_iface.c:234`), so nothing + extra was needed there. +- The **default** `--deltaq-mode=1` (`DELTA_Q_OBJECTIVE`) additionally + gates `delta_q_present_flag` on `gf_group->update_type == LF_UPDATE` + and `allow_deltaq_mode(cpi)`'s own RD search returning a negative + cost sum across every superblock (`encodeframe.c:2192-2211`) -- an + extra, content-dependent condition worth avoiding for a gate that + needs to fire reliably. +- `--deltaq-mode=2` (`DELTA_Q_PERCEPTUAL`) skips that branch entirely: + `delta_q_present_flag = deltaq_mode != NO_DELTA_Q`, gated only by + `base_qindex > 0` (guaranteed by `--cq-level=45`, nonzero). Used this + instead of the charter's suggested `--deltaq-mode=1`/`--aq-mode=1`. +- `--delta-lf-mode=1` sets `extra_cfg->deltalf_mode`, which + `tool_cfg->enable_deltalf_mode = (deltaq_mode != NO_DELTA_Q) && + extra_cfg->deltalf_mode` (`av1_cx_iface.c:1269-1270`) ANDs onto + `delta_lf_present_flag = delta_q_present_flag && + enable_deltalf_mode` (`encodeframe.c:2217-2218`). This flag is real + and does exactly what the charter asked to confirm: r5's worry that + `--deltaq-mode` alone might never set `delta_lf_present` was correct + -- `--delta-lf-mode=1` is the separate flag needed. +- 128x64 (2 superblocks; this decoder hardcodes 64px SBs) is the + charter's own minimum for a per-superblock symbol to have anywhere to + differ. +- `--cpu-used=4` (not `=0`, which every other multi-SB gate here avoids + per the cdef gate's own documented dead-end: aomenc's RD at + `--cpu-used=0` picks HORZ_4/VERT_B at part64 regardless of the + rect/ab/1to4-partition flags, and this decoder's intra part64 match + only covers NONE/SPLIT). Reused the cdef gate's exact working + toolset otherwise (same `--enable-*` flags, same mandelbrot-source + seed sweep for RD diversity). + +New test `a_real_aomenc_stream_with_delta_q_and_delta_lf_decodes_pixel_exact` +(`crates/ec-av1/src/stream.rs`, appended at EOF): 40/40 attempts +pixel-exact vs `ffmpeg`, `delta_q_hits()=1920`, `delta_lf_hits()=1920` at +the end of the run, both hard-asserted `> 0` (not soft-skipped -- +r5's `--deltaq-mode`/`--delta-lf-mode` combination fires reliably on +every attempt, unlike the wedge-interintra gate's occasional zero-hit +run). Also asserts any `"unsupported"` refusal does not name +`delta_q`/`delta_lf` -- that capability is ported, a refusal naming it +would be a regression. + +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j4`: **243 passed, +0 failed, 17 ignored** (r5's 242 plus this one new gate). + +### One documented gap, not gate-provable + +libaom hardcodes `delta_q_info.delta_lf_multi = DEFAULT_DELTA_LF_MULTI` +(`enums.h:73`, value `0`) in the encoder's own frame-setup path with **no +CLI flag that ever sets it to 1** (confirmed by grepping every +`delta_lf_multi =` assignment in `av1/encoder/`: only the one hardcoded +default). This gate therefore proves the single-plane +`!delta_lf_multi` branch of `maybe_read_delta_lf` (the branch every real +aomenc stream can ever produce) but cannot and does not claim to +exercise the 4-plane `delta_lf_multi` loop -- that path stays +code-verified against the spec's read shape only, same disposition r5 +left the whole feature in, now narrowed to just this one sub-branch. +Not a refusal (the code correctly handles `delta_lf_multi=false`, which +is the only value a real encoder ever writes), just a residual +proof-gap worth naming per the charter's own standard. + +## Refusal strings changed this lane + +None. The whole-frame refusal was already removed by r5; this round +added a gate, not a code change to `decode.rs` or +`refusal_inventory.rs`. + +## "Then" -- `--enable-intrabc` + +Declined this round; lane says clear. `decode.rs:2767-2786` already +documents why in its own comment (lane-screen scope): actual intra +block copy needs `assign_dv`'s DV-prediction machinery this decoder +does not carry (`av1_find_mv_refs`/`av1_find_ref_dv` equivalents -- +DV-specific validity checks against tile/frame boundaries, a DV +predictor stack distinct from the existing NEWMV mv-stack, then +integer-pel same-frame block-copy prediction with decoded-region +bounds checks). Every comparable feature already landed in this repo +(warp, OBMC, interintra, masked compound, wedge) took multiple +dedicated lane-rounds each per the ledger; attempting a full IntraBC +landing in whatever budget remained after Job 1 risked either a +shallow/wrong port (a new desync class, per this repo's own extensive +history of exactly that) or leaving genuinely unfinished work +uncommitted at the turn cap. Job 1 was the charter's stated priority +("nothing else in this lane matters until it is done"); IntraBC is +sized for its own dedicated lane, not a "then, if turns remain" addendum. + +## Merge note + +No refusal strings added/removed/reworded. `gate_coverage.rs`'s +`NEVER_EXERCISED` derivation only tracks `--enable-*` flags (verified by +reading its parser); `--deltaq-mode=`/`--delta-lf-mode=` are not +`--enable-*` flags so this new gate needs no entry there, and +`gate_coverage.rs` itself is unmodified. `crates/ec-av1/src/stream.rs` +is the only file touched this round. diff --git a/lanes/realworld-r7.charter.md b/lanes/realworld-r7.charter.md new file mode 100644 index 00000000..94e32213 --- /dev/null +++ b/lanes/realworld-r7.charter.md @@ -0,0 +1,49 @@ +# lane-realworld r7 — merge main, then start high bit depth + +At 48562d6. Read `lanes/realworld-r6.report.md`. + +## Job 1 — merge `main` into this branch and resolve it yourself +`git merge main` from this worktree. Main is at 92d8beb and has landed a lot +since this branch forked: multi-tile decode (gated), CDEF index reads, chroma +smooth/paeth/directional, a `bit_depth != 8` refusal, three reworded partition +refusals, dead-binding cleanup in `decode_stream`, and three guard tests. The +merge conflicts in nine places — eight in `stream.rs` (mostly gate bodies) and +one in `decode.rs`'s inter tile function, where main's per-tile loop meets your +`DeltaParams` threading. **You** resolve it: a wrong resolution there is a +silent decode bug, and you know which side owns each hunk. Suite green, then +COMMIT. Your delta_q/delta_lf work is finished and gated (40/40 pixel-exact, +`delta_q_hits`/`delta_lf_hits` = 1920 each), so this is the last thing standing +between it and main. + +Keep, while resolving: main's `refusal_inventory.rs` entry +`"a stream whose bit depth is not 8 (this decoder reconstructs into 8-bit planes)"`, +and the reworded partition refusals — do not reintroduce any string claiming an +encoder never writes a case. + +## Job 2, if turns remain — high bit depth +This is the critical path to the user's own files. Both AV1 files in this box's +library (`~/Downloads/reelb.mkv` and +`~/Videos/Films/reelc.mkv`) are `yuv420p10le`, and both now stop on +that bit-depth refusal. `Picture`'s `y`/`u`/`v` are `Vec`; nothing in +`decode.rs` reads `bit_depth` at all, though `transform.rs` already takes and +uses it (`row_clamp = bit_depth + 8`, `col_clamp = max(bit_depth + 6, 16)`). + +Scope for this round is the SHAPE, not the whole feature: work out what widening +the planes costs — `Picture` and `PlaneBuf` sample type, the prediction and +filter paths that assume `u8`, and what `ffmpeg_decode_sequence` must do to +produce a 10-bit reference for a gate. Write it down as a typing plan the way +`lanes/realworld-r3.report.md` did for delta_q; that report is why r5 could +implement both halves in one round. Land nothing half-wired. + +The two films are the eventual gate: probe them with +`cargo run -p ec-av1 --example decode_probe -- `, extracting with +`ffmpeg -i -t 3 -c:v copy -f obu` (note `-f obu` — an IVF decodes as zero +frames rather than as an error). Expect a new refusal to appear behind the +bit-depth one; that is progress, and its name is the next lane's charter. + +Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-realworld`; foreground +`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms. Sibling +worktrees have live agents — never build in or edit them. Never push, never +merge into `main` (merging main INTO this branch is job 1 and is fine). 75-turn +cap, does not reset: COMMIT AT EVERY GREEN STEP. End with +`lanes/realworld-r7.report.md`, VERDICT on line 1. diff --git a/lanes/realworld-r7.report.md b/lanes/realworld-r7.report.md new file mode 100644 index 00000000..c0b641bb --- /dev/null +++ b/lanes/realworld-r7.report.md @@ -0,0 +1,189 @@ +# lane-realworld r7 report + +VERDICT: Job 1 (merge main into lane-realworld) DONE, gated green, committed +(f2e516f). Job 2 (high-bit-depth typing plan) DONE as scope-only, written +below; no code changed for it, nothing half-wired. + +## Job 1 -- merge (f2e516f) + +`git merge main` (main at 92d8beb) hit the nine conflicts the charter named: +eight hunks in `crates/ec-av1/src/stream.rs`, one in +`decode_inter_frame_tile_with_cdfs` in `crates/ec-av1/src/decode.rs`. + +- `stream.rs` line ~173-204: kept HEAD's comment (delta_q/delta_lf already + read/applied, r5) plus main's new bit-depth refusal (`"a stream whose bit + depth is not 8..."`, kept verbatim per the charter); dropped main's + now-stale `"a frame with delta_q_present or delta_lf_present set..."` + refusal since that capability is this branch's own finished work. +- `stream.rs` lines ~6545-6893: these seven remaining conflict markers were + git's line-based diff conflating two *different* new test functions HEAD + and main each appended at the same spot (HEAD's + `a_real_aomenc_stream_with_delta_q_and_delta_lf_decodes_pixel_exact`, main's + `a_real_aomenc_stream_with_two_tile_columns_and_an_inter_frame_decodes_pixel_exact`) + -- not a real overlap. Resolved by pulling each side's complete function + from `git show HEAD:.../stream.rs` / `git show main:.../stream.rs` and + placing both, intact and un-interleaved, one after the other. +- `decode.rs` (`decode_inter_frame_tile_with_cdfs`): main reworked the + function from a single tile-wide decoder into the same per-tile loop + `decode_key_frame_tile_with_cdfs` already had (fresh `cdfs`/`dec` per + tile, `base_cdfs`/`result_cdfs` split). HEAD's delta_q/delta_lf state + setup (`DELTA_Q_PRESENT`/`DELTA_Q_RES`/`DELTA_LF_PRESENT`/`DELTA_LF_RES`/ + `DELTA_LF_MULTI`, all frame-level and `q_present`/`res` etc from + `DeltaParams`) now lives once before the loop, same as the intra tile + function; `CURRENT_Q_IDX`/`CURRENT_DELTA_LF` (both genuinely per-tile, + spec `decode_tile` resets `CurrentQIndex` at the top of every tile) moved + inside the loop, mirroring `decode_key_frame_tile_with_cdfs`'s own + `CURRENT_Q_IDX.with(|c| c.set(i32::from(base_q_idx)))` / + `CURRENT_DELTA_LF.with(|c| c.set([0; 4]))` pair placed right where that + function creates its own per-tile `cdfs`/`dec`. +- One knock-on compile error the merge exposed, not a conflict: main's + `a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact` test + (auto-merged cleanly, no conflict marker) calls + `decode_key_frame_tile_with_cdfs` directly and was missing the trailing + `delta: DeltaParams` argument this branch's signature already carries + (r4). Added `header.delta` (the struct is `Copy`, same pattern every + other call site in the file already uses) to fix the E0061. + +`export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-realworld && EC_AV1_REQUIRE_AOMENC=1 nice -n 19 cargo test -p ec-av1 --lib -j4`: +**246 passed, 0 failed, 17 ignored** (was 243 pre-merge on this branch, 239 +pre-merge on main; the merge is additive, no regressions). + +No refusal strings added/removed/reworded beyond what main already carried +in (the bit-depth refusal, kept verbatim; the three reworded partition +refusals, untouched by this merge). + +## Job 2 -- high bit depth: typing plan, not implemented + +Both real files in this box's library +(`~/Downloads/reelb.mkv`, +`~/Videos/Films/reelc.mkv`) are `yuv420p10le` and now stop at +the bit-depth refusal landed by this merge. Turns ran out before probing +them live with `decode_probe`/`ffmpeg -f obu` this round -- next lane's +first move, not scoped further here. + +### Why `Vec` cannot just get a runtime scale + +`transform.rs` already takes `bit_depth: u8` and uses it for the inverse +transform's own intermediate clamp widths (`row_clamp = bit_depth + 8`, +`col_clamp = max(bit_depth + 6, 16)`, `transform.rs:829-830`) -- that part +is bit-depth-aware today. Every dequant call site in `decode.rs` still +hardcodes the literal `8` as that parameter (6 call sites: +`dequant_and_inverse_typed`/`dequant_and_inverse_typed_wh`, e.g. +`decode.rs:2986`, `:3316` intra rect luma/chroma x2 each plus the inter +paths at `:5397`, `:5858`). Threading the real `bit_depth` through those 6 +is narrow (same shape as `base_q_idx`'s existing pass-through). + +The actual width problem is downstream of the transform: **every +reconstruction write clamps to `[0, 255]` and stores `as u8`.** This is +not 2 sites, it is a whole-crate convention: +`decode.rs`'s `PlaneBuf::reconstruct`/`reconstruct_rect` (`:3153`, +`:3226`), CDEF pixel writes (`:4181`), deblocking's op/oq stores (`:4634` +-`:4710`, ~14 sites across the 4/6/8/13/14-tap filters), plus every +sample buffer write in `mc.rs` (inter prediction, `:406`/`:524`/`:587`) +and `intra.rs` (intra prediction proper, `:307`/`:434`/`:568`, and filter +intra `:762`). All of these assume an 8-bit sample IS a `u8`, both as the +storage type and as the clamp bound. + +### The type to widen + +`Picture` (`encode.rs:86`, `y`/`u`/`v: Vec`) and `PlaneBuf` +(`decode.rs:2980`, `data: Vec`) are the two sample-storage structs. +Widening both to `Vec` (AV1 caps at 12-bit, so `u16` covers every +legal `bit_depth`) is the natural target -- but doing that unconditionally +regresses every existing 8-bit fixture's memory/perf for a capability the +crate doesn't have yet. The narrower move: keep `Vec` as the on-disk +`Picture` representation for the 8-bit case (all current fixtures, all +current gates, `Picture::grey`'s `128u8` default) and give `PlaneBuf` +(the internal, per-decode scratch buffer, never a public API surface) a +generic sample type — either a `u16`-always internal buffer (simplest; +8-bit content just never uses the top byte, same choice `dav1d`/libaom +make internally) or a `PlaneBuf` generic over `u8`/`u16` picked once at +`decode_key_frame_tile_with_cdfs`'s entry from the sequence header's +`bit_depth`. Given this crate has no perf-critical caller depending on +`PlaneBuf` staying byte-sized (it is decode-internal, dropped at the end +of each frame), **`u16`-always is the lower-risk pick**: one type, no +monomorphization/dyn-dispatch fork through the ~30 clamp-and-store call +sites, and the existing 8-bit path just runs with a wider-than-needed +sample width, which every reference decoder already does internally. + +### Concrete surface, sized + +1. `PlaneBuf.data: Vec` -> `Vec`; every + `.clamp(0, 255) as u8` write becomes `.clamp(0, max_val) as u16` where + `max_val = (1i32 << bit_depth) - 1` (a new thread-local, same pattern + as `CDEF_BITS`/`ENABLE_EDGE_FILTER`, set once per tile-function entry + from the sequence header's `bit_depth`). ~30 call sites across + `decode.rs` (reconstruct/reconstruct_rect/CDEF/deblock), `mc.rs` + (inter prediction), `intra.rs` (intra + filter-intra prediction) -- + every one is already a `.clamp(0, 255) as u8` grep hit, so the sweep is + mechanical once the constant is threaded, not a design problem. +2. `prediction: Vec` scratch buffers inside `reconstruct`/ + `reconstruct_rect` (`decode.rs:3121`/`:3182`) and the `dst`/`out` + parameters `mc::predict`/`intra::predict`/`predict_filter_intra` + already take by `&mut [u8]` -- these become `&mut [u16]`, a pure + signature widen, no logic change (the intermediate math is already + `i32`/wider before the final clamp-and-store). +3. `transform.rs`'s 6 `bit_depth: 8`-hardcoded call sites in `decode.rs` + become the real `bit_depth: u8` from the sequence header's + `color_config.bit_depth`, threaded the same way `base_q_idx` already + is (a plain pass-through parameter, no new state needed — confirmed + the value is already carried on `SequenceHeader.color_config` and + reachable at every one of these 6 call sites' enclosing function). +4. `Picture` (the public, post-decode return type) gains a `bit_depth: u8` + field and its `y`/`u`/`v` become `Vec` too (matching what + `ffmpeg_decode_sequence`'s gate helper will need to compare against, + below) -- OR stays `Vec` for 8-bit and the crate adds a parallel + `Vec` accessor/variant for >8-bit. Given no downstream consumer of + `Picture` in this crate needs 8-bit specifically (it's an internal test + type per `encode.rs`'s own doc comment "one 8-bit planar picture"), + the simpler move is widening `Picture` itself to `Vec` too and + dropping the "8-bit" from its doc comment -- `Picture::grey`'s `128` + default is bit-depth-agnostic already (mid-grey is `1 << (bit_depth-1)` + either way, one more thread-local read). +5. The refusal (`stream.rs`, this merge's `"a stream whose bit depth is + not 8..."`) is deleted once (1) through (4) land and a gate proves them, + the same sequencing every other capability in this repo's ledger + followed (interintra, masked compound, wedge, warp). + +### What the gate needs -- `ffmpeg_decode_sequence` also assumes 8-bit + +`stream.rs:738`'s test helper hardcodes `-pix_fmt yuv420p` on ffmpeg's +raw output, which is 1 byte/sample regardless of source depth (ffmpeg +would silently truncate a 10-bit decode to 8-bit there too, the exact +silent-wrongness class the new refusal exists to avoid). A 10-bit gate +needs a second helper (or a `bit_depth` parameter on this one) that asks +ffmpeg for `-pix_fmt yuv420p10le` and parses the raw output as +little-endian `u16` pairs, 2 bytes/sample -- mechanical, not a design +question, but it is new code, not reuse of the existing 8-bit gate +helper as-is. + +### Sizing + +This is at minimum its own lane, likely 2: one for the mechanical +`u8`->`u16` PlaneBuf/prediction-buffer widening + real `bit_depth` +threading through the 6 transform call sites (large diff, low risk -- +every site is already a grep-identifiable `.clamp(0,255) as u8` pattern), +gated first against synthetic 10-bit `aomenc` fixtures; a second for +whatever the two real films' streams refuse on *next* (the charter's own +prediction: "expect a new refusal to appear behind the bit-depth one"). +Not attempted this round -- charter scoped this as "the shape, not the +whole feature," and every comparable feature in this repo's ledger +(warp, OBMC, interintra, masked compound, wedge) took multiple dedicated +lane-rounds; landing even the mechanical half in whatever budget remained +after Job 1 risked leaving a half-wired widening uncommitted at the turn +cap, which the charter explicitly forbids ("land nothing half-wired"). + +deferred: probing the two real films with `decode_probe`/`ffmpeg -f obu` +to name the next refusal — no turns left this round — unblocked by +nothing (any future lane can run it immediately); the typing plan above +does not depend on that probe's output, it depends only on the crate's +existing `u8`-everywhere convention, which is repo-visible without the +films. + +## Merge note for future lanes + +`gate_coverage.rs` / `refusal_inventory.rs` needed no manual entry beyond +what the merge itself carried in (both auto-merged clean, no new gate or +refusal added this round). Sibling worktrees (`-lr`, `-palette`, +`-sbpart`, `-superres`, `-tiles`) were not touched. Nothing pushed. +`lane-realworld` was not merged into `main`.