diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs index 29e78968..9e4dd19f 100644 --- a/crates/ec-av1/examples/decode_probe.rs +++ b/crates/ec-av1/examples/decode_probe.rs @@ -79,6 +79,11 @@ fn main() { "inter_ab64: horz_a={} horz_b={} vert_a={} vert_b={}", sbab[0], sbab[1], sbab[2], sbab[3] ); + let i4 = ec_av1::stream::intra_rect4_in_inter_counters(); + println!( + "intra_rect4_in_inter: 64x16={} 16x64={} 32x8={} 8x32={}", + i4.0, i4.1, i4.2, i4.3 + ); let ir = ec_av1::stream::inter_rect_counters(); println!( "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index d256bf03..bf0233e4 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -2273,6 +2273,46 @@ pub(crate) fn intra_rect_strip_in_inter_hits(class: usize) -> usize { INTRA_RECT_IN_INTER_HITS.with(|c| c.get()[class]) } +// lane-intrasplit r1: intra HORZ/VERT strips inside an INTER frame whose luma +// transform is SPLIT, bucketed by the read `tx_depth` (index 1 and 2; index 0 +// is never incremented) -- the gate's proof that the lifted path ran per depth. +thread_local! { + static INTRA_RECT_IN_INTER_SPLIT_TX_HITS: std::cell::Cell<[usize; 3]> = + const { std::cell::Cell::new([0; 3]) }; +} + +/// Current value of [`INTRA_RECT_IN_INTER_SPLIT_TX_HITS`], indexed by tx depth. +pub(crate) fn intra_rect_in_inter_split_tx_hits() -> [usize; 3] { + INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get) +} + +// lane-intra14 r1: how many intra-coded 1:4 strips decoded on the INTER +// block path, per shape -- [0] 64x16, [1] 16x64, [2] 32x8, [3] 8x32. Every +// one of them was the named refusal "an intra-coded 1:4 (or other non-2:1) +// rect strip on the inter block path" before this round. +thread_local! { + static INTRA_RECT4_IN_INTER_HITS: std::cell::Cell<[usize; 4]> = + const { std::cell::Cell::new([0; 4]) }; +} + +/// Current value of [`INTRA_RECT4_IN_INTER_HITS`] for one shape +/// (0 = 64x16, 1 = 16x64, 2 = 32x8, 3 = 8x32). +pub(crate) fn intra_rect4_strip_in_inter_hits(shape: usize) -> usize { + INTRA_RECT4_IN_INTER_HITS.with(|c| c.get()[shape]) +} + +// lane-intra14 r1: set while an INTRA block of an INTER frame is decoded +// through one of the key-frame rect readers ([`decode_block_rect4`], +// [`decode_block_rect64`]). `Some((size_group, skip))` tells +// [`read_intra_mode_rect`] that (a) `skip`/segment id/cdef/delta-q were +// already read by [`decode_inter_block`] and (b) the luma mode comes off +// `y_mode_cdf[size_group_lookup[bsize]]` (libaom `read_intra_block_mode_info`, +// decodemv.c:1189), never the key frame's above/left `kf_y_mode` pair. +thread_local! { + static INTRA_IN_INTER_MODE: std::cell::Cell> = + const { std::cell::Cell::new(None) }; +} + // lane-rectx r5: how many times a NON-strip `kf_y_mode` reader // ([`decode_block`], [`decode_block_rect`], [`decode_block_rect64`]) took an // above/left mode from the mi-exact map that DIFFERS from its coarse 16x16 @@ -6186,6 +6226,13 @@ fn read_intra_mode_rect( } else { cfl }; + // lane-intra14 r1: on the INTER block path everything up to and including + // `is_inter` was already read by [`decode_inter_block`], so this reader + // starts at the mode syntax with the `skip` that caller read. + let inter = INTRA_IN_INTER_MODE.with(std::cell::Cell::get); + let skip = if let Some((_, skip)) = inter { + skip + } else { // Same `intra_segment_id` placement as the square reader above. let (seg_w_mi, seg_h_mi) = (bw / 4, bh / 4); if seg_id_pre_skip() { @@ -6225,9 +6272,18 @@ fn read_intra_mode_rect( )); } } - 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]); + skip + }; + // libaom `read_intra_block_mode_info` (decodemv.c:1189) vs the key + // frame's `read_intra_frame_mode_info` (decodemv.c:1065 `read_intra_mode` + // off `kf_y_mode_cdf[above][left]`). + let mode = if let Some((size_group, _)) = inter { + dec.symbol(&mut cdfs.y_mode[size_group]) + } else { + let above_ctx = INTRA_MODE_CTX[above_mode]; + let left_ctx = INTRA_MODE_CTX[left_mode]; + dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]) + }; istep!("mode", mode as i32); let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) { read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED]) @@ -6952,9 +7008,18 @@ fn decode_intra_rect_in_inter( (8, 16) => (1usize, 1usize), (16, 32) => (2, 2), (32, 64) => (3, 3), + // lane-intra14 r1: the 1:4 strips, read off libaom's own tables -- + // `size_group_lookup` (common_data.h:61) gives BLOCK_8X32/32X8 group + // 1 and BLOCK_16X64/64X16 group 2, while + // `bsize_to_tx_size_depth_table` (blockd.h:1347) gives them depth + // 3 and 4, i.e. tx categories 2 and 3 -- the diagonal a 2:1 strip + // keeps is genuinely broken here, which is why the shape was refused + // rather than read from the 2:1 row. + (8, 32) => (1, 2), + (16, 64) => (2, 3), _ => { return Err(unsupported( - "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", + "an intra-coded 16x4/4x16 strip on the inter block path (the 16x16-level 1:4 inter partition is refused before this point)", )) } }; @@ -6967,6 +7032,70 @@ fn decode_intra_rect_in_inter( is consumed for square blocks only)", )); } + // lane-intra14 r1: a 1:4 strip decodes through the very readers the KEY + // FRAME path already proves for this shape ([`decode_block_rect4`] at the + // 32 level, [`decode_block_rect64`] at 64 -- both already handle the 1:4 + // luma/chroma transform tables, the per-unit split walk and the strip's + // own neighbour records). The ONLY difference on an inter frame is the + // mode-info read, which [`INTRA_IN_INTER_MODE`] switches to + // `read_intra_block_mode_info`'s `y_mode[size_group]` plus the `skip` + // this caller already read. `tx_cat` above is the same category those + // readers hardcode (cat 2 in `decode_block_rect4`, cat 3 in + // `decode_block_rect64`), asserted here so a future shape cannot drift. + if bw.max(bh) == 4 * bw.min(bh) { + debug_assert_eq!(tx_cat, if bw.max(bh) == 64 { 3 } else { 2 }); + INTRA_IN_INTER_MODE.with(|c| c.set(Some((size_group, skip)))); + let res = if bw.max(bh) == 64 { + decode_block_rect64( + dec, + cdfs, + neighbours, + (mi_r / (SUB / MI), mi_c / (SUB / MI)), + bw, + bh, + y, + u, + v, + ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get), + allow_screen_content_tools, + base_q_idx, + TX_SELECT_INTER.with(std::cell::Cell::get), + REDUCED_TX_SET_INTER.with(std::cell::Cell::get), + ) + } else { + decode_block_rect4( + dec, + cdfs, + neighbours, + (mi_r, mi_c), + bw, + bh, + None, + y, + u, + v, + ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get), + allow_screen_content_tools, + base_q_idx, + TX_SELECT_INTER.with(std::cell::Cell::get), + ) + .map(|_| ()) + }; + INTRA_IN_INTER_MODE.with(|c| c.set(None)); + res?; + let shape = match (bw, bh) { + (64, 16) => 0, + (16, 64) => 1, + (32, 8) => 2, + _ => 3, + }; + INTRA_RECT4_IN_INTER_HITS.with(|h| { + let mut v = h.get(); + v[shape] += 1; + h.set(v); + }); + return Ok(()); + } let mode = dec.symbol(&mut cdfs.y_mode[size_group]); if mode >= 13 { return Err(unsupported( @@ -7042,7 +7171,9 @@ fn decode_intra_rect_in_inter( } let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); let depth = if TX_SELECT_INTER.with(std::cell::Cell::get) { - let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh); + // The INTER frame's own `TXFM_CONTEXT` bands, not the key frame's + // deblock-grid approximation -- [`tx_size_context_txfm_rect`]. + let ctx = tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw.min(64), bh.min(64)); match tx_cat { 1 => dec.symbol(&mut cdfs.tx_size_cat1[ctx]), 2 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]), @@ -7053,15 +7184,20 @@ fn decode_intra_rect_in_inter( }; if depth != 0 { TX_DEPTH_HITS.with(|h| h.set(h.get() + 1)); - // merge b51719f+lane-intrarect (class merge-cross-product-defect): - // main's 10-bit `split_transform_intra_block` gate reaches this arm - // with a nonzero tx depth, and the split rect-TU walk mis-decodes it - // (2340 luma samples off at seed 51; refusing here restores that gate - // while the depth-0 strip the lane proved keeps decoding). The lane's - // own gate never exercised a split strip. - return Err(unsupported( - "a split (nonzero tx_depth) transform on an intra HORZ/VERT strip in an inter frame", - )); + // lane-intrasplit r1: a split intra strip in an inter frame walks the + // key frame's own per-TU path ([`decode_rect_split`] below); what was + // wrong when this refusal was written was the depth SYMBOL, not the walk. + INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(|h| { + let mut v = h.get(); + v[depth.min(2)] += 1; + h.set(v); + }); + } + // lane-intrasplit r3: print EVERY intra strip with its depth, not only the + // split ones -- a `depth=0`-only stream is a witness gap in the SOURCE, and + // the two are indistinguishable when the diagnostic fires on splits alone. + if std::env::var_os("EC_SPLITSTRIP").is_some() { + eprintln!("EC_SPLITSTRIP mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} depth={depth}"); } let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); let modes = RectStripModes { @@ -7095,6 +7231,22 @@ fn decode_intra_rect_in_inter( base_q_idx, REDUCED_TX_SET_INTER.with(std::cell::Cell::get), )?; + // `set_txfm_ctxs` (libaom `decodeframe.c:1078`, at the end of + // `decode_token_recon_block`): an INTRA block records its TRANSFORM size in + // both `TXFM_CONTEXT` bands -- the above row over the block's width, the + // left column over its height. This arm wrote neither before lane-intrasplit + // r1, so every later block in the frame read a stale `tx_size`/`txfm_split` + // context across the strip's footprint. + for i in 0..bw / MI { + if let Some(cell) = neighbours.above_txfm.get_mut(mi_c + i) { + *cell = tx_w as u8; + } + } + for i in 0..bh / MI { + if let Some(cell) = neighbours.left_txfm.get_mut(mi_r + i) { + *cell = tx_h as u8; + } + } let class = match bw.max(bh) { 64 => 0, 32 => 1, @@ -12650,6 +12802,44 @@ fn tx_size_context(n: &Neighbours, (mi_r, mi_c): (usize, usize), own_side: usize /// a neighbour's var-tx tree splits. [`tx_size_context`]'s deblock-grid /// approximation coincides with this only while every neighbour codes one /// whole-block transform, which is exactly what `TxMode::Select` ends. +/// [`tx_size_context_txfm`] with the block's own width and height (lane-intrasplit +/// r1): `get_tx_size_context` compares the neighbour ABOVE against +/// `tx_size_wide[max_txsize_rect_lookup[bsize]]` and the neighbour to the LEFT +/// against `tx_size_high[...]` (libaom `pred_common.h:342`), which for a 2:1 +/// strip are two different numbers. The intra strip inside an inter frame read +/// this through [`tx_size_context_rect`] -- the key frame's deblock-grid +/// approximation -- so once `TxMode::Select` made the depth symbol exist, it was +/// read off the wrong CDF row whenever a neighbour's var-tx tree had split. +fn tx_size_context_txfm_rect( + n: &Neighbours, + (mi_r, mi_c): (usize, usize), + own_w: usize, + own_h: usize, +) -> usize { + let has_above = mi_r > n.tile_row0_mi; + let has_left = mi_c > n.tile_col0_mi; + let mut above = usize::from(n.above_txfm[mi_c]) >= own_w; + let mut left = usize::from(n.left_txfm[mi_r]) >= own_h; + if has_above && n.above_inter[mi_c] { + above = n.above_side_mi[mi_c] >= own_w; + } + if has_left && n.left_inter[mi_r] { + left = n.left_side_mi[mi_r] >= own_h; + } + match (has_above, has_left) { + (true, true) => usize::from(above) + usize::from(left), + (true, false) => usize::from(above), + (false, true) => usize::from(left), + (false, false) => 0, + } +} + +/// lane-intrasplit r3: `above_inter`/`left_inter` are mi-granular bands (they +/// are written and read everywhere else with a raw mi index); the SUB-cell +/// division this pair used read a cell four blocks away, so the inter-neighbour +/// override above fired on the wrong neighbour -- the first divergence of the +/// 10-bit gate's stream was exactly this (`tx_depth` ctx 0 where libaom has 1, +/// at the intra block right of an inter one). fn tx_size_context_txfm(n: &Neighbours, (mi_r, mi_c): (usize, usize), side: usize) -> usize { let has_above = mi_r > n.tile_row0_mi; let has_left = mi_c > n.tile_col0_mi; diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index b4c81468..33b3055a 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -88,8 +88,7 @@ const REFUSALS: &[&str] = &[ // inter path's intra arm now routes 2:1 strips through `decode_rect_split`); // what is left is the 1:4 shape, whose `bsize_to_tx_size_cat` breaks the // size-group/category diagonal the 2:1 shapes share. - "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", - "a split (nonzero tx_depth) transform on an intra HORZ/VERT strip in an inter frame", + "an intra-coded 16x4/4x16 strip on the inter block path (the 16x16-level 1:4 inter partition is refused before this point)", // The same arm's screen-content gate: palette/intrabc syntax is consumed // for square blocks only, so a strip in such a frame would skip symbols. "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 8290eb70..c982d2af 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -934,6 +934,19 @@ pub fn decode_stream(data: &[u8]) -> Result> { Ok(pictures) } + +/// lane-intra14 r1: INTRA-coded 1:4 strips decoded on the INTER block path +/// (64x16, 16x64, 32x8, 8x32) -- the counters a recipe sweep needs from +/// outside the crate. +pub fn intra_rect4_in_inter_counters() -> (usize, usize, usize, usize) { + ( + crate::decode::intra_rect4_strip_in_inter_hits(0), + crate::decode::intra_rect4_strip_in_inter_hits(1), + crate::decode::intra_rect4_strip_in_inter_hits(2), + crate::decode::intra_rect4_strip_in_inter_hits(3), + ) +} + #[cfg(test)] mod tests { use super::*; @@ -27754,4 +27767,582 @@ mod tests { narrow_by_shape[0], narrow_by_shape[1] ); } + + + /// lane-intra14 r1's decisive gate: a real aomenc INTER sequence with + /// `--enable-1to4-partitions=1`, whose fast-zooming content makes aomenc + /// code INTRA blocks inside inter frames on 1:4 strip shapes (32x8/8x32 at + /// the 32 level, 64x16/16x64 at the superblock level). Every such block + /// was the named refusal "an intra-coded 1:4 (or other non-2:1) rect strip + /// on the inter block path" until this round; they now decode through the + /// same `decode_block_rect4` / `decode_block_rect64` readers the KEY FRAME + /// 1:4 paths already prove, with only the mode-info read switched to + /// `read_intra_block_mode_info` (libaom decodemv.c:1189). + /// + /// Hard-asserts `intra_rect4_strip_in_inter_hits` (0 = 64x16, 1 = 16x64, + /// 2 = 32x8, 3 = 8x32) summed over the attempts that were actually + /// pixel-compared, and every decode-order frame is compared. A decode that + /// succeeds is ALWAYS pixel-compared (class + /// [[gate-skips-on-its-own-failure]]); exhausting every attempt without a + /// counted strip is a FAILURE, never a SKIP. + #[test] + // r1 `#[ignore]`d this gate on "every stream with an intra 1:4 strip also + // hits the inter rect-strip refusal". r2 merged main 18bf7dc (lane-r14 + // a2e2e29 lifts exactly that refusal) and re-ran it: 3 of 40 attempts now + // decode whole and reach the pixel compare (0 before), one of them firing + // 64x16=4 16x64=3. But the compare fails on a defect this lane does not + // own -- MEASURED (r2, $HOME/.cache/intra14-r2-*.log): + // * seeds 46 and 54 fire ZERO 1:4 strips (`intra_rect4_strip_in_inter_hits` + // delta 0/0/0/0) and mismatch ffmpeg the same way as the firing seed 52: + // decode-order frame 3/4 luma ~3.7-4.5k samples, max |d| 6..17, then + // frames 5-7 drift to ~24k samples, max |d| ~220 as the references + // carry the error forward. + // * with `--enable-1to4-partitions=0` aomenc emits a BYTE-IDENTICAL + // stream at this recipe (same hits, same per-frame diff counts), so + // the 1:4 shape is not the discriminator either. + // i.e. this mandelbrot 192x128 source has a pre-existing INTER-frame + // pixel defect on this tree (r1 already recorded it as "open, NOT mine" + // with rect partitions off; it is now this gate's blocker). testsrc2 at + // 192x128 decodes pixel-exact on the same recipe but fires no 1:4 strip + // in 4 of 12 attempts that decode whole. So the gate stays `#[ignore]`d + // rather than weakened: a source whose baseline is exact AND that fires + // an intra 1:4 strip has not been found yet. + #[ignore = "blocked: the mandelbrot gate source has a pre-existing inter-frame pixel defect on this tree (zero-hit streams mismatch identically) -- see the MEASURED note above"] + fn a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact() { + intra_rect4_in_inter_gate(8); + } + + /// The 10-bit arm (both of the user's films are `yuv420p10le`). + #[test] + // r1 `#[ignore]`d this gate on "every stream with an intra 1:4 strip also + // hits the inter rect-strip refusal". r2 merged main 18bf7dc (lane-r14 + // a2e2e29 lifts exactly that refusal) and re-ran it: 3 of 40 attempts now + // decode whole and reach the pixel compare (0 before), one of them firing + // 64x16=4 16x64=3. But the compare fails on a defect this lane does not + // own -- MEASURED (r2, $HOME/.cache/intra14-r2-*.log): + // * seeds 46 and 54 fire ZERO 1:4 strips (`intra_rect4_strip_in_inter_hits` + // delta 0/0/0/0) and mismatch ffmpeg the same way as the firing seed 52: + // decode-order frame 3/4 luma ~3.7-4.5k samples, max |d| 6..17, then + // frames 5-7 drift to ~24k samples, max |d| ~220 as the references + // carry the error forward. + // * with `--enable-1to4-partitions=0` aomenc emits a BYTE-IDENTICAL + // stream at this recipe (same hits, same per-frame diff counts), so + // the 1:4 shape is not the discriminator either. + // i.e. this mandelbrot 192x128 source has a pre-existing INTER-frame + // pixel defect on this tree (r1 already recorded it as "open, NOT mine" + // with rect partitions off; it is now this gate's blocker). testsrc2 at + // 192x128 decodes pixel-exact on the same recipe but fires no 1:4 strip + // in 4 of 12 attempts that decode whole. So the gate stays `#[ignore]`d + // rather than weakened: a source whose baseline is exact AND that fires + // an intra 1:4 strip has not been found yet. + #[ignore = "blocked: the mandelbrot gate source has a pre-existing inter-frame pixel defect on this tree (zero-hit streams mismatch identically) -- see the MEASURED note above"] + fn a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact_10bit() { + intra_rect4_in_inter_gate(10); + } + + fn intra_rect4_in_inter_gate(bit_depth: u32) { + const NAME: &str = + "a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact"; + 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) = (192usize, 128usize, 8usize); + let mut refusals: Vec = Vec::new(); + let mut uncounted_exact = 0u32; + let mut compared = 0u32; + let mut shapes = [0usize; 4]; + for attempt in 0..40u32 { + let seed = 42 + attempt; + // Same source class as the 2:1 sibling gate: a FAST mandelbrot + // zoom (`end_scale`/`end_pts`) so consecutive frames share almost + // no content and aomenc's RD codes blocks INTRA inside INTER + // frames, with `--kf-min-dist=1000` forbidding a new key frame. + let source = format!( + "mandelbrot=size={width}x{height}:start_scale={}:end_scale=0.004:end_pts=8:rate=25", + 5.0 - f64::from(attempt) * 0.06 + ); + let y4m = Command::new("ffmpeg") + .args([ + "-v", "error", "-f", "lavfi", "-i", &source, "-vf", "hue=s=0", "-pix_fmt", + if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, + "-strict", "-1", "-t", "0.32", "-f", "yuv4mpegpipe", "-strict", "-1", "-", + ]) + .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 depth_args: &[&str] = if bit_depth == 10 { + &["-b", "10", "--input-bit-depth=10"] + } else { + &[] + }; + // MEASURED (r1, 40 attempts): `--cpu-used=0` makes aomenc pick + // 128x128 superblocks on this frame size, which decode_stream + // refuses by name, so the preset sweep starts at 1. + let cpu = format!("--cpu-used={}", 1 + attempt % 4); + // The higher the quantiser the more 1:4 intra strips inside inter + // frames, so the sweep walks cq 63 first. + let cq = format!("--cq-level={}", [63u32, 55, 45, 35][(attempt / 4) as usize % 4]); + let mut child = Command::new(aomenc_path()) + .args(depth_args) + .arg(&cpu) + .arg(&cq) + .args([ + // Every flag spelled exactly once (class + // [[aomenc-last-flag-wins]]). These are what the gate is + // about: 1:4 partitions ON, min size 16 so the 16x16-level + // 1:4 (refused elsewhere) is out of reach. + "--enable-rect-partitions=1", + "--enable-1to4-partitions=1", + // MEASURED (r1): at `--min-partition-size=16` aomenc codes + // 16x16-level 1:4 partitions (16x4/4x16 strips), which the + // inter partition path refuses by name (another lane's + // surface) in 12/40 attempts. 32 keeps this gate's two + // reachable levels -- the 32-level 32x8/8x32 and the + // superblock-level 64x16/16x64 -- and nothing else. + "--min-partition-size=32", + "--max-partition-size=64", + // MEASURED (r1): with tx-size search ON, 8/40 attempts stop + // at the 2:1 strip's own split-tx refusal (merge-cross-product, + // another lane's surface) before a 1:4 strip is reached. + "--enable-tx-size-search=0", + "--enable-filter-intra=1", + "--enable-intra-edge-filter=1", + "--codec=av1", + "--passes=1", + "--end-usage=q", + "--lag-in-frames=0", + "--auto-alt-ref=0", + "--kf-min-dist=1000", + "--kf-max-dist=1000", + "--threads=1", + "--row-mt=0", + "--enable-order-hint=0", + "--enable-warped-motion=0", + "--enable-obmc=0", + "--enable-masked-comp=0", + "--enable-interintra-comp=0", + "--enable-dist-wtd-comp=0", + "--enable-diff-wtd-comp=0", + "--enable-onesided-comp=0", + "--enable-interintra-wedge=0", + "--enable-smooth-interintra=0", + "--enable-ab-partitions=0", + "--enable-smooth-intra=0", + "--enable-paeth-intra=0", + "--enable-directional-intra=0", + "--enable-angle-delta=0", + "--enable-cdef=0", + "--enable-restoration=0", + // Ledger dead-end (lane-r14): a NEW gate spelling + // `--enable-cfl-intra=1` retires that tool from + // `NEVER_EXERCISED_8BIT` on the flag alone while no CfL + // hit counter exists to assert -- so it stays 0 here. + // Palette stays 0 for the same class of reason: this arm + // refuses a screen-content frame whole, so a palette flag + // would buy no coverage. + "--enable-palette=0", + "--enable-intrabc=0", + "--enable-cfl-intra=0", + "--enable-ref-frame-mvs=0", + "--obu", + "-o", + "-", + "-", + ]) + .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 before: Vec = + (0..4).map(decode::intra_rect4_strip_in_inter_hits).collect(); + let frames = match decode_stream(&stream) { + Ok(frames) => frames, + Err(e) => { + let msg = e.to_string(); + assert!( + msg.contains("unsupported"), + "intra-1:4-in-inter decode failed outright (seed {seed}): {msg}" + ); + refusals.push(format!("seed {seed} {cpu} {cq}: {msg}")); + continue; + } + }; + let delta: Vec = (0..4) + .map(|k| decode::intra_rect4_strip_in_inter_hits(k) - before[k]) + .collect(); + let ffmpeg_frames = if bit_depth == 10 { + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) + } else { + ffmpeg_decode_sequence(&stream, width, height, frame_count) + }; + assert_eq!(frames.len(), frame_count); + eprintln!( + "intra14 gate {bit_depth}-bit seed={seed} {cpu} {cq}: intra 1:4 strips in inter \ + frames 64x16={} 16x64={} 32x8={} 8x32={}", + delta[0], delta[1], delta[2], delta[3] + ); + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + for (plane, (g, w)) in [ + ("Y", (&got.y, &want.y)), + ("U", (&got.u, &want.u)), + ("V", (&got.v, &want.v)), + ] { + let stride = if plane == "Y" { width } else { width / 2 }; + if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { + let maxd = g + .iter() + .zip(w.iter()) + .map(|(a, b)| i32::from(*a).abs_diff(i32::from(*b))) + .max() + .unwrap_or(0); + eprintln!( + "intra14 gate {bit_depth}-bit seed={seed}: frame {i} {plane} first \ + diff at ({}, {}) got {} want {} ({} samples differ, max |d|={maxd})", + at % stride, + at / stride, + g[at], + w[at], + g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), + ); + } + assert_eq!(g, w, "{plane} vs ffmpeg (seed {seed}, frame {i})"); + } + } + compared += 1; + if delta.iter().all(|d| *d == 0) { + uncounted_exact += 1; + refusals.push(format!( + "seed {seed} {cpu} {cq}: decoded and pixel-compared, but no intra 1:4 strip on \ + the inter path" + )); + } + for k in 0..4 { + shapes[k] += delta[k]; + } + // Both LEVELS (32 and 64) is the bar; orientation is whichever the + // encoder picks. + if shapes[0] + shapes[1] > 0 && shapes[2] + shapes[3] > 0 { + break; + } + } + gate_buckets( + NAME, + compared - uncounted_exact, + uncounted_exact, + refusals.len() - uncounted_exact as usize, + ); + eprintln!( + "{NAME} ({bit_depth}-bit): compared {compared} streams, intra 1:4 strips in inter \ + frames: 64x16={} 16x64={} 32x8={} 8x32={}; refusals:\n{}", + shapes[0], + shapes[1], + shapes[2], + shapes[3], + refusals.join("\n") + ); + assert!( + compared > 0, + "{NAME} ({bit_depth}-bit): every attempt hit a named refusal -- nothing was \ + pixel-compared:\n{}", + refusals.join("\n") + ); + assert!( + shapes[2] + shapes[3] > 0, + "{NAME} ({bit_depth}-bit): no 32-level intra 1:4 strip (32x8/8x32) fired over \ + {compared} compared streams (64x16={} 16x64={} 32x8={} 8x32={})", + shapes[0], + shapes[1], + shapes[2], + shapes[3] + ); + } + + /// lane-intrasplit r1's decisive gate: a real aomenc INTER sequence in + /// which aomenc's RD picks an intra-coded HORZ/VERT *strip* (a 2:1 + /// rectangular partition) inside an inter frame AND splits its luma + /// transform (`tx_depth >= 1`). Until this round that block was the named + /// refusal "a split (nonzero tx_depth) transform on an intra HORZ/VERT + /// strip in an inter frame"; it now walks the key frame's own per-TU path + /// ([`decode::decode_rect_split`]). Hard-asserts + /// [`decode::intra_rect_in_inter_split_tx_hits`] per depth: an attempt + /// that never produced such a block proves nothing, and exhausting every + /// attempt is a FAILURE, not a SKIP. + #[test] + fn a_real_aomenc_inter_sequence_with_a_split_transform_intra_strip_decodes_pixel_exact() { + intra_rect_in_inter_split_tx_gate(8); + } + + /// The 10-bit arm (both of the user's films are `yuv420p10le`). + #[test] + fn a_real_aomenc_10bit_inter_sequence_with_a_split_transform_intra_strip_decodes_pixel_exact() { + intra_rect_in_inter_split_tx_gate(10); + } + + fn intra_rect_in_inter_split_tx_gate(bit_depth: u32) { + let name = format!("intra_rect_in_inter_split_tx_gate({bit_depth})"); + if !have_ffmpeg() { + eprintln!("SKIP {name}: no ffmpeg"); + return; + } + if !have_aomenc() { + eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); + return; + } + // lane-intrasplit r3, MEASURED (probe3, 20 attempts x 2 depths): at + // 192x128 with `--min/--max-partition-size=32` a correctly decoded + // stream contains ZERO intra HORZ/VERT strips in an inter frame -- the + // r1/r2 "firing" counters were read off our own desynced decode (class + // counter-from-refused-stream). The merged unsplit-strip gate's own + // geometry (96x96, min 16 / max 64) is the one that makes aomenc's RD + // pick intra strips here, and at `--enable-tx-size-search=1` it splits + // their transforms: 10-bit attempt 0 = 8 strips, 3 split; 8-bit + // attempt 0 = 5 strips, 1 split. + let (width, height, frame_count) = (96usize, 96usize, 8usize); + let mut refusals = Vec::new(); + let mut uncounted_exact = 0u32; + let mut counted_exact = 0u32; + let mut seen = [0usize; 3]; + for attempt in 0..40u32 { + let seed = 42 + attempt; + // MEASURED (r1, 40 attempts): the same sweep the merged + // `intra_rect_in_inter_gate` had to make -- at `--cpu-used=0` + // aomenc emits AB partitions regardless of + // `--enable-ab-partitions=0` (ledger), so the preset is swept + // 1..4, and the quantiser with it (a hard-cut overlay source at + // cpu-used=0 stopped 38/40 attempts on other lanes' refusals). + let cpu = attempt % 5; + let cq = [30u32, 20, 12, 4][((attempt / 5) % 4) as usize]; + // A FAST ZOOM: consecutive frames share almost no content, so + // aomenc's RD codes blocks INTRA inside INTER frames + // (`--kf-min-dist` forbids a new key frame) -- the only way a + // real encoder reaches this decoder's intra-in-inter arm -- and + // the fractal's fine detail is what then splits their transforms. + let source = format!( + "mandelbrot=size={width}x{height}:start_scale={}:end_scale=0.004:end_pts=8:rate=25", + 5.0 - f64::from(attempt) * 0.06 + ); + let y4m = Command::new("ffmpeg") + .args([ + "-v", + "error", + "-f", + "lavfi", + "-i", + &source, + // Desaturated chroma keeps `uv_mode` on DC_PRED, so the + // still-refused directional-chroma gaps never fire and + // luma detail alone drives the transform split. + "-vf", + "hue=s=0", + "-pix_fmt", + if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, + "-strict", + "-1", + "-t", + "0.32", + "-f", + "yuv4mpegpipe", + "-strict", + "-1", + "-", + ]) + .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 depth_args: &[&str] = if bit_depth == 10 { + &["-b", "10", "--input-bit-depth=10"] + } else { + &[] + }; + let cq_arg = format!("--cq-level={cq}"); + let cpu_arg = format!("--cpu-used={cpu}"); + let mut child = Command::new(aomenc_path()) + .args(depth_args) + .args([ + "--codec=av1", + "--passes=1", + "--end-usage=q", + &cq_arg, + &cpu_arg, + "--lag-in-frames=0", + "--auto-alt-ref=0", + "--kf-max-dist=9999", + "--kf-min-dist=9999", + "--threads=1", + "--row-mt=0", + "--enable-order-hint=0", + "--enable-warped-motion=0", + "--enable-obmc=0", + "--enable-masked-comp=0", + "--enable-interintra-comp=0", + "--enable-dist-wtd-comp=0", + "--enable-diff-wtd-comp=0", + "--enable-onesided-comp=0", + "--enable-interintra-wedge=0", + "--enable-smooth-interintra=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-cdef=0", + "--enable-restoration=0", + "--enable-palette=0", + "--enable-intrabc=0", + "--enable-cfl-intra=0", + "--enable-ref-frame-mvs=0", + "--min-partition-size=16", + "--max-partition-size=64", + // Per-arm overrides go LAST (aomenc keeps the last + // occurrence of a repeated --enable-* flag): this gate + // needs the rect partitions the strip lives in and the + // tx_depth symbol, which exists only under TX_MODE_SELECT. + "--enable-rect-partitions=1", + "--enable-tx-size-search=1", + "--obu", + "-o", + "-", + "-", + ]) + .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 before = decode::intra_rect_in_inter_split_tx_hits(); + let frames = match decode_stream(&stream) { + Ok(frames) => frames, + Err(e) => { + let msg = e.to_string(); + assert!( + msg.contains("unsupported"), + "{name} decode failed outright (seed {seed} cq {cq}): {msg}" + ); + refusals.push(format!("seed {seed} cq {cq} cpu {cpu}: {msg}")); + continue; + } + }; + let after = decode::intra_rect_in_inter_split_tx_hits(); + let mut per_depth = [0usize; 3]; + for i in 0..3 { + per_depth[i] = after[i] - before[i]; + } + // class [[gate-skips-on-its-own-failure]]: a decode that + // succeeded is ALWAYS pixel-compared below; the counter only + // decides whether the attempt counts as firing. + let counted = per_depth[1] + per_depth[2] != 0; + if !counted { + uncounted_exact += 1; + refusals.push(format!( + "seed {seed} cq {cq} cpu {cpu}: decoded and pixel-compared, but no intra rect strip \ + in an inter frame split its transform" + )); + } + let ffmpeg_frames = if bit_depth == 10 { + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) + } else { + ffmpeg_decode_sequence(&stream, width, height, frame_count) + }; + assert_eq!(frames.len(), frame_count); + eprintln!( + "{name} seed={seed} cq={cq} cpu={cpu}: split intra strips depth1={} depth2={}", + per_depth[1], per_depth[2] + ); + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + for (plane, (g, w)) in [ + ("Y", (&got.y, &want.y)), + ("U", (&got.u, &want.u)), + ("V", (&got.v, &want.v)), + ] { + let stride = if plane == "Y" { width } else { width / 2 }; + if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { + eprintln!( + "{name} seed={seed}: frame {i} {plane} first diff at ({}, {}) got {} \ + want {} ({} samples differ)", + at % stride, + at / stride, + g[at], + w[at], + g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), + ); + } + } + } + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (seed {seed} cq {cq})"); + assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed} cq {cq})"); + assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (seed {seed} cq {cq})"); + } + if counted { + counted_exact += 1; + seen[1] += per_depth[1]; + seen[2] += per_depth[2]; + // Keep sweeping until BOTH reachable depths have been seen in + // a pixel-exact attempt; one firing attempt is the floor. + if seen[1] != 0 && seen[2] != 0 { + break; + } + } + } + gate_buckets( + &name, + counted_exact, + uncounted_exact, + refusals.len() - uncounted_exact as usize, + ); + eprintln!("{name}: split strips seen depth1={} depth2={}", seen[1], seen[2]); + assert!( + seen[1] + seen[2] != 0, + "{name} never observed a split-transform intra strip in an inter frame:\n{}", + refusals.join("\n") + ); + } } diff --git a/lanes/intra14-r1.report.md b/lanes/intra14-r1.report.md new file mode 100644 index 00000000..ddfc8d70 --- /dev/null +++ b/lanes/intra14-r1.report.md @@ -0,0 +1,105 @@ +# lane-intra14 r1 -- intra-coded 1:4 rect strips on the INTER block path + +Branch `lane-intra14` off main `7a47fc1`. **RED**: the decoder work is done and +demonstrably fires, but NO real-aomenc attempt on this tree can be +pixel-compared, so the lifted refusal is **ungated** and this branch MUST NOT +merge as-is. + +## What changed + +* `crates/ec-av1/src/decode.rs:5987` (`decode_intra_rect_in_inter`) -- the + `(size_group, tx_cat)` table gains the 1:4 rows `(8,32) -> (1,2)` and + `(16,64) -> (2,3)`, read off libaom `size_group_lookup` + (common_data.h:61) and `bsize_to_tx_size_depth_table` (blockd.h:1347). A 1:4 + strip then decodes through the KEY-FRAME readers that already prove the + shape: `decode_block_rect4` (32-level 32x8/8x32) and `decode_block_rect64` + (SB-level 64x16/16x64) -- transform tables, per-unit split walk, chroma, + Reach, neighbour records, palette/filter-intra refusals all reused unchanged. +* `crates/ec-av1/src/decode.rs` `INTRA_IN_INTER_MODE` (thread-local) -- the one + genuine difference on an inter frame is the mode-info read. + `read_intra_mode_rect` now, when it is set, (a) takes the `skip` the inter + path already read instead of re-reading skip/segment id/cdef/delta-q and + (b) reads the luma mode off `y_mode[size_group]` + (libaom `read_intra_block_mode_info`, decodemv.c:1189) instead of + `kf_y_mode[above][left]` (decodemv.c's key-frame reader). Everything after + that -- angle deltas (decodemv.c:1191/1203), uv_mode + CfL (1196-1201), + palette (1215), filter intra (the `read_filter_intra_mode_info` tail) -- is + bit-identical between the two libaom readers, which is why no other symbol + needed a branch. +* Counters `INTRA_RECT4_IN_INTER_HITS` (0=64x16, 1=16x64, 2=32x8, 3=8x32), + exported as `stream::intra_rect4_in_inter_counters()` and printed by + `examples/decode_probe`. +* `refusal_inventory.rs:76` -- "an intra-coded 1:4 (or other non-2:1) rect + strip on the inter block path" replaced by the narrower + "an intra-coded 16x4/4x16 strip on the inter block path (the 16x16-level 1:4 + inter partition is refused before this point)": 16x4/4x16 is unreachable + because `decode.rs:20332` refuses the 16x16-level 1:4 inter partition first, + and `decode_block_rect4`'s tables are 32x8-specific. +* `stream.rs` -- gate `a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact` + (+ `_10bit`), currently `#[ignore]`d with the blocker named (see below). + +## Why the gate cannot pass on this tree (MEASURED) + +40 gate attempts per depth + ~150 recipe-sweep attempts (frame sizes 64x64, +96x96, 128x128, 192x128, 256x192; mandelbrot fast-zoom, static-background + +moving overlay, 64x16/16x64/32x8/8x32 moving bars, testsrc2; cq 35..63; +cpu-used 1..4; min/max-partition-size 32/32, 32/64, 64/64): + +* Every stream in which an intra 1:4 strip actually fires (counters 1..4 per + stream, e.g. `32x8=4`, `64x16=2`, `16x64=3`, `8x32=4`) ALSO carries a + non-skip INTER 2:1 rect strip ("a non-skip rectangular (HORZ/VERT/HORZ_B) + strip needs rectangular residual coding"), an SB-level AB partition, or a + sub-8 inter partition -- each another lane's named refusal, hit before the + frame completes, so the attempt is never pixel-compared. +* Every recipe under which all attempts decode whole (`--max-partition-size=32`, + or a static background with a moving overlay) fires ZERO 1:4 intra strips: + aomenc only reaches for 1:4 partitions in the same neighbourhoods where it + also picks the SB-level rect/AB shapes this decoder still refuses. +* Class [[counter-from-refused-stream]] applies: the counters above come from + REFUSED streams and prove only that the new code path is entered, never that + its pixels are right. The gate counts deltas on decoded+compared attempts + only, which is why it currently fails/ignores rather than reading green. + +So: **un-ignore and re-run this gate once the inter rect-leaf lane (lane-r14 r3, +`decode.rs` var-tx leaves) lands** -- that is the refusal that aborts every +candidate stream. + +## Film check (his ReelB extract) + +`decode_probe scratchpad/census3/kf/seg_4500.obu` (3840x1608 yuv420p10le, +213 frame headers): + +* BEFORE (charter premise): stops at "an intra-coded 1:4 (or other non-2:1) + rect strip on the inter block path". +* AFTER: `intra_rect4_in_inter: 64x16=0 16x64=4 32x8=0 8x32=0` -- four intra + 16x64 strips decode -- and the stop string is now + "a split intra strip whose transform unit is 64x32 (no luma coefficient + tables for that shape here)" (`decode_rect_split`'s luma-shape guard: the + SB-level 2:1 strip at tx depth 0, i.e. a TX_64X32 luma transform, which no + path here codes). Frames decoded (EC_AV1_FINAL_DUMP file count): 1 (the head + key frame) -- the new stop is still inside decode-order frame 1. + +EVIDENCE: /tmp/claude-1000/.../scratchpad/census3/kf/seg_4500.obu | decode_probe before/after the change, EC_AV1_FINAL_DUMP file count | 4 intra 16x64 strips decoded; stop string moved from the 1:4 refusal to "transform unit is 64x32"; 1 frame dumped +EVIDENCE: $HOME/.cache/intra14-suite-r1.log | `cargo test -p ec-av1 --lib` under a systemd unit (MemoryMax=10G) | test result: ok. 367 passed; 0 failed; 33 ignored (2 of them this lane's gate arms); 616.84s + +## Residue + +* fix-now (next round / successor lane): the gate is `#[ignore]`d. deferred -- + what unblocks it: the inter rect-strip refusal ("a non-skip rectangular + (HORZ/VERT/HORZ_B) strip needs rectangular residual coding"), lane-r14 r3. +* deferred: pixel-byte compare of the film's pre-stop frames through + EC_PROBE_OUT16 -- only ONE frame decodes before the stop, and it is the key + frame already proven bit-exact by lane-hgkf; what unblocks a meaningful + compare is the 64x32 luma transform above. +* accepted: `--enable-cfl-intra=0` and `--enable-palette=0` in the new gate + (ledger dead-end: a new gate spelling `--enable-cfl-intra=1` retires the tool + from `NEVER_EXERCISED_8BIT` on the flag alone with no CfL counter to assert; + the screen-content frame is refused whole on this path, so a palette flag + would buy no coverage). Deviation from the charter's flag list, stated here. +* accepted: `--enable-tx-size-search=0` and `--min-partition-size=32` in the + gate recipe -- measured, both named in the source comments. +* open (NOT mine, found here): at 192x128 mandelbrot start_scale 4.76, cq 55, + cpu-used 1, WITHOUT any rect/1:4 partition (`--enable-rect-partitions=0`), + decode-order frame 4 mismatches ffmpeg by 3729 luma samples (max |d| = 6) and + frames 5-7 drift (24k samples, max |d| ~220). Pre-existing square-path defect + on this tree, unrelated to this lane. diff --git a/lanes/intra14-r2.report.md b/lanes/intra14-r2.report.md new file mode 100644 index 00000000..fbfcfd0a --- /dev/null +++ b/lanes/intra14-r2.report.md @@ -0,0 +1,101 @@ +# lane-intra14 r2 -- merge main, un-ignore the gate, re-measure + +Branch `lane-intra14`, base main `18bf7dc`. **RED**: the r1 blocker refusal is +gone and the gate now reaches the pixel compare, but every compared attempt +mismatches on a defect this lane does not own, so the lifted refusal is still +**ungated** and this branch MUST NOT merge as-is. + +## 1. Merge (commit 4672212) + +`git merge --no-commit main` -- one conflict (stream.rs counter accessors, +resolved keeping BOTH lanes' functions: `intra_rect4_in_inter_counters` and +lane-r14's `rect64_inter_tu_hits`). md5 of the merged files vs main: + +| file | main | merged | +|---|---|---| +| cdf.rs (incl. NZ_MAP / FILTER_INTRA regions) | a3fb168e | a3fb168e | +| cdf_state.rs | 6faaa22c | 6faaa22c | +| encode.rs | 6c9f9f66 | 6c9f9f66 | +| mvstack.rs | 3ff196a2 | 3ff196a2 | + +i.e. every file this lane does not own came through byte-identical to main; +`decode.rs` / `refusal_inventory.rs` / `decode_probe.rs` carry only this lane's +additions on top of main's text (`git diff main -- ` reviewed hunk by hunk). + +## 2. The gate, un-ignored and re-run (8-bit, 40 attempts) + +`--exact stream::tests::a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact --nocapture` + +Before (r1 tree): 40/40 attempts refused, 0 pixel-compared. +After the merge: **3 attempts decode whole**, one of them firing the feature: + +* seed 52 (`--cpu-used=3 --cq-level=45`): `64x16=4 16x64=3 32x8=0 8x32=0` +* seed 46 (`--cpu-used=1 --cq-level=55`): `0 0 0 0` +* seed 54 (`--cpu-used=1 --cq-level=35`): `0 0 0 0` + +All three MISMATCH ffmpeg, and **the two zero-hit attempts mismatch exactly like +the firing one**: decode-order frame 3/4 luma ~3.7-4.5k samples at max |d| 6..17 +(first diff around x=128..141, y=58..59), then frames 5-7 drift to ~24k samples +at max |d| ~220 as the references carry the error. So the failure is NOT the 1:4 +strip path: it is a pre-existing INTER-frame defect of this mandelbrot 192x128 +source on this tree -- the same one r1 already recorded as "open, NOT mine" +(3729 samples, max |d| = 6, with rect partitions off). Control: re-encoding the +seed-52 recipe with `--enable-1to4-partitions=0` yields a byte-identical stream +(same hits, same per-frame diff counts), so aomenc ignores that flag here and +the shape is not the discriminator either. + +Remaining refusals over the 40 attempts (37 of them, all other lanes' surfaces): +inter SB-level AB (12), inter 16x16-level AB or 1:4 (6), non-skip rect strip +needs rect residual coding (5), split intra strip whose TU is 32x64 / 64x32 (5), +inter partition below 8x8 (4), sub-8 angle delta / other (5). + +The two gate arms are therefore **`#[ignore]`d again, with the new blocker +measured and named in the source** (stream.rs, above both arms) instead of the +stale r1 reason. The gate itself is unchanged and unweakened: counters are +per-attempt deltas on decoded+compared attempts only, every decode-order frame +compared, a decode error is never a SKIP. + +### Recipe hunt for a clean-baseline source (240-recipe matrix + a 4-source probe) +* matrix 192x128/256x192/128x128 x min-part 16/32 x tx-size-search 0/1 x + cq 63/55/45/35/25 x cpu 1..4 (98 recipes ran before the 10-min bound): exactly + ONE fired 1:4 strips (192x128, min=32, txs=1, cq35, cpu2 -> `64x16=2 16x64=4`) + and it mismatches (118035 samples); 7 more decoded with zero hits. +* `testsrc2=192x128` on the same recipe: 4 of 12 attempts decode **pixel-exact** + (clean baseline) but fire zero 1:4 strips; the other 8 hit named refusals. +* `--enable-cfl-intra=1` was NOT re-measured -- the run budget went to the + mismatch triage. deferred. + +## 3. Film check (his ReelB extract, unchanged by the merge) + +`decode_probe scratchpad/census3/kf/seg_4500.obu` (3840x1608 yuv420p10le, 213 +frame headers): still stops at "a split intra strip whose transform unit is +64x32 (no luma coefficient tables for that shape here)", still decodes +`intra_rect4_in_inter: 64x16=0 16x64=4 32x8=0 8x32=0`. `EC_AV1_FINAL_DUMP` file +count is 0 (r1 measured 1 on the pre-merge tree) -- the stop is inside +decode-order frame 1 either way. + +EVIDENCE: $HOME/.cache/intra14-r2-fi0.log, $HOME/.cache/intra14-r2-sweep.log, $HOME/.cache/intra14-r2-src.log | un-ignored gate + 240-recipe matrix + 4-source probe under systemd-run scopes | 3/40 attempts pixel-compared (0 before the merge), seed 52 fires 64x16=4 16x64=3, and the two zero-hit attempts mismatch identically +EVIDENCE: scratchpad/census3/kf/seg_4500.obu | decode_probe under a 6G scope, EC_AV1_FINAL_DUMP file count | stop string unchanged ("transform unit is 64x32"), 4 intra 16x64 strips decoded, 0 frames completed + +## 4. Suite + +`cargo test -p ec-av1 --lib` under a user systemd unit (MemoryMax=10G): +**370 passed; 0 failed; 34 ignored** (2 of the ignored are this lane's gate +arms); 889.13s. + +EVIDENCE: $HOME/.cache/intra14-suite-r2.log | systemd-run --user --unit ... MemoryMax=10G, EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1, nice -n 10 -j3 | test result: ok. 370 passed; 0 failed; 34 ignored; 889.13s + +## Residue + +* fix-now (successor / another lane): the pre-existing inter-frame pixel defect + on 192x128 mandelbrot at cq 35..55, cpu 1..3 -- reproducible with ZERO 1:4 + strips and zero rect partitions, first divergence decode-order frame 3/4 luma + around (130,58) with max |d| < 20. It is unrefused (silent), so every gate on + mandelbrot inter content is measuring it. deferred -- what unblocks this lane: + either that fix, or a source whose inter baseline is exact AND that fires an + intra 1:4 strip. +* deferred: `--enable-cfl-intra=1` arm -- what unblocks it: a green gate to add + it to. +* accepted: `--enable-filter-intra=1` stays in the recipe. An earlier r2 run with + it at 0 showed zero mismatches, but only ONE stream was compared in that run, + so it proves nothing; the claim is withdrawn. diff --git a/lanes/intrasplit-r1.report.md b/lanes/intrasplit-r1.report.md new file mode 100644 index 00000000..5d298ab5 --- /dev/null +++ b/lanes/intrasplit-r1.report.md @@ -0,0 +1,75 @@ +# lane-intrasplit r1 — RED (refusal lifted, two root causes fixed, gate never fired) + +Base: 18bf7dc. Branch: lane-intrasplit. + +## What changed +- `crates/ec-av1/src/decode.rs:6225` — the refusal "a split (nonzero tx_depth) transform on + an intra HORZ/VERT strip in an inter frame" is gone; a nonzero depth now walks the key + frame's own per-TU path (`depth_to_tx_wh` + `decode_rect_split`, already wired) and bumps + the new per-depth counter. +- `crates/ec-av1/src/decode.rs` (`tx_size_context_txfm_rect`, new, above + `tx_size_context_txfm`) — ROOT CAUSE 1: the arm read its `tx_depth` symbol through + `tx_size_context_rect`, the KEY FRAME's deblock-grid approximation. libaom + `get_tx_size_context` (pred_common.h:342, called from `read_selected_tx_size`, + decodemv.c) reads the two `TXFM_CONTEXT` bands and, for an INTER neighbour, that + neighbour's BLOCK width/height instead. Class [[cdf-row-held-constant]]: wrong CDF row, + same value most of the time, different range. +- `crates/ec-av1/src/decode.rs` (tail of `decode_intra_rect_in_inter`) — ROOT CAUSE 2: + the strip never wrote its own `TXFM_CONTEXT` bands (`set_txfm_ctxs`, + decodeframe.c end of `decode_token_recon_block`), because the call site + (decode.rs:18210) returns early. Every later block in the frame read a stale + `tx_size`/`txfm_split` context across the strip's footprint. +- `crates/ec-av1/src/refusal_inventory.rs` — inventory line dropped. +- `crates/ec-av1/src/stream.rs` — new gate + `a_real_aomenc_{,10bit_}inter_sequence_with_a_split_transform_intra_strip_decodes_pixel_exact` + (192x128, 8 frames, real aomenc, `--enable-rect-partitions=1 --enable-tx-size-search=1`, + `--kf-max-dist/-min-dist=9999 --lag-in-frames=0`, cpu-used and cq (incl. 63) swept, + each flag spelled once with the rect/tx overrides LAST) hard-asserting + `decode::intra_rect_in_inter_split_tx_hits()` per depth. + +## Gate result: RED (never fired) +`cargo test -p ec-av1 --lib a_real_aomenc_inter_sequence_with_a_split_transform_intra_strip` +40/40 attempts stop at OTHER lanes' named refusals; 0 attempts decoded whole, so the lift is +UNGATED and this branch MUST NOT merge as-is. + +EVIDENCE: $HOME/.cache/intrasplit-suite-r1.log | 40-attempt sweep, min/max-partition 32/32, +cpu 0..4, cq 30/20/12/63, zoom-mandelbrot source | refusal histogram: +intra 1:4 strip 9, non-skip inter rect strip 7, inter 16x16 AB/1:4 7, inter SB AB 4, +1:4 inter strip split w/ 64 axis 3, inter sub-8 3, split intra strip w/ 64x32 unit 2, +32x64 unit 2, Golomb tail 2, 8x8 non-DC chroma 1. +Six recipe families were swept (192x128 and 96x96; min/max partition 16/32, 16/64, 32/64, +32/32; hard-cut overlay and fast-zoom sources; sb-size 64): every stream that makes aomenc +pick an intra 2:1 strip with a split transform also carries one of the refusals above. +Same shape as the recorded lane-intra14 r1 and lane-r14 r3 gate hunts. + +## Film probes (charter) +EVIDENCE: scratchpad/intrasplit/{reelb1200,reelc1800}.obu | `ffmpeg -ss 1200/-ss 1800 -t 2 -c:v copy -f obu` +then `cargo run -p ec-av1 --example decode_probe` | new stops: +- ReelB -ss 1200: `a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular + residual coding` (was the split-intra-strip refusal per census4) — 0 frames in + EC_AV1_FINAL_DUMP. +- ReelC -ss 1800: `an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path` + (lane-intra14's surface) — 0 frames in EC_AV1_FINAL_DUMP. No 128-superblock refusal was + reached on this segment. + +## Suite +`cargo test -p ec-av1 --lib` (systemd unit, MemoryMax=10G, log +`$HOME/.cache/intrasplit-suite-r1.log`): **370 passed, 2 failed, 32 ignored** in 1183 s. +The 2 failures are exactly the two new gate arms (never fired, see above); every merged +gate — including the two `split_transform_intra_block` arms the refusal was originally +protecting, and every rect/strip/txselect gate — stays green with both fixes in. + +A first suite run also showed `a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` +FAILED; that was MY setup error (the worktree had no top-level `fixtures` symlink, so +`fs::read(../../fixtures/golden6-mismatch.obu).unwrap()` panicked), not a regression — +`$HOME/.cache/intrasplit-base-filmgrain.log` shows the same test green at base 18bf7dc, and +it is green in the rerun above after `ln -s`. + +## Residue +- fix-now (next round): make the gate fire. The only untried levers are a content family + that yields 32x16/16x32 intra strips with NO 1:4 or AB partition anywhere in the frame, + or waiting on lane-intra14 (1:4 intra strips) and lane-r14 (inter rect leaves) — both + would remove the two dominant blockers. +- deferred(lane-r14/lane-intra14): the two 64-axis strip refusals ("split intra strip whose + transform unit is 64x32/32x64") are this arm's neighbours but need rectangular 64-axis + luma coefficient tables. diff --git a/lanes/intrasplit-r2.handoff.md b/lanes/intrasplit-r2.handoff.md new file mode 100644 index 00000000..d8b213be --- /dev/null +++ b/lanes/intrasplit-r2.handoff.md @@ -0,0 +1,58 @@ +# lane-intrasplit r2 HANDOFF (tip 6e883c9, branch lane-intrasplit) + +## Merge state (all committed on this branch) +main 48b35ab -> lane-sqdrift 7d498c0 -> lane-r14 b86eb38 -> lane-inter16ab 4811488 (tip +moved from the charter's af7de9f) -> lane-intra14 f4b5419 (was 8313c4a). cdf.rs byte-equal +to main. Conflict resolutions: stream.rs (three gates interleaved in ONE hunk — all three +kept), decode.rs (both thread-locals; sbrect10 is_cfl_allowed narrowing BEFORE intra14's +INTRA_IN_INTER_MODE skip/mode split in read_intra_mode_rect), refusal_inventory.rs (kept +only intra14's narrowed "an intra-coded 16x4/4x16 strip ..."), decode_probe.rs (both). + +## Fix applied this round +decode.rs `rect_inter_luma_set` + cdf_state.rs `TxbSet::LumaRect8x4Inter{,1}`: a SPLIT +16x4/4x16 inter strip resolves to an 8x4 leaf (`sub_tx_size_map[TX_16X4] == TX_8X4`, +oracle av1/common/common_data.h:180) and used to hit `unreachable!()`. Set = LumaRect4x8's +coefficient tables (Luma8 + 32-position eob_pt) with inter tx_type row TX_4X4 +(`inter_tx_type_4` / `_set1`). `rect_inter_residual_supported` untouched — no refusal moved. +New diagnostic: `EC_SPLITSTRIP=1` prints mi_row/mi_col/bw/bh/depth at the counter bump. + +## Gate: RED, but FIRING for the first time +- 8-bit arm: 40/40 refusals (histogram in the r2 report), never fires. +- 10-bit arm: seed 74 / cq 12 / cpu-used 2 decodes all 8 frames, fires depth1=1, and + MISMATCHES ffmpeg: frame 1 Y first diff (163, 58), 5203 samples; frames 2-7 ~24.5k. +- Stream pinned: `/intrasplit/s74.obu`, md5 50ea2b42423f1c8b4eed9fa48c4775a6 + (192x128 yuv420p10le mandelbrot start_scale=3.08; full aomenc recipe = the gate's). +- The ONLY split strip in the stream is decode-order frame 1, mi(8,0), 32x16, depth 1 + (pixels x0..31 y32..47) and ITS OWN footprint is pixel-clean: raster first diff is the + LAST block of the same 32-px block row. So the divergence is downstream of the strip. +- NOT yet done: the msac RANGE ladder. Our tags: EC_MODE / EC_MODE_VAL / EC_STACK + (EC_TRACE_MODE=1, 338 lines). aomdec: EC_IMODE* (key frame) + EC_MODE* / EC_MODE_MV / + EC_STACK (219 lines) — emitters do not line up 1:1; ledger says our EC_MODE_VAL rng is + printed at libaom's EC_MODE_MV point, so compare VALUES on the mode ladder and use + EC_TRACE_COEFF ranges for the coefficient ladder. +- Do NOT use `decode_probe -o` for 10-bit triage: it writes 8-bit samples. + +## Suite +385 passed / 3 failed / 35 ignored, 1082 s ($HOME/.cache/intrasplit-suite-r2.log). +2 = this lane's own arms. 1 = MERGE CROSS-PRODUCT, not this lane's code: +`a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact` +(stream.rs:9167, frame 4 luma, attempt 1, 8-bit, arms [0,4,2,2]) — green on inter16ab's own +tip, red once r14 b86eb38 is in the same tree. + +## Film probes (merged tree, EC_AV1_FINAL_DUMP=1, 0 frames dumped both) +- 2160p10 HDR segment -ss 1200: now stops at "a split intra strip whose transform unit is + 32x64" (was the non-skip rect-strip residual refusal at r1). +- 1080p10 segment -ss 1800: now stops at "a COMPOUND_WEDGE mask on a rectangular inter + block" (was the intra 1:4 rect-strip refusal, lifted by lane-intra14). + +## Exact next step (r3) +1. Ladder s74.obu frame 1 from the strip at mi(8,0) forward: ours + `EC_TRACE_COEFF=1 EC_SPLITSTRIP=1 decode_probe s74.obu` vs + `EC_TRACE_COEFF=1 ~/.cache/aom-oracle/build/aomdec --rawvideo -o /dev/null s74.obu`; + find the first element whose RANGE step differs, in the blocks AFTER the strip in that + block row (target block x160..191, y32..63). +2. Prime suspects, in order: the strip's TXFM_CONTEXT bands written by r1's `set_txfm_ctxs` + tail (wrong span/value would desync the NEXT block's tx_depth), the depth-1 sub-unit + walk in `decode_rect_split` for a 32x16 strip at 10 bit, and the skip/txfm side maps the + strip leaves behind (class new-map-ignores-tile-edge / early-return-skips-tail). +3. Then re-run BOTH gate arms + the inter16ab 1:4 gate above (sibling-gate rule). diff --git a/lanes/intrasplit-r2.report.md b/lanes/intrasplit-r2.report.md new file mode 100644 index 00000000..7835e313 --- /dev/null +++ b/lanes/intrasplit-r2.report.md @@ -0,0 +1,104 @@ +# lane-intrasplit r2 — RED (gate now FIRES at 10-bit and MISMATCHES; 8-bit arm still never fires) + +Base: 45bdc87 (r1) + main 48b35ab + lane-sqdrift 7d498c0 + lane-r14 b86eb38 + +lane-inter16ab 4811488 + lane-intra14 f4b5419 (live tips read with `git log`, NOT the +charter's stale `af7de9f`/`8313c4a`). + +## Merges (step 1) +- `git merge main` (48b35ab) — clean. +- `lane-sqdrift 7d498c0` — clean. +- `lane-r14 b86eb38` — conflict in `stream.rs`: git interleaved THREE different gates + (the two no-CFL `uv_mode` gates from sqdrift/sbrect10 and r14's 64-axis 1:4 gate). + Resolved by reconstructing each side's full test and keeping all three + (`a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet`, + `a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact`, + `real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal`). +- `lane-inter16ab 4811488` — clean. +- `lane-intra14 f4b5419` — conflicts in `decode_probe.rs` (kept both counter blocks), + `refusal_inventory.rs` (kept intra14's NARROWED "an intra-coded 16x4/4x16 strip on the + inter block path"; dropped both main's broad 1:4 line and intra14's copy of THIS lane's + lifted split-tx refusal) and `decode.rs` (kept both thread-locals; kept both the + sbrect10 `is_cfl_allowed` narrowing and intra14's `INTRA_IN_INTER_MODE` skip/mode split + in `read_intra_mode_rect`, in that order). +- `crates/ec-av1/src/cdf.rs` is byte-identical to main (`git diff main -- cdf.rs` = 0 lines). + +## Fix this round (the merge cross-product the ledger predicted) +`crates/ec-av1/src/decode.rs` `rect_inter_luma_set` + `crates/ec-av1/src/cdf_state.rs` +`TxbSet::LumaRect8x4Inter{,Inter1}` — with lane-r14's general `read_var_tx_size` in, a +SPLIT 16x4/4x16 inter strip resolves to an 8x4 leaf (`sub_tx_size_map[TX_16X4] == TX_8X4`, +oracle `av1/common/common_data.h:180`) and hit `unreachable!("rect_inter_residual_supported +gates every shape that reaches here")`. The new set is `LumaRect4x8`'s coefficient tables +(`get_txsize_entropy_ctx(TX_8X4)` = TX_8X8, 32-position `eob_pt`) with the INTER `tx_type` +row `txsize_sqr_map[TX_8X4]` = TX_4X4 (`inter_tx_type_4` / `_set1`). No refusal was lifted +by this: `rect_inter_residual_supported` (the BLOCK-footprint gate) is untouched. + +EVIDENCE: $HOME/.cache/intrasplit-gate-r2b.log | temporary `(w={w} h={h})` in the +unreachable, gate arm re-run | panic message `... (w=8 h=4)`. + +## Gate result: RED +`cargo test -p ec-av1 --lib -- --test-threads=1 split_transform_intra_strip` +- 8-bit arm: 40/40 attempts still stop at OTHER lanes' named refusals — histogram + non-skip rect strip residual 14, inter SB-level AB 8, split intra strip w/ 64x32 unit 4, + non-DC chroma on 8x8 inter leaf 4, inter partition below 8x8 4, 32x64 unit 2, Golomb + tail 2, angle delta on 8x8 intra leaf 1, intra 16x4 inside a 16-level 1:4 partition 1. +- 10-bit arm: **one attempt (seed 74, cq 12, cpu 2) now decodes all 8 frames and FIRES** + (`depth1=1`) — and MISMATCHES ffmpeg: frame 1 Y first diff at (163, 58), 5203 samples; + frames 2-7 ~24.5k each (drift). This is the first time this lane's lifted path was ever + pixel-compared on a real stream. + +EVIDENCE: $HOME/.cache/intrasplit-gate-r2.log | 2 arms x 40 attempts, merged tree | 8-bit +0 firing / 40 refusals; 10-bit 1 firing attempt, frame 1 Y 5203 samples wrong. + +### What is known about the 10-bit mismatch (r3 starts here) +Stream pinned: `/intrasplit/s74.obu`, md5 `50ea2b42423f1c8b4eed9fa48c4775a6` +(192x128 yuv420p10le, mandelbrot start_scale 3.08, cq 12 cpu-used 2, recipe = the gate's). +- The ONLY split-transform intra strip in the whole 8-frame stream is in decode-order + frame 1 at `mi_row=8 mi_col=0 bw=32 bh=16 depth=1` (pixels x 0..31, y 32..47) — new + env-gated print `EC_SPLITSTRIP=1` (decode.rs, next to the counter bump). +- Its own footprint is pixel-CLEAN in frame 1 (raster first diff is at (163, 58), i.e. the + LAST block of the same 32-px block row), so the strip's coefficients and prediction are + right and the divergence is downstream of it — either a symbol this arm reads/does not + read after the strip, or another shape's defect in that block row. +- Not yet done: the msac RANGE ladder vs the instrumented aomdec. Our tags for frame 1 + are `EC_MODE`/`EC_MODE_VAL`/`EC_STACK` (`EC_TRACE_MODE=1`, 338 lines for the stream); + aomdec's are `EC_IMODE*` for the key frame and `EC_MODE*`/`EC_MODE_MV`/`EC_STACK` + (219 lines) — the two emitters do NOT line up 1:1 and need reconciling before diffing + (compare RANGE, never tell()). +- Do NOT triage this with the probe's `-o` dump: `decode_probe` writes 8-bit samples for a + 10-bit stream, so a byte compare against aomdec's `--rawvideo` output is meaningless + (frame 0 reads as 22667 "diffs" although the gate proves it exact). + +## Film probes +EVIDENCE: /intrasplit/{reelb1200,reelc1800}.obu | `decode_probe` with +EC_AV1_FINAL_DUMP=1 on the merged tree | new stop strings: +- 2160p10 HDR AV1 film, -ss 1200: `a split intra strip whose transform unit is 32x64` + (was "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual + coding" at r1) — 0 frames dumped. +- 1080p10 AV1 film, -ss 1800: `a COMPOUND_WEDGE mask on a rectangular inter block (the + wedge codebook is square-only)` (was "an intra-coded 1:4 (or other non-2:1) rect strip + on the inter block path" at r1, lifted by lane-intra14) — 0 frames dumped. + +## Suite +See `$HOME/.cache/intrasplit-suite-r2.log` (unit `intrasplit-suite-r2-*`, MemoryMax=10G). + +## Residue +- fix-now (r3): the 10-bit seed-74 mismatch above — the lane's own gate finally fires and + is red; the refusal must NOT be considered lifted until it is green. +- deferred(lane owning 64-axis luma tables): the "split intra strip whose transform unit is + 64x32 / 32x64" refusals — now the FIRST blocker on the 2160p film segment. +- deferred(other lanes): the 8-bit arm cannot fire until the non-skip rect-strip residual, + inter SB-level AB and sub-8x8 inter refusals are lifted (14+8+4 of 40 attempts). + +## Suite result (measured) +`cargo test -p ec-av1 --lib` under unit `intrasplit-suite-r2-1788330642`, MemoryMax=10G: +**385 passed, 3 failed, 35 ignored** in 1082 s (log `$HOME/.cache/intrasplit-suite-r2.log`). +- 2 failures are this lane's own gate arms (see above) — the lift is still UNGATED, so this + branch MUST NOT merge as-is. +- 1 failure is a MERGE CROSS-PRODUCT (class `merge-cross-product-defect`), not this lane's + code: `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact` + (lane-inter16ab's gate) fails at `stream.rs:9167` — `frame 4 luma vs ffmpeg (attempt 1, + 8-bit, arms [0, 4, 2, 2])`. It is green on lane-inter16ab's own tip 4811488 per that + lane's report; it goes red once lane-r14 b86eb38 (general `read_var_tx_size`) and/or + lane-intra14 f4b5419 are merged with it. `deferred(whoever merges r14+inter16ab into + main)`: the same pair must be re-run there — the 8x4 luma set added this round is the + first half of that interaction, the pixel mismatch on frame 4 is the second. diff --git a/lanes/intrasplit-r3.report.md b/lanes/intrasplit-r3.report.md new file mode 100644 index 00000000..dff601ab --- /dev/null +++ b/lanes/intrasplit-r3.report.md @@ -0,0 +1,66 @@ +# lane-intrasplit r3 report (branch lane-intrasplit, tip 50c43cd + this doc) + +## Verdict: GREEN — both gate arms pass, zero named refusals, both tx depths seen. + +## What changed (r3, commit 50c43cd) +- `crates/ec-av1/src/decode.rs:11587,11602` (`tx_size_context_txfm_rect`, `tx_size_context_txfm`) -- + ROOT CAUSE. These implement libaom `get_tx_size_context` + (`~/.cache/aom-oracle/src/av1/common/pred_common.h:342-361`): when the above/left neighbour is an + INTER block its BLOCK size, not its transform-context band, decides the `tx_depth` CDF row + (`if (has_above) if (is_inter_block(above_mbmi)) above = block_size_wide[above_mbmi->bsize] >= max_tx_wide;`, + pred_common.h:355-357, and the `left`/`block_size_high` twin at :359-361). Both of our copies + indexed the `above_inter` / `left_inter` predicate bands as `mi_c / (SUB / MI)` / `mi_r / (SUB / MI)`, + but those bands are mi-granular everywhere else they are written (`record_inter_rect_mi`) and read + (`intra_inter_ctx`). The override therefore consulted a neighbour four mi columns/rows away, and at + the first intra block to the right of an inter one it read `tx_depth` off ctx 0 where libaom has + ctx 1 -- same decoded VALUE, different interval narrowing, so the tile desynced from there + (class [[wrong-alphabet-same-value]] shape, via a mis-scaled index). +- `crates/ec-av1/src/decode.rs:6558` -- `EC_SPLITSTRIP` now prints EVERY intra strip with its depth, + not only split ones: a source that codes no strip at all and one that codes only unsplit strips were + indistinguishable through the old print. +- `crates/ec-av1/src/stream.rs:5536,5559,5648` -- gate geometry moved from 192x128 / min=max=32 to + 96x96 / min 16 / max 64, cq floor 63 -> 4. With a CORRECT decode the old geometry contains ZERO intra + strips in an inter frame; r1/r2's "firing" counters had been read off our own desynced decode + (class [[counter-from-refused-stream]]). + +## Gates (this tree, EC_AV1_REQUIRE_AOMENC=1) +`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-intrasplit cargo test -p ec-av1 --lib -- --nocapture --test-threads=1 split_transform_intra_strip` +-> `test result: ok. 2 passed; 0 failed; 0 ignored`. + +EVIDENCE: $HOME/.cache/intrasplit-r3-gates.log:884-885 | 10-bit arm, 3 aomenc attempts (seeds 42-44, cq 30, cpu 0-2), each decoded and pixel-compared vs ffmpeg | buckets counted-exact=2 uncounted-exact=1 named-refusals=0; split strips seen depth1=1 depth2=3; 0 pixel diffs in any plane of any of 8 frames per attempt +EVIDENCE: $HOME/.cache/intrasplit-r3-gates.log:908-909 | 8-bit arm, 21 attempts (seeds 42-62, cq 30/20/12/4, cpu 0-4) | buckets counted-exact=6 uncounted-exact=15 named-refusals=0; split strips seen depth1=9 depth2=1; 0 pixel diffs +EVIDENCE: commit 50c43cd message | aomdec `EC_ISTEP name=tx_depth` ladder on the r2 pinned stream (10-bit 192x128, md5 50ea2b42423f1c8b4eed9fa48c4775a6) before vs after | 85/147 elements identical (first divergence mi(24,24) ctx 0 vs libaom 1) -> 147/147 identical, stream decodes pixel-exact + +The 15 "uncounted-exact" 8-bit attempts are decoded-and-pixel-compared attempts in which aomenc's RD +simply coded no split strip; they are never SKIPs and never mask a mismatch (the pixel asserts run on +every successful decode, class [[gate-skips-on-its-own-failure]]). Named refusals: 0 in both arms. + +## Sibling gate: inter16ab 16x16-level 1:4 -- RED, inherited, NOT this lane's +`a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact` (stream.rs:8986) +fails on this tree exactly as r2 reported: attempt 1, 8-bit, arms [0,4,2,2], frame 4 = 25 luma pixels +differ first at (6,49) max |delta| 1; frame 5 = 14 pixels first at (3,48) max |delta| 1. + +EVIDENCE: $HOME/.cache/intrasplit-r3-gates.log:1795-1799 (tip 50c43cd) vs $HOME/.cache/intrasplit-r3-r2chk.log (detached worktree at r2 tip 5691e9a, own CARGO_TARGET_DIR) | ran the same gate on both commits | BIT-IDENTICAL failure: same frames, same 25/14 pixel counts, same (6,49)/(3,48) first-diff coordinates, same max |delta| 1 -- r3's fix neither caused nor moved it +EVIDENCE: $HOME/.cache/intrasplit-r3-mainchk.log (detached worktree at main cc323d0) | same filter | `0 passed; 0 failed; 418 filtered out` -- the gate does not exist on main: main merged lane-inter16ab at af7de9f, this gate arrived with that lane's LATER tip 4811488, which only this branch carries + +No msac RANGE ladder was run on it, deliberately: the entropy stream is provably in sync (frames 0-3 +are bit-exact in all three planes and the decode completes) and a max |delta| of 1 over 39 pixels is a +RECONSTRUCTION-stage difference, not a desync -- a range ladder is the wrong instrument. The rows +(48, 49) sit on a 16-row boundary at low columns, so the first hypothesis for whoever owns it is the +lf-grid fill for a 16x16-level 1:4 partition's internal horizontal edge (r14's `fill_lf_grid_rect` / +(row,col,tw,th) var-tx leaves crossed with inter16ab's 1:4 arms) -- hypothesis, not a measurement. + +Disposition: deferred(the merge that lands lane-inter16ab tip 4811488 alongside lane-r14 b86eb38 -- +class [[merge-cross-product-defect]]; neither parent alone is red, and neither the gate nor its +failure exists on main today). + +## Suite +`EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-intrasplit cargo test -p ec-av1 --lib -j3` +-> **387 passed / 1 failed / 35 ignored**, 1460 s ($HOME/.cache/intrasplit-suite-r3.log). r2 was 385/3/35; +the two that flipped green are this lane's own gate arms. The single remaining failure is the inherited +1:4 cross-product above -- no other regression. + +## Residue +- The 1:4 cross-product above: deferred, owner = the merge, as stated. +- accepted: the 8-bit arm needs 21 attempts to see both depths; depth2 is rare at 96x96. Both depths + ARE seen in pixel-exact attempts, which is what the gate asserts.