forge
Explore
Log in

Don't you dare go Hollow

Merge cc09f390 (444interband) — suite green: 444interband 628/0

Browse files at this commit

64940fde76eaa0c4270a4d579eb9ca2e348f81eeAhmet Kaan GümüşParent: d1bba6cedc72e0
# Conflicts:
#	crates/ec-av1/src/stream.rs
crates/ec-av1/examples/decode_probe.rsmodified+4 -0
@@ -109,6 +109,10 @@ fn main() {
109 "llintra8_chroma_walk: {}",109 "llintra8_chroma_walk: {}",
110 ec_av1::decode::llintra8_chroma_walk_hits()110 ec_av1::decode::llintra8_chroma_walk_hits()
111 );111 );
112+ println!(
113+ "sub8rect444_chroma_walk: {}",
114+ ec_av1::decode::llsub8rect444_chroma_walk_hits()
115+ );
112 let si = ec_av1::stream::sub8_intra_rect_hits();116 let si = ec_av1::stream::sub8_intra_rect_hits();
113 println!(117 println!(
114 "sub8_intra_rect: horz8x4={} vert4x8={} chroma_ref={} mixed={} split4x4={}",118 "sub8_intra_rect: horz8x4={} vert4x8={} chroma_ref={} mixed={} split4x4={}",
crates/ec-av1/fixtures/ll444_defaultp_inter_strip.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+134 -6
@@ -8469,7 +8469,7 @@ impl Neighbours {
8469 o.2 += dc_vote(left[plane].dc);8469 o.2 += dc_vote(left[plane].dc);
8470 }8470 }
8471 }8471 }
8472- out8472+ out
8473 }8473 }
8474 8474
8475 /// [`Self::around`] with independent above (`w`)/left (`h`) extents, in8475 /// [`Self::around`] with independent above (`w`)/left (`h`) extents, in
@@ -25950,6 +25950,22 @@ pub fn llintra8_chroma_walk_hits() -> usize {
25950 LLINTRA8_CHROMA_WALK_HITS.with(|c| c.get())25950 LLINTRA8_CHROMA_WALK_HITS.with(|c| c.get())
25951 }25951 }
25952 25952
25953+thread_local! {
25954+ /// lane-av1sub8rect444: how many of `decode_intra_sub8_leaf`'s 8x4/4x8
25955+ /// INTRA leaves ran the lossless 4:4:4 per-unit chroma walk (two TX_4X4
25956+ /// units per plane, plane-major) instead of one TX_8X4/TX_4X8 rect unit
25957+ /// -- the shape whose unit count AND skip ctx the rect read got wrong.
25958+ /// A gate proving the arm fired; CHROMA_SPLIT_TX_HITS cannot attribute
25959+ /// its bumps to THIS leaf.
25960+ pub(crate) static LLSUB8RECT444_CHROMA_WALK_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
25961+}
25962+
25963+/// [`LLSUB8RECT444_CHROMA_WALK_HITS`]: lossless 4:4:4 chroma walks through a
25964+/// sub-8 8x4/4x8 INTRA leaf.
25965+pub fn llsub8rect444_chroma_walk_hits() -> usize {
25966+ LLSUB8RECT444_CHROMA_WALK_HITS.with(|c| c.get())
25967+}
25968+
25953 fn read_sb128_root(25969 fn read_sb128_root(
25954 dec: &mut SymbolDecoder,25970 dec: &mut SymbolDecoder,
25955 cdfs: &mut Cdfs,25971 cdfs: &mut Cdfs,
@@ -35914,9 +35930,20 @@ fn decode_intra_sub8_leaf(
35914 // No angle delta below 8x8 (`av1_use_angle_delta`), for luma or chroma.35930 // No angle delta below 8x8 (`av1_use_angle_delta`), for luma or chroma.
35915 let angle_delta_y = 0;35931 let angle_delta_y = 0;
35916 let (uv_mode, alpha) = if has_chroma {35932 let (uv_mode, alpha) = if has_chroma {
35917- // `is_cfl_allowed` is `wide <= 32 && high <= 32` -- true for this35933+ // `is_cfl_allowed` (blockd.h): away from lossless it is
35918- // shape, so the 14-symbol CFL alphabet is the right one.35934+ // `wide <= 32 && high <= 32` -- true for this shape; at lossless the
35919- let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]);35935+ // CHROMA plane block must be a single TX_4X4, so at 4:4:4 only the
35936+ // 4x4 leaf keeps the 14-symbol CFL alphabet while an 8x4/4x8 leaf
35937+ // reads the 13-symbol `uv_mode_no_cfl` one (the t6 frame-1 8x4 leaf
35938+ // desynced at its uv_mode symbol reading the CFL alphabet,
35939+ // lane-av1llintercdf). At 4:2:0 a sub-8 shape's chroma block is
35940+ // always 4x4-or-smaller, so the predicate stays true and this read
35941+ // is unchanged.
35942+ let uv_mode = if cfl_allowed_px(bw, bh, fctx) {
35943+ dec.symbol(&mut cdfs.uv_mode_cfl[mode])
35944+ } else {
35945+ dec.symbol(&mut cdfs.uv_mode_no_cfl[mode])
35946+ };
35920 if step {35947 if step {
35921 eprintln!(35948 eprintln!(
35922 "EC_ISTEP mi_row={} mi_col={} name=uv_mode val={uv_mode} rng={}",35949 "EC_ISTEP mi_row={} mi_col={} name=uv_mode val={uv_mode} rng={}",
@@ -36291,6 +36318,7 @@ fn decode_intra_sub8_leaf(
36291 }36318 }
36292 36319
36293 let ac = alpha.map(|_| if chroma_444 { cfl_src_rect(px, py, bw, bh) } else { cfl_src(gpx, gpy, 8) });36320 let ac = alpha.map(|_| if chroma_444 { cfl_src_rect(px, py, bw, bh) } else { cfl_src(gpx, gpy, 8) });
36321+ let mut chroma_stamped_per_unit = false;
36294 let (u_grid, v_grid): (Grid, Grid) = if skip {36322 let (u_grid, v_grid): (Grid, Grid) = if skip {
36295 if alpha.is_some() {36323 if alpha.is_some() {
36296 hit!(CHROMA_SKIP_CFL_HITS);36324 hit!(CHROMA_SKIP_CFL_HITS);
@@ -36307,6 +36335,95 @@ fn decode_intra_sub8_leaf(
36307 (Grid::Zero(16), Grid::Zero(16))36335 (Grid::Zero(16), Grid::Zero(16))
36308 }36336 }
36309 } else if chroma_444 && bw != bh {36337 } else if chroma_444 && bw != bh {
36338+ if lossless(fctx) {
36339+ // lane-av1sub8rect444: lossless codes TX_4X4 on EVERY plane
36340+ // (`av1_get_tx_size`, blockd.h:1383), so this leaf's 8x4/4x8
36341+ // chroma plane block is a 1x2/2x1 raster of TX_4X4 units per
36342+ // plane, PLANE-MAJOR -- the same per-unit walk
36343+ // [`read_intra_chroma_lossless`] runs for whole blocks and this
36344+ // leaf's own luma `split` runs above, not one TX_8X4/TX_4X8
36345+ // rect unit. The rect read was wrong twice over: its unit count
36346+ // left the second unit's coefficients in the bitstream, and its
36347+ // skip ctx fixed at above+left missed `get_txb_ctx`'s
36348+ // plane-block-bigger-than-transform term (libaom ctx 10+above
36349+ // +left, our tables' +3), where the oracle read ctx 11≡4.
36350+ let (mut uo, mut vo) = (Vec::new(), Vec::new());
36351+ for plane_idx in 1..3 {
36352+ for tu in 0..2usize {
36353+ let (ox, oy) = if vert { (0, tu * 4) } else { (tu * 4, 0) };
36354+ // libaom's `max_blocks_wide/high` clip: a unit whose
36355+ // origin is past the frame edge is not coded at all
36356+ // (`decode_token_recon_block`). At 4:4:4 the unit's
36357+ // chroma origin is the leaf's own (px, py).
36358+ if px + ox >= u.true_width || py + oy >= u.true_height {
36359+ continue;
36360+ }
36361+ // At 4:4:4 a TX_4X4 chroma unit IS one mi cell.
36362+ let tu_mi = (lmi.0 + oy / MI, lmi.1 + ox / MI);
36363+ let tu_around = neighbours.around_mi(tu_mi, MI);
36364+ let tu_r = tu_reach(
36365+ bw,
36366+ bh,
36367+ ox,
36368+ oy,
36369+ 4,
36370+ reach_c,
36371+ px,
36372+ py,
36373+ y.width,
36374+ y.height, fctx,
36375+ );
36376+ let buf: &mut PlaneBuf<'static> =
36377+ if plane_idx == 1 { &mut *u } else { &mut *v };
36378+ // The plane block (8x4/4x8) is bigger than the TX_4X4
36379+ // transform, so `get_txb_ctx`'s chroma ctx_offset is 10,
36380+ // not 7 -- our chroma tables carry the offset-10 rows at
36381+ // +3, the same `Some(3)` [`read_intra_chroma_lossless`]
36382+ // derives from `blk_w > 4 || blk_h > 4`.
36383+ let tu_grid = read_plane(
36384+ dec,
36385+ cdfs,
36386+ TxbSet::Chroma4,
36387+ scan4,
36388+ plane_idx,
36389+ tu_around[plane_idx],
36390+ mode,
36391+ uv_predict_mode,
36392+ angle_delta_uv,
36393+ tu_r,
36394+ buf,
36395+ px + ox,
36396+ py + oy,
36397+ 4,
36398+ TX4,
36399+ base_q_idx,
36400+ None,
36401+ None,
36402+ Some(3),
36403+ smooth_neighbor_uv, fctx,
36404+ )?;
36405+ // The unit's own coefficient context, stamped per unit
36406+ // (`av1_set_contexts`); the tail's whole-leaf chroma
36407+ // stamp below is skipped for this shape.
36408+ neighbours.record_mi_chroma(tu_mi, 4, 4, plane_idx, &tu_grid);
36409+ hit!(CHROMA_SPLIT_TX_HITS);
36410+ let dst = mu_units(
36411+ if plane_idx == 1 { &mut uo } else { &mut vo },
36412+ bw * bh,
36413+ );
36414+ for row in 0..4 {
36415+ let start = (oy + row) * bw + ox;
36416+ dst[start..start + 4].copy_from_slice(&tu_grid[row * 4..][..4]);
36417+ }
36418+ }
36419+ }
36420+ chroma_stamped_per_unit = true;
36421+ hit!(LLSUB8RECT444_CHROMA_WALK_HITS);
36422+ (
36423+ if uo.is_empty() { Grid::Zero(bw * bh) } else { Grid::Own(uo) },
36424+ if vo.is_empty() { Grid::Zero(bw * bh) } else { Grid::Own(vo) },
36425+ )
36426+ } else {
36310 // The leaf's own TX_8X4/TX_4X8 chroma unit: it IS the chroma plane36427 // The leaf's own TX_8X4/TX_4X8 chroma unit: it IS the chroma plane
36311 // block, so `get_txb_ctx` fixes the skip context at above+left.36428 // block, so `get_txb_ctx` fixes the skip context at above+left.
36312 let ca = neighbours.around_mi_rect(lmi, bw, bh);36429 let ca = neighbours.around_mi_rect(lmi, bw, bh);
@@ -36345,6 +36462,7 @@ fn decode_intra_sub8_leaf(
36345 let ug = read_chroma(1, ca[1], alpha.zip(ac).map(|((au, _), ac)| (au, ac)))?;36462 let ug = read_chroma(1, ca[1], alpha.zip(ac).map(|((au, _), ac)| (au, ac)))?;
36346 let vg = read_chroma(2, ca[2], alpha.zip(ac).map(|((_, av), ac)| (av, ac)))?;36463 let vg = read_chroma(2, ca[2], alpha.zip(ac).map(|((_, av), ac)| (av, ac)))?;
36347 (ug, vg)36464 (ug, vg)
36465+ }
36348 } else {36466 } else {
36349 let chroma_around = neighbours.around_mi(if chroma_444 { lmi } else { group_mi }, if chroma_444 { 4 } else { 8 });36467 let chroma_around = neighbours.around_mi(if chroma_444 { lmi } else { group_mi }, if chroma_444 { 4 } else { 8 });
36350 let ug = read_plane(36468 let ug = read_plane(
@@ -36359,9 +36477,19 @@ fn decode_intra_sub8_leaf(
36359 )?;36477 )?;
36360 (ug, vg)36478 (ug, vg)
36361 };36479 };
36480+ // The 4:4:4 lossless walk above already stamped these bands PER UNIT
36481+ // (raster-order last writer per cell, exactly libaom's per-entry last
36482+ // update); the whole-leaf aggregate would clobber the two units' distinct
36483+ // states with one, so it runs only for the one-unit shapes (the same rule
36484+ // [`decode_leaf8`]'s intrabc arm and the inter 8x8 leaf obey). The walk
36485+ // must skip the 4:2:0 group-tail below too: it spans the GROUP's two mi
36486+ // rows/cols with one composed state, which would overwrite the walk's
36487+ // own stamps with the whole-leaf aggregate.
36362 if chroma_444 {36488 if chroma_444 {
36363- neighbours.record_mi_chroma(lmi, bw, bh, 1, &u_grid);36489+ if !chroma_stamped_per_unit {
36364- neighbours.record_mi_chroma(lmi, bw, bh, 2, &v_grid);36490+ neighbours.record_mi_chroma(lmi, bw, bh, 1, &u_grid);
36491+ neighbours.record_mi_chroma(lmi, bw, bh, 2, &v_grid);
36492+ }
36365 } else {36493 } else {
36366 let round_up_even = |n: usize| n.div_ceil(2) * 2;36494 let round_up_even = |n: usize| n.div_ceil(2) * 2;
36367 let bound_h = round_up_even(neighbours.mi_rows);36495 let bound_h = round_up_even(neighbours.mi_rows);
crates/ec-av1/src/stream.rsmodified+109 -0
@@ -6049,6 +6049,115 @@ pub(crate) mod tests {
6049 }6049 }
6050 }6050 }
6051 6051
6052+ /// lane-av1-444interband: the DEFAULT-partition lossless 4:4:4 pin for
6053+ /// the inter 16x4/4x16 strip's chroma band stamping (the pair_chroma
6054+ /// 4:2:0-only gate, commit d5325172). Fixture pinned into `fixtures/`:
6055+ /// testsrc2 128x96 yuv444p, aomenc `--profile=1 --lossless=1
6056+ /// --enable-palette=0 --enable-intrabc=0 --passes=1 --cpu-used=4
6057+ /// --limit=6 --obu` (the av1llkf.report.md recipe), 6 frames; 32487
6058+ /// bytes, sha256
6059+ /// `1e6dd4e05038c8d51e2c8d29f8c337130c4fea0aed629415535e6e53af9a2c72`.
6060+ ///
6061+ /// This is the stream whose frame 1 desynced at the 16x4 inter strip
6062+ /// mi(2,8) -- its U bc=0 `txb_skip` read base 0 where aom reads base 1,
6063+ /// because the skipped strip (1,8)'s pair-form context stamp smeared
6064+ /// zero over `left[2][1]`. Two pins, both measured at d5325172:
6065+ /// end-to-end, every sample of every frame must match the oracle
6066+ /// aomdec exactly (the pre-fix tree refuses mid-frame-1, so the gate
6067+ /// is red by refusal, not by silent pass), and the 1:4 counter delta
6068+ /// must show the strips decoded WITHOUT the pair rewrite firing
6069+ /// (`horz4=20 vert4=28 chroma_pairs=0` -- chroma_pairs > 0 on this
6070+ /// pairless 4:4:4 stream is the defect reappearing, the
6071+ /// class `pair-rewrite-at-ss0`).
6072+ #[test]
6073+ fn a_lossless_444_defaultp_inter_strip_stream_decodes_byte_exact() {
6074+ const NAME: &str = "a_lossless_444_defaultp_inter_strip_stream_decodes_byte_exact";
6075+ const FIXTURE_LEN: usize = 32487;
6076+ const FIXTURE_FNV: u64 = 0x5278_9f0f_ce2d_1e52;
6077+ const W: usize = 128;
6078+ const H: usize = 96;
6079+ const FRAMES: usize = 6;
6080+ let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
6081+ .join("fixtures/ll444_defaultp_inter_strip.obu");
6082+ let stream = std::fs::read(&obu).unwrap_or_else(|e| {
6083+ panic!(
6084+ "{NAME}: pinned fixture {} is missing ({e}) -- the gate cannot run, \
6085+ which is a failure, not a skip",
6086+ obu.display()
6087+ )
6088+ });
6089+ assert_eq!(stream.len(), FIXTURE_LEN, "{NAME}: fixture length moved");
6090+ assert_eq!(fnv1a64(&stream), FIXTURE_FNV, "{NAME}: fixture bytes moved");
6091+
6092+ let _guard = lock_gate_counters();
6093+ let strips_before = decode::inter16_rect4_counters();
6094+ let frames = decode_stream(&stream).unwrap_or_else(|e| {
6095+ panic!("{NAME}: the pinned stream no longer decodes cleanly: {e}")
6096+ });
6097+ let strips_after = decode::inter16_rect4_counters();
6098+ assert_eq!(frames.len(), FRAMES, "{NAME}: frame count");
6099+ for f in &frames {
6100+ assert_eq!((f.width, f.height), (W, H), "{NAME}: dimensions");
6101+ }
6102+ // The 1:4 strips must have fired, and the 4:2:0 pair rewrite must
6103+ // NOT have (there are no chroma pairs at ss 0/0).
6104+ let (horz4, vert4, chroma_pairs) = (
6105+ strips_after.0 - strips_before.0,
6106+ strips_after.1 - strips_before.1,
6107+ strips_after.2 - strips_before.2,
6108+ );
6109+ assert_eq!(horz4, 20, "{NAME}: HORZ_4 strip count moved");
6110+ assert_eq!(vert4, 28, "{NAME}: VERT_4 strip count moved");
6111+ assert_eq!(
6112+ chroma_pairs, 0,
6113+ "{NAME}: chroma pairs closed on a 4:4:4 stream \
6114+ (class pair-rewrite-at-ss0)"
6115+ );
6116+
6117+ // The oracle aomdec, rawvideo out: FRAMES concatenated yuv444p frames.
6118+ if aomdec_path().is_file() {
6119+ let dir = std::env::temp_dir().join(format!("ec-av1-ll444dp-{}", std::process::id()));
6120+ let _ = std::fs::remove_dir_all(&dir);
6121+ std::fs::create_dir_all(&dir).expect("scratch dir");
6122+ let raw = dir.join("aomdec.raw");
6123+ let out = Command::new(aomdec_path())
6124+ .args(["--codec=av1", "--rawvideo", "-o"])
6125+ .arg(&raw)
6126+ .arg(&obu)
6127+ .stdin(Stdio::null())
6128+ .stdout(Stdio::piped())
6129+ .stderr(Stdio::piped())
6130+ .output()
6131+ .expect("aomdec failed to run");
6132+ assert!(
6133+ out.status.success(),
6134+ "{NAME}: the oracle aomdec refused the stream: {}",
6135+ String::from_utf8_lossy(&out.stderr)
6136+ );
6137+ let ref_raw = std::fs::read(&raw).expect("aomdec rawvideo output");
6138+ let _ = std::fs::remove_dir_all(&dir);
6139+ assert_eq!(ref_raw.len(), W * H * 3 * FRAMES, "{NAME}: aomdec raw size");
6140+ for (i, f) in frames.iter().enumerate() {
6141+ let base = i * W * H * 3;
6142+ for ((plane, off), p) in [(&f.y, 0usize), (&f.u, W * H), (&f.v, 2 * W * H)]
6143+ .into_iter()
6144+ .zip(["y", "u", "v"])
6145+ {
6146+ let want = &ref_raw[base + off..base + off + W * H];
6147+ let bad = plane.iter().zip(want).filter(|&(&a, &b)| a as u8 != b).count();
6148+ assert_eq!(
6149+ bad, 0,
6150+ "{NAME}: aomdec frame {i} plane {p}: {bad} samples differ \
6151+ (class pair-rewrite-at-ss0)"
6152+ );
6153+ }
6154+ }
6155+ } else {
6156+ eprintln!("SKIP {NAME} aomdec arm: no oracle aomdec at {}", aomdec_path().display());
6157+ }
6158+ }
6159+
6160+
6052 /// lane-lossless128: a LOSSLESS key frame that codes a 128-axis6161 /// lane-lossless128: a LOSSLESS key frame that codes a 128-axis
6053 /// (`BLOCK_64X128`) intra block -- the shape libaom's `read_tx_size` forces6162 /// (`BLOCK_64X128`) intra block -- the shape libaom's `read_tx_size` forces
6054 /// to `TX_4X4` on its very first line (`decodeframe.c:1183`), so every plane6163 /// to `TX_4X4` on its very first line (`decodeframe.c:1183`), so every plane
lanes/av1444interband.report.mdadded+132 -0
@@ -0,0 +1,132 @@
1+# lane-av1-444interband: the inter 1:4 strip's 4:4:4 chroma band stamping
2+
3+## Ticket
4+
5+Fix the 4:4:4 lossless 16x4 inter strip band stamping (t6 next-site from
6+av1sub8rect444's measurement: post-fix desync at the 16x4 INTER strip
7+mi(2,8), U unit (2,8) — ours `txb_skip` ctx 3 vs oracle ctx 11 with raw
8+cells `above=[0,] left=[23,]`), or stop with the site narrowed further.
9+Worktree at f41d649b, branch lane-av1-444interband.
10+
11+## Named site, re-measured (the report's attribution needed one correction)
12+
13+Fixture `/tmp/llkf/t6.obu`, sha256
14+`1e6dd4e05038c8d51e2c8d29f8c337130c4fea0aed629415535e6e53af9a2c72`,
15+32487 bytes (scratch, regenerable per av1llkf.report.md's recipe;
16+testsrc2 128x96, 1 key + 5 inter frames, `--profile=1 --lossless=1
17+--enable-palette=0 --enable-intrabc=0`, default partition, sb128).
18+Oracle: the shared patched `$HOME/.cache/aom-oracle/build`, fresh
19+`aomdec --rawvideo` on the same bytes.
20+
21+- Pre-change at f41d649b, our decoder refuses mid-frame-1
22+ (`a Golomb tail longer than this decoder reads`) — fail-before,
23+ measured before the edit on this tree.
24+- The oracle's cell dump (`EC_ECDUMP`) walks `left[2][1]` (U plane, mi
25+ row 2) across frame 1: the last writer before the failing read is the
26+ 16x16-INTRA block (0,4)'s U unit bc=3/br=2 (event #2379), which
27+ stamps cul_level 23 (mag 7, dc set); nothing else touches the cell
28+ until the (2,8) strip's U bc=0 reads it as 23. The skipped inter
29+ strips (0,8)/(1,8) log no coefficients and their
30+ `av1_reset_entropy_context` (decodeframe.c:1180) zero only their OWN
31+ cells — row 2's chroma left cell is not theirs to clear.
32+- Correction to the inherited attribution: our ctx 3 on the failing
33+ read is a `TxbSet::Chroma4` TABLE ROW (base 0 in the +3 offset-10
34+ layout), not a luma `skip_contexts` value — the read is the strip's
35+ U bc=0 (`side=4` = the 4x4 chroma tables), so the report's "U unit
36+ (2,8), ctx 3 vs 11" stands; the detour through "luma bc=3" was a
37+ rung-semantics misread (our `EC_ECDUMP_IN` logs the raw `skip_ctx`
38+ argument, which for chroma callers is the pre-offset base/row).
39+
40+## Root cause
41+
42+`decode_inter_block`'s strip tail ran lane-inter16ab r2's `pair_chroma`
43+rewrite unconditionally. The rewrite stamps the PAIR-form chroma span —
44+16x8 (HORZ) / 8x16 (VERT) at `pair_mi`, planes 1/2 — which is libaom's
45+single `av1_set_entropy_contexts` call for the 4:2:0 pair's 8x4 (4x8)
46+chroma unit. At ss 0/0 there is no pair: `pair_mi` == the strip's own
47+mi, every strip is its own chroma reference, and the strip's own
48+`record_rect_mi` (zero grids on the skip arm) already stamps exactly
49+its own 16x4 (4x16) chroma span — the `av1_set_entropy_contexts` /
50+`av1_reset_entropy_context` behaviour. The rewrite therefore smeared
51+the strip's state one extra row (col) too far: skipped strip (1,8)
52+wrote zero over `left[2][1..2]`, erasing the (0,4) intra block's U/V
53+stamps, and (2,8)'s U walk then read base 0 where aom reads base 1.
54+Counter evidence: `INTER16_CHROMA_PAIR_HITS` fired 31x on this
55+pairless 4:4:4 stream (its documented meaning is "odd strips that
56+close a 4:2:0 chroma pair").
57+
58+## Change (decode.rs, one filter + one trace rung)
59+
60+1. `pair_chroma` now carries `.filter(|_| ss_x(fctx) == 1 &&
61+ ss_y(fctx) == 1)`: the pair-span rewrite exists only at 4:2:0, where
62+ it is byte-preserved (the added condition is false-only-at-ss-0).
63+2. `record_mi_chroma` gained the chroma twin of the existing
64+ `EC_ECPUB` rung: `EC_CHROMA_PUB plane= mi=() wh=() lvl= dc=`,
65+ env-gated eprintln (the instrument that localized this site; kept
66+ for the next band hunt).
67+
68+Sibling ownership clean: the edit is in `decode_inter_block`'s tail
69+(lane-inter16ab's rewrite region), not `sub8_leaf_chroma444` nor
70+`decode_intra_sub8_leaf`.
71+
72+## Verification (measured, this tree @ d5325172)
73+
74+- Entropy/pixel witness, t6.obu vs fresh `aomdec --rawvideo`
75+ ($HOME/.cache/aom-oracle/build): all 6 frames decode (pre-change the
76+ decode refused mid-frame-1) and frames 0..5 are **byte-exact, 0
77+ differing bytes** per frame (36864 B/frame compared). Frame exactness
78+ is claimed on exactly that basis.
79+- Non-vacuity: `inter16_1to4` counters on the full t6 decode:
80+ `horz4=20 vert4=28 chroma_pairs=0` (was `chroma_pairs=31` while the
81+ strips decoded); the strips themselves still decode and the frames
82+ above prove it.
83+- Gates: `cargo test -p ec-av1 --lib a_lossless` → 7 passed, 0 failed
84+ (both 4:2:0 lossless libaom gates, the 444 min-partition-64 and
85+ min-partition-8 inter gates, the sb128 pair, the 16x4 pair). The
86+ 4:2:0 inter 16x4 aomenc sweep
87+ (`a_real_aomenc_inter_sequence_with_intra_16x4_strips_...`) is
88+ yuv420p-only and the change is no-op at 4:2:0 by construction (the
89+ filter's condition is satisfied there); not re-run this round.
90+- `cargo check -p ec-av1 --all-targets` (target dir
91+ `$HOME/.cache/cargo-target-av1444interband`, ec-av1 cleaned first):
92+ 0 warnings, 0 errors. `rustfmt --check` reports no hunks inside the
93+ edited ranges (the crate's pre-existing let-chains drift is
94+ untouched).
95+- Commit d5325172 on lane-av1-444interband. Not pushed.
96+
97+### Addendum (review P2): the t6 pin is now an in-tree gate
98+
99+Main's review follow-up: commit
100+`ll444_defaultp_inter_strip.obu` (force-added fixture, 32487 bytes,
101+sha256 `1e6dd4e05038c8d51e2c8d29f8c337130c4fea0aed629415535e6e53af9a2c72`,
102+FNV1a64 `52789f0fce2d1e52` per the crate's pin convention) and gate
103+`a_lossless_444_defaultp_inter_strip_stream_decodes_byte_exact`
104+(stream.rs, av1llpredgate2's pinned-fixture pattern): len + FNV pin,
105+the 1:4 counter delta pinned to `horz4=20 vert4=28 chroma_pairs=0`,
106+and the env-conditional aomdec arm requiring all 6 frames sample-exact.
107+Mutation-proven load-bearing: with the ss-0 filter reverted the gate
108+fails at the pre-fix refusal; restored, it is green (8 passed in the
109+a_lossless battery).
110+
111+## Named, not chased (spoken)
112+
113+1. `Neighbour::level` clamps `cul_level` to 7 while aom stores up to 15
114+ (`COEFF_CONTEXT_MASK` = 15, dc sign in bit 4). Invisible to every
115+ context derived from the cells (the `txb_skip` categories only
116+ distinguish {0} / {1..3} / {>=4}, and dc sign rides its own field),
117+ so it is representation drift, not a defect — noted so nobody
118+ "fixes" the stored value into a desync.
119+2. Oracle-side f2 cross-reference: lane-av1lrflush's 444sb witness f2
120+ diverges at PREFILT entering at column 128 (inter 64x128 at
121+ (128,0)), plausibly this same skipped-inter-strip class one size up
122+ (their filter-pipeline/LR exoneration is consistent with our
123+ entropy-domain finding). Main owns the 444sb gate extension
124+ (take(2) -> take(3)) once this lands. deferred(that check, unblock:
125+ their f2 witness bytes against this tree).
126+3. Whole-stream read-pairing via `EC_ECDUMP_IN`/`EC_ECDUMP` (dif,rng)
127+ triples is NOT a reliable event alignment across the two
128+ implementations: the internal daala-EC representations legitimately
129+ diverge while decoding identically (frame 0 is pixel-exact yet its
130+ pre-read triples fail 1:1 pairing). The robust comparators are
131+ pixels, refusal points, and ctx/cell values. Recorded so the next
132+ band lane doesn't burn a round on the same lesson.
lanes/av1llintercdf.report.mdadded+100 -0
@@ -0,0 +1,100 @@
1+# lane-av1llintercdf: the t6 frame-1 INTER all_zero divergence named (and the one-site fix)
2+
3+## Ticket
4+
5+Deferred item 1 of `lanes/av1llkf.report.md`: the 6-frame default-partition
6+lossless 4:4:4 testsrc2 stream (t6) reads frame 0 fully exact, then diverges at
7+frame 1 (INTER), luma `all_zero` read #2317 — "same ctx row (1) and same decoded
8+value as the oracle but different CDF contents (ours `cdf0=5892` vs aom
9+`27244`)", suspected adaptation-history/row-selection desync. Name the divergent
10+symbol and its reader, decide missed-update vs applied-twice, fix only if one
11+site.
12+
13+## The llkf reading is refuted — the CDF rows were EQUAL
14+
15+Both trace printers were misread as the same quantity:
16+
17+- ours (`decode.rs:6811-6823`): `cdf=[a, 32768, n]` is the row snapshot taken
18+ BEFORE `dec.symbol` — the PRE-update row, in OUR storage, where
19+ `ours_v = 32768 - aom_v` (complement).
20+- oracle (`decodetxb.c:161`): `cdf0=` is printed AFTER `aom_read_symbol` — the
21+ POST-update value in aom storage.
22+
23+Replaying frame 0 read-by-read (rate-4 adaptation, val=0 up / val=1 down in our
24+convention) matches every printed pair: at the divergent read aom's pre-state
25+was `26876` (aom storage) = `5892` (ours) — the rows were IDENTICAL, and both
26+sides adapted that read symmetrically. So the answer to "missed update or
27+applied twice" is **neither**: there was no adaptation desync at all; the rng
28+mismatch at read #2316 (0-indexed; the report's #2317) came from symbols read
29+EARLIER in the same block's mode info, which the all_zero-only ladder cannot
30+see.
31+
32+## The divergent symbol and reader (measured, t6, EC_ECDUMP_IN + EC_TRACE_COEFF
33++ EC_TRACE_MODE_STEP on both sides)
34+
35+Between the last coefficient read of frame 1's first superblock row and read
36+#2316, both sides decode the INTRA 8x4 leaf at mi=(0,2) — an intra leaf inside
37+an INTER frame, through `read_intra_block_mode_info` (decodemv.c:1065). The
38+states part inside its `uv_mode` read:
39+
40+- ours pre-`use_filter_intra` rng 60904, oracle 58668; ours consumed 100 bits
41+ across the block's mode info, the oracle 98 (+2).
42+- ours read `uv_mode` off the **14-symbol `uv_mode_cfl`** row
43+ (`decode.rs:35703`, then unconditional); the oracle reads it off the
44+ **13-symbol `uv_mode_no_cfl`** row, because `av1_is_cfl_allowed` (blockd.h)
45+ returns 0 for a lossless block whose chroma plane block is not a single
46+ TX_4X4 — an 8x4 leaf at 4:4:4 has an 8x4 chroma plane block.
47+
48+Reader: `decode_intra_sub8_leaf`'s uv read (`decode.rs:35703`), the one
49+`uv_mode` site that bypassed the canonical `cfl_allowed_px` predicate every
50+other uv read site uses (`decode.rs:9791, 11206, 15610, 18853, 34062, 38675`).
51+The block comment there stated only the non-lossless term.
52+
53+The neighbouring 4x4 leaf (mi=(0,1)) kept matching by construction: at 4:4:4
54+lossless a 4x4 leaf's chroma block IS a single TX_4X4, so CFL stays allowed and
55+the 14-symbol row is correct there — which is why frame 1 synced for 2316 reads
56+and 5 blocks before diverging on the first 8x4.
57+
58+## Change (decode.rs, one site)
59+
60+`decode_intra_sub8_leaf`'s uv read now goes through
61+`cfl_allowed_px(bw, bh, fctx)` — the canonical predicate, which already
62+implements the lossless term (chroma plane block must be a single TX_4X4).
63+4:2:0 is arithmetically identical: every sub-8 shape's chroma block is
64+4x4-or-smaller under 4:2:0, so the predicate stays true and the row choice is
65+unchanged; the 4:2:0 lossless gates (below) are green.
66+
67+## Verification (measured, this tree @ HEAD + this change)
68+
69+- Entropy: pairs #2316 and #2317 (the whole 8x4 leaf's luma) now match the
70+ oracle's (value, rng) exactly, and the ECIN bits delta returns to the
71+ constant +15 header offset through the block.
72+- Byte witness: t6 frame 0 is byte-exact vs fresh `aomdec --rawvideo` (36864
73+ bytes; sha256 of the full 6-frame decode differs — see the deferred item).
74+- Gates: `cargo test -p ec-av1 --lib a_lossless` → 7 passed, 0 failed (both
75+ 4:2:0 lossless libaom gates, the 444 min-partition-64 inter gate, the sb128
76+ pair, the 16x4 pair).
77+- `cargo check -p ec-av1 --all-targets` (target dir
78+ `$HOME/.cache/cargo-target-av1llintercdf`): 0 warnings, 0 errors.
79+
80+## Named, not chased (spoken)
81+
82+1. t6 frames 1..5 still differ (first diff frame-1 byte 65): a SECOND site in
83+ the same leaf, independent of the alphabet fix. At the still-shared state
84+ rng=51429 after the 8x4 leaf's luma, the oracle reads the leaf's chroma as
85+ FOUR TX_4X4 units (plane 1 bc=0,1 ctx=11 then plane 2 bc=0,1 — lossless
86+ forces per-unit TX_4X4), while `decode_intra_sub8_leaf`'s
87+ `chroma_444 && bw != bh` arm (`decode.rs:36104-36139`) reads the chroma
88+ plane as ONE `TX_8X4`/`TX_4X8` rect unit per plane (`read_coeffs_rect`,
89+ skip ctx fixed at above+left=1 where the oracle derives 11≡4). The fix is
90+ the b3f815c8-style per-unit lossless 444 chroma walk (unit decomposition +
91+ per-unit `get_txb_ctx` + dropped tx_type), i.e. a shape port of its own —
92+ not a one-site fix, so per the ticket it is stopped-with-site, deferred(
93+ the sub-8 4:4:4 lossless chroma walk; unblock: port the
94+ `decode_leaf_rect8`/8x8-leaf per-unit walk into the `chroma_444 && bw != bh`
95+ arm).
96+2. Instrument gap, no decode impact: the rect coefficient reader
97+ (`read_coeffs_rect`, `decode.rs:7056`) prints `EC_COEFF_STEP` with a
98+ hardcoded `plane=0` and no `EC_ECDUMP_IN` line, so rect-path reads are
99+ invisible to the (value, rng, bitpos) pairing used here. Worth one rung of
100+ parity next time that path is debugged.
lanes/av1sub8rect444.report.mdadded+95 -0
@@ -0,0 +1,95 @@
1+# lane-av1sub8rect444: the lossless sub-8 rect leaf's 4:4:4 chroma per-unit walk
2+
3+## Ticket
4+
5+`lanes/av1llintercdf.report.md` "Named, not chased" item 1: at the shared state
6+rng=51429 after the 8x4 leaf's luma, the oracle reads the leaf's chroma as
7+FOUR TX_4X4 units (plane 1 bc=0,1 ctx=11 then plane 2 bc=0,1) while
8+`decode_intra_sub8_leaf`'s `chroma_444 && bw != bh` arm read the chroma plane
9+as ONE `TX_8X4`/`TX_4X8` rect unit per plane (`read_coeffs_rect`, skip ctx
10+fixed at above+left where the oracle derives 11≡4). Wrong unit count AND wrong
11+skip ctx. Template: b3f815c8's per-unit 8x8-leaf walk.
12+
13+## Change (decode.rs, one arm + one tail guard + counter)
14+
15+1. `decode_intra_sub8_leaf`'s rect arm now branches on `lossless(fctx)`: the
16+ walk reads the leaf's 8x4/4x8 chroma plane block as a 1x2/2x1 raster of
17+ `TX_4X4` units per plane, PLANE-MAJOR (`av1_get_tx_size`, blockd.h:1383),
18+ via `read_plane` with `TxbSet::Chroma4`, per-unit `around_mi` (per-unit
19+ `get_txb_ctx`), the plane-block-bigger-than-transform `+3` (libaom's +10
20+ rows, so above+left=1 reads row 4 ↔ libaom ctx 11 — the named 11≡4), and
21+ the lossless tx_type drop (`read_plane`'s own `coding.tx_type = None` for
22+ lossless + DCT_DCT force). Units anchor at the leaf's own (px, py) at
23+ 4:4:4, clip past the frame edge like `read_intra_chroma_lossless`, stamp
24+ each unit's own coefficient context with per-unit `record_mi_chroma`
25+ (`av1_set_contexts` per unit), and assemble the leaf grid at stride bw.
26+ CFL is impossible here (the uv read upstream already takes the
27+ 13-symbol `uv_mode_no_cfl` row for this shape at lossless), so no alpha
28+ rides along — the same `None` the template walks pass.
29+2. Tail guard: the whole-leaf `record_mi_chroma(lmi, bw, bh, ...)` is skipped
30+ when the walk stamped per unit — NESTED inside the `chroma_444` branch.
31+ The first cut wrote `if chroma_444 && !stamped { record } else { <4:2:0
32+ group tail> }`, which let a walked leaf fall into the 4:2:0 group tail:
33+ it spans the GROUP's two mi rows/cols with one composed state and
34+ clobbered the walk's own stamps (measured: `above[3][1]` flipped pos→neg
35+ between the walk's stamp and the next leaf's read — the oracle wants the
36+ per-unit value). The nested form skips BOTH branches for the walk.
37+3. Non-vacuity counter `LLSUB8RECT444_CHROMA_WALK_HITS` +
38+ `llsub8rect444_chroma_walk_hits()` + a `decode_probe` line, per the lane
39+ convention (`CHROMA_SPLIT_TX_HITS` cannot attribute its bumps to this
40+ leaf). 4:2:0 is arithmetically identical: the branch lives inside
41+ `chroma_444`, and the non-lossless rect path and the 4:2:0 group tail are
42+ byte-preserved.
43+
44+## Verification (measured, this tree @ HEAD + this change)
45+
46+- Entropy witness, `/tmp/llkf/t6.obu` vs fresh `aomdec`
47+ (`$HOME/.cache/aom-oracle/build`), `EC_ECDUMP_IN` (value,rng) pairing:
48+ pre-change the first mismatching read is #2326 — inside the named leaf's
49+ chroma at mi(0,2). Post-change #2316–#2488 pair 1:1: the named leaf's FOUR
50+ chroma units read exactly the oracle's symbols
51+ ((30281,51429)/(20612,34312)/(33129,58376)/(30377,36104) against oracle
52+ ctx 11≡4), the sibling INTER leaf mi(1,2) and everything after pairs, and
53+ the walk counter fires (15 walks stream-wide, `decode_probe`).
54+ Fail-before: with the rect read in place the leaf desynced at its own
55+ chroma (t6 frame-1 first differing pixel byte 65, 16032 differing bytes).
56+- The stream still diverges — later and at a DIFFERENT block: first
57+ mismatching read #2489, the U unit (2,8) of the 16x4 INTER strip at
58+ mi(2,8): ours reads `txb_skip` ctx 3 (above[8][1]=0, left[2][1]=0) where
59+ the oracle reads ctx 11 with raw cells `above=[0,] left=[23,]`
60+ (`EC_ECDUMP`, the patched oracle's cell dump) — libaom's left[2][1] holds
61+ level 7 / dc 0 from an earlier row-2 writer, ours holds 0. That cell is
62+ written by the 16x16 intra block (0,4)'s chroma band stamping and the
63+ (1,8) 16x4 strip's own tail — `decode_rect4_16_strip` is llcpred's lane.
64+ With the desync now downstream, our decoder refuses honestly at the strip
65+ (`a Golomb tail longer than this decoder reads`) instead of decoding
66+ garbage, so per-frame byte counts are not claimable this round: **t6
67+ frames 1..5 are NOT exact — no exactness claimed.** Frame 0 is untouched
68+ by construction (both callers, `decode_inter_sub8_split4` and
69+ `decode_inter_sub8_rect2`, are inter-frame paths; the key frame never
70+ reaches this arm) and was byte-exact before.
71+- Non-regression: `cargo test -p ec-av1 --lib a_lossless` → 7 passed, 0
72+ failed (both 4:2:0 lossless libaom gates, the 444 min-partition-64 and
73+ min-partition-8 inter gates, the sb128 pair, the 16x4 pair).
74+- `cargo check -p ec-av1 --all-targets` (target dir
75+ `$HOME/.cache/cargo-target-av1sub8rect444`): 0 warnings, 0 errors.
76+ `rustfmt --check` reports no hunks inside the edited ranges (the crate's
77+ pre-existing drift is untouched).
78+- Fixtures are scratch in /tmp/llkf (t6.obu, regenerable per
79+ av1llkf.report.md's recipe) and /tmp/llsub8rect444; nothing committed
80+ from them.
81+
82+## Named, not chased (spoken)
83+
84+1. The t6 next-site: the 16x4 INTER strip's chroma coefficient-context
85+ stamping at 4:4:4 lossless. Measured above (ctx 3 vs 11 on U (2,8);
86+ oracle cells `above=[0] left=[23]`). The row-2 U band state our tree
87+ drops is written by the 16x16-intra/(0,4) stamping and consumed one
88+ superblock later; `decode_rect4_16_strip` is llcpred's lane — per the
89+ ticket this lane stops at the boundary.
90+ deferred(the 16x4 strip's per-unit chroma context stamping at 4:4:4
91+ lossless; unblock: llcpred's decode_rect4_16_strip lane, t6.obu as the
92+ ready-made fixture, first divergent read #2489 = U unit (2,8)).
93+2. Instrument parity: `read_coeffs_rect` still has no `EC_ECDUMP_IN` rung
94+ (av1llintercdf item 2) — this lane's walk bypasses the rect reader
95+ entirely, so the rung was not needed here.