Frame-edge strips coded transform units outside the frame
Browse files at this commitc850448d065043526750165dbd37fc5fecdcaac8Parent: e9e9d92- fix
- frame-edge strips coded transform units outside the frame
3 changed files +188 -27
- crates/ec-av1/src/decode.rs +59 -15
- crates/ec-av1/src/stream.rs +23 -12
- lanes/golomb-r3.report.md +106 -0
crates/ec-av1/src/decode.rsmodified+59 -15
| @@ -1604,16 +1604,31 @@ pub(crate) fn sb_rect_hits() -> usize { | |||
| 1604 | // PARTITION_HORZ decoded with `has_rows32 == false` (only the top 32x16 half | 1604 | // PARTITION_HORZ decoded with `has_rows32 == false` (only the top 32x16 half |
| 1605 | // is coded), slot 3 = a PARTITION_VERT with `has_cols32 == false`. Both tile | 1605 | // is coded), slot 3 = a PARTITION_VERT with `has_cols32 == false`. Both tile |
| 1606 | // paths (intra and inter) feed the same counter. | 1606 | // paths (intra and inter) feed the same counter. |
| 1607 | +// | ||
| 1608 | +// lane-golomb r3: slots 4..7 are the same four facts one level up, at the | ||
| 1609 | +// SUPERBLOCK (64x64) edge -- 4/5 = the gathered 64-level bit read as | ||
| 1610 | +// HORZ/VERT / SPLIT, 6 = a 64x32 bottom-edge strip decoded with | ||
| 1611 | +// `has_rows == false`, 7 = a 32x64 right-edge strip. Real aomenc answers a | ||
| 1612 | +// bottom-edge superblock with the 64-level HORZ (measured: 192x80 flat-band, | ||
| 1613 | +// every SB of the last row), so the 32-level slots stay 0 on that content and | ||
| 1614 | +// only these prove the arm fired. | ||
| 1607 | thread_local! { | 1615 | thread_local! { |
| 1608 | - static EDGE32_HITS: std::cell::Cell<[usize; 4]> = | 1616 | + static EDGE32_HITS: std::cell::Cell<[usize; 8]> = |
| 1609 | - const { std::cell::Cell::new([0; 4]) }; | 1617 | + const { std::cell::Cell::new([0; 8]) }; |
| 1610 | } | 1618 | } |
| 1611 | 1619 | ||
| 1612 | /// Current value of [`EDGE32_HITS`]. | 1620 | /// Current value of [`EDGE32_HITS`]. |
| 1613 | -pub(crate) fn edge32_hits() -> [usize; 4] { | 1621 | +pub(crate) fn edge32_hits() -> [usize; 8] { |
| 1614 | EDGE32_HITS.with(|c| c.get()) | 1622 | EDGE32_HITS.with(|c| c.get()) |
| 1615 | } | 1623 | } |
| 1616 | 1624 | ||
| 1625 | +/// [`bump_edge32`] of `base + bit`, returning the bit -- the gathered edge | ||
| 1626 | +/// reads are `if`-conditions, so the counter has to ride the expression. | ||
| 1627 | +fn bump_edge32_bit(base: usize, bit: usize) -> usize { | ||
| 1628 | + bump_edge32(base + bit.min(1)); | ||
| 1629 | + bit | ||
| 1630 | +} | ||
| 1631 | + | ||
| 1617 | fn bump_edge32(slot: usize) { | 1632 | fn bump_edge32(slot: usize) { |
| 1618 | EDGE32_HITS.with(|c| { | 1633 | EDGE32_HITS.with(|c| { |
| 1619 | let mut h = c.get(); | 1634 | let mut h = c.get(); |
| @@ -4810,6 +4825,18 @@ fn decode_rect_split( | |||
| 4810 | let tu_mi = (mi_r + tu_row * (tx / MI), mi_c + tu_col * (tx / MI)); | 4825 | let tu_mi = (mi_r + tu_row * (tx / MI), mi_c + tu_col * (tx / MI)); |
| 4811 | let (tu_px, tu_py) = (px + tu_col * tx, py + tu_row * tx); | 4826 | let (tu_px, tu_py) = (px + tu_col * tx, py + tu_row * tx); |
| 4812 | let (col_off, row_off) = (tu_col * tx, tu_row * tx); | 4827 | let (col_off, row_off) = (tu_col * tx, tu_row * tx); |
| 4828 | + // lane-golomb r3: a frame-edge HORZ/VERT strip is the one block | ||
| 4829 | + // shape that hangs off the bottom (or right) of the frame, and | ||
| 4830 | + // libaom's `av1_foreach_transformed_block_in_plane` clips its | ||
| 4831 | + // loop bounds to `max_blocks_high/wide` (`mb_to_bottom_edge` / | ||
| 4832 | + // `mb_to_right_edge`, i.e. `mi_rows * 4` / `mi_cols * 4`): a unit | ||
| 4833 | + // whose TOP-LEFT sample is outside the frame is never coded. We | ||
| 4834 | + // read coefficients for those phantom units and desynced the | ||
| 4835 | + // stream right after -- the next superblock's partition symbol | ||
| 4836 | + // came out SPLIT instead of HORZ (192x80, mi_col=32). | ||
| 4837 | + if tu_px >= y.true_width || tu_py >= y.true_height { | ||
| 4838 | + continue; | ||
| 4839 | + } | ||
| 4813 | // `has_top_right`/`has_bottom_left` (libaom `reconintra.c`) for a | 4840 | // `has_top_right`/`has_bottom_left` (libaom `reconintra.c`) for a |
| 4814 | // transform unit INSIDE a block, which is a different rule from | 4841 | // transform unit INSIDE a block, which is a different rule from |
| 4815 | // the standalone-block table [`Reach::of`] applies -- and the | 4842 | // the standalone-block table [`Reach::of`] applies -- and the |
| @@ -7429,6 +7456,15 @@ fn decode_block( | |||
| 7429 | ); | 7456 | ); |
| 7430 | let tu_px = px + tu_col * logical_tx; | 7457 | let tu_px = px + tu_col * logical_tx; |
| 7431 | let tu_py = py + tu_row * logical_tx; | 7458 | let tu_py = py + tu_row * logical_tx; |
| 7459 | + // lane-golomb r3, same-shape sweep of the strip fix below: | ||
| 7460 | + // libaom clips this loop to `max_blocks_wide/high` too. A | ||
| 7461 | + // square block only hangs off the frame when the frame's mi | ||
| 7462 | + // dimensions are odd at the block's own level (lane-oddh | ||
| 7463 | + // territory), so no gate here reaches it -- it is the | ||
| 7464 | + // identical libaom rule, not a measured fix. | ||
| 7465 | + if tu_px >= y.true_width || tu_py >= y.true_height { | ||
| 7466 | + continue; | ||
| 7467 | + } | ||
| 7432 | let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0]; | 7468 | let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0]; |
| 7433 | let tu_reach = Reach::of(logical_tx, tu_px, tu_py, y.width, y.height); | 7469 | let tu_reach = Reach::of(logical_tx, tu_px, tu_py, y.width, y.height); |
| 7434 | // This transform unit's own bsize (`logical_tx`) is smaller | 7470 | // This transform unit's own bsize (`logical_tx`) is smaller |
| @@ -10246,18 +10282,14 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 10246 | // mi_row=400 mi_col=0, the first block of that row. | 10282 | // mi_row=400 mi_col=0, the first block of that row. |
| 10247 | match (has_cols, has_rows) { | 10283 | match (has_cols, has_rows) { |
| 10248 | (true, false) => { | 10284 | (true, false) => { |
| 10249 | - if dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)) == 1 { | 10285 | + let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)); |
| 10250 | - PARTITION_SPLIT | 10286 | + bump_edge32(4 + b.min(1) as usize); |
| 10251 | - } else { | 10287 | + if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ } |
| 10252 | - PARTITION_HORZ | ||
| 10253 | - } | ||
| 10254 | } | 10288 | } |
| 10255 | (false, true) => { | 10289 | (false, true) => { |
| 10256 | - if dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)) == 1 { | 10290 | + let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)); |
| 10257 | - PARTITION_SPLIT | 10291 | + bump_edge32(4 + b.min(1) as usize); |
| 10258 | - } else { | 10292 | + if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT } |
| 10259 | - PARTITION_VERT | ||
| 10260 | - } | ||
| 10261 | } | 10293 | } |
| 10262 | _ => PARTITION_SPLIT, | 10294 | _ => PARTITION_SPLIT, |
| 10263 | } | 10295 | } |
| @@ -11352,6 +11384,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 11352 | tx_select, | 11384 | tx_select, |
| 11353 | reduced_tx_set, | 11385 | reduced_tx_set, |
| 11354 | )?; | 11386 | )?; |
| 11387 | + if !has_rows { | ||
| 11388 | + bump_edge32(6); | ||
| 11389 | + } | ||
| 11355 | // lane-golomb r1: at the frame edge only the first half of the | 11390 | // lane-golomb r1: at the frame edge only the first half of the |
| 11356 | // strip is coded (libaom `decode_partition` guards the second | 11391 | // strip is coded (libaom `decode_partition` guards the second |
| 11357 | // with the same has_rows test that made this partition non-square). | 11392 | // with the same has_rows test that made this partition non-square). |
| @@ -11393,6 +11428,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 11393 | tx_select, | 11428 | tx_select, |
| 11394 | reduced_tx_set, | 11429 | reduced_tx_set, |
| 11395 | )?; | 11430 | )?; |
| 11431 | + if !has_cols { | ||
| 11432 | + bump_edge32(7); | ||
| 11433 | + } | ||
| 11396 | // lane-golomb r1: at the frame edge only the first half of the | 11434 | // lane-golomb r1: at the frame edge only the first half of the |
| 11397 | // strip is coded (libaom `decode_partition` guards the second | 11435 | // strip is coded (libaom `decode_partition` guards the second |
| 11398 | // with the same has_cols test that made this partition non-square). | 11436 | // with the same has_cols test that made this partition non-square). |
| @@ -17257,7 +17295,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 17257 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered | 17295 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered |
| 17258 | // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT | 17296 | // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT |
| 17259 | // (libaom `ec_read_partition_impl`). | 17297 | // (libaom `ec_read_partition_impl`). |
| 17260 | - if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE)) == 1 { | 17298 | + if bump_edge32_bit( |
| 17299 | + 4, | ||
| 17300 | + dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE)), | ||
| 17301 | + ) == 1 { | ||
| 17261 | PARTITION_SPLIT | 17302 | PARTITION_SPLIT |
| 17262 | } else { | 17303 | } else { |
| 17263 | PARTITION_HORZ | 17304 | PARTITION_HORZ |
| @@ -17267,7 +17308,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 17267 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered | 17308 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered |
| 17268 | // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT | 17309 | // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT |
| 17269 | // (libaom `ec_read_partition_impl`). | 17310 | // (libaom `ec_read_partition_impl`). |
| 17270 | - if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)) == 1 { | 17311 | + if bump_edge32_bit( |
| 17312 | + 4, | ||
| 17313 | + dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)), | ||
| 17314 | + ) == 1 { | ||
| 17271 | PARTITION_SPLIT | 17315 | PARTITION_SPLIT |
| 17272 | } else { | 17316 | } else { |
| 17273 | PARTITION_VERT | 17317 | PARTITION_VERT |
crates/ec-av1/src/stream.rsmodified+23 -12
| @@ -14807,7 +14807,6 @@ mod tests { | |||
| 14807 | /// the partition guard. `#[ignore]` so the suite stays green; run it with | 14807 | /// the partition guard. `#[ignore]` so the suite stays green; run it with |
| 14808 | /// `cargo test -p ec-av1 --lib -- --ignored a_32x32_frame_edge_rect_partition_with_a_flat`. | 14808 | /// `cargo test -p ec-av1 --lib -- --ignored a_32x32_frame_edge_rect_partition_with_a_flat`. |
| 14809 | #[test] | 14809 | #[test] |
| 14810 | - #[ignore = "open r2 defect: the 32-level edge HORZ strip reconstructs wrong pixels"] | ||
| 14811 | fn a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact() { | 14810 | fn a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact() { |
| 14812 | edge32_gate( | 14811 | edge32_gate( |
| 14813 | "a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact", | 14812 | "a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact", |
| @@ -14836,7 +14835,7 @@ mod tests { | |||
| 14836 | // tile walk is exercised too. | 14835 | // tile walk is exercised too. |
| 14837 | arms.push((192, 80, 5, false)); | 14836 | arms.push((192, 80, 5, false)); |
| 14838 | let cqs: [u32; 8] = [35, 40, 45, 50, 55, 57, 59, 61]; | 14837 | let cqs: [u32; 8] = [35, 40, 45, 50, 55, 57, 59, 61]; |
| 14839 | - let mut totals = [0usize; 4]; | 14838 | + let mut totals = [0usize; 8]; |
| 14840 | let mut compared = 0usize; | 14839 | let mut compared = 0usize; |
| 14841 | let mut refusals: Vec<String> = Vec::new(); | 14840 | let mut refusals: Vec<String> = Vec::new(); |
| 14842 | for &(width, height, frame_count, ten_bit) in &arms { | 14841 | for &(width, height, frame_count, ten_bit) in &arms { |
| @@ -14958,7 +14957,7 @@ mod tests { | |||
| 14958 | }; | 14957 | }; |
| 14959 | let after = crate::decode::edge32_hits(); | 14958 | let after = crate::decode::edge32_hits(); |
| 14960 | let delta: Vec<usize> = | 14959 | let delta: Vec<usize> = |
| 14961 | - (0..4).map(|i| after[i] - before[i]).collect(); | 14960 | + (0..8).map(|i| after[i] - before[i]).collect(); |
| 14962 | let reference = if ten_bit { | 14961 | let reference = if ten_bit { |
| 14963 | ffmpeg_decode_sequence_10bit(&stream, width, height, decoded.len()) | 14962 | ffmpeg_decode_sequence_10bit(&stream, width, height, decoded.len()) |
| 14964 | } else { | 14963 | } else { |
| @@ -14999,7 +14998,7 @@ mod tests { | |||
| 14999 | } | 14998 | } |
| 15000 | } | 14999 | } |
| 15001 | compared += 1; | 15000 | compared += 1; |
| 15002 | - for i in 0..4 { | 15001 | + for i in 0..8 { |
| 15003 | totals[i] += delta[i]; | 15002 | totals[i] += delta[i]; |
| 15004 | } | 15003 | } |
| 15005 | } | 15004 | } |
| @@ -15010,27 +15009,39 @@ mod tests { | |||
| 15010 | refusals.join("\n") | 15009 | refusals.join("\n") |
| 15011 | ); | 15010 | ); |
| 15012 | assert!( | 15011 | assert!( |
| 15013 | - totals[0] + totals[1] > 0, | 15012 | + totals[0] + totals[1] + totals[4] + totals[5] > 0, |
| 15014 | - "{NAME}: no 32x32-level frame-edge partition bit was read at all over \ | 15013 | + "{NAME}: no frame-edge partition bit was read at all over \ |
| 15015 | {compared} compared attempts -- the gate proved nothing" | 15014 | {compared} compared attempts -- the gate proved nothing" |
| 15016 | ); | 15015 | ); |
| 15016 | + // lane-golomb r3: the flat-band arm's ASSERT moved one level up. Until | ||
| 15017 | + // r3 the last superblock row was reached through a 32-level edge bit | ||
| 15018 | + // only because our own out-of-frame transform units had desynced the | ||
| 15019 | + // stream; with that fixed, real aomenc answers a bottom-edge | ||
| 15020 | + // superblock with the 64-level `PARTITION_HORZ` (and a right-edge one | ||
| 15021 | + // with `PARTITION_VERT`) and the 32-level slots stay 0 on this | ||
| 15022 | + // content. Slots 6/7 are the strips actually decoded at the edge. | ||
| 15017 | assert!( | 15023 | assert!( |
| 15018 | - !flat_band || totals[2] > 0, | 15024 | + !flat_band || totals[6] > 0, |
| 15019 | - "{NAME}: the 32-level edge bit never named PARTITION_HORZ at the bottom edge \ | 15025 | + "{NAME}: no 64x32 bottom-edge HORZ strip was decoded \ |
| 15020 | (edge32={totals:?}, {compared} compared attempts)" | 15026 | (edge32={totals:?}, {compared} compared attempts)" |
| 15021 | ); | 15027 | ); |
| 15022 | assert!( | 15028 | assert!( |
| 15023 | - !flat_band || totals[3] > 0, | 15029 | + !flat_band || totals[7] > 0, |
| 15024 | - "{NAME}: the 32-level edge bit never named PARTITION_VERT at the right edge \ | 15030 | + "{NAME}: no 32x64 right-edge VERT strip was decoded \ |
| 15025 | (edge32={totals:?}, {compared} compared attempts)" | 15031 | (edge32={totals:?}, {compared} compared attempts)" |
| 15026 | ); | 15032 | ); |
| 15027 | eprintln!( | 15033 | eprintln!( |
| 15028 | - "{NAME}: {compared} pixel-exact attempts, edge32 bits [horz_or_vert={} split={}] \ | 15034 | + "{NAME}: {compared} pixel-exact attempts, 32-level edge bits \ |
| 15029 | - bottom-HORZ={} right-VERT={}, {} named refusals", | 15035 | + [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, 64-level edge bits \ |
| 15036 | + [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, {} named refusals", | ||
| 15030 | totals[0], | 15037 | totals[0], |
| 15031 | totals[1], | 15038 | totals[1], |
| 15032 | totals[2], | 15039 | totals[2], |
| 15033 | totals[3], | 15040 | totals[3], |
| 15041 | + totals[4], | ||
| 15042 | + totals[5], | ||
| 15043 | + totals[6], | ||
| 15044 | + totals[7], | ||
| 15034 | refusals.len() | 15045 | refusals.len() |
| 15035 | ); | 15046 | ); |
| 15036 | for r in &refusals { | 15047 | for r in &refusals { |
lanes/golomb-r3.report.mdadded+106 -0
| @@ -0,0 +1,106 @@ | |||
| 1 | +# lane-golomb r3 — the suite red was my own gate recipe; the edge strip was out-of-frame transform units | ||
| 2 | + | ||
| 3 | +## TASK 1 — bisect table (the r2 suite failure) | ||
| 4 | + | ||
| 5 | +`stream::tests::a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16_decodes_pixel_exact`, | ||
| 6 | +run in a detached scratch worktree (`scratchpad/verify-golomb`, `CARGO_TARGET_DIR=~/.cache/cargo-target-verify`): | ||
| 7 | + | ||
| 8 | +| commit | what it is | result | | ||
| 9 | +|---|---|---| | ||
| 10 | +| a762fff | mcomp64 base | ok, 1 passed | | ||
| 11 | +| 909064f | + fi8 cherry-pick 2d5c425 | ok, 1 passed | | ||
| 12 | +| eacd7fd | r1 edge-bit fix | ok, 1 passed | | ||
| 13 | +| fd54bcf | r2 guards | **FAILED** — "the stream decoded but no coded (non-skip) rect leaf fired" | | ||
| 14 | + | ||
| 15 | +EVIDENCE: bisect stdout above | `git worktree add --detach` at each sha, `cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16` | 3 ok / 1 FAILED, first red = fd54bcf | ||
| 16 | + | ||
| 17 | +Root cause: **not** fi8, not the r1 edge read. r2's per-arm recipe override | ||
| 18 | +(`--min-partition-size=32 --tune-content=film`) was pasted into the WRONG gate — hunk | ||
| 19 | +`stream.rs@8435`, inside `a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16`, whose whole | ||
| 20 | +point is sub-16x16 rect leaves. At `--min-partition-size=32` that 64x64 mandelbrot frame cannot | ||
| 21 | +contain a 16x8 leaf, so `rect_leaf_coeff_hits` went to 0 and the gate's own | ||
| 22 | +"the gate proves nothing" assert fired — the assert did its job. Fixed in ebec75d by restoring | ||
| 23 | +`--min-partition-size=8`; the edge32 gate has always carried its own copy of the override. | ||
| 24 | +No warning is owed to the fi8 merge agent: fi8 is already on main (b1d8457) and is exonerated by | ||
| 25 | +row 2 of the table. | ||
| 26 | + | ||
| 27 | +EVIDENCE: gate stdout | `cargo test -p ec-av1 --lib -- --nocapture a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16` after ebec75d | `pixel-exact, rect_leaf_coeff_hits=8`, 1 passed | ||
| 28 | + | ||
| 29 | +## TASK 2 — the frame-edge strip's wrong pixels: out-of-frame transform units | ||
| 30 | + | ||
| 31 | +Class: `parsed-then-discarded`'s mirror — *read* something the reference never wrote | ||
| 32 | +(`equal-range-means-unread`). | ||
| 33 | + | ||
| 34 | +Reproduced standalone (192x80 cq40 8-bit flat band, md5 `4bd18b25…`, scratchpad `e32.obu`): | ||
| 35 | +1081 Y pixels differ, rows 62..79, **cols 124..191** — the LAST superblock only. | ||
| 36 | + | ||
| 37 | +The oracle's own view of that superblock row (instrumented aomdec): | ||
| 38 | +`EC_PRED mi_row=16 mi_col=16 … bsize=11 part=1 txw=16 txh=16` with **row_off=0 only** (four TUs), | ||
| 39 | +and `mi_row=16 mi_col=32 … bsize=11 part=1 txw=32 txh=32` (two TUs). `bsize=11` is | ||
| 40 | +`BLOCK_64X32`: aomenc answers the bottom-edge superblock with the **64-level** `PARTITION_HORZ`, | ||
| 41 | +never the 32-level one, and codes only the transform-unit ROW that is inside the frame. | ||
| 42 | + | ||
| 43 | +Ours decoded `mi_col=16` identically (`TRACE_RECT_SPLIT bw=64 bh=32 tx=16`) but then walked | ||
| 44 | +`bh/tx = 2` TU rows, reading coefficients for four phantom 16x16 units at y=80..95 — outside a | ||
| 45 | +frame whose `mi_rows*4 == 80`. That desynced the stream at exactly the next symbol: the SB2 | ||
| 46 | +partition bit came out SPLIT (two 32x16 strips, `edge32=[2,0,2,0]`) where the oracle read HORZ. | ||
| 47 | +The r2 report's reading ("prediction/availability inside the strip") was wrong; the strips | ||
| 48 | +were the *symptom* of a desync, and the "32-level edge HORZ fired" counter was a | ||
| 49 | +`counter-from-refused-stream`-shaped artefact of our own desync. | ||
| 50 | + | ||
| 51 | +Fix — `crates/ec-av1/src/decode.rs:4818` (`decode_rect_split`, the only place a block hangs off | ||
| 52 | +the frame): skip a transform unit whose top-left sample is outside `true_width`/`true_height` | ||
| 53 | +(`mi_cols*4`/`mi_rows*4`), mirroring libaom `av1_foreach_transformed_block_in_plane`'s | ||
| 54 | +`max_blocks_wide/high` clip (`mb_to_right_edge`/`mb_to_bottom_edge`). The chroma unit of a strip | ||
| 55 | +always has its top-left inside, so it is unaffected. | ||
| 56 | + | ||
| 57 | +EVIDENCE: scratchpad/{e32.obu, ours.yuv, ao.yuv, ao-pred.txt, ours-step.txt} | instrumented | ||
| 58 | +aomdec `EC_PRED`/`EC_TRACE_MODE_STEP` vs `decode_probe`, byte diff of the two raw yuv420p dumps | | ||
| 59 | +before: 1081 Y pixels differ (first diff at our `EC_ISTEP mi_row=16 mi_col=32 name=skip rng=51413` | ||
| 60 | +vs oracle `rng=32901`); after: **0 differing bytes over all three planes** | ||
| 61 | + | ||
| 62 | +## Counters + the pin, un-ignored | ||
| 63 | + | ||
| 64 | +`EDGE32_HITS` widened 4 → 8 slots (`decode.rs:1602`): slots 4/5 = the **64**-level gathered edge | ||
| 65 | +bit read as HORZ/VERT / SPLIT (both tile paths), 6 = a 64x32 bottom-edge strip decoded with | ||
| 66 | +`has_rows == false`, 7 = a 32x64 right-edge strip. Necessary because the flat-band arm's r2 | ||
| 67 | +assert (`totals[2] > 0`, a 32-level bottom-edge HORZ) was only ever satisfied by our own desync; | ||
| 68 | +on a correct decode of this content the 32-level slots are 0 by construction and the 64-level | ||
| 69 | +slots carry the proof. `#[ignore]` removed from | ||
| 70 | +`a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact`. | ||
| 71 | + | ||
| 72 | +EVIDENCE: gate stdout | `cargo test -p ec-av1 --lib -- --nocapture a_32x32_frame_edge` | | ||
| 73 | +2 passed; flat arm: 32 pixel-exact attempts, 64-level edge bits [horz_or_vert=96 split=0] | ||
| 74 | +bottom-HORZ=48 right-VERT=48, 32-level slots all 0; detail arm: 32 pixel-exact attempts, | ||
| 75 | +64-level [horz_or_vert=7 split=89] right-VERT=7, 32-level split=178 | ||
| 76 | + | ||
| 77 | +## Suite | ||
| 78 | +`$HOME/.cache/golomb-suite-r3.log` — **339 passed / 0 failed / 31 ignored** (277 s), run as a | ||
| 79 | +user systemd unit on the final tree. r2 was 337/1 FAILED/32 ignored: +1 fixed (task 1), +1 | ||
| 80 | +un-ignored (task 2). | ||
| 81 | + | ||
| 82 | +Siblings re-run inside that suite, all green: `a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16`, | ||
| 83 | +`the_reelb_head_key_frame`, both `a_*_32x32_frame_edge_*`, `tiny_frame_size_sweep`, | ||
| 84 | +`superblock_level_*`, `filter_intra_*`, `refusal_inventory`, `gate_coverage`. | ||
| 85 | + | ||
| 86 | +## Same-shape sweep | ||
| 87 | +`decode.rs:7458` (`decode_block`'s square multi-TU loop) has the identical unclipped | ||
| 88 | +`0..n_axis` shape and now carries the identical guard. A square block only hangs off the frame | ||
| 89 | +when the frame's mi dimensions are odd at that block's level (lane-oddh's territory), so no gate | ||
| 90 | +in this suite reaches it: the guard is libaom's rule applied by inspection, proven only inert | ||
| 91 | +here (suite unchanged). `decode_block_rect64` delegates its split case to `decode_rect_split`, | ||
| 92 | +so it is covered by the measured fix. Flagged, not claimed. | ||
| 93 | + | ||
| 94 | +## Film | ||
| 95 | +`hg-head.obu` (18 frames) still stops at | ||
| 96 | +"an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path | ||
| 97 | +recurses a superblock only as SPLIT)" — unchanged by this round (same string as r1's residue; | ||
| 98 | +the inter tile path never reaches a 64-level HORZ). | ||
| 99 | +EVIDENCE: probe stdout | `cargo run -p ec-av1 --example decode_probe -- hg-head.obu` | REFUSED at | ||
| 100 | +the inter SB-level partition, 18 frame headers parsed, tiling cols=1 rows=1 | ||
| 101 | + | ||
| 102 | +## Residue | ||
| 103 | +- deferred: the inter tile path's 64-level `PARTITION_HORZ`/`VERT` (the film's next blocker) — | ||
| 104 | + unblocked by rect inter residual coding, which is lane-inter*/interbis territory, not this one. | ||
| 105 | +- accepted: the square-block guard above is unexercised by any gate on this lane (odd-mi | ||
| 106 | + geometry is lane-oddh's gate). | ||