wip(merge): lane-sub8 merged into main 61c6a5b -- conflicts resolved, gates RED, NOT for main
Browse files at this commit10 changed files +1372 -91
- crates/ec-av1/src/decode.rs +587 -65
- crates/ec-av1/src/encode.rs +55 -20
- crates/ec-av1/src/gate_coverage.rs +1 -5
- crates/ec-av1/src/refusal_inventory.rs +3 -1
- crates/ec-av1/src/stream.rs +200 -0
- lanes/COMMON-20260901.md +76 -0
- lanes/sub8-r1.report.md +206 -0
- lanes/sub8-r4.report.md +74 -0
- lanes/sub8-r5.report.md +93 -0
- lanes/sub8-r6.report.md +77 -0
crates/ec-av1/src/decode.rsmodified+587 -65
| @@ -1583,6 +1583,21 @@ pub(crate) fn angle_delta_hits() -> usize { | ||
| 1583 | 1583 | pub(crate) fn tx_class1_hits() -> usize { |
| 1584 | 1584 | TX_CLASS1_HITS.with(|c| c.get()) |
| 1585 | 1585 | } |
| 1586 | + | |
| 1587 | +// How many `PARTITION_SPLIT` decisions below an 8x8 block (four independent | |
| 1588 | +// `BLOCK_4X4` leaves, spec `decode_partition`'s `bSize < BLOCK_8X8` recursion | |
| 1589 | +// bottom) this thread's decode actually reconstructed -- the same | |
| 1590 | +// before/after counter pattern as [`TX_CLASS1_HITS`], proving a stream | |
| 1591 | +// genuinely exercised the sub-8x8 leaf path rather than every attempt | |
| 1592 | +// coincidentally landing on `PARTITION_NONE`. | |
| 1593 | +thread_local! { | |
| 1594 | + static SUB8_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1595 | +} | |
| 1596 | + | |
| 1597 | +/// Current value of [`SUB8_SPLIT_HITS`]. | |
| 1598 | +pub(crate) fn sub8_split_hits() -> usize { | |
| 1599 | + SUB8_SPLIT_HITS.with(|c| c.get()) | |
| 1600 | +} | |
| 1586 | 1601 | const SUB_MI: u32 = 4; |
| 1587 | 1602 | const MI: usize = 4; |
| 1588 | 1603 | const SB: usize = 64; |
| @@ -2486,6 +2501,26 @@ struct Neighbours { | ||
| 2486 | 2501 | /// one was coded at 8x8. |
| 2487 | 2502 | above_side_mi: Vec<usize>, |
| 2488 | 2503 | left_side_mi: Vec<usize>, |
| 2504 | + /// The luma `mode` of the last `BLOCK_4X4` leaf decoded at each mi column | |
| 2505 | + /// / row, with the mi position it was written at | |
| 2506 | + /// (`(usize::MAX, _)` = never written). `above_mode`/`left_mode` are on | |
| 2507 | + /// the coarse 16x16 grid, which cannot distinguish the two 4x4 leaves an | |
| 2508 | + /// 8x8 `PARTITION_SPLIT` puts in one mi column; libaom's intra-mode | |
| 2509 | + /// context reads `mi(row, col-1)`/`mi(row-1, col)` exactly, so a sub-8x8 | |
| 2510 | + /// leaf whose neighbour is another split group needs that group's leaf 3 | |
| 2511 | + /// (bottom-right), not the leaf the coarse slot happens to hold. Written | |
| 2512 | + /// and read only by [`decode_leaf_split4`]; the position guard makes it | |
| 2513 | + /// fall back to the coarse slot whenever the real neighbour was a block | |
| 2514 | + /// of 8x8 or larger (whose one mode is correct for every row it spans). | |
| 2515 | + sub8_mode_col: Vec<(usize, usize)>, | |
| 2516 | + sub8_mode_row: Vec<(usize, usize)>, | |
| 2517 | + /// The `uv_mode` twin of `sub8_mode_col`/`sub8_mode_row` (lane-sub8 r5): | |
| 2518 | + /// chroma's edge-filter type reads the CHROMA neighbour's `uv_mode` | |
| 2519 | + /// (`get_intra_edge_filter_type`, reconintra.c:974), and the coarse | |
| 2520 | + /// [`SUB`] slots cannot name it once a 16x16 is split into 8x8 leaves -- | |
| 2521 | + /// the leaf above writes the same row slot the block to the left owns. | |
| 2522 | + uv_mode_col: Vec<(usize, usize)>, | |
| 2523 | + uv_mode_row: Vec<(usize, usize)>, | |
| 2489 | 2524 | /// Whether the block above/left of this column/row was coded `skip` -- |
| 2490 | 2525 | /// an inter frame's own `skip` context (spec `SkipContext`), which the |
| 2491 | 2526 | /// key-frame writer never tracks (its skip context is always zero); a |
| @@ -2633,6 +2668,10 @@ impl Neighbours { | ||
| 2633 | 2668 | left_side: vec![SB; rows], |
| 2634 | 2669 | above_side_mi: vec![SB; cols * (SUB / MI)], |
| 2635 | 2670 | left_side_mi: vec![SB; rows * (SUB / MI)], |
| 2671 | + sub8_mode_col: vec![(usize::MAX, 0); cols * (SUB / MI)], | |
| 2672 | + sub8_mode_row: vec![(usize::MAX, 0); rows * (SUB / MI)], | |
| 2673 | + uv_mode_col: vec![(usize::MAX, 0); cols * (SUB / MI)], | |
| 2674 | + uv_mode_row: vec![(usize::MAX, 0); rows * (SUB / MI)], | |
| 2636 | 2675 | above_txfm: vec![TXFM_CTX_INIT; cols * (SUB / MI)], |
| 2637 | 2676 | left_txfm: vec![TXFM_CTX_INIT; rows * (SUB / MI)], |
| 2638 | 2677 | // lane-inter8 r2: mi(4px)-granular, not [`SUB`]-granular -- an |
| @@ -2716,6 +2755,14 @@ impl Neighbours { | ||
| 2716 | 2755 | self.above_compound_idx[i] = 0; |
| 2717 | 2756 | self.above_filter[i] = [3u8; 2]; |
| 2718 | 2757 | } |
| 2758 | + // lane-sub8 r6: the mi-granular column maps are per tile too -- a | |
| 2759 | + // stale `(row, mode)` from the tile to the LEFT names an mi row this | |
| 2760 | + // tile's first block would read as its own above neighbour. | |
| 2761 | + let mcol_end = col1_mi.min(self.sub8_mode_col.len()); | |
| 2762 | + for i in col0_mi.min(mcol_end)..mcol_end { | |
| 2763 | + self.sub8_mode_col[i] = (usize::MAX, 0); | |
| 2764 | + self.uv_mode_col[i] = (usize::MAX, 0); | |
| 2765 | + } | |
| 2719 | 2766 | } |
| 2720 | 2767 | |
| 2721 | 2768 | /// Writes a just-decoded block's own palette-Y size/colours (`size == 0` |
| @@ -2984,6 +3031,10 @@ impl Neighbours { | ||
| 2984 | 3031 | self.left_comp_group_idx.iter_mut().for_each(|r| *r = 0); |
| 2985 | 3032 | self.left_compound_idx.iter_mut().for_each(|r| *r = 0); |
| 2986 | 3033 | self.left_filter.iter_mut().for_each(|f| *f = [3u8; 2]); |
| 3034 | + // lane-sub8 r6: mi-granular row maps reset with the rest of the left | |
| 3035 | + // context (a tile/SB-row boundary has no left neighbour). | |
| 3036 | + self.sub8_mode_row.iter_mut().for_each(|s| *s = (usize::MAX, 0)); | |
| 3037 | + self.uv_mode_row.iter_mut().for_each(|s| *s = (usize::MAX, 0)); | |
| 2987 | 3038 | } |
| 2988 | 3039 | |
| 2989 | 3040 | /// Records a block's `skip`/`is_inter`/`interp_filter` state for the next |
| @@ -3272,6 +3323,85 @@ impl Neighbours { | ||
| 3272 | 3323 | /// [`Self::partition_ctx`]) are the neighbour's own width/height per the |
| 3273 | 3324 | /// spec's per-edge partition-context rule, so a true rectangular block |
| 3274 | 3325 | /// naturally wants two different values here rather than one. |
| 3326 | + /// Writes this block's luma `mode` into the mi-granular | |
| 3327 | + /// [`Self::sub8_mode_col`]/[`Self::sub8_mode_row`] maps, keyed by the mi | |
| 3328 | + /// position a *later* neighbour would read it from: the block's LAST mi | |
| 3329 | + /// row for every column it spans (what the block below reads via | |
| 3330 | + /// `mi(row-1, col)`) and its LAST mi column for every row (what the | |
| 3331 | + /// block to the right reads via `mi(row, col-1)`). Only sub-8x8 leaves | |
| 3332 | + /// read these back, and only when the recorded position is exactly their | |
| 3333 | + /// own neighbour -- see [`Self::sub8_mode_col`]'s doc. | |
| 3334 | + fn record_mode_mi(&mut self, mi_r: usize, mi_c: usize, mi_w: usize, mi_h: usize, mode: usize) { | |
| 3335 | + let (last_r, last_c) = (mi_r + mi_h - 1, mi_c + mi_w - 1); | |
| 3336 | + for cell in 0..mi_w { | |
| 3337 | + if let Some(slot) = self.sub8_mode_col.get_mut(mi_c + cell) { | |
| 3338 | + *slot = (last_r, mode); | |
| 3339 | + } | |
| 3340 | + } | |
| 3341 | + for cell in 0..mi_h { | |
| 3342 | + if let Some(slot) = self.sub8_mode_row.get_mut(mi_r + cell) { | |
| 3343 | + *slot = (last_c, mode); | |
| 3344 | + } | |
| 3345 | + } | |
| 3346 | + } | |
| 3347 | + | |
| 3348 | + /// The mi-exact above/left neighbour luma mode for a block whose top-left | |
| 3349 | + /// mi is `(mi_r, mi_c)`, or `None` when no block has recorded that exact | |
| 3350 | + /// mi position (then the coarse [`SUB`]-grid slot is right by | |
| 3351 | + /// construction). See [`Self::record_mode_mi`]. | |
| 3352 | + fn mode_above_mi(&self, mi_r: usize, mi_c: usize) -> Option<usize> { | |
| 3353 | + match self.sub8_mode_col.get(mi_c) { | |
| 3354 | + Some(&(row, m)) if mi_r > self.tile_row0_mi && row == mi_r - 1 => Some(m), | |
| 3355 | + _ => None, | |
| 3356 | + } | |
| 3357 | + } | |
| 3358 | + | |
| 3359 | + fn mode_left_mi(&self, mi_r: usize, mi_c: usize) -> Option<usize> { | |
| 3360 | + match self.sub8_mode_row.get(mi_r) { | |
| 3361 | + Some(&(col, m)) if mi_c > self.tile_col0_mi && col == mi_c - 1 => Some(m), | |
| 3362 | + _ => None, | |
| 3363 | + } | |
| 3364 | + } | |
| 3365 | + | |
| 3366 | + /// [`Self::record_mode_mi`] for the block's `uv_mode`, into | |
| 3367 | + /// [`Self::uv_mode_col`]/[`Self::uv_mode_row`]. | |
| 3368 | + fn record_uv_mode_mi( | |
| 3369 | + &mut self, | |
| 3370 | + mi_r: usize, | |
| 3371 | + mi_c: usize, | |
| 3372 | + mi_w: usize, | |
| 3373 | + mi_h: usize, | |
| 3374 | + uv_mode: usize, | |
| 3375 | + ) { | |
| 3376 | + let (last_r, last_c) = (mi_r + mi_h - 1, mi_c + mi_w - 1); | |
| 3377 | + for cell in 0..mi_w { | |
| 3378 | + if let Some(slot) = self.uv_mode_col.get_mut(mi_c + cell) { | |
| 3379 | + *slot = (last_r, uv_mode); | |
| 3380 | + } | |
| 3381 | + } | |
| 3382 | + for cell in 0..mi_h { | |
| 3383 | + if let Some(slot) = self.uv_mode_row.get_mut(mi_r + cell) { | |
| 3384 | + *slot = (last_c, uv_mode); | |
| 3385 | + } | |
| 3386 | + } | |
| 3387 | + } | |
| 3388 | + | |
| 3389 | + /// Whether either mi-exact chroma neighbour of the block at `(mi_r, mi_c)` | |
| 3390 | + /// coded a smooth `uv_mode` -- libaom's `intra_edge_filter_type` for | |
| 3391 | + /// planes 1/2. Falls back to the coarse [`SUB`] slot on whichever axis no | |
| 3392 | + /// block has recorded the exact neighbouring mi. | |
| 3393 | + fn smooth_uv_neighbour(&self, mi_r: usize, mi_c: usize, r: usize, c: usize) -> bool { | |
| 3394 | + let above = match self.uv_mode_col.get(mi_c) { | |
| 3395 | + Some(&(row, m)) if mi_r > self.tile_row0_mi && row == mi_r - 1 => m, | |
| 3396 | + _ => self.above_uv_mode[c], | |
| 3397 | + }; | |
| 3398 | + let left = match self.uv_mode_row.get(mi_r) { | |
| 3399 | + Some(&(col, m)) if mi_c > self.tile_col0_mi && col == mi_c - 1 => m, | |
| 3400 | + _ => self.left_uv_mode[r], | |
| 3401 | + }; | |
| 3402 | + is_smooth_mode(above) || is_smooth_mode(left) | |
| 3403 | + } | |
| 3404 | + | |
| 3275 | 3405 | fn record_rect( |
| 3276 | 3406 | &mut self, |
| 3277 | 3407 | at: (usize, usize), |
| @@ -3292,6 +3422,8 @@ impl Neighbours { | ||
| 3292 | 3422 | self.left_uv_mode[r + cell] = uv_mode; |
| 3293 | 3423 | self.left_side[r + cell] = h; |
| 3294 | 3424 | } |
| 3425 | + self.record_mode_mi(r * (SUB / MI), c * (SUB / MI), w / MI, h / MI, mode); | |
| 3426 | + self.record_uv_mode_mi(r * (SUB / MI), c * (SUB / MI), w / MI, h / MI, uv_mode); | |
| 3295 | 3427 | self.record_mi_rect((r * (SUB / MI), c * (SUB / MI)), w, h, grids); |
| 3296 | 3428 | } |
| 3297 | 3429 | |
| @@ -3421,6 +3553,8 @@ impl Neighbours { | ||
| 3421 | 3553 | } |
| 3422 | 3554 | let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); |
| 3423 | 3555 | let (w_mi, h_mi) = (w / MI, h / MI); |
| 3556 | + self.record_mode_mi(mi_r, mi_c, w_mi, h_mi, mode); | |
| 3557 | + self.record_uv_mode_mi(mi_r, mi_c, w_mi, h_mi, uv_mode); | |
| 3424 | 3558 | for cell in 0..h_mi { |
| 3425 | 3559 | self.left_side_mi[mi_r + cell] = h; |
| 3426 | 3560 | } |
| @@ -4734,6 +4868,11 @@ fn decode_leaf_rect( | ||
| 4734 | 4868 | vec![0i32; chroma_w * chroma_h], |
| 4735 | 4869 | ], |
| 4736 | 4870 | ); |
| 4871 | + // lane-sub8 r6: the caller patches only the coarse `above_mode`/ | |
| 4872 | + // `left_mode` slot (one value for the whole 16x16), so record this | |
| 4873 | + // strip's own span mi-exactly like every square leaf does. | |
| 4874 | + neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, mi_w, mi_h, mode); | |
| 4875 | + neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, mi_w, mi_h, uv_predict_mode); | |
| 4737 | 4876 | neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip); |
| 4738 | 4877 | neighbours.fill_lf_grid_rect(leaf_mi, mi_w, mi_h, bw as u8, bh as u8, 0); |
| 4739 | 4878 | Ok(mode) |
| @@ -5182,7 +5321,7 @@ fn read_intra_mode( | ||
| 5182 | 5321 | } |
| 5183 | 5322 | let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0; |
| 5184 | 5323 | if trace { |
| 5185 | - eprintln!("TRACE skip value={}", skip as i32); | |
| 5324 | + eprintln!("TRACE skip value={} rng={}", skip as i32, dec.debug_state().0); | |
| 5186 | 5325 | } |
| 5187 | 5326 | istep!("skip", skip as i32); |
| 5188 | 5327 | if !seg_id_pre_skip() { |
| @@ -5228,7 +5367,7 @@ fn read_intra_mode( | ||
| 5228 | 5367 | let left_ctx = INTRA_MODE_CTX[left_mode]; |
| 5229 | 5368 | let mode = dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]); |
| 5230 | 5369 | if trace { |
| 5231 | - eprintln!("TRACE y_mode ctx=({above_ctx},{left_ctx}) value={mode}"); | |
| 5370 | + eprintln!("TRACE y_mode ctx=({above_ctx},{left_ctx}) value={mode} rng={}", dec.debug_state().0); | |
| 5232 | 5371 | } |
| 5233 | 5372 | istep!("mode", mode as i32); |
| 5234 | 5373 | let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) { |
| @@ -5250,7 +5389,7 @@ fn read_intra_mode( | ||
| 5250 | 5389 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 5251 | 5390 | }; |
| 5252 | 5391 | if trace { |
| 5253 | - eprintln!("TRACE uv_mode cfl={cfl} y_mode={mode} value={uv_mode}"); | |
| 5392 | + eprintln!("TRACE uv_mode cfl={cfl} y_mode={mode} value={uv_mode} rng={}", dec.debug_state().0); | |
| 5254 | 5393 | } |
| 5255 | 5394 | istep!("uv_mode", uv_mode as i32); |
| 5256 | 5395 | let alpha = if cfl && uv_mode == UV_CFL_PRED { |
| @@ -5369,7 +5508,7 @@ fn read_intra_mode( | ||
| 5369 | 5508 | let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[class]) != 0; |
| 5370 | 5509 | if trace { |
| 5371 | 5510 | eprintln!( |
| 5372 | - "TRACE use_filter_intra side={side} value={}", | |
| 5511 | + "TRACE use_filter_intra side={side} rng={} value={}", dec.debug_state().0, | |
| 5373 | 5512 | use_filter_intra as i32 |
| 5374 | 5513 | ); |
| 5375 | 5514 | } |
| @@ -6400,9 +6539,26 @@ fn decode_leaf8( | ||
| 6400 | 6539 | left_mode = pmode; |
| 6401 | 6540 | } |
| 6402 | 6541 | } |
| 6403 | - // See [`PlaneBuf::reconstruct`]'s doc: chroma stays `false` (exact) until | |
| 6404 | - // a smooth/paeth `uv_mode` can reach decode at all. | |
| 6542 | + // The mi-exact neighbour wins over both the coarse 16x16 slot and | |
| 6543 | + // `prev_leaf`: one 16x16 slot cannot hold the two different modes its | |
| 6544 | + // two 8x8 (or four 4x4) columns leave behind, so a leaf whose above/left | |
| 6545 | + // neighbour sits in a split cell read the wrong `kf_y_mode` row. | |
| 6546 | + if let Some(m) = neighbours.mode_above_mi(leaf_mi.0, leaf_mi.1) { | |
| 6547 | + above_mode = m; | |
| 6548 | + } | |
| 6549 | + if let Some(m) = neighbours.mode_left_mi(leaf_mi.0, leaf_mi.1) { | |
| 6550 | + left_mode = m; | |
| 6551 | + } | |
| 6405 | 6552 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 6553 | + // Chroma's edge-filter type reads the CHROMA neighbour's `uv_mode` | |
| 6554 | + // (`get_intra_edge_filter_type`, reconintra.c:974), never the luma mode | |
| 6555 | + // this leaf's `smooth_neighbor` is built from -- passing `false` here | |
| 6556 | + // filtered a directional chroma block's edge at the wrong strength | |
| 6557 | + // (lane-sub8 r5: 4 pixels of one 8x8 leaf's chroma, deltas 1..3). | |
| 6558 | + // The `uv_mode` neighbours are mi-exact (`uv_mode_col`/`uv_mode_row`), | |
| 6559 | + // with the coarse [`SUB`] slot as the fallback when no block recorded | |
| 6560 | + // that exact mi cell. | |
| 6561 | + let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c); | |
| 6406 | 6562 | if smooth_neighbor { |
| 6407 | 6563 | SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); |
| 6408 | 6564 | } |
| @@ -6431,6 +6587,9 @@ fn decode_leaf8( | ||
| 6431 | 6587 | } else { |
| 6432 | 6588 | uv_mode |
| 6433 | 6589 | }; |
| 6590 | + neighbours.above_uv_mode[c] = uv_predict_mode; | |
| 6591 | + neighbours.left_uv_mode[r] = uv_predict_mode; | |
| 6592 | + neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); | |
| 6434 | 6593 | // `TxMode::Select`'s `tx_depth` at an 8x8 leaf (spec 5.11.16): the only |
| 6435 | 6594 | // depths an 8x8 block offers are `TX8` (depth 0) and `TX4` (depth 1, |
| 6436 | 6595 | // which splits the leaf's own 8x8 prediction into a 2x2 grid of 4x4 |
| @@ -6469,7 +6628,7 @@ fn decode_leaf8( | ||
| 6469 | 6628 | &vec![0i32; 16], |
| 6470 | 6629 | alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), |
| 6471 | 6630 | None, |
| 6472 | - false, | |
| 6631 | + smooth_neighbor_uv, | |
| 6473 | 6632 | ); |
| 6474 | 6633 | v.reconstruct( |
| 6475 | 6634 | cpx, |
| @@ -6481,7 +6640,7 @@ fn decode_leaf8( | ||
| 6481 | 6640 | &vec![0i32; 16], |
| 6482 | 6641 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), |
| 6483 | 6642 | None, |
| 6484 | - false, | |
| 6643 | + smooth_neighbor_uv, | |
| 6485 | 6644 | ); |
| 6486 | 6645 | luma_grid = vec![0i32; 64]; |
| 6487 | 6646 | u_grid = vec![0i32; 16]; |
| @@ -6535,7 +6694,7 @@ fn decode_leaf8( | ||
| 6535 | 6694 | alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), |
| 6536 | 6695 | None, |
| 6537 | 6696 | None, |
| 6538 | - false, | |
| 6697 | + smooth_neighbor_uv, | |
| 6539 | 6698 | )?; |
| 6540 | 6699 | v_grid = read_plane( |
| 6541 | 6700 | dec, |
| @@ -6557,7 +6716,7 @@ fn decode_leaf8( | ||
| 6557 | 6716 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), |
| 6558 | 6717 | None, |
| 6559 | 6718 | None, |
| 6560 | - false, | |
| 6719 | + smooth_neighbor_uv, | |
| 6561 | 6720 | )?; |
| 6562 | 6721 | } else { |
| 6563 | 6722 | // `tx_depth` resolved this leaf's luma to `TX4`: a 2x2 raster-order |
| @@ -6633,7 +6792,7 @@ fn decode_leaf8( | ||
| 6633 | 6792 | alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), |
| 6634 | 6793 | None, |
| 6635 | 6794 | None, |
| 6636 | - false, | |
| 6795 | + smooth_neighbor_uv, | |
| 6637 | 6796 | )?; |
| 6638 | 6797 | v_grid = read_plane( |
| 6639 | 6798 | dec, |
| @@ -6655,7 +6814,7 @@ fn decode_leaf8( | ||
| 6655 | 6814 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), |
| 6656 | 6815 | None, |
| 6657 | 6816 | None, |
| 6658 | - false, | |
| 6817 | + smooth_neighbor_uv, | |
| 6659 | 6818 | )?; |
| 6660 | 6819 | // `record_split_luma` expects a `record`-style `(r, c)` position in |
| 6661 | 6820 | // `SUB`-grid units and rescales it by `SUB / MI`; `leaf_mi` is |
| @@ -6687,14 +6846,290 @@ fn decode_leaf8( | ||
| 6687 | 6846 | } |
| 6688 | 6847 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 6689 | 6848 | neighbours.fill_lf_grid(leaf_mi, 2, 4, 0); |
| 6849 | + neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode); | |
| 6690 | 6850 | return Ok(mode); |
| 6691 | 6851 | } |
| 6692 | 6852 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); |
| 6693 | 6853 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 6694 | 6854 | neighbours.fill_lf_grid(leaf_mi, 2, 8, 0); |
| 6855 | + neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode); | |
| 6695 | 6856 | Ok(mode) |
| 6696 | 6857 | } |
| 6697 | 6858 | |
| 6859 | +/// `read_intra_frame_mode_info`'s mode-info read for one `BLOCK_4X4` leaf | |
| 6860 | +/// below an 8x8 partition (spec `decode_partition`'s `bSize < BLOCK_8X8` | |
| 6861 | +/// bottom, where no partition symbol is read at all -- `decode_block` runs | |
| 6862 | +/// directly). No palette (`av1_allow_palette` needs both dims >= 8, spec | |
| 6863 | +/// blockd.h) and no `read_tx_size` (a sub-8x8 block's transform is always | |
| 6864 | +/// its own bsize, spec 5.11.16). `has_chroma` follows `is_chroma_reference` | |
| 6865 | +/// (spec/libaom `av1_common_int.h`): for 4:2:0, only the bottom-right leaf | |
| 6866 | +/// of the 2x2 4x4 group carries chroma syntax at all. | |
| 6867 | +#[allow(clippy::too_many_arguments)] | |
| 6868 | +fn read_intra_mode_sub8( | |
| 6869 | + dec: &mut SymbolDecoder, | |
| 6870 | + cdfs: &mut Cdfs, | |
| 6871 | + above_mode: usize, | |
| 6872 | + left_mode: usize, | |
| 6873 | + has_chroma: bool, | |
| 6874 | + enable_filter_intra: bool, | |
| 6875 | + skip_ctx: usize, | |
| 6876 | + allow_intrabc: bool, | |
| 6877 | + mi_r: usize, | |
| 6878 | + mi_c: usize, | |
| 6879 | +) -> Result<(bool, usize, i32, Option<(usize, i32, Option<(i32, i32)>)>, Option<usize>)> { | |
| 6880 | + let trace = std::env::var_os("EC_AV1_TRACE").is_some(); | |
| 6881 | + let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0; | |
| 6882 | + if trace { | |
| 6883 | + eprintln!("TRACE sub8 skip mi=({mi_r},{mi_c}) ctx={skip_ctx} value={} rng={}", skip as i32, dec.debug_state().0); | |
| 6884 | + } | |
| 6885 | + maybe_read_cdef_idx(dec, mi_r, mi_c, skip); | |
| 6886 | + maybe_read_delta_q(dec, cdfs, mi_r, mi_c, false, skip); | |
| 6887 | + maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, false, skip); | |
| 6888 | + if allow_intrabc { | |
| 6889 | + let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; | |
| 6890 | + if use_intrabc { | |
| 6891 | + return Err(unsupported( | |
| 6892 | + "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)", | |
| 6893 | + )); | |
| 6894 | + } | |
| 6895 | + } | |
| 6896 | + let above_ctx = INTRA_MODE_CTX[above_mode]; | |
| 6897 | + let left_ctx = INTRA_MODE_CTX[left_mode]; | |
| 6898 | + let mode = dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]); | |
| 6899 | + if trace { | |
| 6900 | + eprintln!("TRACE sub8 y_mode mi=({mi_r},{mi_c}) ctx=({above_ctx},{left_ctx}) value={mode} rng={}", dec.debug_state().0); | |
| 6901 | + } | |
| 6902 | + // No `angle_delta` at all below 8x8: spec 5.11.6's `intra_angle_info_y`/ | |
| 6903 | + // `_uv` are gated on `MiSize >= BLOCK_8X8` (libaom `av1_use_angle_delta`, | |
| 6904 | + // blockd.h), so a directional mode on a `BLOCK_4X4` leaf carries no delta | |
| 6905 | + // symbol. Reading one consumed a symbol the encoder never wrote and | |
| 6906 | + // desynced the tile at the very next element. | |
| 6907 | + let angle_delta_y = 0; | |
| 6908 | + let chroma = if has_chroma { | |
| 6909 | + let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]); | |
| 6910 | + if trace { | |
| 6911 | + eprintln!("TRACE sub8 uv_mode value={uv_mode} rng={}", dec.debug_state().0); | |
| 6912 | + } | |
| 6913 | + if (9..=12).contains(&uv_mode) { | |
| 6914 | + SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); | |
| 6915 | + } | |
| 6916 | + let alpha = if uv_mode == UV_CFL_PRED { | |
| 6917 | + Some(read_cfl_alphas(dec, cdfs)) | |
| 6918 | + } else { | |
| 6919 | + None | |
| 6920 | + }; | |
| 6921 | + if (V_PRED..=D67_PRED).contains(&uv_mode) { | |
| 6922 | + DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); | |
| 6923 | + } | |
| 6924 | + // See the luma comment above: no angle delta below 8x8. | |
| 6925 | + let angle_delta_uv = 0; | |
| 6926 | + Some((uv_mode, angle_delta_uv, alpha)) | |
| 6927 | + } else { | |
| 6928 | + None | |
| 6929 | + }; | |
| 6930 | + let mut filter_intra = None; | |
| 6931 | + if mode == DC_PRED && enable_filter_intra { | |
| 6932 | + // `BLOCK_4X4`'s own row (class 0, `filter_intra_size_class(4)`) -- | |
| 6933 | + // every sub-8x8 leaf here is a `BLOCK_4X4`. | |
| 6934 | + let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[0]) != 0; | |
| 6935 | + if trace { | |
| 6936 | + eprintln!("TRACE sub8 use_filter_intra value={}", use_filter_intra as i32); | |
| 6937 | + } | |
| 6938 | + if use_filter_intra { | |
| 6939 | + FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); | |
| 6940 | + let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); | |
| 6941 | + filter_intra = Some(fi_mode); | |
| 6942 | + } | |
| 6943 | + } | |
| 6944 | + Ok((skip, mode, angle_delta_y, chroma, filter_intra)) | |
| 6945 | +} | |
| 6946 | + | |
| 6947 | +/// Decodes a `PARTITION_SPLIT` of one 8x8 block into four `BLOCK_4X4` leaves | |
| 6948 | +/// (spec `decode_partition`'s recursion bottom), sharing [`decode_leaf8`]'s | |
| 6949 | +/// own signature so its caller's `prev_leaf`/`above_mode`/`left_mode` | |
| 6950 | +/// bookkeeping needs no change. Each leaf reads its own luma mode info, | |
| 6951 | +/// neighboured off the *previously decoded leaf in this same group* on | |
| 6952 | +/// whichever axis is adjacent (mirroring [`decode_leaf8`]'s own `prev_leaf` | |
| 6953 | +/// pattern, one level deeper); chroma is read and reconstructed exactly | |
| 6954 | +/// once, on the last (bottom-right) leaf, at the whole 8x8 group's own 4x4 | |
| 6955 | +/// chroma unit -- [`read_intra_mode_sub8`]'s doc has the `is_chroma_reference` | |
| 6956 | +/// derivation. | |
| 6957 | +#[allow(clippy::too_many_arguments)] | |
| 6958 | +fn decode_leaf_split4( | |
| 6959 | + dec: &mut SymbolDecoder, | |
| 6960 | + cdfs: &mut Cdfs, | |
| 6961 | + neighbours: &mut Neighbours, | |
| 6962 | + outer_at: (usize, usize), | |
| 6963 | + leaf_mi: (usize, usize), | |
| 6964 | + scan4: &[u16], | |
| 6965 | + prev_leaf: Option<((usize, usize), usize)>, | |
| 6966 | + y: &mut PlaneBuf, | |
| 6967 | + u: &mut PlaneBuf, | |
| 6968 | + v: &mut PlaneBuf, | |
| 6969 | + base_q_idx: u8, | |
| 6970 | + enable_filter_intra: bool, | |
| 6971 | + allow_intrabc: bool, | |
| 6972 | + reduced_tx_set: bool, | |
| 6973 | + // Returns `(below_mode, right_mode)`: the mode a neighbour BELOW this 8x8 | |
| 6974 | + // group sees (its bottom-left 4x4, libaom reads mi(row-1, col)) and the | |
| 6975 | + // one a neighbour to its RIGHT sees (its top-right 4x4, mi(row, col-1)). | |
| 6976 | +) -> Result<(usize, usize)> { | |
| 6977 | + SUB8_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | |
| 6978 | + let (r, c) = outer_at; | |
| 6979 | + let mut above_mode = neighbours.above_mode[c]; | |
| 6980 | + let mut left_mode = neighbours.left_mode[r]; | |
| 6981 | + if let Some(((pr, pc), pmode)) = prev_leaf { | |
| 6982 | + if pc == leaf_mi.1 && leaf_mi.0 == pr + 2 { | |
| 6983 | + above_mode = pmode; | |
| 6984 | + } else if pr == leaf_mi.0 && leaf_mi.1 == pc + 2 { | |
| 6985 | + left_mode = pmode; | |
| 6986 | + } | |
| 6987 | + } | |
| 6988 | + // See `decode_leaf8`'s own `smooth_neighbor_uv`: the chroma edge-filter | |
| 6989 | + // type is the chroma neighbours' `uv_mode`, mi-exact where recorded. | |
| 6990 | + let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c); | |
| 6991 | + let mut leaf_modes = [0usize; 4]; | |
| 6992 | + let mut leaf_skips = [false; 4]; | |
| 6993 | + let mut last_uv: Option<(usize, i32, Option<(i32, i32)>)> = None; | |
| 6994 | + for i in 0..4usize { | |
| 6995 | + let (dr, dc) = (i / 2, i % 2); | |
| 6996 | + let lmi = (leaf_mi.0 + dr, leaf_mi.1 + dc); | |
| 6997 | + // Neighbour modes at real mi granularity: inside the group the | |
| 6998 | + // sibling leaf, outside it the split-leaf map when the adjacent mi | |
| 6999 | + // was itself a 4x4 leaf, else the coarse 16x16 slot (see | |
| 7000 | + // `sub8_mode_col`'s doc). | |
| 7001 | + let leaf_above = if dr == 0 { | |
| 7002 | + neighbours.mode_above_mi(lmi.0, lmi.1).unwrap_or(above_mode) | |
| 7003 | + } else { | |
| 7004 | + leaf_modes[i - 2] | |
| 7005 | + }; | |
| 7006 | + let leaf_left = if dc == 0 { | |
| 7007 | + neighbours.mode_left_mi(lmi.0, lmi.1).unwrap_or(left_mode) | |
| 7008 | + } else { | |
| 7009 | + leaf_modes[i - 1] | |
| 7010 | + }; | |
| 7011 | + let has_chroma = i == 3; | |
| 7012 | + let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1); | |
| 7013 | + let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8( | |
| 7014 | + dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra, skip_ctx, | |
| 7015 | + allow_intrabc, lmi.0, lmi.1, | |
| 7016 | + )?; | |
| 7017 | + leaf_modes[i] = mode; | |
| 7018 | + leaf_skips[i] = skip; | |
| 7019 | + neighbours.record_mode_mi(lmi.0, lmi.1, 1, 1, mode); | |
| 7020 | + let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); | |
| 7021 | + if smooth_neighbor { | |
| 7022 | + SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | |
| 7023 | + } | |
| 7024 | + let (px, py) = (lmi.1 * MI, lmi.0 * MI); | |
| 7025 | + let reach = Reach::of(4, px, py, y.width, y.height); | |
| 7026 | + if skip { | |
| 7027 | + y.reconstruct(px, py, 4, mode, angle_delta_y, reach, &vec![0i32; 16], None, filter_intra, smooth_neighbor); | |
| 7028 | + neighbours.record_mi_luma(lmi, 4, &vec![0i32; 16]); | |
| 7029 | + } else { | |
| 7030 | + let tu_around = neighbours.around_mi(lmi, 4)[0]; | |
| 7031 | + // A `BLOCK_4X4` leaf's luma TU *is* the whole block, so libaom's | |
| 7032 | + // `get_txb_ctx` takes its `plane_bsize == txsize_to_bsize[tx_size]` | |
| 7033 | + // branch: `txb_skip_ctx = 0`, never the neighbour-magnitude table | |
| 7034 | + // (`txb_common.h:400`). Reading the table here decoded `all_zero` | |
| 7035 | + // off the wrong CDF on the very first leaf and desynced the tile. | |
| 7036 | + let tu_grid = read_plane( | |
| 7037 | + dec, | |
| 7038 | + cdfs, | |
| 7039 | + if reduced_tx_set { TxbSet::Luma4 } else { TxbSet::Luma4Set1 }, | |
| 7040 | + scan4, | |
| 7041 | + 0, | |
| 7042 | + tu_around, | |
| 7043 | + mode, | |
| 7044 | + mode, | |
| 7045 | + angle_delta_y, | |
| 7046 | + reach, | |
| 7047 | + y, | |
| 7048 | + px, | |
| 7049 | + py, | |
| 7050 | + 4, | |
| 7051 | + 4, | |
| 7052 | + base_q_idx, | |
| 7053 | + None, | |
| 7054 | + filter_intra, | |
| 7055 | + None, | |
| 7056 | + smooth_neighbor, | |
| 7057 | + )?; | |
| 7058 | + neighbours.record_mi_luma(lmi, 4, &tu_grid); | |
| 7059 | + } | |
| 7060 | + neighbours.fill_skip_grid(lmi, 1, skip); | |
| 7061 | + neighbours.fill_lf_grid(lmi, 1, 4, 0); | |
| 7062 | + if has_chroma { | |
| 7063 | + last_uv = chroma; | |
| 7064 | + } | |
| 7065 | + } | |
| 7066 | + let (gpx, gpy) = (leaf_mi.1 * MI, leaf_mi.0 * MI); | |
| 7067 | + let (cpx, cpy) = (gpx / 2, gpy / 2); | |
| 7068 | + let group_reach = Reach::of(8, gpx, gpy, y.width, y.height); | |
| 7069 | + let (uv_mode, angle_delta_uv, alpha) = | |
| 7070 | + last_uv.expect("i==3 always sets has_chroma, so chroma is always Some"); | |
| 7071 | + let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; | |
| 7072 | + neighbours.above_uv_mode[c] = uv_predict_mode; | |
| 7073 | + neighbours.left_uv_mode[r] = uv_predict_mode; | |
| 7074 | + neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); | |
| 7075 | + let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[3] { | |
| 7076 | + u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], None, None, smooth_neighbor_uv); | |
| 7077 | + v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], None, None, smooth_neighbor_uv); | |
| 7078 | + (vec![0i32; 16], vec![0i32; 16]) | |
| 7079 | + } else { | |
| 7080 | + let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | |
| 7081 | + let chroma_around = neighbours.around_mi(leaf_mi, 8); | |
| 7082 | + let ug = read_plane( | |
| 7083 | + dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode, | |
| 7084 | + angle_delta_uv, group_reach, u, cpx, cpy, 4, TX4, base_q_idx, | |
| 7085 | + alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, | |
| 7086 | + )?; | |
| 7087 | + let vg = read_plane( | |
| 7088 | + dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode, | |
| 7089 | + angle_delta_uv, group_reach, v, cpx, cpy, 4, TX4, base_q_idx, | |
| 7090 | + alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, | |
| 7091 | + )?; | |
| 7092 | + (ug, vg) | |
| 7093 | + }; | |
| 7094 | + // Chroma neighbour bookkeeping for the whole 8x8 group -- mirrors | |
| 7095 | + // [`decode_leaf8`]'s own tx4-chroma section (`record_split_luma`'s | |
| 7096 | + // rescaling is wrong for an already-mi-unit position, so this inlines | |
| 7097 | + // its tail directly at `leaf_mi`, side_mi=2), EXCEPT for the partition | |
| 7098 | + // context value itself. Unlike `decode_leaf8`'s TX4 branch (still one | |
| 7099 | + // `BLOCK_8X8`, `PARTITION_NONE`, transform depth only), this group is | |
| 7100 | + // genuinely four `BLOCK_4X4` blocks (`PARTITION_SPLIT` at the 8x8 | |
| 7101 | + // level, libaom `decode_partition`'s `bsize2`/`subsize` recursion | |
| 7102 | + // bottom). libaom's `update_ext_partition_context` writes | |
| 7103 | + // `partition_context_lookup[subsize]` at the 8x8 slot -- `{30,30}` for | |
| 7104 | + // `BLOCK_8X8` (bit0=0, what `decode_leaf8` already reproduces via | |
| 7105 | + // side_mi=8) but `{31,31}` for `BLOCK_4X4` (bit0=1) here, and | |
| 7106 | + // `partition_ctx_mi`'s `left_side_mi[mi_r]*2 <= side` needs | |
| 7107 | + // `left_side_mi <= 4` to read that bit as 1. Leaving this at 8 (this | |
| 7108 | + // round's bug) makes the very next sibling 8x8's `partition_w8` read | |
| 7109 | + // with the wrong context and desync immediately. | |
| 7110 | + let side_mi = 2; | |
| 7111 | + for cell in 0..side_mi { | |
| 7112 | + neighbours.left_side_mi[leaf_mi.0 + cell] = 4; | |
| 7113 | + neighbours.above_side_mi[leaf_mi.1 + cell] = 4; | |
| 7114 | + } | |
| 7115 | + let round_up_even = |n: usize| n.div_ceil(2) * 2; | |
| 7116 | + let bound_h = round_up_even(neighbours.mi_rows); | |
| 7117 | + let bound_w = round_up_even(neighbours.mi_cols); | |
| 7118 | + let u_state = neighbour_state(&u_grid); | |
| 7119 | + let v_state = neighbour_state(&v_grid); | |
| 7120 | + for cell in 0..side_mi { | |
| 7121 | + if cell < side_mi.min(bound_h.saturating_sub(leaf_mi.0)) { | |
| 7122 | + neighbours.left[leaf_mi.0 + cell][1] = u_state; | |
| 7123 | + neighbours.left[leaf_mi.0 + cell][2] = v_state; | |
| 7124 | + } | |
| 7125 | + if cell < side_mi.min(bound_w.saturating_sub(leaf_mi.1)) { | |
| 7126 | + neighbours.above[leaf_mi.1 + cell][1] = u_state; | |
| 7127 | + neighbours.above[leaf_mi.1 + cell][2] = v_state; | |
| 7128 | + } | |
| 7129 | + } | |
| 7130 | + Ok((leaf_modes[2], leaf_modes[1])) | |
| 7131 | +} | |
| 7132 | + | |
| 6698 | 7133 | /// Spec 7.15.3's `Cdef_Directions`: `(row, col)` offsets for the two primary |
| 6699 | 7134 | /// taps of each of the eight directions; the secondary taps at `dir+2`/`dir-2` |
| 6700 | 7135 | /// (mod 8) reuse the same table. |
| @@ -8777,11 +9212,38 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 8777 | 9212 | // the one or two the edge leaves. |
| 8778 | 9213 | let (mi_row0, mi_col0) = |
| 8779 | 9214 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 8780 | - let mut prev_leaf: Option<((usize, usize), usize)> = None; | |
| 9215 | + // Each 8x8 leaf's intra-mode context | |
| 9216 | + // must see its own siblings: the | |
| 9217 | + // bottom-left leaf's ABOVE neighbour | |
| 9218 | + // is leaf 0, not the previously | |
| 9219 | + // decoded leaf 1 (and the bottom-right | |
| 9220 | + // leaf's above is leaf 1, while | |
| 9221 | + // `prev_leaf` only ever carried the | |
| 9222 | + // immediately preceding one). The | |
| 9223 | + // coarse `above_mode`/`left_mode` | |
| 9224 | + // arrays hold one slot per 16x16, so | |
| 9225 | + // the sibling modes are swapped in | |
| 9226 | + // around each leaf call and restored | |
| 9227 | + // after; the loop tail writes the last | |
| 9228 | + // leaf's mode as before. | |
| 9229 | + let mut sib_modes: [Option<(usize, usize)>; 4] = [None; 4]; | |
| 8781 | 9230 | for i in 0..4 { |
| 8782 | 9231 | let (mr, mc) = |
| 8783 | 9232 | (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2); |
| 8784 | 9233 | let leaf_mi = (mr as usize, mc as usize); |
| 9234 | + let li = i as usize; | |
| 9235 | + let saved_modes = | |
| 9236 | + (neighbours.above_mode[sc], neighbours.left_mode[sr]); | |
| 9237 | + if li >= 2 { | |
| 9238 | + if let Some((below, _)) = sib_modes[li - 2] { | |
| 9239 | + neighbours.above_mode[sc] = below; | |
| 9240 | + } | |
| 9241 | + } | |
| 9242 | + if li % 2 == 1 { | |
| 9243 | + if let Some((_, right)) = sib_modes[li - 1] { | |
| 9244 | + neighbours.left_mode[sr] = right; | |
| 9245 | + } | |
| 9246 | + } | |
| 8785 | 9247 | let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); |
| 8786 | 9248 | let part8 = |
| 8787 | 9249 | dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); |
| @@ -8790,34 +9252,56 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 8790 | 9252 | "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8}" |
| 8791 | 9253 | ); |
| 8792 | 9254 | } |
| 8793 | - if part8 != PARTITION_NONE { | |
| 9255 | + let leaf_mode = if part8 == PARTITION_NONE { | |
| 9256 | + decode_leaf8( | |
| 9257 | + &mut dec, | |
| 9258 | + &mut cdfs, | |
| 9259 | + &mut neighbours, | |
| 9260 | + at16, | |
| 9261 | + leaf_mi, | |
| 9262 | + (&scan8, &scan4), | |
| 9263 | + None, | |
| 9264 | + &mut y, | |
| 9265 | + &mut u, | |
| 9266 | + &mut v, | |
| 9267 | + base_q_idx, | |
| 9268 | + enable_filter_intra, | |
| 9269 | + allow_screen_content_tools, | |
| 9270 | + allow_intrabc, | |
| 9271 | + tx_select, | |
| 9272 | + reduced_tx_set, | |
| 9273 | + ).map(|m| (m, m))? | |
| 9274 | + } else if part8 == PARTITION_SPLIT { | |
| 9275 | + decode_leaf_split4( | |
| 9276 | + &mut dec, | |
| 9277 | + &mut cdfs, | |
| 9278 | + &mut neighbours, | |
| 9279 | + at16, | |
| 9280 | + leaf_mi, | |
| 9281 | + &scan4, | |
| 9282 | + None, | |
| 9283 | + &mut y, | |
| 9284 | + &mut u, | |
| 9285 | + &mut v, | |
| 9286 | + base_q_idx, | |
| 9287 | + enable_filter_intra, | |
| 9288 | + allow_intrabc, | |
| 9289 | + reduced_tx_set, | |
| 9290 | + )? | |
| 9291 | + } else { | |
| 8794 | 9292 | return Err(unsupported( |
| 8795 | - "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)", | |
| 9293 | + "a HORZ/VERT partition below 8x8 (this decoder's transform primitive is square-only; 4x8/8x4 need a real rectangular transform)", | |
| 8796 | 9294 | )); |
| 8797 | - } | |
| 8798 | - let leaf_mode = decode_leaf8( | |
| 8799 | - &mut dec, | |
| 8800 | - &mut cdfs, | |
| 8801 | - &mut neighbours, | |
| 8802 | - at16, | |
| 8803 | - leaf_mi, | |
| 8804 | - (&scan8, &scan4), | |
| 8805 | - prev_leaf, | |
| 8806 | - &mut y, | |
| 8807 | - &mut u, | |
| 8808 | - &mut v, | |
| 8809 | - base_q_idx, | |
| 8810 | - enable_filter_intra, | |
| 8811 | - allow_screen_content_tools, | |
| 8812 | - allow_intrabc, | |
| 8813 | - tx_select, | |
| 8814 | - reduced_tx_set, | |
| 8815 | - )?; | |
| 8816 | - prev_leaf = Some((leaf_mi, leaf_mode)); | |
| 9295 | + }; | |
| 9296 | + neighbours.above_mode[sc] = saved_modes.0; | |
| 9297 | + neighbours.left_mode[sr] = saved_modes.1; | |
| 9298 | + sib_modes[li] = Some(leaf_mode); | |
| 8817 | 9299 | } |
| 8818 | - if let Some((_, mode)) = prev_leaf { | |
| 8819 | - neighbours.above_mode[sc] = mode; | |
| 8820 | - neighbours.left_mode[sr] = mode; | |
| 9300 | + if let Some((below, _)) = sib_modes[2].or(sib_modes[3]).or(sib_modes[0]) { | |
| 9301 | + neighbours.above_mode[sc] = below; | |
| 9302 | + } | |
| 9303 | + if let Some((_, right)) = sib_modes[1].or(sib_modes[3]).or(sib_modes[0]) { | |
| 9304 | + neighbours.left_mode[sr] = right; | |
| 8821 | 9305 | } |
| 8822 | 9306 | continue; |
| 8823 | 9307 | } |
| @@ -8851,9 +9335,25 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 8851 | 9335 | .map(|i| (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2)) |
| 8852 | 9336 | .filter(|&(mr, mc)| mr < mi_rows && mc < mi_cols) |
| 8853 | 9337 | .collect(); |
| 8854 | - let mut prev_leaf: Option<((usize, usize), usize)> = None; | |
| 9338 | + // See the sibling-mode note in the clean | |
| 9339 | + // SPLIT path above. | |
| 9340 | + let mut sib_modes: [Option<(usize, usize)>; 4] = [None; 4]; | |
| 8855 | 9341 | for (mr, mc) in leaf_positions { |
| 8856 | 9342 | let leaf_mi = (mr as usize, mc as usize); |
| 9343 | + let li = (((mr - mi_row0) / 2) * 2 + (mc - mi_col0) / 2) | |
| 9344 | + as usize; | |
| 9345 | + let saved_modes = | |
| 9346 | + (neighbours.above_mode[sc], neighbours.left_mode[sr]); | |
| 9347 | + if li >= 2 { | |
| 9348 | + if let Some((below, _)) = sib_modes[li - 2] { | |
| 9349 | + neighbours.above_mode[sc] = below; | |
| 9350 | + } | |
| 9351 | + } | |
| 9352 | + if li % 2 == 1 { | |
| 9353 | + if let Some((_, right)) = sib_modes[li - 1] { | |
| 9354 | + neighbours.left_mode[sr] = right; | |
| 9355 | + } | |
| 9356 | + } | |
| 8857 | 9357 | let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); |
| 8858 | 9358 | let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); |
| 8859 | 9359 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| @@ -8861,30 +9361,50 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 8861 | 9361 | "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8}" |
| 8862 | 9362 | ); |
| 8863 | 9363 | } |
| 8864 | - if part8 != PARTITION_NONE { | |
| 9364 | + let leaf_mode = if part8 == PARTITION_NONE { | |
| 9365 | + decode_leaf8( | |
| 9366 | + &mut dec, | |
| 9367 | + &mut cdfs, | |
| 9368 | + &mut neighbours, | |
| 9369 | + at16, | |
| 9370 | + leaf_mi, | |
| 9371 | + (&scan8, &scan4), | |
| 9372 | + None, | |
| 9373 | + &mut y, | |
| 9374 | + &mut u, | |
| 9375 | + &mut v, | |
| 9376 | + base_q_idx, | |
| 9377 | + enable_filter_intra, | |
| 9378 | + allow_screen_content_tools, | |
| 9379 | + allow_intrabc, | |
| 9380 | + tx_select, | |
| 9381 | + reduced_tx_set, | |
| 9382 | + ).map(|m| (m, m))? | |
| 9383 | + } else if part8 == PARTITION_SPLIT { | |
| 9384 | + decode_leaf_split4( | |
| 9385 | + &mut dec, | |
| 9386 | + &mut cdfs, | |
| 9387 | + &mut neighbours, | |
| 9388 | + at16, | |
| 9389 | + leaf_mi, | |
| 9390 | + &scan4, | |
| 9391 | + None, | |
| 9392 | + &mut y, | |
| 9393 | + &mut u, | |
| 9394 | + &mut v, | |
| 9395 | + base_q_idx, | |
| 9396 | + enable_filter_intra, | |
| 9397 | + allow_intrabc, | |
| 9398 | + reduced_tx_set, | |
| 9399 | + )? | |
| 9400 | + } else { | |
| 8865 | 9401 | return Err(unsupported( |
| 8866 | - "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)", | |
| 9402 | + "a HORZ/VERT partition below 8x8 (this decoder's transform primitive is square-only; 4x8/8x4 need a real rectangular transform)", | |
| 8867 | 9403 | )); |
| 8868 | - } | |
| 8869 | - let leaf_mode = decode_leaf8( | |
| 8870 | - &mut dec, | |
| 8871 | - &mut cdfs, | |
| 8872 | - &mut neighbours, | |
| 8873 | - at16, | |
| 8874 | - leaf_mi, | |
| 8875 | - (&scan8, &scan4), | |
| 8876 | - prev_leaf, | |
| 8877 | - &mut y, | |
| 8878 | - &mut u, | |
| 8879 | - &mut v, | |
| 8880 | - base_q_idx, | |
| 8881 | - enable_filter_intra, | |
| 8882 | - allow_screen_content_tools, | |
| 8883 | - allow_intrabc, | |
| 8884 | - tx_select, | |
| 8885 | - reduced_tx_set, | |
| 8886 | - )?; | |
| 8887 | - prev_leaf = Some((leaf_mi, leaf_mode)); | |
| 9404 | + }; | |
| 9405 | + neighbours.above_mode[sc] = saved_modes.0; | |
| 9406 | + neighbours.left_mode[sr] = saved_modes.1; | |
| 9407 | + sib_modes[li] = Some(leaf_mode); | |
| 8888 | 9408 | } |
| 8889 | 9409 | // `record()`'s `above_mode`/`left_mode` |
| 8890 | 9410 | // write is a no-op at an 8x8 leaf's own |
| @@ -8892,9 +9412,11 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 8892 | 9412 | // 16x16 slot's leaves are done, from the |
| 8893 | 9413 | // last leaf (mirrors the writer's r15 |
| 8894 | 9414 | // fix). |
| 8895 | - if let Some((_, mode)) = prev_leaf { | |
| 8896 | - neighbours.above_mode[sc] = mode; | |
| 8897 | - neighbours.left_mode[sr] = mode; | |
| 9415 | + if let Some((below, _)) = sib_modes[2].or(sib_modes[3]).or(sib_modes[0]) { | |
| 9416 | + neighbours.above_mode[sc] = below; | |
| 9417 | + } | |
| 9418 | + if let Some((_, right)) = sib_modes[1].or(sib_modes[3]).or(sib_modes[0]) { | |
| 9419 | + neighbours.left_mode[sr] = right; | |
| 8898 | 9420 | } |
| 8899 | 9421 | } |
| 8900 | 9422 | } |
| @@ -15212,7 +15734,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 15212 | 15734 | let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); |
| 15213 | 15735 | if part8 != PARTITION_NONE { |
| 15214 | 15736 | return Err(unsupported( |
| 15215 | - "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)", | |
| 15737 | + "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", | |
| 15216 | 15738 | )); |
| 15217 | 15739 | } |
| 15218 | 15740 | let (skip, is_inter, skip_mode_leaf, compound_ctx8, leaf_refs) = |
crates/ec-av1/src/encode.rsmodified+55 -20
| @@ -1020,7 +1020,7 @@ pub(crate) struct Reach { | ||
| 1020 | 1020 | /// it. Indexed by the block's position in the superblock, in blocks of its own |
| 1021 | 1021 | /// size, as `row * (128 / side) + col` (`Reach::table_stride`) -- libaom's |
| 1022 | 1022 | /// 128, not this crate's 64 superblock -- bit by bit from the low end. |
| 1023 | -const HAS_TOP_RIGHT: [&[u8]; 3] = [ | |
| 1023 | +const HAS_TOP_RIGHT: [&[u8]; 4] = [ | |
| 1024 | 1024 | &[255, 85, 119, 85, 127, 85, 119, 85], |
| 1025 | 1025 | &[95, 87], |
| 1026 | 1026 | // has_tr_8x8 (libaom av1/common/reconintra.c) -- table_stride(8) == 16 |
| @@ -1029,11 +1029,28 @@ const HAS_TOP_RIGHT: [&[u8]; 3] = [ | ||
| 1029 | 1029 | 255, 255, 85, 85, 119, 119, 85, 85, 127, 127, 85, 85, 119, 119, 85, 85, 255, 127, 85, 85, |
| 1030 | 1030 | 119, 119, 85, 85, 127, 127, 85, 85, 119, 119, 85, 85, |
| 1031 | 1031 | ], |
| 1032 | + | |
| 1033 | + // has_tr_4x4 (libaom av1/common/reconintra.c, transcribed verbatim) -- | |
| 1034 | + // table_stride(4) == 32 (128 / 4), so 32 bits per row, 32 rows, 128 | |
| 1035 | + // bytes. Sub-8x8 leaves (lane-sub8) are the only blocks that reach here | |
| 1036 | + // with side 4 outside a TX4 split; without their own row they clamped | |
| 1037 | + // into the 8x8 table and read above-right samples the decoder has not | |
| 1038 | + // written yet (all-zero pixels in the bottom-right triangle of a | |
| 1039 | + // directional 4x4 leaf). | |
| 1040 | + &[ | |
| 1041 | + 255, 255, 255, 255, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85, 127, 127, 127, 127, | |
| 1042 | + 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85, 255, 127, 255, 127, 85, 85, 85, 85, | |
| 1043 | + 119, 119, 119, 119, 85, 85, 85, 85, 127, 127, 127, 127, 85, 85, 85, 85, 119, 119, 119, 119, | |
| 1044 | + 85, 85, 85, 85, 255, 255, 255, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85, | |
| 1045 | + 127, 127, 127, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85, 255, 127, 255, 127, | |
| 1046 | + 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85, 127, 127, 127, 127, 85, 85, 85, 85, | |
| 1047 | + 119, 119, 119, 119, 85, 85, 85, 85, | |
| 1048 | + ], | |
| 1032 | 1049 | ]; |
| 1033 | 1050 | |
| 1034 | 1051 | /// `has_bl_16x16` / `has_bl_32x32`: the same, for the block below and to the |
| 1035 | 1052 | /// left. |
| 1036 | -const HAS_BOTTOM_LEFT: [&[u8]; 3] = [ | |
| 1053 | +const HAS_BOTTOM_LEFT: [&[u8]; 4] = [ | |
| 1037 | 1054 | &[84, 16, 84, 0, 84, 16, 84, 0], |
| 1038 | 1055 | &[4, 4], |
| 1039 | 1056 | // has_bl_8x8 (libaom av1/common/reconintra.c) |
| @@ -1041,6 +1058,16 @@ const HAS_BOTTOM_LEFT: [&[u8]; 3] = [ | ||
| 1041 | 1058 | 84, 85, 16, 17, 84, 85, 0, 1, 84, 85, 16, 17, 84, 85, 0, 0, 84, 85, 16, 17, 84, 85, 0, 1, |
| 1042 | 1059 | 84, 85, 16, 17, 84, 85, 0, 0, |
| 1043 | 1060 | ], |
| 1061 | + | |
| 1062 | + // has_bl_4x4 (same source, same order). | |
| 1063 | + &[ | |
| 1064 | + 84, 85, 85, 85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 1, 1, 1, 84, 85, 85, 85, 16, 17, 17, 17, | |
| 1065 | + 84, 85, 85, 85, 0, 0, 1, 0, 84, 85, 85, 85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 1, 1, 1, 84, | |
| 1066 | + 85, 85, 85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 0, 0, 0, 84, 85, 85, 85, 16, 17, 17, 17, 84, | |
| 1067 | + 85, 85, 85, 0, 1, 1, 1, 84, 85, 85, 85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 0, 1, 0, 84, 85, | |
| 1068 | + 85, 85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 1, 1, 1, 84, 85, 85, 85, 16, 17, 17, 17, 84, 85, | |
| 1069 | + 85, 85, 0, 0, 0, 0, | |
| 1070 | + ], | |
| 1044 | 1071 | ]; |
| 1045 | 1072 | |
| 1046 | 1073 | /// `has_tr_vert_*` (libaom `reconintra.c`, `has_tr_vert_tables`), indexed by |
| @@ -1196,21 +1223,19 @@ impl Reach { | ||
| 1196 | 1223 | if col + 1 == per_side { |
| 1197 | 1224 | return false; |
| 1198 | 1225 | } |
| 1199 | - // corner-cut: `HAS_TOP_RIGHT`/`HAS_BOTTOM_LEFT` only carry dedicated | |
| 1200 | - // rows for side 8/16/32/64 (libaom's own `has_tr_8x8`/`has_tr_16x16` | |
| 1201 | - // families); a `TxMode::Select` TX4 transform unit reaches here with | |
| 1202 | - // side 4, whose real table (`has_tr_4x4`, 128 bytes) was never | |
| 1203 | - // transcribed. Clamping into the 16/32 table's own bit range keeps | |
| 1204 | - // this in-bounds and correct at every position that table already | |
| 1205 | - // covers periodically -- wrong only at the small remainder past its | |
| 1206 | - // length, a reach over-/under-estimate (extra or missing above-right | |
| 1207 | - // reference pixels), never a stream desync (Reach never gates a | |
| 1208 | - // symbol read). Ceiling: transcribe `has_tr_4x4`/`has_bl_4x4` | |
| 1209 | - // verbatim and give TX4 its own `HAS_TOP_RIGHT`/`HAS_BOTTOM_LEFT` row. | |
| 1210 | - let table = if VERT_AB_PARTITION.with(std::cell::Cell::get) { | |
| 1211 | - HAS_TOP_RIGHT_VERT[Self::table(side)] | |
| 1226 | + // lane-sub8 r4: side 4 now has its own `has_tr_4x4`/`has_bl_4x4` row | |
| 1227 | + // (the clamp corner-cut that used to live here is gone); sides | |
| 1228 | + // 16/32/64 share row 0 exactly as libaom's tables repeat. | |
| 1229 | + // corner-cut: libaom transcribes no vert 4x4 row, so a side-4 block | |
| 1230 | + // inside a `PARTITION_VERT_A`/`_B` falls back to the ordinary table | |
| 1231 | + // -- a reach over-estimate (extra above-right reference pixels), | |
| 1232 | + // never a stream desync. Ceiling: transcribe `has_tr_vert_4x4` / | |
| 1233 | + // `has_bl_vert_4x4` and extend the VERT tables to four rows. | |
| 1234 | + let row = Self::table(side); | |
| 1235 | + let table = if VERT_AB_PARTITION.with(std::cell::Cell::get) && row < HAS_TOP_RIGHT_VERT.len() { | |
| 1236 | + HAS_TOP_RIGHT_VERT[row] | |
| 1212 | 1237 | } else { |
| 1213 | - HAS_TOP_RIGHT[Self::table(side)] | |
| 1238 | + HAS_TOP_RIGHT[row] | |
| 1214 | 1239 | }; |
| 1215 | 1240 | Self::bit( |
| 1216 | 1241 | table, |
| @@ -1230,11 +1255,19 @@ impl Reach { | ||
| 1230 | 1255 | if row + 1 == per_side { |
| 1231 | 1256 | return false; |
| 1232 | 1257 | } |
| 1233 | - // corner-cut: see `top_right`'s note -- same clamp, same ceiling. | |
| 1234 | - let table = if VERT_AB_PARTITION.with(std::cell::Cell::get) { | |
| 1235 | - HAS_BOTTOM_LEFT_VERT[Self::table(side)] | |
| 1258 | + // lane-sub8 r4: side 4 now has its own `has_tr_4x4`/`has_bl_4x4` row | |
| 1259 | + // (the clamp corner-cut that used to live here is gone); sides | |
| 1260 | + // 16/32/64 share row 0 exactly as libaom's tables repeat. | |
| 1261 | + // corner-cut: libaom transcribes no vert 4x4 row, so a side-4 block | |
| 1262 | + // inside a `PARTITION_VERT_A`/`_B` falls back to the ordinary table | |
| 1263 | + // -- a reach over-estimate (extra above-right reference pixels), | |
| 1264 | + // never a stream desync. Ceiling: transcribe `has_tr_vert_4x4` / | |
| 1265 | + // `has_bl_vert_4x4` and extend the VERT tables to four rows. | |
| 1266 | + let row = Self::table(side); | |
| 1267 | + let table = if VERT_AB_PARTITION.with(std::cell::Cell::get) && row < HAS_BOTTOM_LEFT_VERT.len() { | |
| 1268 | + HAS_BOTTOM_LEFT_VERT[row] | |
| 1236 | 1269 | } else { |
| 1237 | - HAS_BOTTOM_LEFT[Self::table(side)] | |
| 1270 | + HAS_BOTTOM_LEFT[row] | |
| 1238 | 1271 | }; |
| 1239 | 1272 | Self::bit( |
| 1240 | 1273 | table, |
| @@ -1270,6 +1303,8 @@ impl Reach { | ||
| 1270 | 1303 | 1 |
| 1271 | 1304 | } else if side == 8 { |
| 1272 | 1305 | 2 |
| 1306 | + } else if side == 4 { | |
| 1307 | + 3 | |
| 1273 | 1308 | } else { |
| 1274 | 1309 | 0 |
| 1275 | 1310 | } |
crates/ec-av1/src/gate_coverage.rsmodified+1 -5
| @@ -139,10 +139,6 @@ const ALIASES: &[(&str, &str)] = &[("superres-mode", "enable-superres")]; | ||
| 139 | 139 | /// depth retires the entry, and this test fails until it is deleted. |
| 140 | 140 | #[cfg(test)] |
| 141 | 141 | const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ |
| 142 | - ( | |
| 143 | - "enable-1to4-partitions", | |
| 144 | - "off in 42 gates, on in none: PARTITION_HORZ_4/VERT_4 at 64x64 needs TX_64X16 luma plus 32x8 chroma scans (lane-part32 r5)", | |
| 145 | - ), | |
| 146 | 142 | ( |
| 147 | 143 | "enable-angle-delta", |
| 148 | 144 | "off in 36 gates, on in none: the directional-intra gates pin it off to isolate the base modes", |
| @@ -203,7 +199,7 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ | ||
| 203 | 199 | // gate passes `=1` for both. |
| 204 | 200 | ( |
| 205 | 201 | "enable-1to4-partitions", |
| 206 | - "hole at both depths, see the 8-bit list", | |
| 202 | + "on in an 8-bit gate (lane-sub8) but no 10-bit gate passes `=1`", | |
| 207 | 203 | ), |
| 208 | 204 | ( |
| 209 | 205 | "enable-angle-delta", |
crates/ec-av1/src/refusal_inventory.rsmodified+3 -1
| @@ -28,7 +28,6 @@ const CAPABILITY_CLAIMS: &[&str] = &[ | ||
| 28 | 28 | "a non-2D tx class on a rectangular transform (never expected at this size)", |
| 29 | 29 | "a non-DC chroma mode on an 8x8 inter-frame leaf (this encoder never writes one)", |
| 30 | 30 | "a nonzero angle delta (this encoder never writes one)", |
| 31 | - "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)", | |
| 32 | 31 | "a tx_type symbol on a rectangular transform (never expected at this size)", |
| 33 | 32 | ]; |
| 34 | 33 | |
| @@ -40,6 +39,8 @@ const REFUSALS: &[&str] = &[ | ||
| 40 | 39 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 41 | 40 | "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect prediction is not ported)", |
| 42 | 41 | "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)", |
| 42 | + "a HORZ/VERT partition below 8x8 (this decoder's transform primitive is square-only; 4x8/8x4 need a real rectangular transform)", | |
| 43 | + "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", | |
| 43 | 44 | "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 44 | 45 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 45 | 46 | "a 32x32 partition type this decoder does not code (value={part32})", |
| @@ -51,6 +52,7 @@ const REFUSALS: &[&str] = &[ | ||
| 51 | 52 | "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)", |
| 52 | 53 | "a block that actually uses a palette (UV) -- reconstruction is out of scope", |
| 53 | 54 | "a block that actually uses a palette (Y) -- reconstruction is out of scope", |
| 55 | + "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)", | |
| 54 | 56 | "an intrabc block under TxMode::Select (its transform size is coded by the inter var-tx partition tree, which this decoder never reads)", |
| 55 | 57 | "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)", |
| 56 | 58 | "a frame OBU with no tile group", |
crates/ec-av1/src/stream.rsmodified+200 -0
| @@ -9528,6 +9528,206 @@ mod tests { | ||
| 9528 | 9528 | ); |
| 9529 | 9529 | } |
| 9530 | 9530 | |
| 9531 | + /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients | |
| 9532 | + /// at low cq reliably makes aomenc split an 8x8 block all the way to | |
| 9533 | + /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec | |
| 9534 | + /// `decode_partition`'s recursion bottom) -- confirmed with | |
| 9535 | + /// `EC_AV1_TRACE=1` against `examples/decode_probe` before this gate was | |
| 9536 | + /// written (`partition_w8 ... value=3` at mi=(0,0) on the very first | |
| 9537 | + /// block). [`decode::sub8_split_hits`] hard-asserts the path actually | |
| 9538 | + /// ran rather than every attempt landing on `PARTITION_NONE`. | |
| 9539 | + #[test] | |
| 9540 | + fn a_real_aomenc_stream_with_a_sub8_split_decodes_pixel_exact() { | |
| 9541 | + if !have_ffmpeg() { | |
| 9542 | + eprintln!("SKIP a_real_aomenc_stream_with_a_sub8_split_decodes_pixel_exact: no ffmpeg"); | |
| 9543 | + return; | |
| 9544 | + } | |
| 9545 | + if !have_aomenc() { | |
| 9546 | + let msg = format!( | |
| 9547 | + "no aomenc at {}", | |
| 9548 | + aomenc_path().display() | |
| 9549 | + ); | |
| 9550 | + assert!( | |
| 9551 | + std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none(), | |
| 9552 | + "EC_AV1_REQUIRE_AOMENC is set but {msg}" | |
| 9553 | + ); | |
| 9554 | + eprintln!("SKIP a_real_aomenc_stream_with_a_sub8_split_decodes_pixel_exact: {msg}"); | |
| 9555 | + return; | |
| 9556 | + } | |
| 9557 | + // round 2: `--enable-rect-partitions=0` was added below to keep | |
| 9558 | + // aomenc off HORZ/VERT-below-8x8 elsewhere in the same tile, but it | |
| 9559 | + // is NOT sufficient alone -- see the round-2 report | |
| 9560 | + // (lanes/sub8-r1.report.md) for the live finding: 0/160 attempts | |
| 9561 | + // across both 64x64 and a spatially-isolated single-16x16-leaf | |
| 9562 | + // fixture passed, and every SPLIT that fires is immediately | |
| 9563 | + // followed by a spurious HORZ/VERT read on the very next sibling | |
| 9564 | + // 8x8 leaf, which reads as a real desync left behind by | |
| 9565 | + // `decode_leaf_split4`/`read_intra_mode_sub8`, not an encoder | |
| 9566 | + // choice this recipe can dodge. Tried and rejected: shrinking the | |
| 9567 | + // frame to 16x16 (single 16x16 leaf, at most 4 candidate 8x8s) -- | |
| 9568 | + // that surfaces an UNRELATED pre-existing tiny-frame edge-straddle | |
| 9569 | + // defect (reproduces with zero sub8 code involved, `--min-partition | |
| 9570 | + // -size`/`--max-partition-size` absent entirely), so it is not a | |
| 9571 | + // safe way to isolate the leaf count. Left red; do not "fix" this | |
| 9572 | + // gate by picking fixture parameters that dodge the desync without | |
| 9573 | + // finding it. | |
| 9574 | + // lane-sub8 r6: three arms. The mi-granular mode maps | |
| 9575 | + // (`sub8_mode_col`/`uv_mode_col` and their row twins) are per TILE -- | |
| 9576 | + // the verifier's repro was a 128x64 `--tile-columns=1` stream (seeds | |
| 9577 | + // 207/228) whose every mismatching luma pixel sat at x>=64, the tile | |
| 9578 | + // boundary -- so one arm per tile axis is part of this gate. | |
| 9579 | + for (width, height, tile_args) in [ | |
| 9580 | + (64usize, 64usize, &[][..]), | |
| 9581 | + (128usize, 64usize, &["--tile-columns=1"][..]), | |
| 9582 | + (64usize, 128usize, &["--tile-rows=1"][..]), | |
| 9583 | + ] { | |
| 9584 | + let mut refusals = Vec::new(); | |
| 9585 | + let mut fired_runs = 0u32; | |
| 9586 | + for attempt in 0..40u32 { | |
| 9587 | + let seed = 100 + attempt; | |
| 9588 | + let cq = 6 + (attempt % 4) * 2; | |
| 9589 | + let y4m = Command::new("ffmpeg") | |
| 9590 | + .args([ | |
| 9591 | + "-v", | |
| 9592 | + "error", | |
| 9593 | + "-f", | |
| 9594 | + "lavfi", | |
| 9595 | + "-i", | |
| 9596 | + &gradients_source(seed, width, height, "rate=25"), | |
| 9597 | + "-vf", | |
| 9598 | + // `noise` without `all_seed` re-renders differently on | |
| 9599 | + // every run (seeded-fixture-not-reproducible); pinning it | |
| 9600 | + // makes (seed, cq) name one exact stream. | |
| 9601 | + &format!("noise=alls=40:allf=t:all_seed={seed},format=yuv420p"), | |
| 9602 | + "-t", | |
| 9603 | + "0.04", | |
| 9604 | + "-f", | |
| 9605 | + "yuv4mpegpipe", | |
| 9606 | + "-", | |
| 9607 | + ]) | |
| 9608 | + .stdin(Stdio::null()) | |
| 9609 | + .stdout(Stdio::piped()) | |
| 9610 | + .stderr(Stdio::piped()) | |
| 9611 | + .output() | |
| 9612 | + .expect("ffmpeg failed to run"); | |
| 9613 | + assert!( | |
| 9614 | + y4m.status.success(), | |
| 9615 | + "ffmpeg fixture: {}", | |
| 9616 | + String::from_utf8_lossy(&y4m.stderr) | |
| 9617 | + ); | |
| 9618 | + let mut child = Command::new(aomenc_path()) | |
| 9619 | + .args([ | |
| 9620 | + "--codec=av1", | |
| 9621 | + "--passes=1", | |
| 9622 | + "--end-usage=q", | |
| 9623 | + &format!("--cq-level={cq}"), | |
| 9624 | + "--cpu-used=0", | |
| 9625 | + "--threads=1", | |
| 9626 | + "--row-mt=0", | |
| 9627 | + "--sb-size=64", | |
| 9628 | + "--min-partition-size=4", | |
| 9629 | + "--max-partition-size=8", | |
| 9630 | + // Below 8x8 only PARTITION_NONE/SPLIT are decodable (HORZ/VERT | |
| 9631 | + // need a real rectangular transform, see the module doc above); | |
| 9632 | + // disabling rect partitions entirely -- not just AB -- keeps | |
| 9633 | + // aomenc from picking the still-refused HORZ/VERT arms almost | |
| 9634 | + // every attempt (round 2 measured ~90% HORZ/VERT-below-8x8 | |
| 9635 | + // refusals with --enable-ab-partitions=0 alone). | |
| 9636 | + "--enable-rect-partitions=0", | |
| 9637 | + "--enable-ab-partitions=0", | |
| 9638 | + "--enable-1to4-partitions=1", | |
| 9639 | + "--enable-palette=0", | |
| 9640 | + "--enable-intrabc=0", | |
| 9641 | + "--enable-restoration=0", | |
| 9642 | + "--enable-cdef=0", | |
| 9643 | + "--loopfilter-control=0", | |
| 9644 | + // use_ref_frame_mvs (temporal MV projection) is unimplemented in | |
| 9645 | + // mvstack; this is a key-frame-only fixture, but keep it off for | |
| 9646 | + // safety against a run that emits a second frame. | |
| 9647 | + "--enable-ref-frame-mvs=0", | |
| 9648 | + "--limit=1", | |
| 9649 | + "--obu", | |
| 9650 | + "-o", | |
| 9651 | + "-", | |
| 9652 | + "-", | |
| 9653 | + ]) | |
| 9654 | + .args(tile_args) | |
| 9655 | + .stdin(Stdio::piped()) | |
| 9656 | + .stdout(Stdio::piped()) | |
| 9657 | + .stderr(Stdio::piped()) | |
| 9658 | + .spawn() | |
| 9659 | + .expect("aomenc failed to start"); | |
| 9660 | + child | |
| 9661 | + .stdin | |
| 9662 | + .take() | |
| 9663 | + .expect("aomenc stdin") | |
| 9664 | + .write_all(&y4m.stdout) | |
| 9665 | + .expect("writing y4m to aomenc"); | |
| 9666 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 9667 | + if !out.status.success() { | |
| 9668 | + refusals.push(format!( | |
| 9669 | + "seed={seed} cq={cq}: aomenc itself refused the fixture" | |
| 9670 | + )); | |
| 9671 | + continue; | |
| 9672 | + } | |
| 9673 | + let stream = out.stdout; | |
| 9674 | + let before = decode::sub8_split_hits(); | |
| 9675 | + let tiles_before = decode::tile_hits(); | |
| 9676 | + let frames = match decode_stream(&stream) { | |
| 9677 | + Ok(frames) => frames, | |
| 9678 | + Err(e) => { | |
| 9679 | + // Only a named refusal ("unsupported: ...") is a skip | |
| 9680 | + // reason; any other decode error is this decoder failing. | |
| 9681 | + let msg = e.to_string(); | |
| 9682 | + assert!( | |
| 9683 | + msg.starts_with("unsupported: "), | |
| 9684 | + "decode error that is not a named refusal \ | |
| 9685 | + (seed={seed} cq={cq} tiles={tile_args:?}): {msg}" | |
| 9686 | + ); | |
| 9687 | + refusals.push(format!("seed={seed} cq={cq}: {msg}")); | |
| 9688 | + continue; | |
| 9689 | + } | |
| 9690 | + }; | |
| 9691 | + // gate-blind-to-feature: a tile arm must actually decode more | |
| 9692 | + // than one tile, not merely carry `tile_info.cols > 1`. | |
| 9693 | + assert!( | |
| 9694 | + tile_args.is_empty() || decode::tile_hits() - tiles_before >= 2, | |
| 9695 | + "tiles={tile_args:?} decoded only {} tile(s) (seed={seed} cq={cq})", | |
| 9696 | + decode::tile_hits() - tiles_before | |
| 9697 | + ); | |
| 9698 | + if decode::sub8_split_hits() == before { | |
| 9699 | + refusals.push(format!( | |
| 9700 | + "seed={seed} cq={cq}: decoded, but no block read a real PARTITION_SPLIT below 8x8" | |
| 9701 | + )); | |
| 9702 | + continue; | |
| 9703 | + } | |
| 9704 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | |
| 9705 | + assert_eq!( | |
| 9706 | + frames[0].y, ffmpeg_frames[0].y, | |
| 9707 | + "luma vs ffmpeg (seed={seed} cq={cq})" | |
| 9708 | + ); | |
| 9709 | + assert_eq!( | |
| 9710 | + frames[0].u, ffmpeg_frames[0].u, | |
| 9711 | + "U vs ffmpeg (seed={seed} cq={cq})" | |
| 9712 | + ); | |
| 9713 | + assert_eq!( | |
| 9714 | + frames[0].v, ffmpeg_frames[0].v, | |
| 9715 | + "V vs ffmpeg (seed={seed} cq={cq})" | |
| 9716 | + ); | |
| 9717 | + fired_runs += 1; | |
| 9718 | + if fired_runs >= 4 { | |
| 9719 | + break; | |
| 9720 | + } | |
| 9721 | + } | |
| 9722 | + assert!( | |
| 9723 | + fired_runs >= 4, | |
| 9724 | + "fewer than 4 firing+pixel-exact runs out of 40 attempts \ | |
| 9725 | + ({width}x{height} tiles={tile_args:?}):\n{}", | |
| 9726 | + refusals.join("\n") | |
| 9727 | + ); | |
| 9728 | + } | |
| 9729 | + } | |
| 9730 | + | |
| 9531 | 9731 | /// lane-av1golden7 r9's decisive fixture: a real aomenc stream (seed 59, |
| 9532 | 9732 | /// `--tune-content=film`, GOLDEN_FRAME firing downstream) whose frame-0 |
| 9533 | 9733 | /// *intra keyframe* mismatched ffmpeg on 3855/4096 luma pixels -- traced |
lanes/COMMON-20260901.mdadded+76 -0
| @@ -0,0 +1,76 @@ | ||
| 1 | +# COMMON CHARTER PREAMBLE — batch 2026-09-01 (ec-av1 decode, his real films) | |
| 2 | + | |
| 3 | +GOAL (why): ec-av1 must decode the user's two real AV1 films bit-exact | |
| 4 | +(`/home/user/Videos/Films/reelc.mkv`, | |
| 5 | +`/home/user/Downloads/reelb.mkv`, | |
| 6 | +both yuv420p10le). 47 refusal strings remain in crates/ec-av1/src/refusal_inventory.rs. | |
| 7 | +Each lane lifts its cluster of refusals WITH a real-aomenc gate proving it. | |
| 8 | + | |
| 9 | +WORKING RULES (binding): | |
| 10 | +- Work ONLY in your worktree; branch named in your charter. Never touch main, never | |
| 11 | + merge into main, never `git checkout <file>` to revert (copy to scratch first). | |
| 12 | +- `export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-<lane>` (named in charter) for EVERY cargo | |
| 13 | + command. sccache is the global rustc wrapper. Use `nice -n 10 cargo ... -j3` — 10 lanes | |
| 14 | + run concurrently on 12 cores / 30G RAM. Long/lavfi runs under | |
| 15 | + `systemd-run --user --scope -p MemoryMax=8G` and bound ffmpeg with `-t`. | |
| 16 | +- Test scope: `cargo test -p ec-av1 --lib` only (plus `cargo check -p ec-av1`). Never the | |
| 17 | + workspace suite. Set `EC_AV1_REQUIRE_AOMENC=1` so an absent oracle FAILS, never SKIPs. | |
| 18 | +- Oracle: `~/.cache/aom-oracle/build/aomenc` and instrumented `aomdec` (scripts/build-aom-oracle.sh, | |
| 19 | + scripts/instrument-aom-oracle.sh; rungs EC_TRACE=1 / EC_TRACE_COEFF=1 / EC_TRACE_MODE=1 / | |
| 20 | + EC_AV1_PREFILT_DUMP). Ours: EC_TRACE_COEFF / EC_TRACE_MODE / EC_TRACE_MODE_STEP in decode.rs. | |
| 21 | + Cross-decoder bisection compares msac RANGE element by element, never tell(). | |
| 22 | + The reference is at the oracle source tree (find via scripts/build-aom-oracle.sh). | |
| 23 | +- FIRST STEP, always: `git log --oneline -8 main` and rebase your branch onto main | |
| 24 | + (`git rebase main`; resolve conflicts, keeping main's fixes). Then RE-MEASURE your lane's | |
| 25 | + premise before building — charters may carry stale premises. Cite the command that | |
| 26 | + produced every premise you act on. | |
| 27 | +- Fixtures: `fixtures` is a symlink to main's fixtures dir (shared). Pin any new stream | |
| 28 | + fixture under crates/ec-av1/fixtures/ or fixtures/ with a hash; hash an aomenc output | |
| 29 | + TWICE before trusting a seed (lavfi gradients ignores its seed). | |
| 30 | +- A refusal is lifted ONLY together with a gate: a real-aomenc stream (tool explicitly | |
| 31 | + enabled on the aomenc command line) decoded pixel-exact vs ffmpeg/aomdec, that | |
| 32 | + HARD-ASSERTS a hit counter proving the feature fired, and never turns a decode error or | |
| 33 | + pixel mismatch into SKIP. Update refusal_inventory.rs + gate_coverage.rs in the same | |
| 34 | + commit. `refusal_inventory` and `gate_coverage` tests must stay green. | |
| 35 | +- Defect classes to check first (memory-proven, each cost rounds): CDF row indexed by a | |
| 36 | + field that moves; table indexed by RAW vs adjusted tx_size; scan/ctx tables transposed | |
| 37 | + vs spec (libaom layout is not the spec's — gate on asymmetric behaviour); neighbour ctx | |
| 38 | + read from one cell instead of gathered over the span; a symbol we read that the | |
| 39 | + reference never wrote (reference range unchanged = unread); a header field parsed then | |
| 40 | + never consumed; counter-reset list missing a table; call-site arg order; a probe loop | |
| 41 | + reusing last run's output file (rm -f first, check exit status). | |
| 42 | +- Tool-call ceiling ~70. If you hit it: commit everything on your branch, write | |
| 43 | + `lanes/<lane>-r<N>.handoff.md` with exact facts (ranges, stream, element) so a fresh | |
| 44 | + agent continues without re-reading. | |
| 45 | +- DONE = commit(s) on your branch + `lanes/<lane>-r<N>.report.md` in your worktree with: | |
| 46 | + what changed (path:line), gate name + command + result, refusals lifted, test totals | |
| 47 | + (`cargo test -p ec-av1 --lib` passed/failed/ignored), and EVIDENCE lines of the form | |
| 48 | + `EVIDENCE: <artifact> | <steps> | <measurement>`. State open residue with | |
| 49 | + fix-now | deferred(<what unblocks>) | accepted. Never claim "done" beyond what you ran. | |
| 50 | +- Film check, when your lane targets a film blocker: extract 0.4s with | |
| 51 | + `ffmpeg -t 0.4 -i <film> -c:v copy -f obu <out>.obu` (bounded), run | |
| 52 | + `cargo run -p ec-av1 --example decode_probe -- <out>.obu` before and after; report | |
| 53 | + the refusal string each film now stops at. | |
| 54 | + | |
| 55 | +VERIFIERS (added 2026-09-01 22:40 after a verifier left a lane worktree on a detached HEAD | |
| 56 | +while its builder was mid-round): a verifier NEVER runs `git checkout`, `git switch`, | |
| 57 | +`git stash` or any tree-changing git command inside a lane worktree. To test a specific | |
| 58 | +commit, `git worktree add --detach /tmp/claude-1000/.../scratchpad/verify-<lane> <sha>` with its | |
| 59 | +own CARGO_TARGET_DIR, and remove it when done. | |
| 60 | + | |
| 61 | +NEIGHBOUR MAPS (added 2026-09-02 00:50, class new-map-ignores-tile-edge): any per-mi side band | |
| 62 | +you add or inherit (mode, uv_mode, skip, ref, filter, txfm ctx, palette) MUST (1) guard | |
| 63 | +availability with `mi_r > tile_row0_mi` / `mi_c > tile_col0_mi`, never `> 0`; (2) be reset in | |
| 64 | +start_tile AND start_row; (3) have a `--tile-columns=1` arm in the lane's gate. Gate Err arms | |
| 65 | +tolerate ONLY messages containing "unsupported"; lavfi sources carry an explicit seed | |
| 66 | +(noise=all_seed=N) and the report shows two identical hashes. | |
| 67 | + | |
| 68 | +SIBLING GATES (added 2026-09-02 03:00, rectsplit r3): a root-cause fix that turns YOUR gate green | |
| 69 | +is not done until every gate that exercises the same tables/paths (grep the table name and the | |
| 70 | +function in stream.rs) is re-run — rectsplit r2 shipped a transposition that fixed its gate and | |
| 71 | +broke the merged SB HORZ/VERT gate at seed 43. Run the siblings before writing "root cause". | |
| 72 | + | |
| 73 | +FORMAT + LOGS (added 2026-09-02 03:30): never run a repo-wide `cargo fmt` in a lane (txselect | |
| 74 | +carried 5000 lines of churn that the merge had to strip; format only files you touched, or | |
| 75 | +not at all). Suite logs go to a PRIVATE path (`$CARGO_TARGET_DIR/../<lane>-suite.log`), never | |
| 76 | +a shared scratchpad name — another session overwrote a verifier's log mid-run. |
lanes/sub8-r1.report.mdadded+206 -0
| @@ -0,0 +1,206 @@ | ||
| 1 | +# lane-sub8 report (rounds 1-2) | |
| 2 | + | |
| 3 | +## Round 1 (2f35dec, a564705) | |
| 4 | +Implemented `read_intra_mode_sub8` + `decode_leaf_split4` in | |
| 5 | +`crates/ec-av1/src/decode.rs` (~5140-5370): decodes `PARTITION_SPLIT` of an | |
| 6 | +8x8 intra block into four `BLOCK_4X4` leaves (spec `decode_partition`'s | |
| 7 | +recursion bottom). Both intra call sites (the straddle path and the clean | |
| 8 | +16x16-SPLIT path) branch on the new `part8` read; `PARTITION_HORZ`/`VERT` | |
| 9 | +below 8x8 and all inter sub-8x8 stay refused by name. | |
| 10 | + | |
| 11 | +**is_chroma_reference derivation** (spec/libaom `av1_common_int.h:1454`): | |
| 12 | +for 4:2:0 subsampling, only the *last* (bottom-right, index 3) of the four | |
| 13 | +4x4 leaves in a split 8x8 group carries chroma syntax at all -- the whole | |
| 14 | +8x8 group's one 4x4 chroma unit is read and reconstructed once, on that | |
| 15 | +leaf. `decode_leaf_split4` implements this via `has_chroma = i == 3`. | |
| 16 | + | |
| 17 | +**Filter-intra CDF row**: `BLOCK_4X4`'s own row (`cdf.rs FILTER_INTRA[0] = | |
| 18 | +4621`) is already present and is what every sub-8x8 leaf here uses | |
| 19 | +(`filter_intra_size_class(4)` in libaom is class 0 for all sub-8x8 sizes). | |
| 20 | +If 4x8/8x4 (HORZ/VERT below 8x8) were ever implemented, they would need two | |
| 21 | +*more* rows: `BLOCK_4X8 = 6743`, `BLOCK_8X4 = 5893` (libaom | |
| 22 | +`BLOCK_SIZES_ALL` order, values from `entropymode.c:821`) -- not present | |
| 23 | +in this table yet. | |
| 24 | + | |
| 25 | +**Why HORZ/VERT below 8x8 stays refused**: this decoder's transform | |
| 26 | +primitive is square-only. A real 4x8/8x4 leaf needs an actual rectangular | |
| 27 | +TX_4X8/TX_8X4 transform (scan order, EOB context, coefficient CDF set all | |
| 28 | +differ from the square 4x4 case); faking it as two 4x4 squares would desync | |
| 29 | +against a real encoder immediately. This is a scope cut, not a bug -- | |
| 30 | +tracked by refusal name in `refusal_inventory.rs`. | |
| 31 | + | |
| 32 | +## Round 2 (6703411) | |
| 33 | +Round 1 left the gate (`a_real_aomenc_stream_with_a_sub8_split_decodes_pixel_exact`, | |
| 34 | +`stream.rs` ~6604) uncompiled. It now compiles clean | |
| 35 | +(`cargo check -p ec-av1 --lib`, zero errors). **The gate is still RED.** | |
| 36 | + | |
| 37 | +### What was tried | |
| 38 | +1. `--enable-rect-partitions=0` added to the aomenc recipe: necessary but | |
| 39 | + not sufficient. Without it, aomenc picks a real `PARTITION_HORZ`/`VERT` | |
| 40 | + at 8x8 (still refused by name) in ~63% of the original 40 attempts | |
| 41 | + (25/40). With it, that specific refusal drops but the gate still hits | |
| 42 | + 0/160 total passing attempts across two fixture shapes (see below). | |
| 43 | +2. Shrinking the fixture to a single-16x16-leaf frame (16x16 pixels, so at | |
| 44 | + most four 8x8 candidates exist in the whole frame) to structurally rule | |
| 45 | + out a second, still-refused HORZ/VERT leaf sharing the tile. This | |
| 46 | + surfaced an **unrelated, pre-existing tiny-frame defect**: a plain | |
| 47 | + 16x16 aomenc stream with NO `--min-partition-size`/`--max-partition-size` | |
| 48 | + override and no sub8 code involved at all (`decode_leaf_split4` never | |
| 49 | + called) still decodes with wrong pixels for most seeds (2/3 sampled). | |
| 50 | + `EC_AV1_TRACE=1` shows the bitstream parses cleanly (no refusal, no | |
| 51 | + panic, valid-looking symbol values throughout) but the picture desyncs | |
| 52 | + silently partway through -- consistent with the frame-edge/"true edge | |
| 53 | + straddle" logic (`decode.rs` ~6864-6957, the `has_cols16`/`has_rows16` | |
| 54 | + branch) being exercised at a degenerate case (frame == exactly one | |
| 55 | + 16x16 block, most of the SB out of frame) that larger sub-SB frames | |
| 56 | + (32x32, 64x64, used successfully elsewhere in this file) don't reach. | |
| 57 | + **Out of scope for this lane** -- not touched, not fixed, flagged here | |
| 58 | + for whichever lane owns edge-straddle handling next. | |
| 59 | +3. Widening the seed/cq sweep for the 64x64 fixture (with | |
| 60 | + `--enable-rect-partitions=0`) to 160 total attempts across two batches: | |
| 61 | + still 0 passes. | |
| 62 | + | |
| 63 | +### The actual finding | |
| 64 | +`EC_AV1_TRACE=1` on failing 64x64 attempts shows the pattern directly: | |
| 65 | +`partition_w8 mi=(0,0) ... value=3` (a real, clean `PARTITION_SPLIT`, | |
| 66 | +`decode_leaf_split4` fires, `SUB8_SPLIT_HITS` increments) is immediately | |
| 67 | +followed by `partition_w8 mi=(0,2) ... value=2` (`PARTITION_VERT`) on the | |
| 68 | +very next sibling 8x8 leaf in the same 16x16 parent -- and that leaf hits | |
| 69 | +the (correct, by-design) HORZ/VERT-below-8x8 refusal. This happened on | |
| 70 | +every single attempt that reached a SPLIT at all, which is not consistent | |
| 71 | +with random encoder choice given `--enable-rect-partitions=0` is set (per | |
| 72 | +libaom `partition_search.c`'s `do_rectangular_split` gating, that flag | |
| 73 | +should make `PARTITION_HORZ`/`VERT` unreachable via RD at 8x8 too). The | |
| 74 | +more consistent read: `decode_leaf_split4`/`read_intra_mode_sub8` leaves | |
| 75 | +some piece of decoder, CDF, or neighbour-context state wrong on return, and | |
| 76 | +the very next `partition_w8` symbol read (on the sibling leaf) decodes a | |
| 77 | +value the real bitstream did not write -- i.e. a real desync introduced by | |
| 78 | +this round's own new code, immediately after it runs. | |
| 79 | + | |
| 80 | +**This was not chased down further this round** -- turn budget spent | |
| 81 | +finding and narrowing it. Next round should NOT try more fixture-shape | |
| 82 | +workarounds; instead: trace `dec`'s range/tell before and after | |
| 83 | +`decode_leaf_split4` against a byte-identical aomdec run (mirror the | |
| 84 | +`av1-mvstack-refmv-corner`/`cdf-counter-not-reset` class method: exact | |
| 85 | +range ladder up to the read, compare the step) to find which of | |
| 86 | +`read_intra_mode_sub8`'s reads or which piece of `Neighbours`/CDF | |
| 87 | +bookkeeping in `decode_leaf_split4`'s tail (the chroma-neighbour section, | |
| 88 | +lines ~5346-5369) is wrong. | |
| 89 | + | |
| 90 | +### Suite / build state at HEAD (6703411) | |
| 91 | +- `cargo check -p ec-av1 --lib`: clean, 0 errors. | |
| 92 | +- Gate `a_real_aomenc_stream_with_a_sub8_split_decodes_pixel_exact`: FAILS | |
| 93 | + (0/40 in-suite attempts pass; `sub8_split_hits()` DOES go nonzero during | |
| 94 | + the run -- the SPLIT path fires -- but no attempt completes pixel-exact). | |
| 95 | +- Full `cargo test -p ec-av1 --lib` and ReelB extract probe: not run | |
| 96 | + this round (turn budget spent on the above investigation). Deferred to | |
| 97 | + round 3. | |
| 98 | + | |
| 99 | +## Round 3 (05b20f9) | |
| 100 | + | |
| 101 | +### Fixed: the partition-context bug the round-2 finding pointed at | |
| 102 | +libaom's `update_ext_partition_context` (`av1_common_int.h:1500`) only | |
| 103 | +writes anything when `bsize >= BLOCK_8X8`; the four recursive | |
| 104 | +`decode_partition(BLOCK_4X4)` calls a real `PARTITION_SPLIT` at 8x8 | |
| 105 | +produces are no-ops for context purposes. The *one* write that happens is | |
| 106 | +at the 8x8 level itself, with `subsize = BLOCK_4X4`: | |
| 107 | +`partition_context_lookup[BLOCK_4X4] = {31, 31}` (bit0 = 1), vs | |
| 108 | +`partition_context_lookup[BLOCK_8X8] = {30, 30}` (bit0 = 0) for a plain | |
| 109 | +`PARTITION_NONE` 8x8. `decode_leaf_split4`'s chroma-tail (the block that | |
| 110 | +sets `left_side_mi`/`above_side_mi` for the whole 8x8 group, `decode.rs` | |
| 111 | +~5350-5354) had copied `decode_leaf8`'s own TX4-branch value (`8`, | |
| 112 | +correct there -- that block is still one whole `BLOCK_8X8`, just with a | |
| 113 | +split *transform*) instead of the value that makes | |
| 114 | +`partition_ctx_mi`'s `left_side_mi[mi_r]*2 <= side` bit read as 1, which | |
| 115 | +needs `<= 4`. Changed both writes to `4`. Verified directly against the | |
| 116 | +libaom source at `~/.cache/aom-oracle/src/av1/common/av1_common_int.h:1441-1552` | |
| 117 | +(`update_partition_context`/`update_ext_partition_context`/ | |
| 118 | +`partition_plane_context`), not by re-deriving it by hand. | |
| 119 | + | |
| 120 | +**Effect measured**: before the fix, every attempt that hit a real SPLIT | |
| 121 | +crashed the very next sibling 8x8's `partition_w8` read (round 2's | |
| 122 | +finding). After the fix, `EC_AV1_TRACE=1` on the dumped stream that | |
| 123 | +previously crashed shows the sibling reads land on the *correct* context | |
| 124 | +(cross-checked bit-for-bit against instrumented aomdec's `EC_PART` trace | |
| 125 | +at the equivalent block, ctx encodes the same left/above bits both sides) | |
| 126 | +and the whole stream decodes to completion with `Ok`, no error, no panic. | |
| 127 | +This is real, but not sufficient -- see below. | |
| 128 | + | |
| 129 | +### Range-ladder result: gate still RED, and the divergence is UPSTREAM of any sub8 code | |
| 130 | +Ran the decisive check the charter asked for: rebuilt | |
| 131 | +`~/.cache/aom-oracle` (rungs 2/5/10 already present in the source, | |
| 132 | +`EC_PART`/`EC_PART_VAL`/`EC_ISTEP` per-symbol range ladder), decoded the | |
| 133 | +one dumped failing stream (seed=139, cq=12, 64x64, | |
| 134 | +`--enable-rect-partitions=0 --min-partition-size=4 --max-partition-size=8`) | |
| 135 | +through instrumented `aomdec` and compared trace order against our own | |
| 136 | +`EC_AV1_TRACE` output block by block. | |
| 137 | + | |
| 138 | +**First divergence**: the 16x16-level partition read at SUB-unit | |
| 139 | +`at16=(0,1)` (mi=(0,4)), the *second* 16x16 quadrant of the first 32x32 | |
| 140 | +block -- i.e. it fires before our decoder has executed one single line of | |
| 141 | +`decode_leaf_split4`/`read_intra_mode_sub8` (the actual sub8x8-SPLIT in | |
| 142 | +this stream is at mi=(2,6), inside quadrant (0,1)'s own subtree, per | |
| 143 | +aomdec's `EC_PART_VAL mi_row=2 mi_col=6 bsize=3 value=3`). aomdec reads | |
| 144 | +`PARTITION_SPLIT` (value=3) there; ours reads `PARTITION_NONE` (value=0). | |
| 145 | +The context bits agree (both decode to left=1, above=0, aomdec's combined | |
| 146 | +`ctx=6` and ours `ctx=2` are the same left/above pair under different | |
| 147 | +context-array encodings) -- so this is not a context bug, it is either a | |
| 148 | +CDF-adaptation drift carried in from the *first* 16x16 quadrant's own | |
| 149 | +four 8x8 leaves (all plain `decode_leaf8`, zero sub8 code touched) or a | |
| 150 | +genuine range/probability desync from something even earlier that this | |
| 151 | +round did not get to trace symbol-by-symbol (no per-symbol trace exists | |
| 152 | +in our decoder for `decode_leaf8`'s own mode-info reads, only for the | |
| 153 | +`read_intra_mode_sub8` leaves added in round 1 -- that instrumentation | |
| 154 | +gap is why the ladder stops here this round). | |
| 155 | + | |
| 156 | +**This changes the round-2 hypothesis**: the failure is very likely NOT | |
| 157 | +inside `decode_leaf_split4`/`read_intra_mode_sub8` at all. It reproduces | |
| 158 | +on this stream before any of that code has run. Whatever the true root | |
| 159 | +cause is, it sits in code shared by every 8x8/16x16 intra block in this | |
| 160 | +recipe (`decode_leaf8`, `partition_w16`/`partition_w32` context, or CDF | |
| 161 | +adaptation for `kf_y_mode`/`uv_mode`/`skip`), and `--min-partition-size=4` | |
| 162 | +is what surfaces it (this exact recipe may not be exercised by any other | |
| 163 | +gate). Round 4 should NOT keep assuming the bug is sub8-owned code -- | |
| 164 | +start by adding the same per-symbol trace (`skip`/`mode`/`uv_mode`/ | |
| 165 | +`angle_delta`) to `decode_leaf8` itself and ladder the *first* 16x16 | |
| 166 | +quadrant's four 8x8 leaves symbol-by-symbol against aomdec's `EC_ISTEP` | |
| 167 | +trace before looking at sub8 code again. | |
| 168 | + | |
| 169 | +### Suite / build state at HEAD (05b20f9) | |
| 170 | +- `cargo check --workspace --all-targets`: clean. | |
| 171 | +- Gate `a_real_aomenc_stream_with_a_sub8_split_decodes_pixel_exact`: | |
| 172 | + still FAILS, now for a different, better-localized reason (see above). | |
| 173 | + Only 1/40 attempts this round both fired a real SPLIT and reached the | |
| 174 | + pixel comparison at all (39/40 either fired no SPLIT -- most now decode | |
| 175 | + clean with `PARTITION_NONE` chosen throughout the min-partition-size=4 | |
| 176 | + region, itself now consistent with correct decoding since they don't | |
| 177 | + panic -- or the run's own aomenc/decode plumbing skipped). The one that | |
| 178 | + did fire failed pixel-exact per the finding above. | |
| 179 | +- `cargo test -p ec-av1 --lib`: not completed this round (turn budget | |
| 180 | + spent on the range-ladder trace above); deferred to round 4, run it | |
| 181 | + first thing. | |
| 182 | +- Debug-only instrumentation (`EC_AV1_DUMP_SUB8` stream dump in | |
| 183 | + `stream.rs`, temp `dec.rng()` trace print attempt in `decode.rs`) was | |
| 184 | + added, used, and **reverted** this round -- not left in the tree. | |
| 185 | + | |
| 186 | +## Open (round 4 charter should start here) | |
| 187 | +- fix-now candidate: root cause is upstream of sub8's own code (see | |
| 188 | + "changes the round-2 hypothesis" above) -- add per-symbol trace to | |
| 189 | + `decode_leaf8` and ladder against aomdec `EC_ISTEP` on the first 16x16 | |
| 190 | + quadrant before touching `decode_leaf_split4` again. | |
| 191 | +- `cargo test -p ec-av1 --lib` full run: not done this round, do it first. | |
| 192 | +- ReelB extract probe (charter step 4): not reached this round -- | |
| 193 | + the gate is still red and the 10-bit wall in this branch (main merged | |
| 194 | + 10-bit at 5636fd2, this branch has not) makes it low-value until the | |
| 195 | + above is fixed. | |
| 196 | + | |
| 197 | +## Open (carried from round 2, unchanged) | |
| 198 | +- fix-now candidate: the desync in `decode_leaf_split4`/ | |
| 199 | + `read_intra_mode_sub8` (see "the actual finding" above) -- root cause, | |
| 200 | + not yet found. | |
| 201 | +- deferred: tiny-frame (exactly-16x16) edge-straddle defect, unrelated to | |
| 202 | + sub8, found as a side effect of workaround #2 above -- needs its own | |
| 203 | + charter, not this lane's. | |
| 204 | +- deferred: ReelB extract probe (charter step 4) and the ledger | |
| 205 | + append for round 1's findings (charter step 5) -- partially done here | |
| 206 | + (this file), full ledger append below. |
lanes/sub8-r4.report.mdadded+74 -0
| @@ -0,0 +1,74 @@ | ||
| 1 | +# lane-sub8 report (round 4) | |
| 2 | + | |
| 3 | +## Premise correction (this is the round's main result) | |
| 4 | +Round 2/3 assumed aomenc was really choosing `PARTITION_HORZ`/`VERT` below 8x8 | |
| 5 | +and AB partitions in this gate's recipe. **It is not.** Instrumented aomdec on | |
| 6 | +the gate's own stream (seed=117 cq=8, `--enable-rect-partitions=0`) reads only | |
| 7 | +`value=0` (NONE) and `value=3` (SPLIT) at every level: | |
| 8 | + | |
| 9 | +``` | |
| 10 | +EC_TRACE=1 ~/.cache/aom-oracle/build/aomdec --rawvideo -o /dev/null s117.obu \ | |
| 11 | + | grep EC_PART_VAL | awk '{print $4,$5}' | sort | uniq -c | |
| 12 | + 42 bsize=3 value=0 22 bsize=3 value=3 16 bsize=6 value=3 | |
| 13 | + 4 bsize=9 value=3 1 bsize=12 value=3 | |
| 14 | +``` | |
| 15 | + | |
| 16 | +So all 40 of the gate's "refusals" (`HORZ/VERT below 8x8`, `HORZ_A/B/VERT_A | |
| 17 | +below 16x16`, `a 32x32 partition type value=4/8/9`) were **hallucinated symbols | |
| 18 | +from our own desync**, not encoder choices. `--enable-rect-partitions=0` IS | |
| 19 | +honoured. Every refusal-shaped conclusion in rounds 2-3 was measuring the | |
| 20 | +desync. | |
| 21 | + | |
| 22 | +## Root causes found and fixed (commit "mi-exact intra mode neighbours ...") | |
| 23 | +1. **Coarse mode neighbours (`context-read-from-one-cell` class).** | |
| 24 | + `above_mode`/`left_mode` are one slot per 16x16; a split cell leaves two | |
| 25 | + (8x8) or four (4x4) different modes behind, and a leaf whose above/left | |
| 26 | + neighbour sits in such a cell read the wrong `kf_y_mode` CDF row -> desync. | |
| 27 | + `Neighbours` now keeps a mi-granular map (`sub8_mode_col`/`sub8_mode_row`, | |
| 28 | + `record_mode_mi`), written by `record_rect`, `record_split_luma`, | |
| 29 | + `decode_leaf8` and every 4x4 leaf, read back with an exact-position guard | |
| 30 | + (`mode_above_mi`/`mode_left_mi`) that falls back to the coarse slot. | |
| 31 | +2. **`has_tr_4x4`/`has_bl_4x4` never transcribed** (`encode.rs`, the | |
| 32 | + `corner-cut` comment that named this exact ceiling). Side-4 blocks clamped | |
| 33 | + into the 8x8 table, so a directional 4x4 leaf predicted from above-right | |
| 34 | + samples the decoder has not written yet -- all-zero pixels in the leaf's | |
| 35 | + bottom-right triangle. Both tables transcribed verbatim from | |
| 36 | + `~/.cache/aom-oracle/src/av1/common/reconintra.c:65,254`; `Reach::table` | |
| 37 | + maps side 4 to the new row. | |
| 38 | +3. Cherry-picked lane-tiny `9b1297a` (deblocker chroma tx size from the block | |
| 39 | + span) per the charter -- it does not change this lane's residue but keeps | |
| 40 | + the branch aligned with main's fix. | |
| 41 | + | |
| 42 | +## Gate result | |
| 43 | +`a_real_aomenc_stream_with_a_sub8_split_decodes_pixel_exact` -- **still RED**, | |
| 44 | +but for a 4-pixel chroma residue instead of a desync: | |
| 45 | +- symbol ladder vs instrumented aomdec is now **exact** on both sampled | |
| 46 | + streams (324/324 elements seed=117, 318/318 seed=100), no refusal, decode | |
| 47 | + completes; | |
| 48 | +- luma is **bit-exact** on seed=100; | |
| 49 | +- chroma differs on 4 pixels: U/V (row 20, cols 18-19), deltas 1..3. | |
| 50 | + | |
| 51 | +EVIDENCE: /tmp/.../scratchpad/{ref100.yuv,ours100.yuv} | aomenc seed=100 cq=6 recipe from the gate, decoded by ec-av1 and by ffmpeg | 4096/4096 luma bytes equal, 4/2048 chroma bytes differ (max |delta| 3); before this round the same stream refused at a hallucinated partition symbol | |
| 52 | +EVIDENCE: /tmp/.../scratchpad/{ref.txt,ours.txt} + ladder.py | EC_TRACE/EC_TRACE_MODE_STEP ladder, ours vs instrumented aomdec, seed=117 | 324 elements, no divergence (was: first divergence at element 62) | |
| 53 | + | |
| 54 | +## Suite | |
| 55 | +`cargo test -p ec-av1 --lib` (EC_AV1_REQUIRE_AOMENC=1): **267 passed, 2 failed, | |
| 56 | +22 ignored**, 1124 s. | |
| 57 | +- `stream::a_real_aomenc_stream_with_a_sub8_split_decodes_pixel_exact` -- the | |
| 58 | + 4-pixel chroma residue above. | |
| 59 | +- `refusal_inventory::the_decode_path_refuses_exactly_the_listed_cases` -- | |
| 60 | + NOT investigated this round (budget). Expected shape: a refusal the | |
| 61 | + inventory expects to fire no longer fires now that the desync is gone | |
| 62 | + (that is what the fix was for), but it is a RED test and no refusal string | |
| 63 | + was lifted this round. | |
| 64 | + | |
| 65 | +## Open | |
| 66 | +- fix-now: the 4-pixel chroma residue (U/V row 20, cols 18-19 of the 64x64 | |
| 67 | + seed=100 frame; block = chroma 4x4 at (20,16), luma 8x8 group mi(10,8)). | |
| 68 | + Tried and REVERTED (no effect on these pixels): OR-ing the subsampling scale | |
| 69 | + into the chroma edge's mi (`set_lpf_parameters`' `scale_vert | ...`) in | |
| 70 | + `edge_params`. Next step: dump post-reconstruction vs `EC_AV1_PREFILT_DUMP` | |
| 71 | + to separate recon from deblock before touching either. | |
| 72 | +- fix-now: `refusal_inventory` red (see above). | |
| 73 | +- deferred(gate green): lifting any refusal string -- nothing lifted, none | |
| 74 | + proven. |
lanes/sub8-r5.report.mdadded+93 -0
| @@ -0,0 +1,93 @@ | ||
| 1 | +# lane-sub8 report (round 5) | |
| 2 | + | |
| 3 | +## Root cause of the 4-pixel chroma residue | |
| 4 | + | |
| 5 | +Recon vs filtering was separated FIRST (charter step 1): the gate's own aomenc | |
| 6 | +recipe carries `--enable-cdef=0 --loopfilter-control=0`, and our | |
| 7 | +`EC_AV1_PREFILT_DUMP` / `EC_AV1_POSTDEBLOCK_DUMP` dumps are byte-identical to | |
| 8 | +the final planes -- so every filter stage is inert on this stream and the | |
| 9 | +residue was pure reconstruction. (r4's `edge_params` experiment could not have | |
| 10 | +moved it: there is no deblocking in this stream at all.) | |
| 11 | + | |
| 12 | +The mismatching block is NOT a sub-8x8 group: `EC_AV1_TRACE` shows | |
| 13 | +`partition_w8 mi=(10,8) value=0` -- a plain `PARTITION_NONE` 8x8 leaf with | |
| 14 | +`tx_depth=1` (four 4x4 luma TUs), luma mode H_PRED, `uv_mode=6` (D157_PRED), | |
| 15 | +chroma 4x4 at (16,20). Subtracting the (bit-exact) residual from both recons | |
| 16 | +isolates it to the *prediction*: ours and libaom's differ only at row 0, | |
| 17 | +columns 2-3. | |
| 18 | + | |
| 19 | +**`get_intra_edge_filter_type` (reconintra.c:974) reads the CHROMA neighbours' | |
| 20 | +`uv_mode` for planes 1/2**, never the luma mode. `decode_leaf8` and | |
| 21 | +`decode_leaf_split4` passed a hardcoded `false` on every chroma | |
| 22 | +`reconstruct`/`read_plane`, so a directional chroma block whose chroma | |
| 23 | +neighbour is smooth filtered its above edge at `intra_edge_filter_strength` | |
| 24 | +type 0 (kernel `{0,4,8,4,0}`, strength 1 at d=67) instead of type 1 | |
| 25 | +(`{0,5,6,5,0}`, strength 2) -- deltas of 1..3 on the two pixels the kernel | |
| 26 | +difference reaches. | |
| 27 | + | |
| 28 | +Second half of the cause: the coarse `SUB`-grid `above_uv_mode`/`left_uv_mode` | |
| 29 | +slots cannot name that neighbour. Adding the leaf's own write to them makes | |
| 30 | +the top-left 8x8 leaf of a 16x16 clobber the row slot that the block to the | |
| 31 | +LEFT owns, and the block at mi(10,8) then still read `false` (measured: the | |
| 32 | +frame stayed 4 pixels off). So this round adds the `uv_mode` twin of the | |
| 33 | +existing mi-granular `sub8_mode_col`/`sub8_mode_row` machinery. | |
| 34 | + | |
| 35 | +## What changed | |
| 36 | +- `crates/ec-av1/src/decode.rs:1784` -- new `uv_mode_col`/`uv_mode_row` mi-granular | |
| 37 | + maps on `Neighbours` (+ init). | |
| 38 | +- `crates/ec-av1/src/decode.rs:2548` `record_uv_mode_mi`, `:2573` | |
| 39 | + `smooth_uv_neighbour` (mi-exact above/left `uv_mode`, coarse `SUB` slot as | |
| 40 | + fallback), written from `record_rect` (:2606), `record_split_luma` (:2718), | |
| 41 | + `decode_leaf8` (:5362) and `decode_leaf_split4` (:5845). | |
| 42 | +- `crates/ec-av1/src/decode.rs:5331,5758` -- `smooth_neighbor_uv` replaces the | |
| 43 | + hardcoded `false` at all 10 chroma reconstruct/read_plane arguments in those | |
| 44 | + two functions. | |
| 45 | +- `crates/ec-av1/src/refusal_inventory.rs:31` -- deleted the stale capability | |
| 46 | + claim `"a partition below 8x8 (this decoder codes no leaf smaller than | |
| 47 | + 8x8)"` (corrected in r6: the string named here originally was wrong); r4's fixes | |
| 48 | + removed that string from the decode path, which is exactly what made | |
| 49 | + `the_decode_path_refuses_exactly_the_listed_cases` RED (charter step 2). | |
| 50 | + It was the only entry the test named. | |
| 51 | + | |
| 52 | +## Gate | |
| 53 | +`a_real_aomenc_stream_with_a_sub8_split_decodes_pixel_exact` -- **GREEN** | |
| 54 | +(4 firing + pixel-exact runs; `sub8_split_hits` hard-asserted, no SKIP). | |
| 55 | + | |
| 56 | +``` | |
| 57 | +EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib sub8 | |
| 58 | + test stream::tests::a_real_aomenc_stream_with_a_sub8_split_decodes_pixel_exact ... ok | |
| 59 | +``` | |
| 60 | + | |
| 61 | +EVIDENCE: <scratchpad>/sub8r5/{mine.yuv,ref.yuv} | seed=100 cq=6 gate recipe re-run standalone (sha256 64f6f74e... 3994 B), decoded by `examples/decode_probe` and by ffmpeg | 6144/6144 bytes equal (was 4 chroma bytes off, |delta| <= 3) | |
| 62 | +EVIDENCE: <scratchpad>/sub8r5/prefilt+postdeblock dumps | EC_AV1_PREFILT_DUMP / EC_AV1_POSTDEBLOCK_DUMP on the same stream | both byte-identical to the final planes -> filters inert, residue is reconstruction | |
| 63 | +EVIDENCE: <scratchpad>/sub8r5/hg.obu | `ffmpeg -t 0.4 -c:v copy -f obu` from the ReelB film, `decode_probe` after the fix | REFUSED at "a HORZ/VERT partition below 8x8" (was: "a partition below 8x8") | |
| 64 | + | |
| 65 | +## Refusals | |
| 66 | +Nothing lifted, nothing to lift: the PARTITION_SPLIT-to-4x4 shape the charter | |
| 67 | +names has had **no refusal string** since `decode_leaf_split4` landed (r2) -- | |
| 68 | +the gate is what was missing, and it is now green, so the capability is | |
| 69 | +proven rather than assumed. The two below-8x8 strings that remain are both | |
| 70 | +out of this lane by the standing constraint: | |
| 71 | +- `"a HORZ/VERT partition below 8x8 (... 4x8/8x4 need a real rectangular | |
| 72 | + transform)"` -- deferred(a real TX_4X8/TX_8X4 primitive). This is now the | |
| 73 | + ReelB blocker. | |
| 74 | +- `"an inter partition below 8x8 ..."` -- deferred(an inter lane; lane-sub8 is | |
| 75 | + intra-scoped). | |
| 76 | + | |
| 77 | +## Suite | |
| 78 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib`: **269 passed, 0 failed, 22 | |
| 79 | +ignored**, 476 s (r4 was 267 passed, 2 failed -- both now green). | |
| 80 | + | |
| 81 | +## Open / disposition | |
| 82 | +- deferred(an inter-frame gate whose chroma neighbour codes a smooth `uv_mode`) | |
| 83 | + -- same-shape sweep: `decode.rs:12084,12096` (`decode_inter_block8`'s | |
| 84 | + intra-in-inter chroma reconstruct) still pass a hardcoded `false` for the | |
| 85 | + chroma edge-filter type. Every other chroma site now takes a `uv_mode`-derived | |
| 86 | + flag; `decode_block`/`decode_inter_block` (:3251,:3765,:4893,:10929) take it | |
| 87 | + from the coarse `SUB` slots, which is exact for >=16x16 neighbours and | |
| 88 | + approximate when the neighbour is an 8x8 leaf -- upgrade path is to route | |
| 89 | + those four through `smooth_uv_neighbour` too. | |
| 90 | +- accepted: `smooth_uv_neighbour` falls back to the coarse slot when no block | |
| 91 | + recorded the exact neighbouring mi (documented at the field). | |
| 92 | +- Film: ReelB now stops at the HORZ/VERT-below-8x8 refusal above; the | |
| 93 | + film is also yuv420p10le, so a 10-bit refusal waits behind it. |
lanes/sub8-r6.report.mdadded+77 -0
| @@ -0,0 +1,77 @@ | ||
| 1 | +# lane-sub8 report (round 6) -- verifier FAIL closed | |
| 2 | + | |
| 3 | +## The defect the verifier found (root cause) | |
| 4 | + | |
| 5 | +The mi-granular mode maps added in r2/r5 (`sub8_mode_col`/`sub8_mode_row`, | |
| 6 | +`uv_mode_col`/`uv_mode_row`) are FRAME-wide arrays read with a FRAME-relative | |
| 7 | +availability guard (`mi_r > 0` / `mi_c > 0`) and never reset per tile. Every | |
| 8 | +other neighbour site in `decode.rs` guards tile-relatively | |
| 9 | +(`mi_r > self.tile_row0_mi`, e.g. :2240, :3222, :6152). With more than one | |
| 10 | +tile, the first block of tile N read a `(row, mode)` entry left by the tile to | |
| 11 | +its LEFT (or above) as if it were its own neighbour -- wrong intra-mode | |
| 12 | +context / wrong chroma edge-filter type, and from there wrong pixels. | |
| 13 | + | |
| 14 | +## What changed (all in the lane worktree, branch `lane-sub8`) | |
| 15 | +- `crates/ec-av1/src/decode.rs:2533,2540,2574,2578` -- the four reads now guard | |
| 16 | + with `self.tile_row0_mi` / `self.tile_col0_mi`. | |
| 17 | +- `crates/ec-av1/src/decode.rs:2000` (`start_tile`) -- clears | |
| 18 | + `sub8_mode_col`/`uv_mode_col` over the tile's own mi column span | |
| 19 | + (`col0_mi..col1_mi`), alongside the existing `above_*` reset. | |
| 20 | +- `crates/ec-av1/src/decode.rs:2286` (`start_row`) -- clears | |
| 21 | + `sub8_mode_row`/`uv_mode_row` with the rest of the left context. | |
| 22 | +- `crates/ec-av1/src/decode.rs:3763` -- `decode_leaf_rect` (the 16x8/8x16 | |
| 23 | + strips) now calls `record_mode_mi`/`record_uv_mode_mi` over its real span; | |
| 24 | + before, the caller patched only the coarse 16x16 `above_mode`/`left_mode` | |
| 25 | + slot, so a neighbour of the TOP strip read the BOTTOM strip's mode. | |
| 26 | + (Sweep item 1 of the verifier's list.) | |
| 27 | +- `crates/ec-av1/src/decode.rs:5326` -- deleted the stale `corner-cut` comment | |
| 28 | + claiming the uv neighbours are coarse; they are mi-exact since r5. | |
| 29 | +- `crates/ec-av1/src/stream.rs:7259..` -- gate rewritten: three arms | |
| 30 | + (single tile / `--tile-columns=1` at 128x64 / `--tile-rows=1` at 64x128), | |
| 31 | + each needing 4 firing + pixel-exact runs; `tile_hits()` delta >= 2 asserted | |
| 32 | + on the tile arms (gate-blind-to-feature); the `Err` arm now ASSERTS the | |
| 33 | + message starts with `unsupported: ` -- any other decode error panics | |
| 34 | + instead of counting as a tolerated refusal; the fixture's `noise` filter | |
| 35 | + carries `all_seed={seed}`. | |
| 36 | +- `lanes/sub8-r5.report.md:45` -- the deleted refusal string named correctly | |
| 37 | + ("a partition below 8x8 ..."). | |
| 38 | + | |
| 39 | +## Gate | |
| 40 | + | |
| 41 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib sub8` -> **ok, 1 passed** | |
| 42 | +(3 arms x 4 firing+pixel-exact runs). | |
| 43 | + | |
| 44 | +Regression value proved by reverting only the guard+reset hunks: the same gate | |
| 45 | +FAILS (`U vs ffmpeg (seed=139 cq=12)`, stream.rs:7394) -- so this gate catches | |
| 46 | +the defect, it is not a pass-by-construction arm. | |
| 47 | + | |
| 48 | +EVIDENCE: <scratchpad>/bad207.obu (sha256 0f78db8b...), bad228.obu (sha256 6a73db99...) | `decode_probe <obu> out.yuv` + `ffmpeg -i <obu> -f rawvideo -pix_fmt yuv420p` on this branch | both 12288/12288 bytes equal (verifier's pre-fix .mine.yuv: 221 and 158 differing bytes, all at x>=64) | |
| 49 | +EVIDENCE: gate run above | 3-arm gate incl. --tile-columns=1 / --tile-rows=1, tile_hits delta >= 2 asserted | ok; with the guard+reset hunks reverted the same gate FAILS at seed=139 cq=12 (U plane) | |
| 50 | +EVIDENCE: <scratchpad>/reelb_r6.obu | `ffmpeg -t 0.4 -c:v copy -f obu` from the ReelB film, `decode_probe` on this branch | REFUSED at "a HORZ/VERT partition below 8x8 (... 4x8/8x4 need a real rectangular transform)" -- unchanged from r5, and past main's "a partition below 8x8" | |
| 51 | +EVIDENCE: fixture reproducibility | the gate's lavfi source (seed 207, 128x64) rendered twice with and without `all_seed=207` | with: d3c4b3e3... both runs; without: 5619b3ee... both runs -- ffmpeg's `noise` was in fact deterministic in this pair of runs, `all_seed` pins it explicitly rather than relying on that | |
| 52 | + | |
| 53 | +## Refusals | |
| 54 | +None lifted, none added this round; `refusal_inventory` and `gate_coverage` | |
| 55 | +stay green (totals below). | |
| 56 | + | |
| 57 | +## Suite | |
| 58 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib`: **269 passed, 0 failed, 22 ignored**, 933 s (r5: 269/0/22). | |
| 59 | + | |
| 60 | +An earlier run of the same command on the same tree reported `error: test | |
| 61 | +failed` with the failing test's name swallowed by my own grep filter; the | |
| 62 | +full rerun above (log `<scratchpad>/suite_r6.log`) is clean. Flagged as a | |
| 63 | +possible flake under 10 concurrent lanes rather than claimed benign -- | |
| 64 | +open, unblocked by a rerun that captures the whole log. | |
| 65 | + | |
| 66 | +## Open / disposition | |
| 67 | +- deferred(an inter lane) -- `decode.rs:8547-8548` (`up_available`/ | |
| 68 | + `left_available` in the inter path) and `mvstack.rs:727,733,742,756,1486, | |
| 69 | + 1492,1501,1515` still use frame-relative `mi_row > 0` / `mi_col > 0` where | |
| 70 | + libaom uses `tile->mi_row_start`/`mi_col_start`. Same shape as this round's | |
| 71 | + defect but in code this lane never touched and no intra gate reaches; | |
| 72 | + unblocked by a multi-tile INTER gate. | |
| 73 | +- deferred(an inter-frame gate whose chroma neighbour codes a smooth | |
| 74 | + `uv_mode`) -- carried from r5: `decode.rs:12084,12096` still pass a | |
| 75 | + hardcoded `false` chroma edge-filter type. | |
| 76 | +- accepted: `smooth_uv_neighbour` falls back to the coarse `SUB` slot when no | |
| 77 | + block recorded the exact neighbouring mi. |