forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-hgkf': key-frame frame-edge partition bit was parsed and discarded (forced SPLIT) at 64/32/16; the ReelB head key frame decodes bit-exact at 10-bit

Browse files at this commit

a13d4a27d022514729793e3ac9532259cf1aaacbAhmet Kaan GümüşParent: 60135675b4ff4a
Merge resolution (main e6b8bf8):
- 64/32-level key-frame edge readers: the lane's arms (identical fix to the
  unmerged lane-golomb one already on main, plus the EDGE_PART_HITS counter).
- 16-level: main's (lane-oddh) body kept -- it decodes the strip and records
  above_mode/left_mode -- with the lane's `bump_edge_part` added.
- Remaining conflicts were comment-only; main's wording kept.
Also carries the lane's r2: a skipped intra block predicts per transform
unit, not per block (SKIP_SPLIT_TX_HITS).
crates/ec-av1/src/decode.rsmodified+299 -90
@@ -1374,6 +1374,24 @@ pub(crate) fn palette_split_tx_hits() -> usize {
1374 PALETTE_SPLIT_TX_HITS.with(|c| c.get())1374 PALETTE_SPLIT_TX_HITS.with(|c| c.get())
1375 }1375 }
1376 1376
1377+// lane-hgkf r2: SKIPPED intra blocks whose `tx_depth` split the luma transform
1378+// and which are therefore predicted one transform unit at a time (a skipped
1379+// block codes no coefficients, so nothing else in the stream witnesses this
1380+// path -- only the pixels do).
1381+thread_local! {
1382+ static SKIP_SPLIT_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1383+}
1384+
1385+/// Current value of [`SKIP_SPLIT_TX_HITS`] (blocks, not units).
1386+pub fn skip_split_tx_hits() -> usize {
1387+ SKIP_SPLIT_TX_HITS.with(|c| c.get())
1388+}
1389+
1390+/// Zeroes [`SKIP_SPLIT_TX_HITS`] before a gate's own decode attempt.
1391+pub fn reset_skip_split_tx_hits() {
1392+ SKIP_SPLIT_TX_HITS.with(|c| c.set(0));
1393+}
1394+
1377 // lane-intrainter r1: intra blocks inside an INTER frame whose `tx_depth`1395 // lane-intrainter r1: intra blocks inside an INTER frame whose `tx_depth`
1378 // symbol split their luma transform, bucketed by block side (8, 16, 32, 64) --1396 // symbol split their luma transform, bucketed by block side (8, 16, 32, 64) --
1379 // the gate's proof that the lifted path actually ran, per size.1397 // the gate's proof that the lifted path actually ran, per size.
@@ -1955,6 +1973,33 @@ thread_local! {
1955 }1973 }
1956 1974
1957 /// Current value of [`SB_RECT_HITS`].1975 /// Current value of [`SB_RECT_HITS`].
1976+// lane-hgkf r1: the frame-edge partition bit, one level each. Slot 0 = a
1977+// 64-level gathered edge bit read as HORZ/VERT, 1 = the same bit read as
1978+// SPLIT, 2/3 = the 32-level pair. A gate asserting slot 0 or 2 proves the
1979+// non-SPLIT edge arm actually decoded (before this round the bit was read and
1980+// thrown away, so that arm was unreachable).
1981+thread_local! {
1982+ static EDGE_PART_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) };
1983+}
1984+
1985+/// Current value of [`EDGE_PART_HITS`].
1986+pub(crate) fn edge_part_hits() -> [usize; 4] {
1987+ EDGE_PART_HITS.with(|c| c.get())
1988+}
1989+
1990+/// Reset [`EDGE_PART_HITS`] (a gate counts one stream at a time).
1991+pub(crate) fn reset_edge_part_hits() {
1992+ EDGE_PART_HITS.with(|c| c.set([0; 4]));
1993+}
1994+
1995+fn bump_edge_part(slot: usize) {
1996+ EDGE_PART_HITS.with(|c| {
1997+ let mut h = c.get();
1998+ h[slot] += 1;
1999+ c.set(h);
2000+ });
2001+}
2002+
1958 pub(crate) fn sb_rect_hits() -> usize {2003 pub(crate) fn sb_rect_hits() -> usize {
1959 SB_RECT_HITS.with(|c| c.get())2004 SB_RECT_HITS.with(|c| c.get())
1960 }2005 }
@@ -5639,6 +5684,16 @@ fn decode_rect_split(
5639 let tu_mi = (mi_r + tu_row * (tx_h / MI), mi_c + tu_col * (tx_w / MI));5684 let tu_mi = (mi_r + tu_row * (tx_h / MI), mi_c + tu_col * (tx_w / MI));
5640 let (tu_px, tu_py) = (px + tu_col * tx_w, py + tu_row * tx_h);5685 let (tu_px, tu_py) = (px + tu_col * tx_w, py + tu_row * tx_h);
5641 let (col_off, row_off) = (tu_col * tx_w, tu_row * tx_h);5686 let (col_off, row_off) = (tu_col * tx_w, tu_row * tx_h);
5687+ // lane-hgkf r1 (ported from lane-golomb 791d87a, unmerged):
5688+ // libaom clips `av1_foreach_transformed_block_in_plane` to
5689+ // `max_blocks_wide/high` (`mb_to_right_edge`/`mb_to_bottom_edge`,
5690+ // i.e. `mi_cols * 4` / `mi_rows * 4`): a transform unit whose
5691+ // TOP-LEFT sample falls outside the frame is never coded. We read
5692+ // coefficients for those phantom units and desynced the stream at
5693+ // the very next symbol.
5694+ if tu_px >= y.true_width || tu_py >= y.true_height {
5695+ continue;
5696+ }
5642 // `has_top_right`/`has_bottom_left` (libaom `reconintra.c`) for a5697 // `has_top_right`/`has_bottom_left` (libaom `reconintra.c`) for a
5643 // transform unit INSIDE a block, which is a different rule from5698 // transform unit INSIDE a block, which is a different rule from
5644 // the standalone-block table [`Reach::of`] applies -- and the5699 // the standalone-block table [`Reach::of`] applies -- and the
@@ -8088,6 +8143,26 @@ fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 {
8088 /// [`crate::intra::predict`] instead of hand-rolling `DC_PRED` alone.8143 /// [`crate::intra::predict`] instead of hand-rolling `DC_PRED` alone.
8089 /// lane-tiny r4: raw padded-plane dump for filter-stage bisection, written8144 /// lane-tiny r4: raw padded-plane dump for filter-stage bisection, written
8090 /// only when `var` names a path. Same byte shape as `EC_AV1_PREFILT_DUMP`.8145 /// only when `var` names a path. Same byte shape as `EC_AV1_PREFILT_DUMP`.
8146+/// lane-hgkf r2: 16-bit cropped stage dump, the high-bitdepth twin of
8147+/// [`dump_stage`] (whose `as u8` truncation hides |delta| <= 2 defects) --
8148+/// matches aomdec's own `ec_dump16` rung byte for byte (crop dims, u16 LE).
8149+fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) {
8150+ use std::io::Write;
8151+ if let Ok(path) = std::env::var(var)
8152+ && let Ok(mut f) = std::fs::File::create(format!("{path}.f0"))
8153+ {
8154+ for (p, w, h) in [(y, fw, fh), (u, fw.div_ceil(2), fh.div_ceil(2)), (v, fw.div_ceil(2), fh.div_ceil(2))] {
8155+ for row in 0..h {
8156+ let mut bytes = Vec::with_capacity(w * 2);
8157+ for &s in &p.data[row * p.width..][..w] {
8158+ bytes.extend_from_slice(&s.to_le_bytes());
8159+ }
8160+ let _ = f.write_all(&bytes);
8161+ }
8162+ }
8163+ }
8164+}
8165+
8091 fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) {8166 fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) {
8092 use std::io::Write;8167 use std::io::Write;
8093 if let Ok(path) = std::env::var(var)8168 if let Ok(path) = std::env::var(var)
@@ -8233,6 +8308,7 @@ impl PlaneBuf {
8233 /// via [`Self::edges_rect`] and [`crate::intra::predict`]'s own8308 /// via [`Self::edges_rect`] and [`crate::intra::predict`]'s own
8234 /// already-rect-capable `(bw, bh)` pair.8309 /// already-rect-capable `(bw, bh)` pair.
8235 #[allow(clippy::too_many_arguments)]8310 #[allow(clippy::too_many_arguments)]
8311+ #[track_caller]
8236 fn reconstruct_rect(8312 fn reconstruct_rect(
8237 &mut self,8313 &mut self,
8238 x: usize,8314 x: usize,
@@ -8291,6 +8367,16 @@ impl PlaneBuf {
8291 }8367 }
8292 prediction8368 prediction
8293 };8369 };
8370+ // lane-hgkf r2: per-TU prediction trace, the twin of aomdec's
8371+ // EC_PRED/EC_PREDND rungs (x/y are this plane's pixel origin).
8372+ if std::env::var_os("EC_PRED").is_some() {
8373+ let sum: i64 = prediction.iter().map(|&v| i64::from(v)).sum();
8374+ let row0: Vec<u16> = prediction[..bw.min(8)].to_vec();
8375+ let col0: Vec<u16> = (0..bh.min(8)).map(|r| prediction[r * bw]).collect();
8376+ eprintln!(
8377+ "@{} OUR_PRED x={x} y={y} bw={bw} bh={bh} mode={mode} ad={angle_delta} sum={sum} row0={row0:?} col0={col0:?}", std::panic::Location::caller()
8378+ );
8379+ }
8294 for row in 0..bh {8380 for row in 0..bh {
8295 for col in 0..bw {8381 for col in 0..bw {
8296 let idx = row * bw + col;8382 let idx = row * bw + col;
@@ -8310,6 +8396,7 @@ impl PlaneBuf {
8310 /// nudges the prediction by [`cfl_scaled`]'s per-sample amount before the8396 /// nudges the prediction by [`cfl_scaled`]'s per-sample amount before the
8311 /// residual is added — `av1_cfl_predict_block`'s own clip-then-add-residual8397 /// residual is added — `av1_cfl_predict_block`'s own clip-then-add-residual
8312 /// order (cfl.c).8398 /// order (cfl.c).
8399+ #[track_caller]
8313 fn reconstruct(8400 fn reconstruct(
8314 &mut self,8401 &mut self,
8315 x: usize,8402 x: usize,
@@ -8373,6 +8460,16 @@ impl PlaneBuf {
8373 }8460 }
8374 prediction8461 prediction
8375 };8462 };
8463+ // lane-hgkf r2: per-TU prediction trace, the twin of aomdec's
8464+ // EC_PRED/EC_PREDND rungs (x/y are this plane's pixel origin).
8465+ if std::env::var_os("EC_PRED").is_some() {
8466+ let sum: i64 = prediction.iter().map(|&v| i64::from(v)).sum();
8467+ let row0: Vec<u16> = prediction[..side.min(8)].to_vec();
8468+ let col0: Vec<u16> = (0..side.min(8)).map(|r| prediction[r * side]).collect();
8469+ eprintln!(
8470+ "@{} OUR_PRED x={x} y={y} side={side} side={side} mode={mode} ad={angle_delta} sum={sum} row0={row0:?} col0={col0:?}", std::panic::Location::caller()
8471+ );
8472+ }
8376 for row in 0..side {8473 for row in 0..side {
8377 for col in 0..side {8474 for col in 0..side {
8378 let idx = row * side + col;8475 let idx = row * side + col;
@@ -8704,18 +8801,69 @@ fn decode_block(
8704 if skip {8801 if skip {
8705 // A skipped block codes no residual syntax at all (spec 5.11.34):8802 // A skipped block codes no residual syntax at all (spec 5.11.34):
8706 // straight prediction, on every plane.8803 // straight prediction, on every plane.
8707- y.reconstruct(8804+ //
8708- px,8805+ // lane-hgkf r2: an intra block's `tx_depth` is read whether or not it
8709- py,8806+ // is skipped (only an INTER skip forces the largest transform), and
8710- side,8807+ // spec 7.11.2 / libaom `predict_and_reconstruct_intra_block` predicts
8711- mode,8808+ // ONE TRANSFORM UNIT AT A TIME -- each unit's edges are the units
8712- angle_delta_y,8809+ // already written left/above of it inside this same block. Predicting
8713- reach,8810+ // the whole `side`x`side` at once gives a different (uniformly off by
8714- &vec![0i32; side * side],8811+ // ~1) answer, which is exactly the residue this lane was chasing.
8715- None,8812+ // The palette/intrabc override path keeps the single-call shape (its
8716- filter_intra,8813+ // per-TU windowing is the non-skip loop's own `palette_y_buf` slice,
8717- smooth_neighbor,8814+ // untested for skip and unreachable in these streams).
8718- );8815+ let split_tx_skip =
8816+ tx_select && logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none();
8817+ if split_tx_skip {
8818+ SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
8819+ let n_axis = side / logical_tx;
8820+ for tu_row in 0..n_axis {
8821+ for tu_col in 0..n_axis {
8822+ let tu_px = px + tu_col * logical_tx;
8823+ let tu_py = py + tu_row * logical_tx;
8824+ if tu_px >= y.true_width || tu_py >= y.true_height {
8825+ continue;
8826+ }
8827+ let tu_reach = tu_reach(
8828+ side,
8829+ side,
8830+ tu_col * logical_tx,
8831+ tu_row * logical_tx,
8832+ logical_tx,
8833+ reach,
8834+ px,
8835+ py,
8836+ y.width,
8837+ y.height,
8838+ );
8839+ y.reconstruct(
8840+ tu_px,
8841+ tu_py,
8842+ logical_tx,
8843+ mode,
8844+ angle_delta_y,
8845+ tu_reach,
8846+ &vec![0i32; logical_tx * logical_tx],
8847+ None,
8848+ filter_intra,
8849+ smooth_neighbor,
8850+ );
8851+ }
8852+ }
8853+ } else {
8854+ y.reconstruct(
8855+ px,
8856+ py,
8857+ side,
8858+ mode,
8859+ angle_delta_y,
8860+ reach,
8861+ &vec![0i32; side * side],
8862+ None,
8863+ filter_intra,
8864+ smooth_neighbor,
8865+ );
8866+ }
8719 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));8867 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
8720 if let Some((ub, _)) = &palette_uv_bufs {8868 if let Some((ub, _)) = &palette_uv_bufs {
8721 set_palette_pred(ub.clone());8869 set_palette_pred(ub.clone());
@@ -8852,6 +9000,12 @@ fn decode_block(
8852 );9000 );
8853 let tu_px = px + tu_col * logical_tx;9001 let tu_px = px + tu_col * logical_tx;
8854 let tu_py = py + tu_row * logical_tx;9002 let tu_py = py + tu_row * logical_tx;
9003+ // Same libaom clip as `decode_rect_split`'s loop above; a
9004+ // square block only hangs off the frame when the frame's mi
9005+ // dimensions are odd at the block's own level.
9006+ if tu_px >= y.true_width || tu_py >= y.true_height {
9007+ continue;
9008+ }
8855 let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0];9009 let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0];
8856 // A transform unit inside a block is NOT a block at that9010 // A transform unit inside a block is NOT a block at that
8857 // position (lane-palette2 r12): `Reach::of` granted the9011 // position (lane-palette2 r12): `Reach::of` granted the
@@ -9127,18 +9281,59 @@ fn decode_leaf8(
9127 let (cpx, cpy) = (px / 2, py / 2);9281 let (cpx, cpy) = (px / 2, py / 2);
9128 let (luma_grid, u_grid, v_grid);9282 let (luma_grid, u_grid, v_grid);
9129 if skip {9283 if skip {
9130- y.reconstruct(9284+ // lane-hgkf r2 (same shape as `decode_block`'s own skip branch): an
9131- px,9285+ // 8x8 leaf whose `tx_depth` resolved to TX_4X4 predicts FOUR 4x4
9132- py,9286+ // transform units, each off the units already written left/above of
9133- 8,9287+ // it inside this same leaf -- an intra block's transform size is read
9134- mode,9288+ // whether or not it is skipped, and spec 7.11.2 predicts per unit.
9135- angle_delta_y,9289+ if resolved == 4 {
9136- reach,9290+ SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
9137- &vec![0i32; 64],9291+ for tu_row in 0..2 {
9138- None,9292+ for tu_col in 0..2 {
9139- filter_intra,9293+ let (tu_px, tu_py) = (px + tu_col * 4, py + tu_row * 4);
9140- smooth_neighbor,9294+ if tu_px >= y.true_width || tu_py >= y.true_height {
9141- );9295+ continue;
9296+ }
9297+ let tu_reach = tu_reach(
9298+ 8,
9299+ 8,
9300+ tu_col * 4,
9301+ tu_row * 4,
9302+ 4,
9303+ reach,
9304+ px,
9305+ py,
9306+ y.width,
9307+ y.height,
9308+ );
9309+ y.reconstruct(
9310+ tu_px,
9311+ tu_py,
9312+ 4,
9313+ mode,
9314+ angle_delta_y,
9315+ tu_reach,
9316+ &vec![0i32; 16],
9317+ None,
9318+ filter_intra,
9319+ smooth_neighbor,
9320+ );
9321+ }
9322+ }
9323+ } else {
9324+ y.reconstruct(
9325+ px,
9326+ py,
9327+ 8,
9328+ mode,
9329+ angle_delta_y,
9330+ reach,
9331+ &vec![0i32; 64],
9332+ None,
9333+ filter_intra,
9334+ smooth_neighbor,
9335+ );
9336+ }
9142 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));9337 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));
9143 u.reconstruct(9338 u.reconstruct(
9144 cpx,9339 cpx,
@@ -12049,28 +12244,23 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
12049 }12244 }
12050 p12245 p
12051 } else {12246 } else {
12052- // lane-golomb r1 (class `parsed-then-discarded`): the gathered12247+ // lane-hgkf r1 (class `parsed-then-discarded`, same finding as
12053- // bit is the answer, not a formality -- libaom's12248+ // the unmerged lane-golomb r1): the gathered bit IS the
12054- // `ec_read_partition_impl` returns `PARTITION_HORZ` (resp.12249+ // partition -- libaom `ec_read_partition_impl` returns
12055- // `PARTITION_VERT`) when it reads 0, and only `PARTITION_SPLIT`12250+ // PARTITION_HORZ (resp. VERT) for 0 and only SPLIT for 1.
12056- // when it reads 1. Forcing SPLIT here desynced the last12251+ // Forcing SPLIT desynced the last superblock row of every
12057- // superblock row of every frame whose height is not a multiple12252+ // frame whose height is not a multiple of 64: the ReelB key frames (3840x1608) diverge at mi_row=400 mi_col=0,
12058- // of 64 -- the ReelB head (3840x1608) diverges at12253+ // the first block of that row.
12059- // mi_row=400 mi_col=0, the first block of that row.
12060 match (has_cols, has_rows) {12254 match (has_cols, has_rows) {
12061 (true, false) => {12255 (true, false) => {
12062- if dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)) == 1 {12256+ let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE));
12063- PARTITION_SPLIT12257+ bump_edge_part(b.min(1) as usize);
12064- } else {12258+ if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }
12065- PARTITION_HORZ
12066- }
12067 }12259 }
12068 (false, true) => {12260 (false, true) => {
12069- if dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)) == 1 {12261+ let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE));
12070- PARTITION_SPLIT12262+ bump_edge_part(b.min(1) as usize);
12071- } else {12263+ if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }
12072- PARTITION_VERT
12073- }
12074 }12264 }
12075 _ => PARTITION_SPLIT,12265 _ => PARTITION_SPLIT,
12076 }12266 }
@@ -12128,26 +12318,25 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
12128 }12318 }
12129 p12319 p
12130 } else {12320 } else {
12321+ // lane-hgkf r1: the 32-level frame-edge bit is the
12322+ // partition too (same libaom reader as the
12323+ // superblock level above).
12131 match (has_cols32, has_rows32) {12324 match (has_cols32, has_rows32) {
12132 (true, false) => {12325 (true, false) => {
12133- // lane-golomb r1 (class `parsed-then-discarded`): the gathered12326+ let b = dec.symbol_fixed(&gather(
12134- // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT12327+ &cdfs.partition_w32[ctx32],
12135- // (libaom `ec_read_partition_impl`).12328+ VERT_ALIKE,
12136- if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE)) == 1 {12329+ ));
12137- PARTITION_SPLIT12330+ bump_edge_part(2 + b.min(1) as usize);
12138- } else {12331+ if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }
12139- PARTITION_HORZ
12140- }
12141 }12332 }
12142 (false, true) => {12333 (false, true) => {
12143- // lane-golomb r1 (class `parsed-then-discarded`): the gathered12334+ let b = dec.symbol_fixed(&gather(
12144- // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT12335+ &cdfs.partition_w32[ctx32],
12145- // (libaom `ec_read_partition_impl`).12336+ HORZ_ALIKE,
12146- if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE)) == 1 {12337+ ));
12147- PARTITION_SPLIT12338+ bump_edge_part(2 + b.min(1) as usize);
12148- } else {12339+ if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }
12149- PARTITION_VERT
12150- }
12151 }12340 }
12152 _ => PARTITION_SPLIT,12341 _ => PARTITION_SPLIT,
12153 }12342 }
@@ -12608,6 +12797,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
12608 HORZ_ALIKE,12797 HORZ_ALIKE,
12609 ))12798 ))
12610 };12799 };
12800+ // lane-hgkf r1: slots 2/3 of
12801+ // [`EDGE_PART_HITS`], the gate's proof the
12802+ // non-SPLIT edge arm actually decoded.
12803+ bump_edge_part(if edge_split == 1 { 3 } else { 2 });
12611 if edge_split == 0 {12804 if edge_split == 0 {
12612 // lane-oddh r1: the strip IS decodable12805 // lane-oddh r1: the strip IS decodable
12613 // -- libaom's `decode_partition` codes12806 // -- libaom's `decode_partition` codes
@@ -12774,22 +12967,27 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
12774 tx_select,12967 tx_select,
12775 reduced_tx_set,12968 reduced_tx_set,
12776 )?;12969 )?;
12777- decode_block_rect(12970+ // lane-hgkf r1: at the frame edge only the first half of the strip is
12778- &mut dec,12971+ // coded (libaom `decode_partition` guards the second half with the same
12779- &mut cdfs,12972+ // test that made this partition non-square).
12780- &mut neighbours,12973+ if has_rows32 {
12781- (at32.0 + 1, at32.1),12974+ decode_block_rect(
12782- 32,12975+ &mut dec,
12783- 16,12976+ &mut cdfs,
12784- &mut y,12977+ &mut neighbours,
12785- &mut u,12978+ (at32.0 + 1, at32.1),
12786- &mut v,12979+ 32,
12787- enable_filter_intra,12980+ 16,
12788- allow_screen_content_tools,12981+ &mut y,
12789- base_q_idx,12982+ &mut u,
12790- tx_select,12983+ &mut v,
12791- reduced_tx_set,12984+ enable_filter_intra,
12792- )?;12985+ allow_screen_content_tools,
12986+ base_q_idx,
12987+ tx_select,
12988+ reduced_tx_set,
12989+ )?;
12990+ }
12793 }12991 }
12794 PARTITION_VERT => {12992 PARTITION_VERT => {
12795 // lane-intradisp r1: mirror of PARTITION_HORZ12993 // lane-intradisp r1: mirror of PARTITION_HORZ
@@ -12810,22 +13008,27 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
12810 tx_select,13008 tx_select,
12811 reduced_tx_set,13009 reduced_tx_set,
12812 )?;13010 )?;
12813- decode_block_rect(13011+ // lane-hgkf r1: at the frame edge only the first half of the strip is
12814- &mut dec,13012+ // coded (libaom `decode_partition` guards the second half with the same
12815- &mut cdfs,13013+ // test that made this partition non-square).
12816- &mut neighbours,13014+ if has_cols32 {
12817- (at32.0, at32.1 + 1),13015+ decode_block_rect(
12818- 16,13016+ &mut dec,
12819- 32,13017+ &mut cdfs,
12820- &mut y,13018+ &mut neighbours,
12821- &mut u,13019+ (at32.0, at32.1 + 1),
12822- &mut v,13020+ 16,
12823- enable_filter_intra,13021+ 32,
12824- allow_screen_content_tools,13022+ &mut y,
12825- base_q_idx,13023+ &mut u,
12826- tx_select,13024+ &mut v,
12827- reduced_tx_set,13025+ enable_filter_intra,
12828- )?;13026+ allow_screen_content_tools,
13027+ base_q_idx,
13028+ tx_select,
13029+ reduced_tx_set,
13030+ )?;
13031+ }
12829 }13032 }
12830 PARTITION_HORZ_A => {13033 PARTITION_HORZ_A => {
12831 // lane-part32 r1: two 16x16 squares on top +13034 // lane-part32 r1: two 16x16 squares on top +
@@ -13410,6 +13613,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
13410 // that isolate whether a decode-order frame's mismatch already exists13613 // that isolate whether a decode-order frame's mismatch already exists
13411 // in reconstruction (this dump) vs is introduced by the loop filter13614 // in reconstruction (this dump) vs is introduced by the loop filter
13412 // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump).13615 // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump).
13616+ dump_stage16("EC_AV1_PREFILT_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
13413 if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") {13617 if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") {
13414 use std::io::Write;13618 use std::io::Write;
13415 let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);13619 let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
@@ -13453,8 +13657,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
13453 // EC_AV1_POSTDEBLOCK_DUMP (decodeframe.c ~5404) -- with the pre-filter13657 // EC_AV1_POSTDEBLOCK_DUMP (decodeframe.c ~5404) -- with the pre-filter
13454 // dump above these bisect WHICH filter stage introduced a mismatch.13658 // dump above these bisect WHICH filter stage introduced a mismatch.
13455 dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v);13659 dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v);
13660+ dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
13456 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);13661 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);
13457 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);13662 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);
13663+ dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
13458 apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid);13664 apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid);
13459 13665
13460 let (fw, fh) = (frame_width as usize, frame_height as usize);13666 let (fw, fh) = (frame_width as usize, frame_height as usize);
@@ -21193,6 +21399,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
21193 // that isolate whether a decode-order frame's mismatch already exists21399 // that isolate whether a decode-order frame's mismatch already exists
21194 // in reconstruction (this dump) vs is introduced by the loop filter21400 // in reconstruction (this dump) vs is introduced by the loop filter
21195 // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump).21401 // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump).
21402+ dump_stage16("EC_AV1_PREFILT_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
21196 if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") {21403 if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") {
21197 use std::io::Write;21404 use std::io::Write;
21198 let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);21405 let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
@@ -21219,8 +21426,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
21219 // EC_AV1_POSTDEBLOCK_DUMP (decodeframe.c ~5404) -- with the pre-filter21426 // EC_AV1_POSTDEBLOCK_DUMP (decodeframe.c ~5404) -- with the pre-filter
21220 // dump above these bisect WHICH filter stage introduced a mismatch.21427 // dump above these bisect WHICH filter stage introduced a mismatch.
21221 dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v);21428 dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v);
21429+ dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
21222 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);21430 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);
21223 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);21431 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);
21432+ dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
21224 apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid);21433 apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid);
21225 21434
21226 let motion_field = build_motion_field(21435 let motion_field = build_motion_field(
crates/ec-av1/src/stream.rsmodified+167 -0
@@ -21482,4 +21482,171 @@ mod tests {
21482 yuv420p10le)"21482 yuv420p10le)"
21483 );21483 );
21484 }21484 }
21485+
21486+ /// lane-hgkf r1: a frame whose height (or width) is not a multiple of the
21487+ /// block size makes the last superblock row (column) read a GATHERED
21488+ /// partition bit instead of a full alphabet symbol -- and libaom's
21489+ /// `ec_read_partition_impl` answers that bit with `PARTITION_HORZ`
21490+ /// (resp. `VERT`) when it is 0, only `SPLIT` when it is 1. All three
21491+ /// key-frame edge readers (64-, 32- and 16-level) read the bit and threw
21492+ /// it away, forcing SPLIT; every such frame desynced at the first block
21493+ /// of its partial row. 192x136 / 136x192 is the smallest shape that hits
21494+ /// all three levels at once (136 = 2*64 + 8, so mi_rows = 34: the 64-,
21495+ /// 32- and 16-level halves all fall outside), and it is the shape of a
21496+ /// real 3840x1608 10-bit film key frame (1608 mod 64 == 8) that decoded
21497+ /// 51768 samples wrong before this round.
21498+ ///
21499+ /// The counter is sampled per attempt and read only on an attempt that
21500+ /// decoded AND is pixel-compared; slot 0/2 (the bit taken as HORZ/VERT)
21501+ /// must be nonzero or the gate proves nothing -- before this round that
21502+ /// arm was unreachable by construction.
21503+ #[test]
21504+ fn a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact() {
21505+ const NAME: &str =
21506+ "a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact";
21507+ let _gate_lock = lock_gate_counters();
21508+ if !have_ffmpeg() {
21509+ eprintln!("SKIP {NAME}: no ffmpeg");
21510+ return;
21511+ }
21512+ if !have_aomenc() {
21513+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
21514+ return;
21515+ }
21516+ let mut compared = 0usize;
21517+ let mut edge_horz_total = 0usize;
21518+ let mut edge_sub_total = 0usize;
21519+ // The last two shapes are the ledger-measured 64-level pair: on a
21520+ // flat band (192x80 / 80x192) real aomenc answers the bottom-edge
21521+ // superblock with the 64-level HORZ/VERT, which the 136 shapes above
21522+ // never produce (their SBs always split down to the 32/16 levels).
21523+ for (width, height, flat) in [
21524+ (192usize, 136usize, false),
21525+ (136usize, 192usize, false),
21526+ (192usize, 80usize, true),
21527+ (80usize, 192usize, true),
21528+ ] {
21529+ for depth in [8usize, 10] {
21530+ let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" };
21531+ let y4m = Command::new("ffmpeg")
21532+ .args([
21533+ "-v", "error", "-f", "lavfi", "-i",
21534+ &if flat {
21535+ format!("color=c=gray:size={width}x{height}")
21536+ } else {
21537+ format!("mandelbrot=size={width}x{height}:start_x=-0.6")
21538+ },
21539+ "-pix_fmt", pix, "-strict", "-1", "-t", "1", "-vframes", "1",
21540+ "-f", "yuv4mpegpipe", "-",
21541+ ])
21542+ .stdin(Stdio::null())
21543+ .stdout(Stdio::piped())
21544+ .stderr(Stdio::piped())
21545+ .output()
21546+ .expect("ffmpeg failed to run");
21547+ assert!(
21548+ y4m.status.success(),
21549+ "{NAME}: ffmpeg fixture ({width}x{height}, depth={depth}): {}",
21550+ String::from_utf8_lossy(&y4m.stderr)
21551+ );
21552+ let encode = || {
21553+ let mut child = Command::new(aomenc_path())
21554+ .args([
21555+ "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32",
21556+ "--cpu-used=3", "--threads=1", "--row-mt=0", "--sb-size=64",
21557+ "--kf-max-dist=0", "--enable-rect-partitions=1",
21558+ "--enable-ab-partitions=0", "--enable-1to4-partitions=0",
21559+ "--enable-tx-size-search=0", "--reduced-tx-type-set=1",
21560+ "--min-partition-size=8", "--max-partition-size=64",
21561+ &format!("--input-bit-depth={depth}"),
21562+ &format!("--bit-depth={depth}"),
21563+ "--obu", "-o", "-", "-",
21564+ ])
21565+ .stdin(Stdio::piped())
21566+ .stdout(Stdio::piped())
21567+ .stderr(Stdio::piped())
21568+ .spawn()
21569+ .expect("aomenc failed to start");
21570+ child
21571+ .stdin
21572+ .take()
21573+ .expect("aomenc stdin")
21574+ .write_all(&y4m.stdout)
21575+ .expect("writing y4m to aomenc");
21576+ let out = child.wait_with_output().expect("aomenc failed to run");
21577+ assert!(
21578+ out.status.success(),
21579+ "aomenc refused the fixture ({width}x{height}, depth={depth}): {}",
21580+ String::from_utf8_lossy(&out.stderr)
21581+ );
21582+ out.stdout
21583+ };
21584+ let stream = encode();
21585+ assert_eq!(
21586+ stream,
21587+ encode(),
21588+ "{NAME}: aomenc output is not reproducible ({width}x{height}, depth={depth})"
21589+ );
21590+ crate::decode::reset_edge_part_hits();
21591+ let frames = match decode_stream(&stream) {
21592+ Ok(frames) => frames,
21593+ Err(e) => {
21594+ let msg = e.to_string();
21595+ assert!(
21596+ msg.contains("unsupported"),
21597+ "{NAME}: decode failed ({width}x{height}, depth={depth}): {msg}"
21598+ );
21599+ eprintln!(
21600+ "{NAME}: {width}x{height} depth={depth} arm refused (not compared): {msg}"
21601+ );
21602+ continue;
21603+ }
21604+ };
21605+ let hits = crate::decode::edge_part_hits();
21606+ let ffmpeg_frames = if depth == 10 {
21607+ ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len())
21608+ } else {
21609+ ffmpeg_decode_sequence(&stream, width, height, frames.len())
21610+ };
21611+ assert_eq!(ffmpeg_frames.len(), frames.len(), "{NAME}: ffmpeg frame count");
21612+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
21613+ assert_eq!(
21614+ got.y, want.y,
21615+ "{NAME} frame {i} luma vs ffmpeg ({width}x{height}, depth={depth}, \
21616+ edge bits horz/split 64-level {}/{}, sub-level {}/{})",
21617+ hits[0], hits[1], hits[2], hits[3]
21618+ );
21619+ assert_eq!(
21620+ got.u, want.u,
21621+ "{NAME} frame {i} U vs ffmpeg ({width}x{height}, depth={depth})"
21622+ );
21623+ assert_eq!(
21624+ got.v, want.v,
21625+ "{NAME} frame {i} V vs ffmpeg ({width}x{height}, depth={depth})"
21626+ );
21627+ }
21628+ compared += 1;
21629+ edge_horz_total += hits[0];
21630+ edge_sub_total += hits[2];
21631+ eprintln!(
21632+ "{NAME}: pixel-exact {width}x{height} at {depth}-bit, edge bits \
21633+ 64-level horz/vert={} split={} sub-level horz/vert={} split={}",
21634+ hits[0], hits[1], hits[2], hits[3]
21635+ );
21636+ }
21637+ }
21638+ assert!(
21639+ compared > 0,
21640+ "{NAME}: every arm refused -- the gate compared no pixels at all"
21641+ );
21642+ assert!(
21643+ edge_horz_total > 0,
21644+ "{NAME}: no 64-level frame-edge bit was ever answered HORZ/VERT -- the arm this \
21645+ round fixed never fired"
21646+ );
21647+ assert!(
21648+ edge_sub_total > 0,
21649+ "{NAME}: no 32/16-level frame-edge bit was ever answered HORZ/VERT"
21650+ );
21651+ }
21485 }21652 }
lanes/hgkf-r1.report.mdadded+86 -0
@@ -0,0 +1,86 @@
1+# lane-hgkf r1 — the frame-edge partition bit, all three levels
2+
3+Branch `lane-hgkf` off main `0df090a`. Two 3840x1608 10-bit key frames that
4+decoded without refusal but pixel-wrong (scratch: `.../scratchpad/census2/kf_0.obu`,
5+`kf_4500.obu`).
6+
7+## Root cause (class `parsed-then-discarded`)
8+
9+A superblock/block whose second half falls outside the frame does not carry a
10+full partition alphabet symbol; it carries one GATHERED bit. libaom
11+`ec_read_partition_impl` answers that bit with `PARTITION_HORZ` (resp. `VERT`)
12+when it is **0**, and only `PARTITION_SPLIT` when it is 1. All three key-frame
13+edge readers read the bit and threw it away, forcing SPLIT:
14+
15+* `crates/ec-av1/src/decode.rs:11373` — 64-level (superblock)
16+* `crates/ec-av1/src/decode.rs:11446` — 32-level
17+* `crates/ec-av1/src/decode.rs:11938` — 16-level (this one had no HORZ/VERT arm
18+ at all; it now decodes the single in-frame 16x8 / 8x16 strip through
19+ `decode_leaf_rect`)
20+
21+The HORZ/VERT arms also decode ONLY the in-frame half of the strip (libaom
22+`decode_partition` guards the second half with the same has_rows/has_cols test
23+that made the partition non-square) — `decode.rs:12480`, `12525`, `12038`,
24+`12086`.
25+
26+Every frame whose height or width is not a multiple of 64 desynced at the first
27+block of its partial row. 1608 mod 64 == 8, so both film key frames lost their
28+whole bottom 8-pixel band and everything the desync dragged after it.
29+
30+New counter `EDGE_PART_HITS` (`decode.rs`, `edge_part_hits()` /
31+`reset_edge_part_hits()`): slot 0/1 = 64-level bit taken as HORZ-VERT / SPLIT,
32+2/3 = the 32+16-level pair.
33+
34+Also ported (unmerged lane-golomb 791d87a) the libaom TU-origin clip: a
35+transform unit whose top-left sample lies outside `mi_cols*4 x mi_rows*4` is
36+never coded (`decode_rect_split` and `decode_block`'s multi-TU loop). Measured
37+INERT on both frames here (byte-identical output before/after); kept because it
38+is the libaom rule.
39+
40+## Evidence
41+
42+EVIDENCE: /home/user/.cache/hgkf-work/{ours,p,q,r}_kf_0.f0.yuv vs ref_kf_0.yuv | `dump_yuv kf_0.obu` vs `ffmpeg -pix_fmt yuv420p10le`, 16-bit sample compare | 3819 mismatching samples (Y 238 / U 1776 / V 1805, first Y row 1600 col 1120) -> **0, bit-exact all three planes**
43+EVIDENCE: /home/user/.cache/hgkf-work/r_kf_4500.f0.yuv vs ref_kf_4500.yuv | same command pair on the mid-film key frame | 51768 mismatching samples (Y 35861 / U 8419 / V 7488) -> **2403, luma only, |delta| <= 2, chroma bit-exact**
44+EVIDENCE: /home/user/.cache/hgkf-work/{a45.l,o45c.l} | `EC_TRACE_MODE_STEP=1` ladder, ours vs instrumented aomdec, ranges compared element by element | 0 changed lines (only oracle-side lines we do not print: `tx_depth`, `use_filter_intra`); pre-fix the ladders diverged at mi_row=400 mi_col=0, `skip` range 43258 vs 34753
45+EVIDENCE: gate `a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact` | `cargo test -p ec-av1 --lib frame_edge_partition_bit -- --nocapture` | 8/8 arms pixel-exact; 192x136+136x192 mandelbrot 8/10-bit sub-level HORZ-VERT bits 9/7/4/3; 192x80+80x192 flat 8/10-bit 64-level HORZ-VERT bits 3 each; **test result: ok. 1 passed**
46+
47+## Gate
48+
49+`crates/ec-av1/src/stream.rs` — one test, eight arms (two shapes x
50+{mandelbrot,flat} x {8,10}-bit). Both "answered HORZ/VERT" counter slots must
51+be nonzero, counters read only on an attempt that decoded AND is compared, Err
52+tolerated only for messages containing "unsupported", aomenc output hashed
53+twice for reproducibility. 136 = 2*64+8 is the small-scale twin of the film's
54+1608 mod 64 == 8; the flat 80-tall pair is the ledger-measured shape where real
55+aomenc answers the SUPERBLOCK edge bit non-SPLIT.
56+
57+Refusals lifted: none (this was a silent wrong-decode, not a refusal).
58+`refusal_inventory` and `gate_coverage` unchanged.
59+
60+## Open residue
61+
62+`fix-now` for a follow-up round, not reachable inside this one: the mid-film key
63+frame still has **2403 luma samples wrong, |delta| <= 2, chroma exact**, in two
64+clusters — SB(row 19, col 17) 1409 samples and SB(row 6..9, col 49..51) ~990,
65+first at Y row 416 col 3169 (mi_row 104, mi_col 792), ours 210 vs 209. The
66+entropy ladder is exact through the whole frame, so this is a RECONSTRUCTION
67+(prediction or post-filter) defect, not a symbol defect — the +-1/+-2 magnitude
68+and the isolated superblocks point at an intra prediction corner or a
69+CDEF/deblock strength on those blocks. `deferred: mid-film key frame +-2 luma
70+residue — needs a per-TU EC_PRED compare at mi(104,792) — unblocked by this
71+round's entropy exactness, any agent can start at that block.`
72+
73+Suite: `cargo test -p ec-av1 --lib` (systemd unit, log `$HOME/.cache/hgkf-suite2.log`) -- **356 passed / 0 failed / 29 ignored**, 683s.
74+
75+## Same-shape sweep (class `parsed-then-discarded`, frame-edge partition bit)
76+
77+Grepped every gathered-edge reader in `decode.rs`. Fixed: the three key-frame
78+ones (64/32/16-level). **Flagged, not fixed**: the INTER tile has the identical
79+three readers — `decode.rs:18441` (64-level, `part64` match), `decode.rs:18590`
80+(32-level) and `decode.rs:18755` (16-level) — all still discard the bit and
81+force SPLIT, so an inter frame whose height is not a multiple of 64 mis-decodes
82+its partial row exactly the way the key frames did. It is left alone here
83+because the inter edge-strip decoders do not exist yet (lane-oddh r2 measured
84+that no aomenc recipe even reaches that arm today, so a fix could not be gated).
85+`deferred: inter-frame edge partition bit — needs the inter frame-edge
86+half-strip decoder (lane-oddh territory) plus a recipe that reaches it.`
lanes/hgkf-r2.report.mdadded+90 -0
@@ -0,0 +1,90 @@
1+# lane-hgkf r2 — a skipped intra block predicts per TRANSFORM UNIT
2+
3+Branch `lane-hgkf`, on top of r1 (`4939695`). Target: the r1 residue on the
4+mid-film 3840x1608 10-bit key frame — 2403 luma samples wrong, |delta| <= 2,
5+chroma exact, entropy ladder exact frame-wide.
6+
7+## Stage split (the charter's step 1)
8+
9+Both decoders' 8-bit stage rungs truncate 10-bit samples, so a |delta| <= 2
10+defect is invisible in them. Added a 16-bit twin on both sides:
11+`ec_dump16` in the oracle (`EC_AV1_PREFILT_DUMP16` /
12+`EC_AV1_POSTDEBLOCK_DUMP16`, `av1/decoder/decodeframe.c`) and `dump_stage16`
13+in ours (same two names plus `EC_AV1_POSTCDEF_DUMP16`, `decode.rs`).
14+
15+EVIDENCE: /home/user/.cache/hgkf-work/{o,a}_pre.f0, {o,a}_pdb.f0, o_fin.f0.yuv vs ref_kf_4500.yuv | ours vs instrumented aomdec, 16-bit cropped planes at PREFILT / POSTDEBLOCK / FINAL | PREFILT Y 2372 wrong (maxabs 3, first row 416 col 3170, ours 210 vs 209), POSTDEBLOCK identical set, FINAL 2403 -> **the defect is already in reconstruction**; deblock/CDEF/LR only smear it
16+
17+## Root cause (class `decision-at-wrong-granularity`)
18+
19+An intra block's `tx_depth` is read whether or not the block is skipped (only
20+an INTER skip forces the largest transform), and spec 7.11.2 / libaom
21+`predict_and_reconstruct_intra_block` predicts **one transform unit at a
22+time** — each unit's above/left edges are the units already reconstructed
23+inside that same block. Our skip branches predicted the whole block in one
24+call:
25+
26+* `crates/ec-av1/src/decode.rs` `decode_block`'s `if skip` arm — a 32x32 block
27+ with `logical_tx == 8` was one 32x32 DC prediction (123) where libaom does 16
28+ 8x8 DC predictions (124 each).
29+* `crates/ec-av1/src/decode.rs` `decode_leaf8`'s `if skip` arm — the same shape
30+ one level down: an 8x8 leaf with `resolved == 4` is four 4x4 units.
31+
32+Both now loop the units with a zero residual, reusing the non-skip loop's own
33+`tu_reach` geometry and its out-of-frame TU-origin clip. The palette/intrabc
34+override keeps the single-call shape (its per-TU windowing is the non-skip
35+path's, untested for skip and unreachable in these streams).
36+
37+New counter `SKIP_SPLIT_TX_HITS` (`skip_split_tx_hits()` /
38+`reset_skip_split_tx_hits()`, blocks not units): the only witness this path
39+has, since a skipped block codes no coefficients at all.
40+
41+## Evidence
42+
43+EVIDENCE: /home/user/.cache/hgkf-work/aom_pred.txt, our_pred.txt | new oracle rung `EC_PREDND` (non-directional high-bitdepth prediction; the pre-existing `EC_PRED` rung sat AFTER the `is_hbd` early return and printed nothing on a 10-bit stream) vs our new `OUR_PRED` rung | at px(1088,1216) libaom prints 16 8x8 DC predictions of 124, ours one 32x32 of 123 — sum 7936 x16 vs 125952
44+EVIDENCE: /home/user/.cache/hgkf-work/fx_kf_4500.f0.yuv vs ref_kf_4500.yuv | `dump_yuv kf_4500.obu` vs `ffmpeg -pix_fmt yuv420p10le`, 16-bit compare | 2403 wrong -> **0, all three planes bit-exact**
45+EVIDENCE: /home/user/.cache/hgkf-work/fx_kf_0.f0.yuv vs ref_kf_0.yuv | same command pair | **0, still bit-exact** (r1's frame did not regress)
46+
47+Scratch pin (not a repo fixture, scratch-only as the charter requires):
48+`.../scratchpad/census2/kf_4500.obu` sha256
49+`80529979df3735bce82f9c48fb0be66ec2019f4316ad6e617def86141c2b9010` — 48 split-skip
50+TU predictions, decodes bit-exact; `kf_0.obu` sha256
51+`53c311dec790bb2413afdde92cb24de498a7c4f66f6f0c7f4f5910ab0d2c65dc` — 0 hits, bit-exact.
52+
53+## Gate: NOT LANDED — no encoder recipe reached the path
54+
55+`deferred: an in-repo gate for split-tx skipped intra prediction — no
56+reproducible encoder recipe found in this round's budget — unblocked by either
57+an aomenc flag combination that keeps a split `tx_depth` on a block it then
58+skips, or by lifting the 1:4-partition refusal so an SVT-AV1 stream can be
59+decoded whole.`
60+
61+Swept, all 10-bit, all with the decode's success checked (a refused decode's
62+counter is a `counter-from-refused-stream` artefact, so every arm below reports
63+both):
64+
65+* aomenc `--enable-tx-size-search=1`, mandelbrot/testsrc2/low-amplitude noise,
66+ 256x192..1280x720, cq 12..55, cpu-used 0..8, aq-mode 0/1, 8- and 10-bit:
67+ **0 hits on every arm that decoded**. aomenc's tx search ties on a zero
68+ residual and keeps the largest transform, so it essentially never writes this
69+ combination.
70+* ffmpeg `libsvtav1` (v3.1.2) preset 4, 1280x720 10-bit: **reaches the path**
71+ (4..24 units at crf 25..55) — but every one of those streams also uses a 1:4
72+ partition below 16x16 / intrabc / palette, all of which this decoder refuses,
73+ so nothing could be pixel-compared.
74+* `gradients=size=1280x720:n=4` + libsvtav1 crf 30 decoded whole once with 16
75+ units, but lavfi `gradients` is not reproducible (3 encodes, 3 different
76+ sha256) — the known `seeded-fixture-not-reproducible` trap, rejected as a
77+ fixture.
78+
79+## Same-shape sweep
80+
81+Every intra skip-prediction site in `decode.rs`: `decode_block` (fixed),
82+`decode_leaf8` (fixed), the 4x8/8x4 leaf at `decode.rs:9570` (already per-TU,
83+lane-palette2), the inter-frame vartx leaf at `decode.rs:16450` (already
84+per-TU), the 4x4 leaf (no split exists). Chroma skip prediction is still
85+whole-block: for 4:2:0 the chroma transform only splits above a 64x64 luma
86+block, which no gate or film frame here reaches —
87+`deferred: chroma skip prediction per TU above 64x64 luma — no stream reaches
88+it — unblocked by a 128x128-superblock 10-bit gate.`
89+
90+Suite: `cargo test -p ec-av1 --lib` (user unit, log `$HOME/.cache/hgkf-suite-r2.log`) -- **356 passed / 0 failed / 29 ignored**, 416s.