Merge branch 'lane-sb128c' (2432624): 128-root AB partitions, tx_size ctx against max_txsize_rect, per-unit reach above 64
Browse files at this commit7 changed files +649 -6
- crates/ec-av1/src/decode.rs +232 -1
- crates/ec-av1/src/encode.rs +22 -3
- crates/ec-av1/src/refusal_inventory.rs +1 -1
- crates/ec-av1/src/stream.rs +197 -1
- lanes/sb128c-r10.report.md +66 -0
- lanes/sb128c-r9.handoff.md +50 -0
- lanes/sb128c-r9.report.md +81 -0
crates/ec-av1/src/decode.rsmodified+232 -1
| @@ -6598,6 +6598,12 @@ fn tx_size_context_rect( | |||
| 6598 | own_w: usize, | 6598 | own_w: usize, |
| 6599 | own_h: usize, | 6599 | own_h: usize, |
| 6600 | ) -> usize { | 6600 | ) -> usize { |
| 6601 | + // `get_tx_size_context` compares against `max_txsize_rect_lookup[bsize]`, | ||
| 6602 | + // not the block's own side: no transform is wider or taller than 64, so a | ||
| 6603 | + // block with a 128 side resolves against 64 (the square path already caps | ||
| 6604 | + // this way, lane-sb128b r1). Without the cap the 64x128 half of a 128-root | ||
| 6605 | + // VERT reads the tx-depth symbol off row 0 where libaom uses row 1. | ||
| 6606 | + let (own_w, own_h) = (own_w.min(64), own_h.min(64)); | ||
| 6601 | let above = mi_r > n.tile_row0_mi && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w; | 6607 | let above = mi_r > n.tile_row0_mi && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w; |
| 6602 | let left = mi_c > n.tile_col0_mi && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h; | 6608 | let left = mi_c > n.tile_col0_mi && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h; |
| 6603 | if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { | 6609 | if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { |
| @@ -15048,6 +15054,14 @@ thread_local! { | |||
| 15048 | /// only shape a 1080p (mi_rows = 270) stream reaches. | 15054 | /// only shape a 1080p (mi_rows = 270) stream reaches. |
| 15049 | pub(crate) static PART128_EDGE_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 15055 | pub(crate) static PART128_EDGE_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 15050 | pub(crate) static PART128_EDGE_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 15056 | pub(crate) static PART128_EDGE_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 15057 | + /// lane-sb128c r9: 128 roots that resolved to one of the four AB shapes, | ||
| 15058 | + /// in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B` order. | ||
| 15059 | + pub(crate) static PART128_AB_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) }; | ||
| 15060 | +} | ||
| 15061 | + | ||
| 15062 | +/// [`PART128_AB_HITS`], for a gate's own before/after delta. | ||
| 15063 | +pub(crate) fn part128_ab_hits() -> [usize; 4] { | ||
| 15064 | + PART128_AB_HITS.with(std::cell::Cell::get) | ||
| 15051 | } | 15065 | } |
| 15052 | 15066 | ||
| 15053 | /// [`PART128_NONE_HITS`], for a gate's own before/after delta. | 15067 | /// [`PART128_NONE_HITS`], for a gate's own before/after delta. |
| @@ -15170,9 +15184,19 @@ fn read_sb128_root( | |||
| 15170 | PARTITION_NONE => PART128_NONE_HITS.with(|c| c.set(c.get() + 1)), | 15184 | PARTITION_NONE => PART128_NONE_HITS.with(|c| c.set(c.get() + 1)), |
| 15171 | PARTITION_HORZ => PART128_HORZ_HITS.with(|c| c.set(c.get() + 1)), | 15185 | PARTITION_HORZ => PART128_HORZ_HITS.with(|c| c.set(c.get() + 1)), |
| 15172 | PARTITION_VERT => PART128_VERT_HITS.with(|c| c.set(c.get() + 1)), | 15186 | PARTITION_VERT => PART128_VERT_HITS.with(|c| c.set(c.get() + 1)), |
| 15187 | + // lane-sb128c r9: the four AB shapes at the 128 root -- one | ||
| 15188 | + // 128x64/64x128 half plus two 64x64 quadrants, decoded by both tile | ||
| 15189 | + // paths below in libaom `decode_partition`'s own visit order. | ||
| 15190 | + p if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&p) => { | ||
| 15191 | + PART128_AB_HITS.with(|c| { | ||
| 15192 | + let mut h = c.get(); | ||
| 15193 | + h[p - PARTITION_HORZ_A] += 1; | ||
| 15194 | + c.set(h); | ||
| 15195 | + }); | ||
| 15196 | + } | ||
| 15173 | _ => { | 15197 | _ => { |
| 15174 | return Err(unsupported( | 15198 | return Err(unsupported( |
| 15175 | - "a 128x128 superblock AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B at the 128 root)", | 15199 | + "a 128x128 superblock partition value outside the 8-symbol alphabet", |
| 15176 | )); | 15200 | )); |
| 15177 | } | 15201 | } |
| 15178 | } | 15202 | } |
| @@ -15387,6 +15411,131 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 15387 | mi_cols, | 15411 | mi_cols, |
| 15388 | mi_rows, | 15412 | mi_rows, |
| 15389 | )?; | 15413 | )?; |
| 15414 | + if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part128) { | ||
| 15415 | + // lane-sb128c r9: the four AB shapes at the 128 root. | ||
| 15416 | + // libaom `decode_partition` (decodeframe.c) codes each as | ||
| 15417 | + // two `bsize2` (64x64) squares plus one `subsize` | ||
| 15418 | + // (128x64 / 64x128) half, visited HORZ_A = TL, TR, bottom | ||
| 15419 | + // half; HORZ_B = top half, BL, BR; VERT_A = TL, BL, right | ||
| 15420 | + // half; VERT_B = left half, TR, BR. AB values only come | ||
| 15421 | + // from the FULL alphabet symbol, which is only read when | ||
| 15422 | + // both halves of the root are inside the frame, so no | ||
| 15423 | + // piece needs libaom's `i > 0` frame-edge break (a piece | ||
| 15424 | + // may still overhang the bottom/right, which | ||
| 15425 | + // `PlaneBuf::reconstruct`'s r8 clip handles). | ||
| 15426 | + sb128_none = true; | ||
| 15427 | + let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4); | ||
| 15428 | + let (br, bc) = (at128.0 + 4, at128.1 + 4); | ||
| 15429 | + let (q_r, q_c) = ((sb_r & !1) as usize, (sb_c & !1) as usize); | ||
| 15430 | + // Only the VERTICAL arms reorder the squares (TL, BL, TR, | ||
| 15431 | + // BR), so only they switch libaom's `has_tr_vert_*` / | ||
| 15432 | + // `has_bl_vert_*` tables (lane-sb128c r6 visit order). | ||
| 15433 | + let _vert_ab = | ||
| 15434 | + (part128 == PARTITION_VERT_A || part128 == PARTITION_VERT_B) | ||
| 15435 | + .then(crate::encode::Reach::vert_ab_partition); | ||
| 15436 | + // One `cdef_idx` literal per CODED BLOCK, at the first | ||
| 15437 | + // non-skip one of each 64x64 CDEF unit; the 128x64 / | ||
| 15438 | + // 64x128 half covers two units and its read lands in the | ||
| 15439 | + // unit holding its origin, so that value is copied to the | ||
| 15440 | + // other one (libaom: every mi of the block points at the | ||
| 15441 | + // same `MB_MODE_INFO`). | ||
| 15442 | + let cdef_copy = |src: (usize, usize), dst: (usize, usize)| { | ||
| 15443 | + CDEF_IDX_GRID.with(|g| { | ||
| 15444 | + let mut g = g.borrow_mut(); | ||
| 15445 | + let cols = CDEF_SB_COLS.with(|c| c.get()); | ||
| 15446 | + if cols == 0 { | ||
| 15447 | + return; | ||
| 15448 | + } | ||
| 15449 | + let (si, di) = ( | ||
| 15450 | + (q_r + src.0) * cols + q_c + src.1, | ||
| 15451 | + (q_r + dst.0) * cols + q_c + dst.1, | ||
| 15452 | + ); | ||
| 15453 | + if q_c + src.1 < cols | ||
| 15454 | + && q_c + dst.1 < cols | ||
| 15455 | + && si < g.len() | ||
| 15456 | + && di < g.len() | ||
| 15457 | + { | ||
| 15458 | + g[di] = g[si]; | ||
| 15459 | + } | ||
| 15460 | + }); | ||
| 15461 | + }; | ||
| 15462 | + macro_rules! square64 { | ||
| 15463 | + ($at:expr) => {{ | ||
| 15464 | + CDEF_TRANSMITTED.with(|c| c.set(false)); | ||
| 15465 | + decode_block( | ||
| 15466 | + &mut dec, | ||
| 15467 | + &mut cdfs, | ||
| 15468 | + &mut neighbours, | ||
| 15469 | + $at, | ||
| 15470 | + SB, | ||
| 15471 | + TxbSet::Luma64, | ||
| 15472 | + TxbSet::Chroma32, | ||
| 15473 | + TX32, | ||
| 15474 | + TX32, | ||
| 15475 | + (&scan32, &scan32), | ||
| 15476 | + false, | ||
| 15477 | + &mut y, | ||
| 15478 | + &mut u, | ||
| 15479 | + &mut v, | ||
| 15480 | + base_q_idx, | ||
| 15481 | + enable_filter_intra, | ||
| 15482 | + allow_screen_content_tools, | ||
| 15483 | + allow_intrabc, | ||
| 15484 | + &scan32, | ||
| 15485 | + &scan16, | ||
| 15486 | + &scan8, | ||
| 15487 | + &scan4, | ||
| 15488 | + tx_select, | ||
| 15489 | + reduced_tx_set, | ||
| 15490 | + )? | ||
| 15491 | + }}; | ||
| 15492 | + } | ||
| 15493 | + macro_rules! half128 { | ||
| 15494 | + ($at:expr, $bw:expr, $bh:expr, $src:expr, $dst:expr) => {{ | ||
| 15495 | + CDEF_TRANSMITTED.with(|c| c.set(false)); | ||
| 15496 | + decode_block_128rect( | ||
| 15497 | + &mut dec, | ||
| 15498 | + &mut cdfs, | ||
| 15499 | + &mut neighbours, | ||
| 15500 | + $at, | ||
| 15501 | + $bw, | ||
| 15502 | + $bh, | ||
| 15503 | + &mut y, | ||
| 15504 | + &mut u, | ||
| 15505 | + &mut v, | ||
| 15506 | + base_q_idx, | ||
| 15507 | + enable_filter_intra, | ||
| 15508 | + allow_screen_content_tools, | ||
| 15509 | + tx_select, | ||
| 15510 | + reduced_tx_set, | ||
| 15511 | + )?; | ||
| 15512 | + cdef_copy($src, $dst); | ||
| 15513 | + }}; | ||
| 15514 | + } | ||
| 15515 | + match part128 { | ||
| 15516 | + PARTITION_HORZ_A => { | ||
| 15517 | + square64!(at128); | ||
| 15518 | + square64!((at128.0, bc)); | ||
| 15519 | + half128!((br, at128.1), 128, 64, (1, 0), (1, 1)); | ||
| 15520 | + } | ||
| 15521 | + PARTITION_HORZ_B => { | ||
| 15522 | + half128!(at128, 128, 64, (0, 0), (0, 1)); | ||
| 15523 | + square64!((br, at128.1)); | ||
| 15524 | + square64!((br, bc)); | ||
| 15525 | + } | ||
| 15526 | + PARTITION_VERT_A => { | ||
| 15527 | + square64!(at128); | ||
| 15528 | + square64!((br, at128.1)); | ||
| 15529 | + half128!((at128.0, bc), 64, 128, (0, 1), (1, 1)); | ||
| 15530 | + } | ||
| 15531 | + _ => { | ||
| 15532 | + half128!(at128, 64, 128, (0, 0), (1, 0)); | ||
| 15533 | + square64!((at128.0, bc)); | ||
| 15534 | + square64!((br, bc)); | ||
| 15535 | + } | ||
| 15536 | + } | ||
| 15537 | + continue; | ||
| 15538 | + } | ||
| 15390 | if matches!(part128, PARTITION_HORZ | PARTITION_VERT) { | 15539 | if matches!(part128, PARTITION_HORZ | PARTITION_VERT) { |
| 15391 | // lane-sb128c r8: libaom `decode_partition` | 15540 | // lane-sb128c r8: libaom `decode_partition` |
| 15392 | // (decodeframe.c:1554) codes PARTITION_HORZ at the 128 | 15541 | // (decodeframe.c:1554) codes PARTITION_HORZ at the 128 |
| @@ -25262,6 +25411,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 25262 | } | 25411 | } |
| 25263 | { | 25412 | { |
| 25264 | let mut sb128_rect = None; | 25413 | let mut sb128_rect = None; |
| 25414 | + let mut sb128_ab = None; | ||
| 25265 | if sb128 && sb_start { | 25415 | if sb128 && sb_start { |
| 25266 | let part128 = read_sb128_root( | 25416 | let part128 = read_sb128_root( |
| 25267 | &mut dec, | 25417 | &mut dec, |
| @@ -25275,6 +25425,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 25275 | mi_cols, | 25425 | mi_cols, |
| 25276 | mi_rows, | 25426 | mi_rows, |
| 25277 | )?; | 25427 | )?; |
| 25428 | + if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part128) { | ||
| 25429 | + // lane-sb128c r9: an AB shape at the 128 root -- one | ||
| 25430 | + // 128x64/64x128 half plus two 64x64 quadrants, same visit | ||
| 25431 | + // order as the key-frame path. | ||
| 25432 | + sb128_none = true; | ||
| 25433 | + sb128_ab = Some(part128); | ||
| 25434 | + } | ||
| 25278 | if matches!(part128, PARTITION_HORZ | PARTITION_VERT) { | 25435 | if matches!(part128, PARTITION_HORZ | PARTITION_VERT) { |
| 25279 | // Two 128x64 (HORZ) or two 64x128 (VERT) inter blocks; the | 25436 | // Two 128x64 (HORZ) or two 64x128 (VERT) inter blocks; the |
| 25280 | // whole 128x128 root is consumed here, so the remaining | 25437 | // whole 128x128 root is consumed here, so the remaining |
| @@ -25448,6 +25605,80 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 25448 | } | 25605 | } |
| 25449 | }}; | 25606 | }}; |
| 25450 | } | 25607 | } |
| 25608 | + if let Some(part128) = sb128_ab { | ||
| 25609 | + // libaom `decode_partition` (decodeframe.c): HORZ_A = TL, TR, | ||
| 25610 | + // bottom half; HORZ_B = top half, BL, BR; VERT_A = TL, BL, | ||
| 25611 | + // right half; VERT_B = left half, TR, BR. AB only comes from | ||
| 25612 | + // the full alphabet symbol (both halves in frame), so there is | ||
| 25613 | + // no `i > 0` edge break to mirror. | ||
| 25614 | + let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4); | ||
| 25615 | + let base_mi = sub16_to_mi(at128); | ||
| 25616 | + let (br_mi, bc_mi) = (base_mi.0 + 16, base_mi.1 + 16); | ||
| 25617 | + let (q_r, q_c) = ((sb_r & !1) as usize, (sb_c & !1) as usize); | ||
| 25618 | + let _vert_ab = (part128 == PARTITION_VERT_A || part128 == PARTITION_VERT_B) | ||
| 25619 | + .then(crate::encode::Reach::vert_ab_partition); | ||
| 25620 | + let cdef_copy = |src: (usize, usize), dst: (usize, usize)| { | ||
| 25621 | + CDEF_IDX_GRID.with(|g| { | ||
| 25622 | + let mut g = g.borrow_mut(); | ||
| 25623 | + let cols = CDEF_SB_COLS.with(|c| c.get()); | ||
| 25624 | + if cols == 0 { | ||
| 25625 | + return; | ||
| 25626 | + } | ||
| 25627 | + let (si, di) = ( | ||
| 25628 | + (q_r + src.0) * cols + q_c + src.1, | ||
| 25629 | + (q_r + dst.0) * cols + q_c + dst.1, | ||
| 25630 | + ); | ||
| 25631 | + if q_c + src.1 < cols && q_c + dst.1 < cols && si < g.len() && di < g.len() | ||
| 25632 | + { | ||
| 25633 | + g[di] = g[si]; | ||
| 25634 | + } | ||
| 25635 | + }); | ||
| 25636 | + }; | ||
| 25637 | + macro_rules! square64_inter { | ||
| 25638 | + ($at_mi:expr) => {{ | ||
| 25639 | + CDEF_TRANSMITTED.with(|c| c.set(false)); | ||
| 25640 | + inter_piece!( | ||
| 25641 | + $at_mi, SB, | ||
| 25642 | + TxbSet::Luma64, TxbSet::Luma64, TxbSet::Chroma32, TX32, TX32, | ||
| 25643 | + &scan32, &scan32, 3, SB, SB | ||
| 25644 | + ); | ||
| 25645 | + }}; | ||
| 25646 | + } | ||
| 25647 | + macro_rules! half128_inter { | ||
| 25648 | + ($at_mi:expr, $bw:expr, $bh:expr, $src:expr, $dst:expr) => {{ | ||
| 25649 | + CDEF_TRANSMITTED.with(|c| c.set(false)); | ||
| 25650 | + inter_piece!( | ||
| 25651 | + $at_mi, SB * 2, | ||
| 25652 | + TxbSet::Luma64, TxbSet::Luma64, TxbSet::Chroma32, TX32, TX32, | ||
| 25653 | + &scan32, &scan32, 3, $bw, $bh | ||
| 25654 | + ); | ||
| 25655 | + cdef_copy($src, $dst); | ||
| 25656 | + }}; | ||
| 25657 | + } | ||
| 25658 | + match part128 { | ||
| 25659 | + PARTITION_HORZ_A => { | ||
| 25660 | + square64_inter!(base_mi); | ||
| 25661 | + square64_inter!((base_mi.0, bc_mi)); | ||
| 25662 | + half128_inter!((br_mi, base_mi.1), 128, 64, (1, 0), (1, 1)); | ||
| 25663 | + } | ||
| 25664 | + PARTITION_HORZ_B => { | ||
| 25665 | + half128_inter!(base_mi, 128, 64, (0, 0), (0, 1)); | ||
| 25666 | + square64_inter!((br_mi, base_mi.1)); | ||
| 25667 | + square64_inter!((br_mi, bc_mi)); | ||
| 25668 | + } | ||
| 25669 | + PARTITION_VERT_A => { | ||
| 25670 | + square64_inter!(base_mi); | ||
| 25671 | + square64_inter!((br_mi, base_mi.1)); | ||
| 25672 | + half128_inter!((base_mi.0, bc_mi), 64, 128, (0, 1), (1, 1)); | ||
| 25673 | + } | ||
| 25674 | + _ => { | ||
| 25675 | + half128_inter!(base_mi, 64, 128, (0, 0), (1, 0)); | ||
| 25676 | + square64_inter!((base_mi.0, bc_mi)); | ||
| 25677 | + square64_inter!((br_mi, bc_mi)); | ||
| 25678 | + } | ||
| 25679 | + } | ||
| 25680 | + continue; | ||
| 25681 | + } | ||
| 25451 | if let Some(part128) = sb128_rect { | 25682 | if let Some(part128) = sb128_rect { |
| 25452 | // lane-sb128c r7: libaom `decode_partition` (decodeframe.c:1554) | 25683 | // lane-sb128c r7: libaom `decode_partition` (decodeframe.c:1554) |
| 25453 | // codes PARTITION_HORZ at the 128 root as `subsize = | 25684 | // codes PARTITION_HORZ at the 128 root as `subsize = |
crates/ec-av1/src/encode.rsmodified+22 -3
| @@ -1261,13 +1261,32 @@ impl Reach { | |||
| 1261 | tx_h: usize, | 1261 | tx_h: usize, |
| 1262 | block: Self, | 1262 | block: Self, |
| 1263 | ) -> Self { | 1263 | ) -> Self { |
| 1264 | + // A block wider than 64 is coded in 64x64 "mu" chunks in raster | ||
| 1265 | + // order, so both libaom predicates special-case it (lane-sb128c r10); | ||
| 1266 | + // without this the last unit column of every chunk of a 128x64 block | ||
| 1267 | + // predicts from a chunk libaom has not decoded yet. | ||
| 1268 | + let wide = bw > 64; | ||
| 1264 | Self { | 1269 | Self { |
| 1265 | - above_right: if col_off + tx_w < bw { | 1270 | + above_right: if row_off > 0 { |
| 1271 | + // `has_top_right`'s `row_off > 0` branch: the offset is taken | ||
| 1272 | + // modulo the 64-wide chunk, except for the one unit whose | ||
| 1273 | + // top-right corner is the centre of a 128x128 block. | ||
| 1274 | + if wide { | ||
| 1275 | + (row_off == 64 && col_off + tx_w == 64) || (col_off % 64) + tx_w < 64 | ||
| 1276 | + } else { | ||
| 1277 | + col_off + tx_w < bw | ||
| 1278 | + } | ||
| 1279 | + } else if col_off + tx_w < bw { | ||
| 1266 | true | 1280 | true |
| 1267 | } else { | 1281 | } else { |
| 1268 | - row_off == 0 && block.above_right | 1282 | + block.above_right |
| 1269 | }, | 1283 | }, |
| 1270 | - below_left: if col_off > 0 { | 1284 | + below_left: if wide && col_off > 0 && col_off % 64 == 0 { |
| 1285 | + // `has_bottom_left`: at the left edge of a right-hand chunk | ||
| 1286 | + // the bottom-left pixels are in the already-coded left chunk, | ||
| 1287 | + // provided they stay inside it. | ||
| 1288 | + (row_off % 64) + tx_h < bh.min(64) | ||
| 1289 | + } else if col_off > 0 { | ||
| 1271 | false | 1290 | false |
| 1272 | } else if row_off + tx_h < bh { | 1291 | } else if row_off + tx_h < bh { |
| 1273 | true | 1292 | true |
crates/ec-av1/src/refusal_inventory.rsmodified+1 -1
| @@ -43,7 +43,7 @@ const REFUSALS: &[&str] = &[ | |||
| 43 | "a tx_type symbol outside its CDF's own set: {t}", | 43 | "a tx_type symbol outside its CDF's own set: {t}", |
| 44 | "an INTER 32x32 partition type this decoder does not code (value={part32})", | 44 | "an INTER 32x32 partition type this decoder does not code (value={part32})", |
| 45 | "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4", | 45 | "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4", |
| 46 | - "a 128x128 superblock AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B at the 128 root)", | 46 | + "a 128x128 superblock partition value outside the 8-symbol alphabet", |
| 47 | "an inter var-tx tree with a leaf transform larger than 64x64", | 47 | "an inter var-tx tree with a leaf transform larger than 64x64", |
| 48 | "CfL, filter intra or a palette on a 128-root HORZ/VERT intra block (every one of their size gates caps at 64x64 or below, so none of these symbols exists there)", | 48 | "CfL, filter intra or a palette on a 128-root HORZ/VERT intra block (every one of their size gates caps at 64x64 or below, so none of these symbols exists there)", |
| 49 | "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)", | 49 | "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)", |
crates/ec-av1/src/stream.rsmodified+197 -1
| @@ -128,6 +128,13 @@ pub fn intra_sb128_counters() -> (usize, usize, [usize; 3]) { | |||
| 128 | crate::decode::intra_sb128_hits() | 128 | crate::decode::intra_sb128_hits() |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | +/// lane-sb128c r9: the four AB shapes at the 128 root, in `PARTITION_HORZ_A`, | ||
| 132 | +/// `_HORZ_B`, `_VERT_A`, `_VERT_B` order (key and inter tile paths share the | ||
| 133 | +/// counter -- it is bumped where the root symbol resolves). | ||
| 134 | +pub fn sb128_ab_counters() -> [usize; 4] { | ||
| 135 | + crate::decode::part128_ab_hits() | ||
| 136 | +} | ||
| 137 | + | ||
| 131 | pub fn rect4_32_counters() -> (usize, usize, usize) { | 138 | pub fn rect4_32_counters() -> (usize, usize, usize) { |
| 132 | ( | 139 | ( |
| 133 | crate::decode::rect4_32_horz_hits(), | 140 | crate::decode::rect4_32_horz_hits(), |
| @@ -23120,6 +23127,12 @@ mod tests { | |||
| 23120 | (44, "--cq-level=8", 256, 192, false, false, true), | 23127 | (44, "--cq-level=8", 256, 192, false, false, true), |
| 23121 | (46, "--cq-level=55", 192, 256, false, true, false), | 23128 | (46, "--cq-level=55", 192, 256, false, true, false), |
| 23122 | (45, "--cq-level=45", 192, 256, true, true, true), | 23129 | (45, "--cq-level=45", 192, 256, true, true, true), |
| 23130 | + // lane-sb128c r10: a SECOND 128 superblock column is what the | ||
| 23131 | + // arms above never had -- the right 64x128 half of a 128-root | ||
| 23132 | + // VERT at mi_col 80 read its tx-depth symbol off the wrong CDF | ||
| 23133 | + // row and every unit column of a 128x64 chunk predicted from the | ||
| 23134 | + // not-yet-decoded chunk to its right. | ||
| 23135 | + (47, "--cq-level=45", 512, 512, false, false, true), | ||
| 23123 | ]; | 23136 | ]; |
| 23124 | let (mut matched, mut named_refusals, mut out_of_scope) = (0u32, 0u32, 0u32); | 23137 | let (mut matched, mut named_refusals, mut out_of_scope) = (0u32, 0u32, 0u32); |
| 23125 | let (mut horz_arms, mut vert_arms) = (0u32, 0u32); | 23138 | let (mut horz_arms, mut vert_arms) = (0u32, 0u32); |
| @@ -23136,7 +23149,17 @@ mod tests { | |||
| 23136 | // through `geq` instead -- same effect on the encoder's | 23149 | // through `geq` instead -- same effect on the encoder's |
| 23137 | // partition choice, byte-identical across runs. | 23150 | // partition choice, byte-identical across runs. |
| 23138 | &format!( | 23151 | &format!( |
| 23139 | - "nullsrc=size={width}x{height}:rate=25,format=yuv420p, geq=lum='128+90*sin((X+2*N)/37)+30*sin(Y/29)': cb='128+30*sin(X/23)':cr='128+30*sin((Y+N)/19)'" | 23152 | + "nullsrc=size={width}x{height}:rate=25,format=yuv420p, geq=lum='{lum}': cb='128+30*sin(X/23)':cr='128+30*sin((Y+N)/19)'", |
| 23153 | + // The 512x512 arm carries the r9 witness's own | ||
| 23154 | + // higher-frequency luma: the smooth two-term source | ||
| 23155 | + // gives every 128-rect block a whole-block TX_64X64 | ||
| 23156 | + // and no VERT root at all, which is exactly the | ||
| 23157 | + // combination that hid the tx-depth CDF row defect. | ||
| 23158 | + lum = if width == 512 { | ||
| 23159 | + "128+80*sin((X+3*N)/17)+50*sin(Y/29)+30*sin((X+Y)/13)" | ||
| 23160 | + } else { | ||
| 23161 | + "128+90*sin((X+2*N)/37)+30*sin(Y/29)" | ||
| 23162 | + } | ||
| 23140 | ), | 23163 | ), |
| 23141 | "-pix_fmt", pix, "-strict", "-1", "-t", "0.2", | 23164 | "-pix_fmt", pix, "-strict", "-1", "-t", "0.2", |
| 23142 | "-f", "yuv4mpegpipe", "-", | 23165 | "-f", "yuv4mpegpipe", "-", |
| @@ -23262,6 +23285,179 @@ mod tests { | |||
| 23262 | ); | 23285 | ); |
| 23263 | } | 23286 | } |
| 23264 | 23287 | ||
| 23288 | + /// lane-sb128c r9 GATE: the four AB shapes at the 128 root | ||
| 23289 | + /// (`PARTITION_HORZ_A`/`_HORZ_B`/`_VERT_A`/`_VERT_B`), each one | ||
| 23290 | + /// 128x64/64x128 half plus two 64x64 quadrants in libaom | ||
| 23291 | + /// `decode_partition`'s visit order. The recipe is r8's measured one | ||
| 23292 | + /// (`--sb-size=128 --min-partition-size=64 --enable-ab-partitions=1` over | ||
| 23293 | + /// a 512x512 `geq` sinusoid), which is what made aomenc pick the shapes at | ||
| 23294 | + /// all; arms cover cq 18/45, 8 and 10 bit, and one INTER arm | ||
| 23295 | + /// (`--kf-max-dist=100`) so the shapes are exercised on both tile paths. | ||
| 23296 | + /// Continue-and-sweep: an arm that stops on ANOTHER lane's named refusal | ||
| 23297 | + /// is counted and skipped, a decode failure or a pixel mismatch is a hard | ||
| 23298 | + /// failure, and the end-of-sweep assert names which of the four fired. | ||
| 23299 | + #[test] | ||
| 23300 | + fn a_real_aomenc_sb128_ab_partition_at_the_128_root_decodes_pixel_exact() { | ||
| 23301 | + const NAME: &str = "a_real_aomenc_sb128_ab_partition_at_the_128_root_decodes_pixel_exact"; | ||
| 23302 | + let _gate_lock = lock_gate_counters(); | ||
| 23303 | + if !have_ffmpeg() { | ||
| 23304 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 23305 | + return; | ||
| 23306 | + } | ||
| 23307 | + if !have_aomenc() { | ||
| 23308 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 23309 | + return; | ||
| 23310 | + } | ||
| 23311 | + // (tag, cq, width, height, 10-bit, inter) | ||
| 23312 | + let arms: Vec<(u32, &str, usize, usize, bool, bool)> = vec![ | ||
| 23313 | + (18, "--cq-level=18", 512, 512, false, false), | ||
| 23314 | + (45, "--cq-level=45", 512, 512, false, false), | ||
| 23315 | + (32, "--cq-level=32", 512, 512, true, false), | ||
| 23316 | + (55, "--cq-level=55", 384, 320, false, false), | ||
| 23317 | + (91, "--cq-level=45", 512, 512, false, true), | ||
| 23318 | + (92, "--cq-level=18", 512, 512, false, true), | ||
| 23319 | + ]; | ||
| 23320 | + let (mut matched, mut named_refusals, mut out_of_scope) = (0u32, 0u32, 0u32); | ||
| 23321 | + let mut ab_seen = [0usize; 4]; | ||
| 23322 | + let mut ab_inter = [0usize; 4]; | ||
| 23323 | + for (tag, cq, width, height, ten_bit, inter) in arms { | ||
| 23324 | + let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" }; | ||
| 23325 | + let y4m = Command::new("ffmpeg") | ||
| 23326 | + .args([ | ||
| 23327 | + "-v", "error", "-f", "lavfi", "-i", | ||
| 23328 | + // Same DETERMINISTIC sinusoid source that made aomenc pick | ||
| 23329 | + // the AB shapes in the r8 sweep (lavfi `gradients` ignores | ||
| 23330 | + // its seed and is not reproducible -- never use it here). | ||
| 23331 | + &format!( | ||
| 23332 | + "nullsrc=size={width}x{height}:rate=25,format=yuv420p,\ | ||
| 23333 | + geq=lum='128+80*sin((X+3*N)/17)+50*sin(Y/29)+30*sin((X+Y)/13)':\ | ||
| 23334 | + cb='128+30*sin(X/23)':cr='128+30*sin((Y+N)/19)'" | ||
| 23335 | + ), | ||
| 23336 | + "-pix_fmt", pix, "-strict", "-1", "-t", "0.2", | ||
| 23337 | + "-f", "yuv4mpegpipe", "-", | ||
| 23338 | + ]) | ||
| 23339 | + .stdin(Stdio::null()) | ||
| 23340 | + .stdout(Stdio::piped()) | ||
| 23341 | + .stderr(Stdio::piped()) | ||
| 23342 | + .output() | ||
| 23343 | + .expect("ffmpeg failed to run"); | ||
| 23344 | + assert!( | ||
| 23345 | + y4m.status.success(), | ||
| 23346 | + "{NAME}: ffmpeg fixture: {}", | ||
| 23347 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 23348 | + ); | ||
| 23349 | + let mut args: Vec<&str> = vec![ | ||
| 23350 | + "--codec=av1", "--passes=1", "--end-usage=q", cq, | ||
| 23351 | + "--cpu-used=0", "--threads=1", "--row-mt=0", | ||
| 23352 | + "--sb-size=128", "--min-partition-size=64", | ||
| 23353 | + "--enable-rect-partitions=1", "--enable-ab-partitions=1", | ||
| 23354 | + "--enable-1to4-partitions=0", "--enable-palette=0", | ||
| 23355 | + "--enable-intrabc=0", "--deltaq-mode=0", "--limit=5", | ||
| 23356 | + ]; | ||
| 23357 | + // AOMENC FLAG PRECEDENCE: last occurrence wins, so the per-arm | ||
| 23358 | + // key-frame cadence goes AFTER the base recipe. | ||
| 23359 | + args.push(if inter { "--kf-max-dist=100" } else { "--kf-max-dist=1" }); | ||
| 23360 | + if ten_bit { | ||
| 23361 | + args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]); | ||
| 23362 | + } | ||
| 23363 | + args.extend_from_slice(&["--obu", "-o", "-", "-"]); | ||
| 23364 | + let mut child = Command::new(aomenc_path()) | ||
| 23365 | + .args(&args) | ||
| 23366 | + .stdin(Stdio::piped()) | ||
| 23367 | + .stdout(Stdio::piped()) | ||
| 23368 | + .stderr(Stdio::piped()) | ||
| 23369 | + .spawn() | ||
| 23370 | + .expect("aomenc failed to start"); | ||
| 23371 | + child | ||
| 23372 | + .stdin | ||
| 23373 | + .take() | ||
| 23374 | + .expect("aomenc stdin") | ||
| 23375 | + .write_all(&y4m.stdout) | ||
| 23376 | + .expect("writing y4m to aomenc"); | ||
| 23377 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 23378 | + assert!( | ||
| 23379 | + out.status.success(), | ||
| 23380 | + "{NAME}: aomenc refused the fixture: {}", | ||
| 23381 | + String::from_utf8_lossy(&out.stderr) | ||
| 23382 | + ); | ||
| 23383 | + let stream = out.stdout; | ||
| 23384 | + let before = sb128_ab_counters(); | ||
| 23385 | + if let Err(e) = decode_stream(&stream) { | ||
| 23386 | + let msg = e.to_string(); | ||
| 23387 | + assert!( | ||
| 23388 | + msg.contains("unsupported"), | ||
| 23389 | + "{NAME} failed outright, not a named refusal \ | ||
| 23390 | + (arm {tag} {width}x{height}): {msg}" | ||
| 23391 | + ); | ||
| 23392 | + named_refusals += 1; | ||
| 23393 | + eprintln!("{NAME}: arm {tag} {width}x{height} refusal: {msg}"); | ||
| 23394 | + continue; | ||
| 23395 | + } | ||
| 23396 | + let (frames, hidden) = decode_all_frames_vs_oracle( | ||
| 23397 | + &stream, | ||
| 23398 | + &format!("sb128c-ab-{tag}-{width}x{height}"), | ||
| 23399 | + ); | ||
| 23400 | + assert!(frames > 0, "{NAME}: no frames decoded at {width}x{height}"); | ||
| 23401 | + let after = sb128_ab_counters(); | ||
| 23402 | + let ab: Vec<usize> = (0..4).map(|i| after[i] - before[i]).collect(); | ||
| 23403 | + eprintln!( | ||
| 23404 | + "{NAME}: arm {tag} cq {cq} {width}x{height} {}bit {}: {frames} frames \ | ||
| 23405 | + pixel-exact ({hidden} hidden), AB[HORZ_A,HORZ_B,VERT_A,VERT_B] {ab:?}", | ||
| 23406 | + if ten_bit { 10 } else { 8 }, | ||
| 23407 | + if inter { "INTER" } else { "KEY" }, | ||
| 23408 | + ); | ||
| 23409 | + if ab.iter().sum::<usize>() == 0 { | ||
| 23410 | + out_of_scope += 1; | ||
| 23411 | + } | ||
| 23412 | + for i in 0..4 { | ||
| 23413 | + ab_seen[i] += ab[i]; | ||
| 23414 | + if inter { | ||
| 23415 | + ab_inter[i] += ab[i]; | ||
| 23416 | + } | ||
| 23417 | + } | ||
| 23418 | + matched += 1; | ||
| 23419 | + } | ||
| 23420 | + assert!( | ||
| 23421 | + matched > 0, | ||
| 23422 | + "{NAME}: every attempt refused ({named_refusals}); the gate never \ | ||
| 23423 | + decoded a stream" | ||
| 23424 | + ); | ||
| 23425 | + assert!( | ||
| 23426 | + ab_seen.iter().sum::<usize>() > 0, | ||
| 23427 | + "{NAME}: {matched} stream(s) decoded pixel-exact ({out_of_scope} carried \ | ||
| 23428 | + no 128-root AB partition at all) but NOT ONE AB shape fired -- the \ | ||
| 23429 | + shapes this gate exists for" | ||
| 23430 | + ); | ||
| 23431 | + // Which of the four this sweep actually reaches, hard-asserted so a | ||
| 23432 | + // later change that stops reaching one of them fails here instead of | ||
| 23433 | + // silently narrowing the gate (class `gate-blind-to-feature`). | ||
| 23434 | + for (i, name) in ["HORZ_A", "HORZ_B", "VERT_A", "VERT_B"].iter().enumerate() { | ||
| 23435 | + if AB_ARMS_REACHED[i] { | ||
| 23436 | + assert!( | ||
| 23437 | + ab_seen[i] > 0, | ||
| 23438 | + "{NAME}: PARTITION_{name} at the 128 root fired in the round that \ | ||
| 23439 | + pinned this gate but not now: {ab_seen:?}" | ||
| 23440 | + ); | ||
| 23441 | + } else { | ||
| 23442 | + eprintln!( | ||
| 23443 | + "{NAME}: PARTITION_{name} NOT reached by this sweep (aomenc never \ | ||
| 23444 | + picked it): {ab_seen:?}" | ||
| 23445 | + ); | ||
| 23446 | + } | ||
| 23447 | + } | ||
| 23448 | + assert!( | ||
| 23449 | + ab_inter.iter().sum::<usize>() > 0, | ||
| 23450 | + "{NAME}: the AB shapes fired only on KEY frames -- the inter tile path's \ | ||
| 23451 | + own AB arm was never exercised: key {ab_seen:?} inter {ab_inter:?}" | ||
| 23452 | + ); | ||
| 23453 | + } | ||
| 23454 | + | ||
| 23455 | + /// Which of the four 128-root AB shapes the gate above MEASURED aomenc | ||
| 23456 | + /// picking (lane-sb128c r9). An arm that is `false` is not reachable from | ||
| 23457 | + /// this sweep's recipes and stays unasserted rather than weakening the | ||
| 23458 | + /// asserts of the ones that are. | ||
| 23459 | + const AB_ARMS_REACHED: [bool; 4] = [true, true, true, true]; | ||
| 23460 | + | ||
| 23265 | #[test] | 23461 | #[test] |
| 23266 | #[ignore = "lane-sb128 r2 diagnostic: is the frame-6 mismatch sb128-specific?"] | 23462 | #[ignore = "lane-sb128 r2 diagnostic: is the frame-6 mismatch sb128-specific?"] |
| 23267 | fn sb128_r2_control_sb64() { | 23463 | fn sb128_r2_control_sb64() { |
lanes/sb128c-r10.report.mdadded+66 -0
| @@ -0,0 +1,66 @@ | |||
| 1 | +# lane-sb128c r10 report | ||
| 2 | + | ||
| 3 | +Tip `1f6d885` on `lane-sb128c` (from `c24a2ac`). The r9 blocker is closed: two | ||
| 4 | +root causes, both in code shared by every block wider or taller than 64. | ||
| 5 | + | ||
| 6 | +## Root cause 1 -- `tx_size_context_rect` compared against the block side | ||
| 7 | + | ||
| 8 | +`crates/ec-av1/src/decode.rs:5845` `tx_size_context_rect` tested the above/left | ||
| 9 | +neighbour transform sizes against the block's own `bw`/`bh`. libaom's | ||
| 10 | +`get_tx_size_context` tests against `max_txsize_rect_lookup[bsize]`, which tops | ||
| 11 | +out at TX_64X64: a 64x128 block must compare against 64, not 128. The square | ||
| 12 | +path (`read_tx_depth`, decode.rs:11838) already capped with `side.min(64)` | ||
| 13 | +(lane-sb128b r1); the rect path never did. Consequence: the right 64x128 half | ||
| 14 | +of a 128-root PARTITION_VERT at mi_col 80 read its tx-depth symbol off CDF row | ||
| 15 | +0 where libaom uses row 1, decoded depth 0 (TX_64X64) instead of depth 2 | ||
| 16 | +(TX_16X16), and the tile desynced from that block on. | ||
| 17 | + | ||
| 18 | +Fix: cap both dimensions at 64 inside the helper (one `min`), so all eight call | ||
| 19 | +sites are covered at once. | ||
| 20 | + | ||
| 21 | +## Root cause 2 -- `Reach::of_tu` ignored the 64x64 "mu" chunk order | ||
| 22 | + | ||
| 23 | +`crates/ec-av1/src/encode.rs:1252` `Reach::of_tu` used the plain | ||
| 24 | +`col_off + tx_w < bw` rule. A block wider than 64 is coded in 64x64 chunks in | ||
| 25 | +raster order, so `has_top_right` (reconintra.c) takes `col_off` MODULO the | ||
| 26 | +64-wide chunk in its `row_off > 0` branch (with one exception: the unit whose | ||
| 27 | +top-right corner is the centre of a 128x128), and `has_bottom_left` grants the | ||
| 28 | +left edge of a right-hand chunk what the already-coded left chunk holds. | ||
| 29 | +Without it the last unit column of every chunk of a 128x64 intra block | ||
| 30 | +predicted from a chunk libaom has not decoded yet -- 375 wrong luma samples in | ||
| 31 | +the first such block of a 512x512 key frame, entropy exact. | ||
| 32 | + | ||
| 33 | +## Evidence | ||
| 34 | + | ||
| 35 | +EVIDENCE: `$HOME/.cache/sb128c-r10/{aom.trace,our.trace}` | `EC_TRACE_MODE EC_TRACE_COEFF` aomdec vs `EC_TRACE_MODE EC_TRACE_MODE_STEP EC_TRACE_COEFF` decode_probe on `$HOME/.cache/sb128c-r9/noab.obu`, both under `systemd-run --scope -p MemoryMax=6G`, all_zero rng ladder | first divergence at element 151 = the block at mi_row 0 mi_col 80 (bsize 13, 64x128): oracle reads a tx-depth symbol (rng 32968 -> 42504) and codes TX_16X16 units, ours read none and coded TX_64X64. After fix 1 the whole 5370-element ladder is IDENTICAL. | ||
| 36 | + | ||
| 37 | +EVIDENCE: `$HOME/.cache/sb128c-r10/pred.trace` | `EC_PRED=1 aomdec` on the same stream | the 128x64 block at mi_col 32 has `n_tr=16` for col_off 0/4/8 and `n_tr=0` for col_off 12 at every `row_off > 0` -- exactly the unit column where our recon differed (diff map: 375 samples, all in x 176..191 and 192..255's last column). | ||
| 38 | + | ||
| 39 | +EVIDENCE: `$HOME/.cache/sb128c-r10/{o.f*,m.f*}` | `EC_AV1_PREFILT_DUMP` both decoders over all five r9 streams (noab, ab45, ab18, abi45, ab55; recipe `$HOME/.cache/sb128c-r9/mk.sh`) | every frame of every stream byte-identical after both fixes (before: 5/5 streams DIFF on every frame, 326839/393216 bytes on noab f0). | ||
| 40 | + | ||
| 41 | +EVIDENCE: gate `a_real_aomenc_sb128_intra_rect_block_decodes_pixel_exact` arm 47 | `cargo test -p ec-av1 --lib a_real_aomenc_sb128_intra_rect_block_decodes_pixel_exact -- --nocapture` | `arm 47 cq --cq-level=45 512x512 8bit txsearch=1: 5 frames pixel-exact (0 hidden), intra_128x64 +164 intra_64x128 +156 depth[64/32/16] [26, 0, 294]`. | ||
| 42 | + | ||
| 43 | +EVIDENCE: `$HOME/.cache/reelc-head.obu` | `decode_probe` under `systemd-run --scope -p MemoryMax=6G` after both fixes | `OK: 48 frames decoded, 1920x792`, `sb128_rect: edge_horz=720 inter_128x64=720` -- no refusal, no regression. | ||
| 44 | + | ||
| 45 | +## Gate arm added | ||
| 46 | + | ||
| 47 | +`crates/ec-av1/src/stream.rs:19176` -- a 512x512 arm (tag 47) on the sb128 | ||
| 48 | +intra_rect_block gate: a SECOND 128 superblock column, which no earlier arm had | ||
| 49 | +(192x256 / 384x320 / 256x192 all stop at one 128 column), plus the r9 witness's | ||
| 50 | +own higher-frequency luma source, because the gate's smooth two-term source | ||
| 51 | +gives every 128-rect block a whole-block TX_64X64 and no VERT root -- the exact | ||
| 52 | +combination that hid the defect. Counters prove the shape: 156 64x128 blocks, | ||
| 53 | +294 units at TX_16X16. | ||
| 54 | + | ||
| 55 | +## Suite | ||
| 56 | + | ||
| 57 | +`cargo test -p ec-av1 --lib` (unit `sb128c-suite-r10-1788351731`, after fix 1 | ||
| 58 | +only): 387 passed, 1 failed, 35 ignored -- the one failure was | ||
| 59 | +`a_real_aomenc_sb128_ab_partition_at_the_128_root_decodes_pixel_exact`, which | ||
| 60 | +fix 2 closes. Final run: unit `sb128c-suite-r10b-*`, log | ||
| 61 | +`$HOME/.cache/sb128c-suite-r10b.log` -- **388 passed, 0 failed, 35 ignored** (475 s), including `a_real_aomenc_sb128_ab_partition_at_the_128_root_decodes_pixel_exact`, `..._intra_rect_block_...` (with the new 512x512 arm), `..._gathered_edge_horz_...` and the r7 inter gate. | ||
| 62 | + | ||
| 63 | +## Residue | ||
| 64 | + | ||
| 65 | +- No refusal string was lifted this round; the r9 gate that the AB refusal | ||
| 66 | + lift needs is now green. accepted. | ||
lanes/sb128c-r9.handoff.mdadded+50 -0
| @@ -0,0 +1,50 @@ | |||
| 1 | +# lane-sb128c r9 -> r10 handoff | ||
| 2 | + | ||
| 3 | +Tip `d00a97b` (branch `lane-sb128c`). The four 128-root AB shapes are | ||
| 4 | +IMPLEMENTED on both tile paths and the refusal is lifted; the new gate | ||
| 5 | +`a_real_aomenc_sb128_ab_partition_at_the_128_root_decodes_pixel_exact` is RED | ||
| 6 | +for a reason that is NOT the AB code. | ||
| 7 | + | ||
| 8 | +## The blocker, bisected (do not re-derive) | ||
| 9 | + | ||
| 10 | +- Stream `$HOME/.cache/sb128c-r9/ab45.obu` (512x512 cq45 8-bit key, recipe in | ||
| 11 | + `$HOME/.cache/sb128c-r9/mk.sh`). Frame 0 differs from the oracle. | ||
| 12 | +- `EC_AV1_PREFILT_DUMP` on BOTH decoders: first differing sample is | ||
| 13 | + **byte 321 = (x=320, y=0)**, i.e. the very FIRST sample of the RIGHT 64x128 | ||
| 14 | + half of the third 128 root, which is `PARTITION_VERT` (root values of frame | ||
| 15 | + 0: 1,1,2,5,1,1,3,3,0,0,3,3,0,0,3,3). Post-filter the diff bleeds left to | ||
| 16 | + x=317, which is a deblock artefact, not the cause. | ||
| 17 | +- 326839 of 393216 bytes differ => entropy desync from that block on, not a | ||
| 18 | + reconstruction rounding defect. | ||
| 19 | +- CONTROL: the same stream encoded with `--enable-ab-partitions=0` | ||
| 20 | + (`$HOME/.cache/sb128c-r9/noab.obu`, `mknoab.sh`) diverges at the SAME place. | ||
| 21 | + The defect is r8's `decode_block_128rect` / the 128-root VERT arm, reached | ||
| 22 | + only now that the AB refusal no longer short-circuits the compare (class | ||
| 23 | + `refusal-hides-a-defect`). | ||
| 24 | +- Frame 0 of every failing arm contains ZERO AB partitions -- the first AB in | ||
| 25 | + `ab18.obu` is the 38th 128 root (frame 2). | ||
| 26 | + | ||
| 27 | +## Where to look first | ||
| 28 | + | ||
| 29 | +The right 64x128 half at (mi_row 0, mi_col 80). Suspects, cheapest first: | ||
| 30 | +1. `decode_block_128rect`'s mode-info read for a block whose LEFT neighbour is | ||
| 31 | + the other half of the same root (`read_intra_mode_rect` ctx / neighbour | ||
| 32 | + record of the left half at 64-px granularity). | ||
| 33 | +2. The left half's neighbour recording: r8 stamps the lf/skip grids with the | ||
| 34 | + resolved unit size, so a 64x128 block records 2 units of 64 -- check | ||
| 35 | + `record_mi_luma` / `fill_skip_grid` cover the full 64x128 footprint. | ||
| 36 | +3. A cross-decoder msac RANGE ladder at that block's entry (never tell()). | ||
| 37 | + | ||
| 38 | +## Cheap repro | ||
| 39 | + | ||
| 40 | + ~/.cache/sb128c-r9/cmp.sh ~/.cache/sb128c-r9/ab45.obu # post-filter | ||
| 41 | + EC_AV1_PREFILT_DUMP=... aomdec / decode_probe # pre-filter | ||
| 42 | + | ||
| 43 | +## Still owed | ||
| 44 | + | ||
| 45 | +- The full suite was never run this round (deadline). Expect 388 tests, 1 | ||
| 46 | + failure (the new gate) until the above is fixed. | ||
| 47 | +- `gate_coverage.rs` was NOT touched: the new gate passes | ||
| 48 | + `--enable-ab-partitions=1`, which other gates already do, so its | ||
| 49 | + `NEVER_EXERCISED` lists are unaffected -- CONFIRM by running | ||
| 50 | + `cargo test -p ec-av1 --lib gate_coverage`. | ||
lanes/sb128c-r9.report.mdadded+81 -0
| @@ -0,0 +1,81 @@ | |||
| 1 | +# lane-sb128c r9 -- the four AB shapes at the 128 root (key + inter) | ||
| 2 | + | ||
| 3 | +Branch `lane-sb128c`, worktree `edith_codecs-sb128c`, | ||
| 4 | +`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128c`. | ||
| 5 | + | ||
| 6 | +## What changed | ||
| 7 | + | ||
| 8 | +- `crates/ec-av1/src/decode.rs` `read_sb128_root`: the AB refusal is LIFTED. | ||
| 9 | + Values 4..7 now count into `PART128_AB_HITS` (`part128_ab_hits()`), and the | ||
| 10 | + `_` arm refuses only a value outside the 8-symbol alphabet. | ||
| 11 | +- `crates/ec-av1/src/decode.rs` key-frame tile: a new arm decodes each AB | ||
| 12 | + shape as two 64x64 squares (`decode_block`, `SB`, `Luma64`/`Chroma32`) plus | ||
| 13 | + one 128x64/64x128 half (`decode_block_128rect`, r8) in libaom | ||
| 14 | + `decode_partition`'s order -- HORZ_A = TL, TR, bottom half; HORZ_B = top | ||
| 15 | + half, BL, BR; VERT_A = TL, BL, right half; VERT_B = left half, TR, BR -- | ||
| 16 | + with `Reach::vert_ab_partition` live for the two VERT arms (r6 visit order, | ||
| 17 | + class `visit-order-changes-availability`), `CDEF_TRANSMITTED` reset per | ||
| 18 | + piece (one CDEF unit each, so libaom's per-unit `cdef_transmitted[index]`), | ||
| 19 | + and the half's `cdef_idx` copied to the second 64x64 unit it covers. | ||
| 20 | +- `crates/ec-av1/src/decode.rs` inter tile: the same four arms through | ||
| 21 | + `inter_piece!` (`SB`/`SB*2` with `ww`/`wh` = the true footprint). | ||
| 22 | +- `crates/ec-av1/src/stream.rs` `sb128_ab_counters()`; new gate | ||
| 23 | + `a_real_aomenc_sb128_ab_partition_at_the_128_root_decodes_pixel_exact`. | ||
| 24 | +- `crates/ec-av1/src/refusal_inventory.rs`: the 128-root AB string is replaced | ||
| 25 | + by the alphabet-bound one. | ||
| 26 | + | ||
| 27 | +## Gate: RED -- and the divergence is NOT in the AB code | ||
| 28 | + | ||
| 29 | +`cargo test -p ec-av1 --lib ab_partition_at_the_128_root -- --nocapture` | ||
| 30 | +fails on its FIRST arm: `sb128c-ab-18-512x512` decode-order frame 0 differs | ||
| 31 | +from the oracle at byte 319 (ours 105 vs 107), 326839 bytes differ. | ||
| 32 | + | ||
| 33 | +Frame 0 of that stream contains **no AB partition at all** (`EC_AV1_TRACE` | ||
| 34 | +`partition_w128` values for its 16 roots are 2,2,2,0,0,3,3,0,... ; the first | ||
| 35 | +value in 4..7 is the 38th root, i.e. frame 2). The first differing sample is | ||
| 36 | +(x=317..319, y=0), inside the LEFT 64x128 half of the third 128 root, which is | ||
| 37 | +`PARTITION_VERT` -- r8's `decode_block_128rect`, untouched this round. | ||
| 38 | + | ||
| 39 | +Hand sweep of four 512x512/384x320 arms (`$HOME/.cache/sb128c-r9/cmp.sh`, | ||
| 40 | +oracle `aomdec` vs our `decode_probe`, `EC_AV1_FINAL_DUMP` per frame): | ||
| 41 | + | ||
| 42 | +| stream | first differing byte (frame 0) | AB values in stream | | ||
| 43 | +|---|---|---| | ||
| 44 | +| 512x512 cq18 key | 320 (x=319,y=0) | HORZ_A x3 | | ||
| 45 | +| 512x512 cq45 key | 318 | HORZ_B x1, VERT_B x1 | | ||
| 46 | +| 512x512 cq45 inter (`--kf-max-dist=100`) | 319 | HORZ_A x1 | | ||
| 47 | +| 384x320 cq55 key | 95531 (x=299,y=248), frame 2 exact | none | | ||
| 48 | +| 512x512 cq45 key, `--enable-ab-partitions=0` | 318 | (aomenc still emitted one HORZ_B) | | ||
| 49 | + | ||
| 50 | +The last row is the control: the SAME byte-318 divergence with the AB flag | ||
| 51 | +off, so the 512x512 defect is independent of this round's code. | ||
| 52 | + | ||
| 53 | +EVIDENCE: $HOME/.cache/sb128c-gate-r9.log + $HOME/.cache/sb128c-r9/{ab18,ab45,abi45,ab55,noab}.obu | cargo test ab_partition_at_the_128_root --nocapture; cmp.sh per stream | 5/5 512x512 arms differ at byte 317..320 of frame 0, a frame with zero AB partitions | ||
| 54 | + | ||
| 55 | +## Film (1080p 10-bit AV1) | ||
| 56 | + | ||
| 57 | +| stream | r9 stop | | ||
| 58 | +|---|---| | ||
| 59 | +| `~/.cache/reelc-head.obu` | OK, 48 frames decoded, 1920x792 | | ||
| 60 | +| `-ss 900` 2 s | "an inter 16x16-level AB or 1:4 partition" (another lane) | | ||
| 61 | +| `-ss 9000` 2 s | "an inter SB-level AB partition" (the 64 root, another lane) | | ||
| 62 | + | ||
| 63 | +Unchanged vs r8 -- the 128-root AB was not the film's next wall at these | ||
| 64 | +offsets. | ||
| 65 | + | ||
| 66 | +EVIDENCE: $HOME/.cache/sb128c-r9/{x900,x9000}.obu | decode_probe on head + two 2 s extracts | 48/48 frames on the head, two named refusals from OTHER lanes' 16x16/64-root AB gaps | ||
| 67 | + | ||
| 68 | +## Suite | ||
| 69 | + | ||
| 70 | +NOT run this round (60-minute deadline spent on the divergence bisection). | ||
| 71 | +The new gate is RED, so the suite is 388 tests with 1 failure until the | ||
| 72 | +512x512 128-rect defect is fixed. | ||
| 73 | + | ||
| 74 | +## Residue | ||
| 75 | + | ||
| 76 | +- fix-now (next round): the 512x512 `decode_block_128rect` divergence at | ||
| 77 | + (x~317, y=0) of a `PARTITION_VERT` 128 root. Pinned streams above; the | ||
| 78 | + `--enable-ab-partitions=0` control isolates it from this round's work. Class | ||
| 79 | + `refusal-hides-a-defect`: r8's gate only ran 192x256/384x320 VERT sources, | ||
| 80 | + which never reached it. | ||
| 81 | +- deferred: intra `tx_depth` > 0 at the 128 root (r8 residue, unchanged). | ||