From a24f3293b899f146c0e6bb9c7abf028971bd325d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Sep 2026 05:47:59 +0300 Subject: [PATCH] feat(av1): decode the frame-edge half-strip instead of refusing it (odd height/width) Cherry-picks lane-golomb eacd7fd (the gathered edge partition bit is the answer, 6 sites) and adds the arms it left refusing: the key-frame 16-level edge strip (one 16x8/8x16 through decode_leaf_rect) and the inter path's superblock-level and 16-level edge strips (one 64x32/32x64 resp. 16x8/8x16 inter block via write_w/write_h, square CDF corner-cut as at the 32-level rect arm). None of it is gated yet: a 64x72 key frame desyncs at its FIRST partition symbol (mi=(0,0) BLOCK_64X64 ctx=0: aomdec value=3, ours value=9; whole-frame 4583/4608 Y samples wrong while the 64x64 control is exact), so every stream that reaches these arms is already off the rails. That desync is r2's target; see lanes/oddh-r1.report.md for the ladder, the ruled-out header paths and the disposition of the width-192 defect the even-height control shares. --- .../ec-av1/fixtures/reelb_head_key_frame.obu | Bin 0 -> 147 bytes crates/ec-av1/src/decode.rs | 387 +++++++++++++++--- crates/ec-av1/src/stream.rs | 35 ++ lanes/golomb-r1.report.md | 47 +++ lanes/oddh-r1.report.md | 76 ++++ 5 files changed, 479 insertions(+), 66 deletions(-) create mode 100644 crates/ec-av1/fixtures/reelb_head_key_frame.obu create mode 100644 lanes/golomb-r1.report.md create mode 100644 lanes/oddh-r1.report.md diff --git a/crates/ec-av1/fixtures/reelb_head_key_frame.obu b/crates/ec-av1/fixtures/reelb_head_key_frame.obu new file mode 100644 index 0000000000000000000000000000000000000000..ecc409b000d6550743e1c768e075b23186e41c08 GIT binary patch literal 147 zcmV;E0Brvf016KP003g^zw$Zv^PwUEDS#>l0R!g%dVne#0_gYEq$Xw$Tu=>E zIRFFb000000)R4F5CDe&fB*mh03grHo2NmWeoqO5rDriCF8GQw;s}Qn usize { HORZ_VERT_INTRA_HITS.with(|c| c.get()) } +// How many blocks were decoded as a frame-edge rect strip -- the single +// coded half of a `PARTITION_HORZ`/`PARTITION_VERT` at the true frame edge +// (lane-oddh r1), i.e. a block living inside the 8px band of a frame whose +// height or width is 8 mod 16 (the user's 3840x1608 film). Intra and inter +// paths share the counter. +thread_local! { + static EDGE_RECT_STRIP_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; +} + +/// Current value of [`EDGE_RECT_STRIP_HITS`]. +pub(crate) fn edge_rect_strip_hits() -> usize { + EDGE_RECT_STRIP_HITS.with(|c| c.get()) +} + // How many HORZ/VERT intra strips resolved a SPLIT luma transform // (`tx_depth != 0`) and decoded it per transform unit (lane-rectsplit r1) -- // the case every rect path here refused by name before, and the first @@ -10809,16 +10824,31 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( } p } else { + // lane-golomb r1 (class `parsed-then-discarded`): the gathered + // bit is the answer, not a formality -- libaom's + // `ec_read_partition_impl` returns `PARTITION_HORZ` (resp. + // `PARTITION_VERT`) when it reads 0, and only `PARTITION_SPLIT` + // when it reads 1. Forcing SPLIT here desynced the last + // superblock row of every frame whose height is not a multiple + // of 64 -- the ReelB head (3840x1608) diverges at + // mi_row=400 mi_col=0, the first block of that row. match (has_cols, has_rows) { (true, false) => { - dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)); + if dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)) == 1 { + PARTITION_SPLIT + } else { + PARTITION_HORZ + } } (false, true) => { - dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)); + if dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)) == 1 { + PARTITION_SPLIT + } else { + PARTITION_VERT + } } - _ => {} + _ => PARTITION_SPLIT, } - PARTITION_SPLIT }; match part { PARTITION_NONE => { @@ -10875,20 +10905,27 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( } else { match (has_cols32, has_rows32) { (true, false) => { - dec.symbol_fixed(&gather( - &cdfs.partition_w32[ctx32], - VERT_ALIKE, - )); + // lane-golomb r1 (class `parsed-then-discarded`): the gathered + // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT + // (libaom `ec_read_partition_impl`). + if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE)) == 1 { + PARTITION_SPLIT + } else { + PARTITION_HORZ + } } (false, true) => { - dec.symbol_fixed(&gather( - &cdfs.partition_w32[ctx32], - HORZ_ALIKE, - )); + // lane-golomb r1 (class `parsed-then-discarded`): the gathered + // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT + // (libaom `ec_read_partition_impl`). + if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE)) == 1 { + PARTITION_SPLIT + } else { + PARTITION_VERT + } } - _ => {} + _ => PARTITION_SPLIT, } - PARTITION_SPLIT }; match part32 { PARTITION_NONE => { @@ -11327,16 +11364,63 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( does not code yet", )); } - if has_cols16 { + // lane-golomb r1 (class + // `parsed-then-discarded`): the gathered + // bit IS the partition -- 0 names + // PARTITION_HORZ (resp. VERT), only 1 is + // SPLIT (libaom `ec_read_partition_impl`). + // This path can only walk the four SPLIT + // leaves, so a 0 refuses by name instead + // of desyncing. + let edge_split = if has_cols16 { dec.symbol_fixed(&gather( &cdfs.partition_w16[ctx16], VERT_ALIKE, - )); + )) } else { dec.symbol_fixed(&gather( &cdfs.partition_w16[ctx16], HORZ_ALIKE, - )); + )) + }; + if edge_split == 0 { + // lane-oddh r1: the strip IS decodable + // -- libaom's `decode_partition` codes + // only the FIRST half of an edge + // HORZ/VERT (the second call is + // guarded by the same has_rows/ + // has_cols test that made the + // partition non-square), so one + // 16x8 (resp. 8x16) strip covers the + // whole visible band of a frame whose + // height (resp. width) is 8 mod 16 -- + // the user's 3840x1608 film. + HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1)); + EDGE_RECT_STRIP_HITS.with(|c| c.set(c.get() + 1)); + let (mi_row0, mi_col0) = + (sr as u32 * SUB_MI, sc as u32 * SUB_MI); + let (bw, bh) = if has_cols16 { (16, 8) } else { (8, 16) }; + let mode = decode_leaf_rect( + &mut dec, + &mut cdfs, + &mut neighbours, + at16, + (mi_row0 as usize, mi_col0 as usize), + bw, + bh, + None, + &mut y, + &mut u, + &mut v, + enable_filter_intra, + allow_screen_content_tools, + base_q_idx, + tx_select, + reduced_tx_set, + )?; + neighbours.above_mode[sc] = mode; + neighbours.left_mode[sr] = mode; + continue; } let (mi_row0, mi_col0) = (sr as u32 * SUB_MI, sc as u32 * SUB_MI); @@ -11886,22 +11970,27 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( tx_select, reduced_tx_set, )?; - decode_block_rect64( - &mut dec, - &mut cdfs, - &mut neighbours, - (at.0 + 2, at.1), - 64, - 32, - &mut y, - &mut u, - &mut v, - enable_filter_intra, - allow_screen_content_tools, - base_q_idx, - tx_select, - reduced_tx_set, - )?; + // lane-golomb r1: at the frame edge only the first half of the + // strip is coded (libaom `decode_partition` guards the second + // with the same has_rows test that made this partition non-square). + if has_rows { + decode_block_rect64( + &mut dec, + &mut cdfs, + &mut neighbours, + (at.0 + 2, at.1), + 64, + 32, + &mut y, + &mut u, + &mut v, + enable_filter_intra, + allow_screen_content_tools, + base_q_idx, + tx_select, + reduced_tx_set, + )?; + } } PARTITION_VERT => { // lane-sbpart r2: mirror of PARTITION_HORZ above with @@ -11922,22 +12011,27 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( tx_select, reduced_tx_set, )?; - decode_block_rect64( - &mut dec, - &mut cdfs, - &mut neighbours, - (at.0, at.1 + 2), - 32, - 64, - &mut y, - &mut u, - &mut v, - enable_filter_intra, - allow_screen_content_tools, - base_q_idx, - tx_select, - reduced_tx_set, - )?; + // lane-golomb r1: at the frame edge only the first half of the + // strip is coded (libaom `decode_partition` guards the second + // with the same has_cols test that made this partition non-square). + if has_cols { + decode_block_rect64( + &mut dec, + &mut cdfs, + &mut neighbours, + (at.0, at.1 + 2), + 32, + 64, + &mut y, + &mut u, + &mut v, + enable_filter_intra, + allow_screen_content_tools, + base_q_idx, + tx_select, + reduced_tx_set, + )?; + } } PARTITION_HORZ_A | PARTITION_HORZ_B | PARTITION_VERT_A | PARTITION_VERT_B => { // lane-part32 r4: the four superblock-level AB arms, each @@ -17776,12 +17870,24 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( p } (true, false) => { - dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE)); - PARTITION_SPLIT + // lane-golomb r1 (class `parsed-then-discarded`): the gathered + // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT + // (libaom `ec_read_partition_impl`). + if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE)) == 1 { + PARTITION_SPLIT + } else { + PARTITION_HORZ + } } (false, true) => { - dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)); - PARTITION_SPLIT + // lane-golomb r1 (class `parsed-then-discarded`): the gathered + // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT + // (libaom `ec_read_partition_impl`). + if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)) == 1 { + PARTITION_SPLIT + } else { + PARTITION_VERT + } } (false, false) => PARTITION_SPLIT, }; @@ -17847,6 +17953,68 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( )?; continue; } + // lane-oddh r1: a superblock at the TRUE frame edge whose gathered + // partition bit read 0 is a `PARTITION_HORZ` (resp. `VERT`) whose + // second half lies outside the frame -- libaom `decode_partition` + // guards that second call with the same has_rows/has_cols test, so + // exactly one 64x32 (resp. 32x64) block is coded. Interior rect + // superblocks still refuse below (this arm can only be reached from + // the gathered edge bit). + if (part64 == PARTITION_HORZ && !has_rows) || (part64 == PARTITION_VERT && !has_cols) { + EDGE_RECT_STRIP_HITS.with(|c| c.set(c.get() + 1)); + let (write_w, write_h) = + if part64 == PARTITION_HORZ { (SB, SB / 2) } else { (SB / 2, SB) }; + decode_inter_block( + &mut dec, + &mut cdfs, + &mut neighbours, + &mut grid, + sb_at, + SB, + mi_cols, + mi_rows, + &mut y, + &mut u, + &mut v, + &ref_y, + &ref_u, + &ref_v, + &ref_slots, + &sign_bias_table, + &global_motion, + base_q_idx, + TxbSet::Luma64, + TxbSet::Luma64, + TxbSet::Chroma32, + TX32, + TX32, + &scan32, + &scan32, + 3, + allow_high_precision_mv, + force_integer_mv, + interp_fixed, + enable_dual_filter, + tpl_frame.as_ref(), + reference_select, + enable_masked_compound, + enable_interintra_compound, + enable_jnt_comp, + order_hint_bits, + order_hint, + ref_order_hints, + skip_mode_present, + skip_mode_frame, + switchable_motion_mode, + allow_warped_motion, + false, + write_w, + write_h, + allow_screen_content_tools, + frame_width as usize, + )?; + continue; + } if part64 != PARTITION_SPLIT { return Err(unsupported( "an inter SB-level partition type other than NONE or SPLIT (this decoder's \ @@ -17886,14 +18054,27 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( } else { match (has_cols32, has_rows32) { (true, false) => { - dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE)); + // lane-golomb r1 (class `parsed-then-discarded`): the gathered + // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT + // (libaom `ec_read_partition_impl`). + if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE)) == 1 { + PARTITION_SPLIT + } else { + PARTITION_HORZ + } } (false, true) => { - dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE)); + // lane-golomb r1 (class `parsed-then-discarded`): the gathered + // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT + // (libaom `ec_read_partition_impl`). + if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE)) == 1 { + PARTITION_SPLIT + } else { + PARTITION_VERT + } } - _ => {} + _ => PARTITION_SPLIT, } - PARTITION_SPLIT }; match part32 { PARTITION_NONE => { @@ -17985,17 +18166,24 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( p } else { if has_cols16 { - dec.symbol_fixed(&gather( - &cdfs.partition_w16[ctx16], - VERT_ALIKE, - )); + // lane-golomb r1 (class `parsed-then-discarded`): the gathered + // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT + // (libaom `ec_read_partition_impl`). + if dec.symbol_fixed(&gather(&cdfs.partition_w16[ctx16], VERT_ALIKE)) == 1 { + PARTITION_SPLIT + } else { + PARTITION_HORZ + } } else { - dec.symbol_fixed(&gather( - &cdfs.partition_w16[ctx16], - HORZ_ALIKE, - )); + // lane-golomb r1 (class `parsed-then-discarded`): the gathered + // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT + // (libaom `ec_read_partition_impl`). + if dec.symbol_fixed(&gather(&cdfs.partition_w16[ctx16], HORZ_ALIKE)) == 1 { + PARTITION_SPLIT + } else { + PARTITION_VERT + } } - PARTITION_SPLIT }; if part16 == PARTITION_NONE { decode_inter_block( @@ -18051,6 +18239,73 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( allow_screen_content_tools, frame_width as usize, )?; + } else if (part16 == PARTITION_HORZ && !has_rows16) + || (part16 == PARTITION_VERT && !has_cols16) + { + // lane-oddh r1: the frame-edge half-strip (see the + // superblock-level arm) one level down -- a single + // 16x8 (resp. 8x16) inter block covering the whole + // visible band. Interior 16x8/8x16 inter leaves stay + // refused below. + EDGE_RECT_STRIP_HITS.with(|c| c.set(c.get() + 1)); + let (write_w, write_h) = if part16 == PARTITION_HORZ { + (SUB, SUB / 2) + } else { + (SUB / 2, SUB) + }; + decode_inter_block( + &mut dec, + &mut cdfs, + &mut neighbours, + &mut grid, + at16, + SUB, + mi_cols, + mi_rows, + &mut y, + &mut u, + &mut v, + &ref_y, + &ref_u, + &ref_v, + &ref_slots, + &sign_bias_table, + &global_motion, + base_q_idx, + TxbSet::Luma16, + if reduced_tx_set { + TxbSet::Luma16Inter + } else { + TxbSet::Luma16InterSet1 + }, + TxbSet::Chroma8, + TX16, + TX8, + &scan16, + &scan8, + 2, + allow_high_precision_mv, + force_integer_mv, + interp_fixed, + enable_dual_filter, + tpl_frame.as_ref(), + reference_select, + enable_masked_compound, + enable_interintra_compound, + enable_jnt_comp, + order_hint_bits, + order_hint, + ref_order_hints, + skip_mode_present, + skip_mode_frame, + switchable_motion_mode, + allow_warped_motion, + false, + write_w, + write_h, + allow_screen_content_tools, + frame_width as usize, + )?; } else if part16 != PARTITION_SPLIT { return Err(unsupported( "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index b8a0b7d0..e0c1f2e1 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -2671,6 +2671,41 @@ mod tests { eprintln!("{NAME}: pixel-exact, grain_hits={}", crate::film_grain::grain_hits()); } + /// lane-golomb r1: THE FILM ITSELF. `crates/ec-av1/fixtures/reelb_head_key_frame.obu` + /// is the first frame of the user's ReelB AV1 release (3840x1608 + /// yuv420p10le, `ffmpeg -i -c copy -frames:v 1 -f obu`, 147 bytes) -- + /// a real 10-bit key frame whose height is NOT a multiple of the 64-pixel + /// superblock, so its last superblock row (mi_row=400 of 402) carries the + /// edge partition symbol this lane fixed: libaom's `ec_read_partition_impl` + /// returns `PARTITION_HORZ` when the gathered `split_or_horz` bit is 0, and + /// this decoder used to READ that bit and throw it away, forcing SPLIT + /// (class `parsed-then-discarded`). The desync surfaced two rows later as + /// "a Golomb tail longer than this decoder reads" -- a refusal naming the + /// symptom, never the cause. + #[test] + fn the_reelb_head_key_frame_decodes_pixel_exact() { + const NAME: &str = "the_reelb_head_key_frame_decodes_pixel_exact"; + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("fixtures/reelb_head_key_frame.obu"); + let stream = std::fs::read(&path) + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); + let (width, height) = (3840usize, 1608usize); + let frames = match decode_stream(&stream) { + Ok(frames) => frames, + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), + }; + assert_eq!(frames.len(), 1, "{NAME}: one key frame"); + assert_eq!((frames[0].width, frames[0].height), (width, height)); + let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1); + assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg"); + assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg"); + assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); + } + /// lane-hbd10 r1: a real `aomenc --bit-depth=10 --superres-mode=1 /// --superres-denominator=12` key frame, decoded pixel-exact against /// ffmpeg's own 10-bit decode. Proves `superres::upscale_row`'s diff --git a/lanes/golomb-r1.report.md b/lanes/golomb-r1.report.md new file mode 100644 index 00000000..484257cb --- /dev/null +++ b/lanes/golomb-r1.report.md @@ -0,0 +1,47 @@ +# lane-golomb r1 — the edge partition bit was read and thrown away + +## Verdict +The "a Golomb tail longer than this decoder reads" refusal on the ReelB head was, as +suspected (`refusal-from-own-desync`), a symptom. Root cause: at a frame edge the partition +symbol is a single *gathered* bit, and this decoder read it and **discarded** it, always +inferring `PARTITION_SPLIT`. libaom `ec_read_partition_impl` (decodeframe.c:1255): +`!has_rows && has_cols` → `read ? PARTITION_SPLIT : PARTITION_HORZ`; the mirror case → +`PARTITION_VERT`. Class: `parsed-then-discarded`. + +Charter STEP-2 fallback ("libaom read_golomb caps at 32 bits, extend the reader") is FALSE: +`~/.cache/aom-oracle/src/av1/decoder/decodetxb.c:22` aborts the frame at `length > 20`, exactly +our cap. The cap was never the bug and is unchanged. + +## First divergent element (EVIDENCE) +EVIDENCE: /tmp/.../scratchpad/{ao-all.txt,ours-all.txt} | instrumented aomdec vs decode_probe, +EC_TRACE_MODE+EC_TRACE_MODE_STEP+EC_TRACE_COEFF on the 2-frame extract f2.obu, ladders aligned +element by element on msac RANGE | first diff at element 12053: key frame, **mi_row=400 +mi_col=0** (last, 8-pixel-tall superblock row of a 1608-tall frame), `name=skip` +oracle rng=34753 vs ours rng=43258. Oracle codes that superblock as one `BLOCK_64X32` +(`EC_IMODE ... bsize=11`, PARTITION_HORZ); we forced SPLIT and descended to 16x16. +After the fix the range ladder is element-exact for all 13712 shared elements of the key frame +(EVIDENCE: /tmp/.../scratchpad/{a4.n,o4.n} | awk first-diff | idx 13713, inside a later INTER +frame, i.e. past the whole key frame). + +## Fix +`crates/ec-av1/src/decode.rs` — every edge-partition site, both tile paths, all three levels +(64/32/16, intra and inter): the gathered bit now names HORZ/VERT vs SPLIT. The 64-level +HORZ/VERT arms only decode the second half when it is inside the frame (`has_rows`/`has_cols`), +mirroring libaom `decode_partition`. The intra 16x16 edge site can only walk four SPLIT leaves, +so a 0 bit refuses by name there (new string, listed in `refusal_inventory.rs`) instead of +desyncing. + +## Gates +- NEW `stream::tests::the_reelb_head_key_frame_decodes_pixel_exact` — the film itself: + `crates/ec-av1/fixtures/reelb_head_key_frame.obu` (147 B, first frame of his 3840x1608 + yuv420p10le release) decodes and matches `ffmpeg -pix_fmt yuv420p10le` on Y, U and V. + EVIDENCE: cargo test -p ec-av1 --lib -- the_reelb_head_key_frame | 1 passed | + Y/U/V all equal to ffmpeg's decode, 3840x1608. +- Full lib suite: `$HOME/.cache/golomb-suite.log` — **337 passed / 0 failed / 31 ignored**. + +## Film probes after the fix +- `hg-head.obu` (18 frames): key frame + first inter frames now entropy-exact; stops at + "an inter SB-level partition type other than NONE or SPLIT" — the same edge partition, now + correctly decoded as HORZ, on an INTER superblock row the inter path cannot code (rect inter + residual coding does not exist here). Next lane. +- `reelb5.obu`: "a 32x32-level 1:4 strip with a split transform (depth=2)" (unchanged by this lane). diff --git a/lanes/oddh-r1.report.md b/lanes/oddh-r1.report.md new file mode 100644 index 00000000..e3913c71 --- /dev/null +++ b/lanes/oddh-r1.report.md @@ -0,0 +1,76 @@ +# lane-oddh r1 — frames whose height/width is 8 mod 16 + +Branch `lane-oddh` off main `b1d8457`. Target: the user's ReelB film shape +(3840x1608, `1608 % 16 == 8`), where every inter attempt derailed. + +## What the round established (measured, not reasoned) + +1. **The charter's premise is stale in its blame, right in its shape.** The refusal + `"a non-DC chroma mode on an 8x8 inter-frame leaf"` is NOT what odd-height frames + stop at once lane-golomb's edge-partition fix is present. Cherry-picking + `eacd7fd` (clean, no conflicts) moves 192x136 to the same refusal its + *even-height control* 192x128 hits, i.e. that one is width/content-related, not + odd-height (see 4). + +2. **Minimal repro is 64x72, not 192x136.** With the standard inter-gate recipe + (`--enable-rect-partitions=0 --min/max-partition-size=8/16`, mandelbrot, cq 40): + - `64x64` decodes 4/4 frames pixel-exact (control), + - `64x72` (bottom band 8 px) stopped at the key-frame 16-level edge refusal, + - `72x64` (right band 8 px) stops in the inter tile path. + +3. **The real blocker underneath is a first-symbol desync of the KEY tile at + height 72.** Not an edge-band defect at all: the *first* partition symbol of the + frame diverges. + `EVIDENCE: /tmp/.../scratchpad/k-64x72.obu (667 B, key frame only, aomenc cq40) | EC_AV1_TRACE=1 decode_probe vs EC_TRACE=1 aomdec | first element mi=(0,0) bsize=BLOCK_64X64 ctx=0: aomdec value=3 (PARTITION_SPLIT, tell=1 rng=32768), ours value=9` + `EVIDENCE: /tmp/.../scratchpad/k-64x72.{ours,aom,ref}.y | aomdec --rawvideo + ffmpeg rawvideo vs our Y dump | aomdec == ffmpeg byte-for-byte; ours differs in 4583 of 4608 Y samples (whole frame), while the 64x64 control differs in 0` + Our tile payload starts at file offset 20 in both the 64x64 and the 64x72 stream + (`key_tile_bytes len=543`/`647`, file sizes 563/667), and `base_q_idx=160`, + `mi_cols=16`, `mi_rows=18` all parse correctly, so the header field values are + right; the divergence is in the very first symbol read off those bytes. + **Not diagnosed further — this is the handoff item.** Ruled out by reading the + source: `sb_rows`/`sb_cols` (`sequence.rs:409-422`, 18 -> 2 correct) and the + uniform-spacing tile-info loops (`frame.rs:1296-1334`, both increment loops match + spec 5.9.15, so the extra `increment_tile_rows_log2` bit that height 72 introduces + IS consumed). + +4. Pre-existing, unrelated to odd height: `192x128` and `192x136` both stop at + `"a 1:4 partition below 16x16"` with `--enable-1to4-partitions=0` on the command + line — a same-shaped refusal-from-own-desync at width 192, present on the control. + +## Code changed (all in this worktree, unproven end to end) + +- cherry-pick `eacd7fd` (lane-golomb) — the frame-edge partition bit at 6 sites in + both tile paths, plus its film key-frame fixture/gate. Clean merge. +- `crates/ec-av1/src/decode.rs:11371` — the key-frame 16-level frame-edge + `PARTITION_HORZ`/`VERT` now decodes its single visible 16x8 / 8x16 strip through + `decode_leaf_rect` instead of refusing (removes that refusal string; entry dropped + from `refusal_inventory.rs`). +- `crates/ec-av1/src/decode.rs` (inter tile path, superblock level and 16-level) — + the same edge half-strip as one 64x32 / 32x64 resp. 16x8 / 8x16 inter block + (`write_w`/`write_h`, square CDF/size-class corner-cut, exactly the accepted + corner-cut of the 32-level rect arm at `decode.rs:18448`). Interior rect + partitions still refuse by name. +- `decode.rs` — new counter `edge_rect_strip_hits()` (blocks decoded inside the 8px + edge band), for the gate a successor must write. + +`corner-cut:` the two inter edge arms read square CDFs / size classes for a +rectangular block (ceiling: coefficient and mode syntax for TX_64X32/TX_16X8 inter is +not modelled; upgrade path = the same treatment the 32-level rect arm eventually gets). + +## Verification status — honest + +- NO gate was added and NO refusal claim is proven: every stream that reaches the new + arms is desynced before them (finding 3), so a pixel compare would measure the + desync, not the arm. Writing + `a_real_aomenc_inter_sequence_with_an_8px_tall_edge_row_decodes_pixel_exact` on top + of a first-symbol desync would have produced a vacuous or a permanently-red gate. +- Suite: see `$HOME/.cache/oddh-suite.log` (run as a systemd unit, result quoted in + the handoff message). + +## Disposition + +- fix-now (next round, r2): the 64x72 key-tile first-symbol desync. It is the root + blocker; the edge arms above are dead code until it is fixed. +- deferred(the desync above): the 8px-edge-band gate + the refusal lift claim. +- deferred(width-192 defect, separate lane): the `"1:4 partition below 16x16"` stop + that both 192x128 and 192x136 share.