lane-av1-ibcrect: intrabc on 128-root HORZ/VERT strips decodes pixel-exact; per-unit chroma replay after the end-of-block record
Browse files at this commit6f2548b2a63c004bea2aceb21711beec2587170eParent: b9432314 changed files +823 -44
- crates/ec-av1/examples/decode_probe.rs +14 -0
- crates/ec-av1/src/decode.rs +480 -4
- crates/ec-av1/src/refusal_inventory.rs +128 -40
- crates/ec-av1/src/stream.rs +201 -0
crates/ec-av1/examples/decode_probe.rsmodified+14 -0
| @@ -63,6 +63,12 @@ fn main() { | |||
| 63 | ec_av1::decode::intrabc_rect_hits(), | 63 | ec_av1::decode::intrabc_rect_hits(), |
| 64 | ec_av1::decode::intrabc_rect_vartx_hits() | 64 | ec_av1::decode::intrabc_rect_vartx_hits() |
| 65 | ); | 65 | ); |
| 66 | + // lane-av1-ibcrect: `use_intrabc` on a 128-root HORZ/VERT strip -- | ||
| 67 | + // the shape `decode_block_128rect` used to refuse. | ||
| 68 | + println!( | ||
| 69 | + "intrabc_128rect: {}", | ||
| 70 | + ec_av1::stream::intrabc_128rect_hits() | ||
| 71 | + ); | ||
| 66 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); | 72 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); |
| 67 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); | 73 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); |
| 68 | println!( | 74 | println!( |
| @@ -142,6 +148,14 @@ fn main() { | |||
| 142 | "sb128_rect: edge_horz={} edge_vert={} inter_128x64={} inter_64x128={}", | 148 | "sb128_rect: edge_horz={} edge_vert={} inter_128x64={} inter_64x128={}", |
| 143 | sb.0, sb.1, sb.2, sb.3 | 149 | sb.0, sb.1, sb.2, sb.3 |
| 144 | ); | 150 | ); |
| 151 | + // lane-av1-ibcrect: the interior 128-root partition arms and the key | ||
| 152 | + // frame's intra 128-axis blocks, so a recipe sweep can tell "the | ||
| 153 | + // encoder never chose HORZ/VERT at the 128 root" from "it did". | ||
| 154 | + let p128 = ec_av1::stream::part128_census(); | ||
| 155 | + println!( | ||
| 156 | + "part128: split={} none={} horz={} vert={} ab={:?} intra_horz={} intra_vert={}", | ||
| 157 | + p128.0, p128.1, p128.2, p128.3, p128.4, p128.5, p128.6 | ||
| 158 | + ); | ||
| 145 | // lane-sbab r1: the superblock-level inter AB arms. | 159 | // lane-sbab r1: the superblock-level inter AB arms. |
| 146 | let sbab = ec_av1::decode::sb_ab_inter_hits_by_arm(); | 160 | let sbab = ec_av1::decode::sb_ab_inter_hits_by_arm(); |
| 147 | println!( | 161 | println!( |
crates/ec-av1/src/decode.rsmodified+480 -4
| @@ -3810,6 +3810,27 @@ pub fn intrabc_rect_vartx_hits() -> usize { | |||
| 3810 | INTRABC_RECT_VARTX_HITS.with(|c| c.get()) | 3810 | INTRABC_RECT_VARTX_HITS.with(|c| c.get()) |
| 3811 | } | 3811 | } |
| 3812 | 3812 | ||
| 3813 | +thread_local! { | ||
| 3814 | + /// lane-av1-ibcrect: `use_intrabc` blocks on a 128-root HORZ/VERT strip | ||
| 3815 | + /// (BLOCK_128X64 / BLOCK_64X128) whose reconstruction | ||
| 3816 | + /// [`decode_intrabc_128rect`] ran -- the shape the named refusal used to | ||
| 3817 | + /// guard (`decode_block_128rect`). A refused block bumps | ||
| 3818 | + /// [`INTRABC_HITS`] but never this one. | ||
| 3819 | + static INTRABC_128RECT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 3820 | +} | ||
| 3821 | + | ||
| 3822 | +/// Current value of [`INTRABC_128RECT_HITS`]. | ||
| 3823 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | ||
| 3824 | +pub fn intrabc_128rect_hits() -> usize { | ||
| 3825 | + INTRABC_128RECT_HITS.with(|c| c.get()) | ||
| 3826 | +} | ||
| 3827 | + | ||
| 3828 | +/// Zeroes [`INTRABC_128RECT_HITS`]. | ||
| 3829 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | ||
| 3830 | +pub(crate) fn reset_intrabc_128rect_hits() { | ||
| 3831 | + INTRABC_128RECT_HITS.with(|c| c.set(0)); | ||
| 3832 | +} | ||
| 3833 | + | ||
| 3813 | /// Current value of [`INTRABC_VARTX_HITS`]. | 3834 | /// Current value of [`INTRABC_VARTX_HITS`]. |
| 3814 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 3835 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates |
| 3815 | pub(crate) fn intrabc_vartx_hits() -> usize { | 3836 | pub(crate) fn intrabc_vartx_hits() -> usize { |
| @@ -11409,6 +11430,447 @@ fn decode_intrabc_rect( | |||
| 11409 | Ok(()) | 11430 | Ok(()) |
| 11410 | } | 11431 | } |
| 11411 | 11432 | ||
| 11433 | +/// lane-av1-ibcrect: reconstruction for a `use_intrabc` block on a 128-root | ||
| 11434 | +/// HORZ/VERT strip (`BLOCK_128X64` / `BLOCK_64X128`) -- the shape | ||
| 11435 | +/// `decode_block_128rect` refused by name before this port. libaom decodes | ||
| 11436 | +/// such a block through the INTER machinery (an intrabc block | ||
| 11437 | +/// `is_inter_block`): `predict_inter_block` copies the whole block from this | ||
| 11438 | +/// frame's own reconstruction at the integer block vector once, then | ||
| 11439 | +/// `decode_token_recon_block`'s inter arm walks 64x64 "mu" chunks -- | ||
| 11440 | +/// per chunk every plane, luma units at the block's own resolved transform | ||
| 11441 | +/// (`read_block_tx_size_rect`, TX_64X64 roots) and chroma at | ||
| 11442 | +/// `av1_get_max_uv_txsize(BLOCK_128X64)` = TX_32X32, one unit per plane per | ||
| 11443 | +/// chunk at 4:2:0. Chroma never codes its own `tx_type`; each unit inherits | ||
| 11444 | +/// the coded type of the luma leaf covering its quadrant (`av1_get_tx_type`, | ||
| 11445 | +/// blockd.h:1291). `mode`/`uv_mode` read as `DC_PRED`/`UV_DC_PRED` back in | ||
| 11446 | +/// [`read_intra_mode_rect`]; no palette/filter-intra/CFL symbol exists here. | ||
| 11447 | +#[allow(clippy::too_many_arguments)] | ||
| 11448 | +fn decode_intrabc_128rect( | ||
| 11449 | + dec: &mut SymbolDecoder, | ||
| 11450 | + cdfs: &mut Cdfs, | ||
| 11451 | + neighbours: &mut Neighbours, | ||
| 11452 | + (mi_r, mi_c): (usize, usize), | ||
| 11453 | + (bw, bh): (usize, usize), | ||
| 11454 | + skip: bool, | ||
| 11455 | + (dv_row, dv_col): (i32, i32), | ||
| 11456 | + y: &mut PlaneBuf<'static>, | ||
| 11457 | + u: &mut PlaneBuf<'static>, | ||
| 11458 | + v: &mut PlaneBuf<'static>, | ||
| 11459 | + base_q_idx: u8, | ||
| 11460 | + fctx: &crate::decode::FrameCtx, | ||
| 11461 | +) -> Result<()> { | ||
| 11462 | + hit!(INTRABC_128RECT_HITS); | ||
| 11463 | + if crate::envflags::env_flag!("EC_AV1_TRACE") { | ||
| 11464 | + let (rng, _) = dec.debug_state(); | ||
| 11465 | + eprintln!( | ||
| 11466 | + "EC_IBC128 mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} skip={skip} dv=({dv_row},{dv_col}) rng={rng}" | ||
| 11467 | + ); | ||
| 11468 | + } | ||
| 11469 | + let (px, py) = (mi_c * MI, mi_r * MI); | ||
| 11470 | + let (cpx, cpy) = (px / 2, py / 2); | ||
| 11471 | + let (cw, ch) = (bw / 2, bh / 2); | ||
| 11472 | + // The square strides the proven INTER path lays its residual grids, | ||
| 11473 | + // prediction windows and `TxParams` at (see [`decode_intrabc_rect`]'s r2 | ||
| 11474 | + // note): 128/64 here. | ||
| 11475 | + let side = bw.max(bh); | ||
| 11476 | + let cside = cw.max(ch); | ||
| 11477 | + // `av1_calc_mi_size`'s 8-px-aligned grid: units past the frame edge code | ||
| 11478 | + // nothing (`decode_reconstruct_tx`'s max_blocks_* early return). | ||
| 11479 | + let mi_cols = 2 * y.true_width.div_ceil(8); | ||
| 11480 | + let mi_rows = 2 * y.true_height.div_ceil(8); | ||
| 11481 | + // An intrabc block is is_inter_block: the tx tree is the INTER one, and | ||
| 11482 | + // [`read_block_tx_size_rect`]'s 128-root branch already carries the | ||
| 11483 | + // LARGEST (no symbol, two TX_64X64 units), TX_MODE_SELECT (var-tx tree | ||
| 11484 | + // rooted at TX_64X64), skip (band stamp only) and lossless (TX_4X4 grid) | ||
| 11485 | + // arms (lane-sb128c r7). | ||
| 11486 | + let leaves = read_block_tx_size_rect( | ||
| 11487 | + dec, | ||
| 11488 | + cdfs, | ||
| 11489 | + neighbours, | ||
| 11490 | + (mi_r, mi_c), | ||
| 11491 | + (bw, bh), | ||
| 11492 | + (mi_cols, mi_rows), | ||
| 11493 | + skip, fctx, | ||
| 11494 | + )?; | ||
| 11495 | + // Whole-block prediction, once, before any coefficient is read | ||
| 11496 | + // (`predict_inter_block`); the source is this frame's own | ||
| 11497 | + // reconstruction, including the writes this superblock has queued. | ||
| 11498 | + flush_recon(fctx, y, u, v); | ||
| 11499 | + let mut pred_y_dense = vec![0u16; bw * bh]; | ||
| 11500 | + mc::predict_with_filter( | ||
| 11501 | + &y.data, y.width, y.true_width, y.true_height, | ||
| 11502 | + mv_to_q4(px, dv_col, true), mv_to_q4(py, dv_row, true), | ||
| 11503 | + bw, bh, mc::InterpFilterKind::Bilinear, &mut pred_y_dense, fctx, | ||
| 11504 | + ); | ||
| 11505 | + let mut pred_y = vec![0u16; side * side]; | ||
| 11506 | + for row in 0..bh { | ||
| 11507 | + pred_y[row * side..][..bw].copy_from_slice(&pred_y_dense[row * bw..][..bw]); | ||
| 11508 | + } | ||
| 11509 | + let mut pred_u_dense = vec![0u16; cw * ch]; | ||
| 11510 | + mc::predict_with_filter( | ||
| 11511 | + &u.data, u.width, u.true_width, u.true_height, | ||
| 11512 | + mv_to_q4(cpx, dv_col, false), mv_to_q4(cpy, dv_row, false), | ||
| 11513 | + cw, ch, mc::InterpFilterKind::Bilinear, &mut pred_u_dense, fctx, | ||
| 11514 | + ); | ||
| 11515 | + let mut pred_u = vec![0u16; cside * cside]; | ||
| 11516 | + for row in 0..ch { | ||
| 11517 | + pred_u[row * cside..][..cw].copy_from_slice(&pred_u_dense[row * cw..][..cw]); | ||
| 11518 | + } | ||
| 11519 | + let mut pred_v_dense = vec![0u16; cw * ch]; | ||
| 11520 | + mc::predict_with_filter( | ||
| 11521 | + &v.data, v.width, v.true_width, v.true_height, | ||
| 11522 | + mv_to_q4(cpx, dv_col, false), mv_to_q4(cpy, dv_row, false), | ||
| 11523 | + cw, ch, mc::InterpFilterKind::Bilinear, &mut pred_v_dense, fctx, | ||
| 11524 | + ); | ||
| 11525 | + let mut pred_v = vec![0u16; cside * cside]; | ||
| 11526 | + for row in 0..ch { | ||
| 11527 | + pred_v[row * cside..][..cw].copy_from_slice(&pred_v_dense[row * cw..][..cw]); | ||
| 11528 | + } | ||
| 11529 | + let (luma_grid, u_grid, v_grid); | ||
| 11530 | + // lane-av1-ibcrect: whether the coded arm stamped its CHROMA neighbour | ||
| 11531 | + // contexts per transform unit -- the replay after this fn's end-of-block | ||
| 11532 | + // record restores them (the record itself re-stamps both planes with ONE | ||
| 11533 | + // composed state, class `override-slot-on-one-arm`). | ||
| 11534 | + let mut mu_chroma = false; | ||
| 11535 | + if skip { | ||
| 11536 | + // No residual syntax at all: the prediction IS the block. Strides are | ||
| 11537 | + // `side`/`cside`, not `bw` -- `reconstruct_mc_rect` indexes | ||
| 11538 | + // `row * stride + w` for row in 0..h (the r5 VERT-strip overrun). | ||
| 11539 | + push_mc_rect(0, px, py, side, bw, bh, Pred::Inline(&pred_y, side), &ZERO_RESIDUAL[..side * side], fctx); | ||
| 11540 | + push_mc_rect(1, cpx, cpy, cside, cw, ch, Pred::Inline(&pred_u, cside), &ZERO_RESIDUAL[..cside * cside], fctx); | ||
| 11541 | + push_mc_rect(2, cpx, cpy, cside, cw, ch, Pred::Inline(&pred_v, cside), &ZERO_RESIDUAL[..cside * cside], fctx); | ||
| 11542 | + if let Some(ls) = leaves.as_ref() { | ||
| 11543 | + // A LOSSLESS frame's `read_block_tx_size_rect` resolves the TX_4X4 | ||
| 11544 | + // grid before it looks at `skip`; the skipped block still zeroes | ||
| 11545 | + // its entropy-band footprint over every unit (libaom | ||
| 11546 | + // `av1_reset_entropy_context` under `if (mbmi->skip_txfm)`) -- | ||
| 11547 | + // the same arm [`decode_intrabc_rect`]'s loss64 merge added. | ||
| 11548 | + hit!(SKIP_LOSSLESS_BAND_RESET_HITS); | ||
| 11549 | + for &(row, col, tw, th) in ls { | ||
| 11550 | + neighbours.record_mi_luma_rect( | ||
| 11551 | + (mi_r + row, mi_c + col), | ||
| 11552 | + tw, | ||
| 11553 | + th, | ||
| 11554 | + &ZERO_RESIDUAL[..tw * th], | ||
| 11555 | + ); | ||
| 11556 | + } | ||
| 11557 | + } | ||
| 11558 | + luma_grid = Grid::Zero(side * side); | ||
| 11559 | + u_grid = Grid::Zero(cside * cside); | ||
| 11560 | + v_grid = Grid::Zero(cside * cside); | ||
| 11561 | + } else { | ||
| 11562 | + let leaves = leaves.expect( | ||
| 11563 | + "read_block_tx_size_rect returns None only for skip below 128 at this shape", | ||
| 11564 | + ); | ||
| 11565 | + // libaom `get_transform_size`'s split override applies to LUMA only, | ||
| 11566 | + // per leaf -- each unit's own transform edges get filtered | ||
| 11567 | + // ([`decode_intrabc_rect`]'s P2, the proven inter path's step). | ||
| 11568 | + for &(row, col, tw, th) in leaves.iter() { | ||
| 11569 | + neighbours.fill_lf_grid_leaf_luma( | ||
| 11570 | + (mi_r + row, mi_c + col), | ||
| 11571 | + tw / MI, | ||
| 11572 | + th / MI, | ||
| 11573 | + tw as u8, | ||
| 11574 | + th as u8, | ||
| 11575 | + ); | ||
| 11576 | + } | ||
| 11577 | + let reduced = fctx.reduced_tx_set_inter.with(std::cell::Cell::get); | ||
| 11578 | + let mut u_units: Vec<i32> = Vec::new(); | ||
| 11579 | + let mut v_units: Vec<i32> = Vec::new(); | ||
| 11580 | + let mut leaf_tx_types: Vec<(usize, usize, usize, usize, TxType)> = Vec::new(); | ||
| 11581 | + // Frame-edge clip of the mu walk (`max_block_wide/high`): a unit whose | ||
| 11582 | + // top-left sample is outside the frame codes nothing. | ||
| 11583 | + let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(mi_c)); | ||
| 11584 | + let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(mi_r)); | ||
| 11585 | + for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() { | ||
| 11586 | + debug_assert_eq!(tw, th, "a square TX_64X64 tree root only yields square leaves"); | ||
| 11587 | + let tu_mi = (mi_r + row, mi_c + col); | ||
| 11588 | + let (tu_px, tu_py) = (px + col * MI, py + row * MI); | ||
| 11589 | + if tu_px >= y.true_width || tu_py >= y.true_height { | ||
| 11590 | + continue; | ||
| 11591 | + } | ||
| 11592 | + let tu_pred = Pred::Inline(&pred_y, side).offset(row * MI * side + col * MI); | ||
| 11593 | + let scan = default_scan(tw.min(32)); | ||
| 11594 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tw / MI); | ||
| 11595 | + let (tu_grid, tu_tx_type) = read_inter_plane( | ||
| 11596 | + dec, | ||
| 11597 | + cdfs, | ||
| 11598 | + inter_txbset_for(tw, reduced), | ||
| 11599 | + &scan, | ||
| 11600 | + 0, | ||
| 11601 | + neighbours.around_mi(tu_mi, tw)[0], | ||
| 11602 | + 0, | ||
| 11603 | + y, | ||
| 11604 | + tu_px, | ||
| 11605 | + tu_py, | ||
| 11606 | + tw, | ||
| 11607 | + base_q_idx, | ||
| 11608 | + tu_pred, | ||
| 11609 | + None, | ||
| 11610 | + Some(tu_skip_ctx), fctx, | ||
| 11611 | + )?; | ||
| 11612 | + leaf_tx_types.push((row, col, tw, th, tu_tx_type)); | ||
| 11613 | + neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid); | ||
| 11614 | + // libaom `decode_token_recon_block` codes EVERY PLANE of a 64x64 | ||
| 11615 | + // mu chunk before the next one starts: once this chunk's leaves | ||
| 11616 | + // are done, its chroma is read immediately (the inter 128 path's | ||
| 11617 | + // interleave). | ||
| 11618 | + let chunk = (row / 16, col / 16); | ||
| 11619 | + let done = idx + 1 == leaves.len() | ||
| 11620 | + || (leaves[idx + 1].0 / 16, leaves[idx + 1].1 / 16) != chunk; | ||
| 11621 | + if done { | ||
| 11622 | + let (cr, cc) = chunk; | ||
| 11623 | + // `av1_get_max_uv_txsize(BLOCK_128X64)` = TX_32X32: one | ||
| 11624 | + // TX_32X32 chroma unit per plane per chunk at 4:2:0, raster | ||
| 11625 | + // within the chunk, plane-major inside the chunk. | ||
| 11626 | + let cu_tx = 32usize; | ||
| 11627 | + let chunk_chroma = cside * 64 / side; | ||
| 11628 | + let unit_luma = cu_tx * (side / cside); | ||
| 11629 | + let chunk_w_mi = 16.min(max_w_mi.saturating_sub(cc * 16)); | ||
| 11630 | + let chunk_h_mi = 16.min(max_h_mi.saturating_sub(cr * 16)); | ||
| 11631 | + let units_x = chunk_w_mi / (unit_luma / MI); | ||
| 11632 | + let units_y = chunk_h_mi / (unit_luma / MI); | ||
| 11633 | + if lossless(fctx) { | ||
| 11634 | + // TX_4X4 chroma units over this chunk (lane-lossless2's | ||
| 11635 | + // walk, shared with the inter 128 path). | ||
| 11636 | + read_inter_chroma_lossless( | ||
| 11637 | + dec, cdfs, neighbours, u, v, | ||
| 11638 | + Pred::Inline(&pred_u, cside), Pred::Inline(&pred_v, cside), | ||
| 11639 | + (mi_r, mi_c), (cpx, cpy), | ||
| 11640 | + (cc * chunk_chroma, cr * chunk_chroma), | ||
| 11641 | + (chunk_chroma, chunk_chroma), | ||
| 11642 | + (cw, ch), | ||
| 11643 | + cside, 0, base_q_idx, | ||
| 11644 | + &mut u_units, &mut v_units, fctx, | ||
| 11645 | + )?; | ||
| 11646 | + // lane-av1-ibcrect: read_inter_chroma_lossless stamped | ||
| 11647 | + // every TX_4X4 unit's own context (`record_mi_chroma` | ||
| 11648 | + // inside the walk) -- the end-of-block record below must | ||
| 11649 | + // not overwrite them with the composed grid (the inter | ||
| 11650 | + // 128 path sets the same flag on this arm). | ||
| 11651 | + mu_chroma = true; | ||
| 11652 | + continue; | ||
| 11653 | + } | ||
| 11654 | + let cu_scan = default_scan(cu_tx); | ||
| 11655 | + for plane_idx in 1..3 { | ||
| 11656 | + let (src, buf) = if plane_idx == 1 { | ||
| 11657 | + (Pred::Inline(&pred_u, cside), &mut *u) | ||
| 11658 | + } else { | ||
| 11659 | + (Pred::Inline(&pred_v, cside), &mut *v) | ||
| 11660 | + }; | ||
| 11661 | + for ur in 0..units_y { | ||
| 11662 | + for uc in 0..units_x { | ||
| 11663 | + let unit_mi = ( | ||
| 11664 | + mi_r + cr * 16 + ur * (unit_luma / MI), | ||
| 11665 | + mi_c + cc * 16 + uc * (unit_luma / MI), | ||
| 11666 | + ); | ||
| 11667 | + // Per unit, AFTER the earlier units' stamps: this | ||
| 11668 | + // unit's coefficient context must see them. | ||
| 11669 | + let cu_around = neighbours.around_mi(unit_mi, unit_luma); | ||
| 11670 | + if crate::envflags::env_flag!("EC_ECDUMP") { | ||
| 11671 | + for p in 1..3 { | ||
| 11672 | + let ab: Vec<String> = (0..unit_luma / MI) | ||
| 11673 | + .map(|k| { | ||
| 11674 | + format!( | ||
| 11675 | + "{:?}/{}", | ||
| 11676 | + neighbours.above[unit_mi.1 + k][p].dc, | ||
| 11677 | + neighbours.above[unit_mi.1 + k][p].level | ||
| 11678 | + ) | ||
| 11679 | + }) | ||
| 11680 | + .collect(); | ||
| 11681 | + let lf: Vec<String> = (0..unit_luma / MI) | ||
| 11682 | + .map(|k| { | ||
| 11683 | + format!( | ||
| 11684 | + "{:?}/{}", | ||
| 11685 | + neighbours.left[unit_mi.0 + k][p].dc, | ||
| 11686 | + neighbours.left[unit_mi.0 + k][p].level | ||
| 11687 | + ) | ||
| 11688 | + }) | ||
| 11689 | + .collect(); | ||
| 11690 | + eprintln!( | ||
| 11691 | + "EC_IBC128_BANDS mi=({mi_r},{mi_c}) unit=({cr},{cc}) plane={p} ctx=({},{},{}) above=[{}] left=[{}]", | ||
| 11692 | + cu_around[p].0, cu_around[p].1, cu_around[p].2, ab.join(","), lf.join(",") | ||
| 11693 | + ); | ||
| 11694 | + } | ||
| 11695 | + } | ||
| 11696 | + let (cu_x, cu_y) = ( | ||
| 11697 | + cpx + cc * chunk_chroma + uc * cu_tx, | ||
| 11698 | + cpy + cr * chunk_chroma + ur * cu_tx, | ||
| 11699 | + ); | ||
| 11700 | + // `av1_get_tx_type` (blockd.h:1291): an inter | ||
| 11701 | + // block's chroma unit never codes a tx_type; it | ||
| 11702 | + // inherits the coded type of the luma leaf | ||
| 11703 | + // covering its own quadrant (all of this chunk's | ||
| 11704 | + // leaves are read by now). | ||
| 11705 | + let unit_rel_mi = ( | ||
| 11706 | + unit_mi.0 - mi_r, | ||
| 11707 | + unit_mi.1 - mi_c, | ||
| 11708 | + ); | ||
| 11709 | + let covering = leaf_tx_types | ||
| 11710 | + .iter() | ||
| 11711 | + .copied() | ||
| 11712 | + .find(|&(lr, lc, lw, lh, _)| { | ||
| 11713 | + lr <= unit_rel_mi.0 | ||
| 11714 | + && unit_rel_mi.0 < lr + lh / MI | ||
| 11715 | + && lc <= unit_rel_mi.1 | ||
| 11716 | + && unit_rel_mi.1 < lc + lw / MI | ||
| 11717 | + }) | ||
| 11718 | + .map(|(_, _, _, _, t)| t); | ||
| 11719 | + let cu_pred = src.offset( | ||
| 11720 | + (cr * chunk_chroma + ur * cu_tx) * cside | ||
| 11721 | + + cc * chunk_chroma | ||
| 11722 | + + uc * cu_tx, | ||
| 11723 | + ); | ||
| 11724 | + let cu_grid = read_inter_plane( | ||
| 11725 | + dec, | ||
| 11726 | + cdfs, | ||
| 11727 | + TxbSet::Chroma32, | ||
| 11728 | + &cu_scan, | ||
| 11729 | + plane_idx, | ||
| 11730 | + cu_around[plane_idx], | ||
| 11731 | + 0, | ||
| 11732 | + buf, | ||
| 11733 | + cu_x, | ||
| 11734 | + cu_y, | ||
| 11735 | + cu_tx, | ||
| 11736 | + base_q_idx, | ||
| 11737 | + cu_pred, | ||
| 11738 | + Some(covering.unwrap_or(TxType::DctDct)), | ||
| 11739 | + Some(3), fctx, | ||
| 11740 | + )? | ||
| 11741 | + .0; | ||
| 11742 | + // Immediately, so the NEXT unit reads this one's | ||
| 11743 | + // coefficient context. | ||
| 11744 | + neighbours.record_mi_chroma( | ||
| 11745 | + unit_mi, | ||
| 11746 | + unit_luma, | ||
| 11747 | + unit_luma, | ||
| 11748 | + plane_idx, | ||
| 11749 | + &cu_grid, | ||
| 11750 | + ); | ||
| 11751 | + if crate::envflags::env_flag!("EC_ECDUMP") { | ||
| 11752 | + let st = crate::decode::neighbour_state(&cu_grid); | ||
| 11753 | + eprintln!( | ||
| 11754 | + "EC_IBC128_STAMP mi=({mi_r},{mi_c}) unit=({cr},{cc}) plane={plane_idx} state=({:?},{})", | ||
| 11755 | + st.dc, st.level | ||
| 11756 | + ); | ||
| 11757 | + } | ||
| 11758 | + hit!(CHROMA_SPLIT_TX_HITS); | ||
| 11759 | + // lane-av1-ibcrect: per-unit chroma context -- the | ||
| 11760 | + // end-of-block record's composed-grid re-stamp | ||
| 11761 | + // must not stand (replayed below). | ||
| 11762 | + mu_chroma = true; | ||
| 11763 | + let dst = mu_units( | ||
| 11764 | + if plane_idx == 1 { &mut u_units } else { &mut v_units }, | ||
| 11765 | + cside * cside, | ||
| 11766 | + ); | ||
| 11767 | + for rr in 0..cu_tx { | ||
| 11768 | + let start = (cr * chunk_chroma + ur * cu_tx + rr) | ||
| 11769 | + * cside | ||
| 11770 | + + cc * chunk_chroma | ||
| 11771 | + + uc * cu_tx; | ||
| 11772 | + dst[start..start + cu_tx] | ||
| 11773 | + .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]); | ||
| 11774 | + } | ||
| 11775 | + } | ||
| 11776 | + } | ||
| 11777 | + } | ||
| 11778 | + } | ||
| 11779 | + } | ||
| 11780 | + // The block-level luma bands were recorded per leaf above; the | ||
| 11781 | + // composed chroma grids carry every unit in place. | ||
| 11782 | + luma_grid = Grid::Zero(side * side); | ||
| 11783 | + u_grid = if u_units.is_empty() { | ||
| 11784 | + Grid::Zero(cside * cside) | ||
| 11785 | + } else { | ||
| 11786 | + Grid::Own(std::mem::take(&mut u_units)) | ||
| 11787 | + }; | ||
| 11788 | + v_grid = if v_units.is_empty() { | ||
| 11789 | + Grid::Zero(cside * cside) | ||
| 11790 | + } else { | ||
| 11791 | + Grid::Own(std::mem::take(&mut v_units)) | ||
| 11792 | + }; | ||
| 11793 | + } | ||
| 11794 | + // Bookkeeping (see [`decode_intrabc_rect`]): DC_PRED everywhere a | ||
| 11795 | + // neighbour reads a mode, zeroed palette state, the skip grid, the | ||
| 11796 | + // TXFM_CONTEXT bands (`read_block_tx_size_rect` already stamped them), | ||
| 11797 | + // and the DV into the intrabc mi grid. | ||
| 11798 | + if skip { | ||
| 11799 | + neighbours.record_rect_mi( | ||
| 11800 | + (mi_r, mi_c), bw, bh, DC_PRED, DC_PRED, | ||
| 11801 | + &[&luma_grid[..], &u_grid[..], &v_grid[..]], | ||
| 11802 | + ); | ||
| 11803 | + } else { | ||
| 11804 | + neighbours.record_split_luma_rect_mi( | ||
| 11805 | + (mi_r, mi_c), bw, bh, DC_PRED, DC_PRED, [&u_grid[..], &v_grid[..]], | ||
| 11806 | + ); | ||
| 11807 | + } | ||
| 11808 | + // lane-av1-ibcrect: the coded arm's chroma contexts were stamped PER | ||
| 11809 | + // TRANSFORM UNIT (libaom `av1_set_entropy_contexts` inside | ||
| 11810 | + // `decode_reconstruct_tx`'s mu-chunk loop), but the record above re-stamps | ||
| 11811 | + // both planes with ONE `neighbour_state(composed_grid)` over the whole | ||
| 11812 | + // span -- level = the SUM of every unit's levels and dc = the top-left | ||
| 11813 | + // unit's sign (lane-vert46 r1 measured the same smearing at the 64x128 | ||
| 11814 | + // inter block: the next block read a stale `dc_sign_ctx` one row low). | ||
| 11815 | + // Measured on this shape: the 128x64 block at mi(64,32) of the | ||
| 11816 | + // `ibcrect-hunt/E2` sb128 screen stream left chunk-1 U's level 1 smeared | ||
| 11817 | + // into chunk-0's cells and the block below read `txb_skip` off the sum. | ||
| 11818 | + // Replay every coded unit's own state after the record, in mu-chunk order | ||
| 11819 | + // so a later unit still wins over an earlier one on the shared seam cells | ||
| 11820 | + // (the composed construction `mu_chroma_units` uses, transcribed here). | ||
| 11821 | + if mu_chroma { | ||
| 11822 | + let cu = if lossless(fctx) { 4usize } else { 32usize }; | ||
| 11823 | + // The unit's own footprint on the LUMA mi grid (the chroma context | ||
| 11824 | + // bands are luma-mi indexed, [`Self::record_mi_chroma`]'s | ||
| 11825 | + // convention): 8 px x2 per TX_4X4 unit, 64 px per TX_32X32 one. | ||
| 11826 | + let unit_luma = cu * 2; | ||
| 11827 | + // Raster over the block's chroma plane, `chunk_chroma` per mu chunk | ||
| 11828 | + // (the same extents the read loop above laid the composed grid out | ||
| 11829 | + // at) -- a unit the frame edge clipped codes nothing and carries no | ||
| 11830 | + // composed samples beyond the clip, so it replays as the zero state | ||
| 11831 | + // exactly like libaom's uncoded unit. | ||
| 11832 | + let chunk_chroma = cside * 64 / side; | ||
| 11833 | + let (rows, cols) = ((ch / chunk_chroma).max(1), (cw / chunk_chroma).max(1)); | ||
| 11834 | + for cr in 0..rows { | ||
| 11835 | + for cc in 0..cols { | ||
| 11836 | + let unit_mi = (mi_r + cr * (unit_luma / MI), mi_c + cc * (unit_luma / MI)); | ||
| 11837 | + for (plane_idx, grid) in [(1usize, &u_grid), (2usize, &v_grid)] { | ||
| 11838 | + let mut unit = Vec::with_capacity(cu * cu); | ||
| 11839 | + for rr in 0..cu { | ||
| 11840 | + let start = | ||
| 11841 | + (cr * chunk_chroma + rr) * cside + cc * chunk_chroma; | ||
| 11842 | + unit.extend_from_slice(&grid[start..start + cu]); | ||
| 11843 | + } | ||
| 11844 | + neighbours.record_mi_chroma( | ||
| 11845 | + unit_mi, unit_luma, unit_luma, plane_idx, &unit, | ||
| 11846 | + ); | ||
| 11847 | + } | ||
| 11848 | + } | ||
| 11849 | + } | ||
| 11850 | + } | ||
| 11851 | + neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); | ||
| 11852 | + neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); | ||
| 11853 | + neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); | ||
| 11854 | + neighbours.fill_lf_grid_rect( | ||
| 11855 | + (mi_r, mi_c), | ||
| 11856 | + bw / MI, | ||
| 11857 | + bh / MI, | ||
| 11858 | + bw.min(64) as u8, | ||
| 11859 | + bh.min(64) as u8, | ||
| 11860 | + 0, fctx, | ||
| 11861 | + ); | ||
| 11862 | + record_intrabc_mi_rect( | ||
| 11863 | + mi_r, | ||
| 11864 | + mi_c, | ||
| 11865 | + bw / MI, | ||
| 11866 | + bh / MI, | ||
| 11867 | + Some((dv_row, dv_col)), | ||
| 11868 | + neighbours, | ||
| 11869 | + fctx, | ||
| 11870 | + ); | ||
| 11871 | + Ok(()) | ||
| 11872 | +} | ||
| 11873 | + | ||
| 11412 | /// Decodes one true `bw`x`bh` `PARTITION_HORZ`/`PARTITION_VERT` intra strip | 11874 | /// Decodes one true `bw`x`bh` `PARTITION_HORZ`/`PARTITION_VERT` intra strip |
| 11413 | /// (lane-intradisp r1, spec `decode_block` restricted to a 32x32 quadrant's | 11875 | /// (lane-intradisp r1, spec `decode_block` restricted to a 32x32 quadrant's |
| 11414 | /// two rect children). Only the `skip` case is supported: `skip`/`y_mode`/ | 11876 | /// two rect children). Only the `skip` case is supported: `skip`/`y_mode`/ |
| @@ -16437,10 +16899,24 @@ fn decode_block_128rect( | |||
| 16437 | mi_r, | 16899 | mi_r, |
| 16438 | mi_c, fctx, | 16900 | mi_c, fctx, |
| 16439 | )?; | 16901 | )?; |
| 16440 | - if intrabc.is_some() { | 16902 | + if let Some((dv_row, dv_col)) = intrabc { |
| 16441 | - return Err(unsupported( | 16903 | + // lane-av1-ibcrect: the reconstruction is ported -- an intrabc block |
| 16442 | - "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", | 16904 | + // is is_inter_block, so libaom predicts the whole 128x64/64x128 strip |
| 16443 | - )); | 16905 | + // from this frame's own reconstruction and runs the INTER residual |
| 16906 | + // walk (`decode_token_recon_block`'s else arm) over it. | ||
| 16907 | + return decode_intrabc_128rect( | ||
| 16908 | + dec, | ||
| 16909 | + cdfs, | ||
| 16910 | + neighbours, | ||
| 16911 | + (mi_r, mi_c), | ||
| 16912 | + (bw, bh), | ||
| 16913 | + skip, | ||
| 16914 | + (dv_row, dv_col), | ||
| 16915 | + y, | ||
| 16916 | + u, | ||
| 16917 | + v, | ||
| 16918 | + base_q_idx, fctx, | ||
| 16919 | + ); | ||
| 16444 | } | 16920 | } |
| 16445 | if alpha.is_some() || filter_intra.is_some() || palette_y.is_some() || palette_uv.is_some() { | 16921 | if alpha.is_some() || filter_intra.is_some() || palette_y.is_some() || palette_uv.is_some() { |
| 16446 | return Err(unsupported( | 16922 | return Err(unsupported( |
crates/ec-av1/src/refusal_inventory.rsmodified+128 -40
| @@ -63,7 +63,15 @@ const REFUSALS: &[&str] = &[ | |||
| 63 | // reader a real ctx/cache pair, so no stream could reach either (audit | 63 | // reader a real ctx/cache pair, so no stream could reach either (audit |
| 64 | // `every_read_intra_mode_call_site_hands_the_reader_a_palette_cache`, | 64 | // `every_read_intra_mode_call_site_hands_the_reader_a_palette_cache`, |
| 65 | // which keeps that invariant now the refusal is gone). | 65 | // which keeps that invariant now the refusal is gone). |
| 66 | - "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", | 66 | + // lane-av1-ibcrect: `intra block copy on a HORZ/VERT/1:4 rect intra strip |
| 67 | + // (reconstruction is not ported at this shape)` is GONE -- lane-av1-intrabc | ||
| 68 | + // and lane-av1-rect14 reconstructed the 16x16/32x32-level strips, and this | ||
| 69 | + // lane ported the last site, `decode_block_128rect`'s 128-root HORZ/VERT | ||
| 70 | + // strip (`decode_intrabc_128rect`; a 128 root has no 1:4 arm at all). | ||
| 71 | + // Witness: | ||
| 72 | + // `an_sb128_rect_strip_with_intrabc_decodes_pixel_exact` (real aomenc | ||
| 73 | + // sb128 screen streams coding `use_intrabc` on BLOCK_128X64 strips, | ||
| 74 | + // pixel-exact vs ffmpeg). | ||
| 67 | // lane-av1txr: `a sub-8x8 leaf that uses intrabc (…)` is GONE -- the | 75 | // lane-av1txr: `a sub-8x8 leaf that uses intrabc (…)` is GONE -- the |
| 68 | // capability landed in this lane (4x4 / 4x8 / 8x4 intrabc leaves read the | 76 | // capability landed in this lane (4x4 / 4x8 / 8x4 intrabc leaves read the |
| 69 | // DV and reconstruct a frame copy + the INTER residual; gates | 77 | // DV and reconstruct a frame copy + the INTER residual; gates |
| @@ -367,15 +375,12 @@ const PROVEN: &[(&str, &str)] = &[ | |||
| 367 | "a frame using quantisation matrices (using_qmatrix=1): dequantisation here is base_q_idx plus the plane DC/AC deltas only, so qm_y/qm_u/qm_v would be ignored and the frame would decode silently wrong pixels", | 375 | "a frame using quantisation matrices (using_qmatrix=1): dequantisation here is base_q_idx plus the plane DC/AC deltas only, so qm_y/qm_u/qm_v would be ignored and the frame would decode silently wrong pixels", |
| 368 | "a_frame_using_quantisation_matrices_is_refused_by_name", | 376 | "a_frame_using_quantisation_matrices_is_refused_by_name", |
| 369 | ), | 377 | ), |
| 370 | - // lane-av1-rect14: the 16x16- and 32x32-level strips are reconstructed | 378 | + // lane-av1-ibcrect: the pairing for "intra block copy on a HORZ/VERT/1:4 |
| 371 | - // (`decode_intrabc_rect` / `decode_intrabc_pair_strip`). The string remains | 379 | + // rect intra strip (reconstruction is not ported at this shape)" is GONE |
| 372 | - // only in `decode_block_128rect`. No sb128 screen recipe in this lane | 380 | + // with the string -- lane-av1-intrabc/rect14 reconstructed the |
| 373 | - // reached that arm (256x192 cq50 sb128 decoded without entering it), so | 381 | + // 16x16/32x32-level strips and this lane ported the last site, |
| 374 | - // the pairing still names the rect-strip gate, which no longer refuses. | 382 | + // `decode_block_128rect`'s 128-root strip. Witness: |
| 375 | - ( | 383 | + // `an_sb128_rect_strip_with_intrabc_decodes_pixel_exact`. |
| 376 | - "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", | ||
| 377 | - "a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips", | ||
| 378 | - ), | ||
| 379 | // lane-t900 r26, enumeration: a y_mode symbol comes from a 13-symbol CDF | 384 | // lane-t900 r26, enumeration: a y_mode symbol comes from a 13-symbol CDF |
| 380 | // and all three guards refuse 13 and above. | 385 | // and all three guards refuse 13 and above. |
| 381 | ( | 386 | ( |
| @@ -589,7 +594,11 @@ mod tests { | |||
| 589 | .chain(REFUSALS) | 594 | .chain(REFUSALS) |
| 590 | .map(|&s| s.to_owned()) | 595 | .map(|&s| s.to_owned()) |
| 591 | .collect(); | 596 | .collect(); |
| 592 | - assert!(found.len() >= 30, "the refusal scan found only {} reasons -- it is broken, not the decoder", found.len()); | 597 | + assert!( |
| 598 | + found.len() >= 30, | ||
| 599 | + "the refusal scan found only {} reasons -- it is broken, not the decoder", | ||
| 600 | + found.len() | ||
| 601 | + ); | ||
| 593 | 602 | ||
| 594 | let added: Vec<&String> = found.difference(&listed).collect(); | 603 | let added: Vec<&String> = found.difference(&listed).collect(); |
| 595 | assert!( | 604 | assert!( |
| @@ -635,9 +644,14 @@ mod tests { | |||
| 635 | let mut found: BTreeSet<String> = BTreeSet::new(); | 644 | let mut found: BTreeSet<String> = BTreeSet::new(); |
| 636 | for (i, _) in src.match_indices("\"SKIP ") { | 645 | for (i, _) in src.match_indices("\"SKIP ") { |
| 637 | let rest = &src[i + "\"SKIP ".len()..]; | 646 | let rest = &src[i + "\"SKIP ".len()..]; |
| 638 | - let Some(colon) = rest.find(':') else { continue }; | 647 | + let Some(colon) = rest.find(':') else { |
| 648 | + continue; | ||
| 649 | + }; | ||
| 639 | let name = &rest[..colon]; | 650 | let name = &rest[..colon]; |
| 640 | - if !name.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') { | 651 | + if !name |
| 652 | + .chars() | ||
| 653 | + .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') | ||
| 654 | + { | ||
| 641 | continue; | 655 | continue; |
| 642 | } | 656 | } |
| 643 | // The tail of the message says what was skipped. Only "{e}" -- the | 657 | // The tail of the message says what was skipped. Only "{e}" -- the |
| @@ -650,7 +664,10 @@ mod tests { | |||
| 650 | } | 664 | } |
| 651 | } | 665 | } |
| 652 | let listed: BTreeSet<&str> = GATES_THAT_SKIP_ON_A_DECODE_ERROR.iter().copied().collect(); | 666 | let listed: BTreeSet<&str> = GATES_THAT_SKIP_ON_A_DECODE_ERROR.iter().copied().collect(); |
| 653 | - let added: Vec<&String> = found.iter().filter(|n| !listed.contains(n.as_str())).collect(); | 667 | + let added: Vec<&String> = found |
| 668 | + .iter() | ||
| 669 | + .filter(|n| !listed.contains(n.as_str())) | ||
| 670 | + .collect(); | ||
| 654 | assert!( | 671 | assert!( |
| 655 | added.is_empty(), | 672 | added.is_empty(), |
| 656 | "these gates turn a decode error into a printed SKIP and are not declared: \ | 673 | "these gates turn a decode error into a printed SKIP and are not declared: \ |
| @@ -723,9 +740,18 @@ mod tests { | |||
| 723 | fn every_partition_value_of_an_enumerated_alphabet_has_an_arm() { | 740 | fn every_partition_value_of_an_enumerated_alphabet_has_an_arm() { |
| 724 | // (the refusal in the fallback arm, the alphabet its CDF codes) | 741 | // (the refusal in the fallback arm, the alphabet its CDF codes) |
| 725 | let blocks: [(&str, usize); 4] = [ | 742 | let blocks: [(&str, usize); 4] = [ |
| 726 | - ("a 32x32 partition type this decoder does not code", crate::cdf::PARTITION_W32[0].len() - 1), | 743 | + ( |
| 727 | - ("an INTER 32x32 partition type this decoder does not code", crate::cdf::PARTITION_W32[0].len() - 1), | 744 | + "a 32x32 partition type this decoder does not code", |
| 728 | - ("a 128x128 superblock partition value outside the 8-symbol alphabet", crate::cdf::PARTITION_W128[0].len() - 1), | 745 | + crate::cdf::PARTITION_W32[0].len() - 1, |
| 746 | + ), | ||
| 747 | + ( | ||
| 748 | + "an INTER 32x32 partition type this decoder does not code", | ||
| 749 | + crate::cdf::PARTITION_W32[0].len() - 1, | ||
| 750 | + ), | ||
| 751 | + ( | ||
| 752 | + "a 128x128 superblock partition value outside the 8-symbol alphabet", | ||
| 753 | + crate::cdf::PARTITION_W128[0].len() - 1, | ||
| 754 | + ), | ||
| 729 | // lane-t900 r24: the key-frame superblock root. Its `part` is | 755 | // lane-t900 r24: the key-frame superblock root. Its `part` is |
| 730 | // either a `partition_w64` symbol or, at a frame edge, one of the | 756 | // either a `partition_w64` symbol or, at a frame edge, one of the |
| 731 | // three gathered outcomes (PARTITION_HORZ, PARTITION_VERT, | 757 | // three gathered outcomes (PARTITION_HORZ, PARTITION_VERT, |
| @@ -779,7 +805,10 @@ mod tests { | |||
| 779 | "the `match` at decode.rs:{} refuses {reason:?} but has no arm for {:?} -- that \ | 805 | "the `match` at decode.rs:{} refuses {reason:?} but has no arm for {:?} -- that \ |
| 780 | is a real gap in its {alphabet}-value alphabet, not a dead refusal", | 806 | is a real gap in its {alphabet}-value alphabet, not a dead refusal", |
| 781 | i + 1, | 807 | i + 1, |
| 782 | - missing.iter().map(|v| PARTITION_NAMES[*v]).collect::<Vec<_>>() | 808 | + missing |
| 809 | + .iter() | ||
| 810 | + .map(|v| PARTITION_NAMES[*v]) | ||
| 811 | + .collect::<Vec<_>>() | ||
| 783 | ); | 812 | ); |
| 784 | } | 813 | } |
| 785 | assert_eq!( | 814 | assert_eq!( |
| @@ -833,7 +862,11 @@ mod tests { | |||
| 833 | .next() | 862 | .next() |
| 834 | .unwrap_or("") | 863 | .unwrap_or("") |
| 835 | .to_owned(); | 864 | .to_owned(); |
| 836 | - assert!(!var.is_empty(), "the chain at decode.rs:{} tests nothing", head + 1); | 865 | + assert!( |
| 866 | + !var.is_empty(), | ||
| 867 | + "the chain at decode.rs:{} tests nothing", | ||
| 868 | + head + 1 | ||
| 869 | + ); | ||
| 837 | 870 | ||
| 838 | // Walk up collecting every branch head of this chain, each read to | 871 | // Walk up collecting every branch head of this chain, each read to |
| 839 | // the line that opens its body. | 872 | // the line that opens its body. |
| @@ -843,7 +876,8 @@ mod tests { | |||
| 843 | loop { | 876 | loop { |
| 844 | i -= 1; | 877 | i -= 1; |
| 845 | let t = lines[i].trim_start(); | 878 | let t = lines[i].trim_start(); |
| 846 | - if indent(lines[i]) != outer || !(t.starts_with("} else if ") || t.starts_with("if ")) | 879 | + if indent(lines[i]) != outer |
| 880 | + || !(t.starts_with("} else if ") || t.starts_with("if ")) | ||
| 847 | { | 881 | { |
| 848 | if i == 0 { | 882 | if i == 0 { |
| 849 | break; | 883 | break; |
| @@ -893,7 +927,10 @@ mod tests { | |||
| 893 | "the chain at decode.rs:{} refuses {reason:?} but no branch names {:?} -- that \ | 927 | "the chain at decode.rs:{} refuses {reason:?} but no branch names {:?} -- that \ |
| 894 | is a real gap in its {alphabet}-value alphabet, not a dead refusal", | 928 | is a real gap in its {alphabet}-value alphabet, not a dead refusal", |
| 895 | head + 1, | 929 | head + 1, |
| 896 | - missing.iter().map(|v| PARTITION_NAMES[*v]).collect::<Vec<_>>() | 930 | + missing |
| 931 | + .iter() | ||
| 932 | + .map(|v| PARTITION_NAMES[*v]) | ||
| 933 | + .collect::<Vec<_>>() | ||
| 897 | ); | 934 | ); |
| 898 | } | 935 | } |
| 899 | assert_eq!(found, chains.len()); | 936 | assert_eq!(found, chains.len()); |
| @@ -996,11 +1033,18 @@ mod tests { | |||
| 996 | values.insert(((1u64 << length) - 2) as u32); | 1033 | values.insert(((1u64 << length) - 2) as u32); |
| 997 | } | 1034 | } |
| 998 | let max = *values.iter().max().unwrap(); | 1035 | let max = *values.iter().max().unwrap(); |
| 999 | - assert_eq!(max, (1u32 << 20) - 2, "the enumeration misses the spec's own ceiling"); | 1036 | + assert_eq!( |
| 1037 | + max, | ||
| 1038 | + (1u32 << 20) - 2, | ||
| 1039 | + "the enumeration misses the spec's own ceiling" | ||
| 1040 | + ); | ||
| 1000 | // A coefficient is masked to 20 bits (spec 5.11.39), and the base and | 1041 | // A coefficient is masked to 20 bits (spec 5.11.39), and the base and |
| 1001 | // base-range syntax contribute at most 15 of that before the tail, so | 1042 | // base-range syntax contribute at most 15 of that before the tail, so |
| 1002 | // this is the largest tail a legal coefficient can need. | 1043 | // this is the largest tail a legal coefficient can need. |
| 1003 | - assert!(max >= 0xF_FFFF - 15, "the ceiling is below the largest legal tail"); | 1044 | + assert!( |
| 1045 | + max >= 0xF_FFFF - 15, | ||
| 1046 | + "the ceiling is below the largest legal tail" | ||
| 1047 | + ); | ||
| 1004 | for value in values { | 1048 | for value in values { |
| 1005 | match roundtrip(value) { | 1049 | match roundtrip(value) { |
| 1006 | Ok(read) => assert_eq!(read, value, "the Golomb tail {value} read back as {read}"), | 1050 | Ok(read) => assert_eq!(read, value, "the Golomb tail {value} read back as {read}"), |
| @@ -1056,7 +1100,11 @@ mod tests { | |||
| 1056 | ]; | 1100 | ]; |
| 1057 | assert_eq!(alphabets[0].1, 13, "the y_mode alphabet changed size"); | 1101 | assert_eq!(alphabets[0].1, 13, "the y_mode alphabet changed size"); |
| 1058 | for group in &crate::cdf::Y_MODE { | 1102 | for group in &crate::cdf::Y_MODE { |
| 1059 | - assert_eq!(group.len() - 1, alphabets[0].1, "the y_mode rows disagree on width"); | 1103 | + assert_eq!( |
| 1104 | + group.len() - 1, | ||
| 1105 | + alphabets[0].1, | ||
| 1106 | + "the y_mode rows disagree on width" | ||
| 1107 | + ); | ||
| 1060 | } | 1108 | } |
| 1061 | 1109 | ||
| 1062 | let src = include_str!("decode.rs"); | 1110 | let src = include_str!("decode.rs"); |
| @@ -1064,12 +1112,17 @@ mod tests { | |||
| 1064 | let mut sites = 0usize; | 1112 | let mut sites = 0usize; |
| 1065 | for (i, line) in lines.iter().enumerate() { | 1113 | for (i, line) in lines.iter().enumerate() { |
| 1066 | let t = line.trim(); | 1114 | let t = line.trim(); |
| 1067 | - let Some(rest) = t.strip_prefix("if mode >= ") else { continue }; | 1115 | + let Some(rest) = t.strip_prefix("if mode >= ") else { |
| 1116 | + continue; | ||
| 1117 | + }; | ||
| 1068 | let Some(threshold) = rest.trim_end_matches(" {").parse::<usize>().ok() else { | 1118 | let Some(threshold) = rest.trim_end_matches(" {").parse::<usize>().ok() else { |
| 1069 | continue; | 1119 | continue; |
| 1070 | }; | 1120 | }; |
| 1071 | // Only the guards carrying THIS refusal. | 1121 | // Only the guards carrying THIS refusal. |
| 1072 | - if !lines[i..(i + 4).min(lines.len())].join("\n").contains(REFUSAL) { | 1122 | + if !lines[i..(i + 4).min(lines.len())] |
| 1123 | + .join("\n") | ||
| 1124 | + .contains(REFUSAL) | ||
| 1125 | + { | ||
| 1073 | continue; | 1126 | continue; |
| 1074 | } | 1127 | } |
| 1075 | sites += 1; | 1128 | sites += 1; |
| @@ -1099,7 +1152,10 @@ mod tests { | |||
| 1099 | i + 1 | 1152 | i + 1 |
| 1100 | ); | 1153 | ); |
| 1101 | } | 1154 | } |
| 1102 | - assert_eq!(sites, 3, "the intra-mode guard is at three sites, found {sites}"); | 1155 | + assert_eq!( |
| 1156 | + sites, 3, | ||
| 1157 | + "the intra-mode guard is at three sites, found {sites}" | ||
| 1158 | + ); | ||
| 1103 | } | 1159 | } |
| 1104 | 1160 | ||
| 1105 | /// lane-t900 r31, ENUMERATION for "a HORZ/VERT intra strip in a | 1161 | /// lane-t900 r31, ENUMERATION for "a HORZ/VERT intra strip in a |
| @@ -1159,7 +1215,10 @@ mod tests { | |||
| 1159 | } | 1215 | } |
| 1160 | } | 1216 | } |
| 1161 | } | 1217 | } |
| 1162 | - assert!(with_128 > 0, "enumeration is vacuous -- no 128-sided footprint was tried"); | 1218 | + assert!( |
| 1219 | + with_128 > 0, | ||
| 1220 | + "enumeration is vacuous -- no 128-sided footprint was tried" | ||
| 1221 | + ); | ||
| 1163 | assert_eq!( | 1222 | assert_eq!( |
| 1164 | allowed_at_128, 0, | 1223 | allowed_at_128, 0, |
| 1165 | "a footprint with a 128-pixel side passed av1_allow_palette's bound -- the \ | 1224 | "a footprint with a 128-pixel side passed av1_allow_palette's bound -- the \ |
| @@ -1271,11 +1330,17 @@ mod tests { | |||
| 1271 | // (3) The two tables, read out of decode_rect_split's own text: every | 1330 | // (3) The two tables, read out of decode_rect_split's own text: every |
| 1272 | // `(w, h) =>` / `(w, h) |` match arm head between the table's `let` | 1331 | // `(w, h) =>` / `(w, h) |` match arm head between the table's `let` |
| 1273 | // and the guard that follows it. | 1332 | // and the guard that follows it. |
| 1274 | - let body_at = src.find("fn decode_rect_split(").expect("decode_rect_split is gone"); | 1333 | + let body_at = src |
| 1334 | + .find("fn decode_rect_split(") | ||
| 1335 | + .expect("decode_rect_split is gone"); | ||
| 1275 | let body = &src[body_at..]; | 1336 | let body = &src[body_at..]; |
| 1276 | let slice = |from: &str, to: &str| -> &str { | 1337 | let slice = |from: &str, to: &str| -> &str { |
| 1277 | - let a = body.find(from).unwrap_or_else(|| panic!("{from:?} is gone from decode_rect_split")); | 1338 | + let a = body |
| 1278 | - let b = body[a..].find(to).unwrap_or_else(|| panic!("{to:?} is gone from decode_rect_split")); | 1339 | + .find(from) |
| 1340 | + .unwrap_or_else(|| panic!("{from:?} is gone from decode_rect_split")); | ||
| 1341 | + let b = body[a..] | ||
| 1342 | + .find(to) | ||
| 1343 | + .unwrap_or_else(|| panic!("{to:?} is gone from decode_rect_split")); | ||
| 1279 | &body[a..a + b] | 1344 | &body[a..a + b] |
| 1280 | }; | 1345 | }; |
| 1281 | let arm_shapes = |text: &str| -> BTreeSet<(usize, usize)> { | 1346 | let arm_shapes = |text: &str| -> BTreeSet<(usize, usize)> { |
| @@ -1348,7 +1413,10 @@ mod tests { | |||
| 1348 | } | 1413 | } |
| 1349 | } | 1414 | } |
| 1350 | } | 1415 | } |
| 1351 | - assert_eq!(checked, 40, "the strip domain is not the ten rect shapes x four depths"); | 1416 | + assert_eq!( |
| 1417 | + checked, 40, | ||
| 1418 | + "the strip domain is not the ten rect shapes x four depths" | ||
| 1419 | + ); | ||
| 1352 | } | 1420 | } |
| 1353 | 1421 | ||
| 1354 | /// lane-t900 r33, ENUMERATION for "CfL, filter intra or a palette on a | 1422 | /// lane-t900 r33, ENUMERATION for "CfL, filter intra or a palette on a |
| @@ -1458,9 +1526,15 @@ mod tests { | |||
| 1458 | } | 1526 | } |
| 1459 | continue; | 1527 | continue; |
| 1460 | } | 1528 | } |
| 1461 | - let Some(rest) = line.strip_prefix('(') else { continue }; | 1529 | + let Some(rest) = line.strip_prefix('(') else { |
| 1462 | - let Some((pair, _)) = rest.split_once(") =>") else { continue }; | 1530 | + continue; |
| 1463 | - let Some((a, b)) = pair.split_once(',') else { continue }; | 1531 | + }; |
| 1532 | + let Some((pair, _)) = rest.split_once(") =>") else { | ||
| 1533 | + continue; | ||
| 1534 | + }; | ||
| 1535 | + let Some((a, b)) = pair.split_once(',') else { | ||
| 1536 | + continue; | ||
| 1537 | + }; | ||
| 1464 | let bw: usize = a.trim().parse().expect("arm bw"); | 1538 | let bw: usize = a.trim().parse().expect("arm bw"); |
| 1465 | let bh: usize = b.trim().parse().expect("arm bh"); | 1539 | let bh: usize = b.trim().parse().expect("arm bh"); |
| 1466 | assert!( | 1540 | assert!( |
| @@ -1472,9 +1546,18 @@ mod tests { | |||
| 1472 | seen.push((bw, bh)); | 1546 | seen.push((bw, bh)); |
| 1473 | arms += 1; | 1547 | arms += 1; |
| 1474 | } | 1548 | } |
| 1475 | - assert!(arms >= 10, "only {arms} arms parsed -- the table's shape changed"); | 1549 | + assert!( |
| 1476 | - assert!(saw_none_fallback, "filter_intra_size_class_rect lost its `_ => None` fallback"); | 1550 | + arms >= 10, |
| 1477 | - assert!(saw_square_delegate, "filter_intra_size_class_rect lost its square-delegate arm"); | 1551 | + "only {arms} arms parsed -- the table's shape changed" |
| 1552 | + ); | ||
| 1553 | + assert!( | ||
| 1554 | + saw_none_fallback, | ||
| 1555 | + "filter_intra_size_class_rect lost its `_ => None` fallback" | ||
| 1556 | + ); | ||
| 1557 | + assert!( | ||
| 1558 | + saw_square_delegate, | ||
| 1559 | + "filter_intra_size_class_rect lost its square-delegate arm" | ||
| 1560 | + ); | ||
| 1478 | // The guard arm delegates square strips to `filter_intra_size_class`; | 1561 | // The guard arm delegates square strips to `filter_intra_size_class`; |
| 1479 | // drive the delegate directly, so a widening there turns THIS test red | 1562 | // drive the delegate directly, so a widening there turns THIS test red |
| 1480 | // (the numeric walk never reaches the guard arm). | 1563 | // (the numeric walk never reaches the guard arm). |
| @@ -1524,7 +1607,10 @@ mod tests { | |||
| 1524 | ); | 1607 | ); |
| 1525 | } | 1608 | } |
| 1526 | } | 1609 | } |
| 1527 | - assert_eq!(sites, 8, "the call-site audit found {sites} sites, not the 8 it enumerated"); | 1610 | + assert_eq!( |
| 1611 | + sites, 8, | ||
| 1612 | + "the call-site audit found {sites} sites, not the 8 it enumerated" | ||
| 1613 | + ); | ||
| 1528 | } | 1614 | } |
| 1529 | 1615 | ||
| 1530 | /// Every entry of [`PROVEN`] must still name a live refusal and a test | 1616 | /// Every entry of [`PROVEN`] must still name a live refusal and a test |
| @@ -1543,7 +1629,9 @@ mod tests { | |||
| 1543 | "{reason:?} is listed as proven but is no longer a decode-path refusal -- drop it from PROVEN (the capability landed) or fix the string" | 1629 | "{reason:?} is listed as proven but is no longer a decode-path refusal -- drop it from PROVEN (the capability landed) or fix the string" |
| 1544 | ); | 1630 | ); |
| 1545 | assert!( | 1631 | assert!( |
| 1546 | - sources.iter().any(|src| src.contains(&format!("fn {gate}("))), | 1632 | + sources |
| 1633 | + .iter() | ||
| 1634 | + .any(|src| src.contains(&format!("fn {gate}("))), | ||
| 1547 | "{reason:?} names the proving test {gate}, which exists in neither stream.rs \ | 1635 | "{reason:?} names the proving test {gate}, which exists in neither stream.rs \ |
| 1548 | nor decode.rs" | 1636 | nor decode.rs" |
| 1549 | ); | 1637 | ); |
crates/ec-av1/src/stream.rsmodified+201 -0
| @@ -171,6 +171,30 @@ pub fn sb128_rect_counters() -> (usize, usize, usize, usize) { | |||
| 171 | ) | 171 | ) |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | +/// lane-av1-ibcrect: the 128 root's interior partition arms plus the key-frame | ||
| 175 | +/// intra 128-axis blocks -- (split, none, horz, vert, ab[4], intra_horz, | ||
| 176 | +/// intra_vert). Non-zero horz/vert mean a stream carried real PARTITION_HORZ/ | ||
| 177 | +/// VERT at the 128 root, so an intrabc-rect hunt can tell "the partition was | ||
| 178 | +/// never chosen" from "chosen and decoded intra (or refused)". | ||
| 179 | +pub fn part128_census() -> (usize, usize, usize, usize, [usize; 4], usize, usize) { | ||
| 180 | + ( | ||
| 181 | + crate::decode::part128_split_hits(), | ||
| 182 | + crate::decode::part128_none_hits(), | ||
| 183 | + crate::decode::part128_horz_hits(), | ||
| 184 | + crate::decode::part128_vert_hits(), | ||
| 185 | + crate::decode::part128_ab_hits(), | ||
| 186 | + crate::decode::intra_sb128_hits().0, | ||
| 187 | + crate::decode::intra_sb128_hits().1, | ||
| 188 | + ) | ||
| 189 | +} | ||
| 190 | + | ||
| 191 | +/// lane-av1-ibcrect: `use_intrabc` blocks on a 128-root HORZ/VERT strip whose | ||
| 192 | +/// reconstruction ([`crate::decode::decode_intrabc_128rect`]) ran -- the | ||
| 193 | +/// engagement counter the sb128 intrabc-rect gate asserts on. | ||
| 194 | +pub fn intrabc_128rect_hits() -> usize { | ||
| 195 | + crate::decode::intrabc_128rect_hits() | ||
| 196 | +} | ||
| 197 | + | ||
| 174 | /// Blocks reconstructed with intra block copy at an 8x8 LEAF specifically | 198 | /// Blocks reconstructed with intra block copy at an 8x8 LEAF specifically |
| 175 | /// (lane-kf900 r7's shape); [`crate::decode::intrabc_hits`] counts every shape. | 199 | /// (lane-kf900 r7's shape); [`crate::decode::intrabc_hits`] counts every shape. |
| 176 | pub fn leaf8_intrabc_hits() -> usize { | 200 | pub fn leaf8_intrabc_hits() -> usize { |
| @@ -7098,6 +7122,183 @@ pub(crate) mod tests { | |||
| 7098 | ); | 7122 | ); |
| 7099 | } | 7123 | } |
| 7100 | 7124 | ||
| 7125 | + /// lane-av1-ibcrect: `use_intrabc` on a 128-root HORZ/VERT strip | ||
| 7126 | + /// (BLOCK_128X64 / BLOCK_64X128) decodes PIXEL-EXACT against the | ||
| 7127 | + /// instrumented oracle -- the witness the refusal inventory names after | ||
| 7128 | + /// `decode_block_128rect`'s rect-strip intrabc refusal was lifted | ||
| 7129 | + /// (`decode_intrabc_128rect`). The square-block twin is | ||
| 7130 | + /// [`an_sb128_screen_stream_with_intrabc_decodes_pixel_exact`] above. | ||
| 7131 | + /// | ||
| 7132 | + /// The recipes are the hunt's proven arms (lanes/ibcrect r1/r2, the same | ||
| 7133 | + /// `--sb-size=128 --min-partition-size=64 --enable-rect-partitions=1 | ||
| 7134 | + /// --enable-ab-partitions=0 --enable-1to4-partitions=0` partition recipe | ||
| 7135 | + /// [`a_real_aomenc_sb128_intra_rect_block_decodes_pixel_exact`] uses, plus | ||
| 7136 | + /// `--tune-content=screen --enable-intrabc=1` over the DETERMINISTIC geq | ||
| 7137 | + /// sinusoid sources -- lavfi `gradients` ignores its seed and re-rolls | ||
| 7138 | + /// every run, so a "flake" there was really this): | ||
| 7139 | + /// | ||
| 7140 | + /// * HORZ arm: 384x320 cq32, 5 all-key frames -- 14 unskipped 128x64 | ||
| 7141 | + /// intrabc blocks (`skip=false`, real residual reads); | ||
| 7142 | + /// * VERT arm: 512x512 cq45, 5 all-key frames -- an unskipped 64x128 | ||
| 7143 | + /// intrabc block at mi(64,96). | ||
| 7144 | + /// | ||
| 7145 | + /// Both arms HARD-assert `intrabc_128rect_hits() > 0` and decode-order | ||
| 7146 | + /// pixel-exactness of EVERY frame (hidden alt-refs included) against the | ||
| 7147 | + /// oracle's own dump, so a stream that stopped engaging the shape fails | ||
| 7148 | + /// the gate instead of passing vacuously (class `gate-blind-to-feature`). | ||
| 7149 | + /// | ||
| 7150 | + /// The 10-bit arm rides along DECODE-ONLY: measured (hunt r2), aomenc | ||
| 7151 | + /// never engages the 128-strip intrabc shape at these recipes at 10 bit | ||
| 7152 | + /// (no 128-root HORZ/VERT partition is taken at all), so there is nothing | ||
| 7153 | + /// to assert there beyond "decodes without refusing and matches the | ||
| 7154 | + /// oracle" -- the per-depth firing assert would be vacuous, and this is | ||
| 7155 | + /// the known, printed coverage gap, not a silent pass. | ||
| 7156 | + /// | ||
| 7157 | + /// The chroma context this shape reads was the r2 defect: per-unit chroma | ||
| 7158 | + /// entropy states were stamped inside the mu-chunk loop, then the | ||
| 7159 | + /// end-of-block `record_split_luma_rect_mi` re-stamped BOTH planes over | ||
| 7160 | + /// the whole 128x64 span with ONE composed state -- level = the SUM of | ||
| 7161 | + /// both 64x64 chunks' units, dc = chunk-0's top-left (class | ||
| 7162 | + /// `override-slot-on-one-arm`; the inter-128 path fixed the same class | ||
| 7163 | + /// with its `mu_chroma_units` replay, decode.rs). The next block then | ||
| 7164 | + /// read `txb_skip` off the smeared state. | ||
| 7165 | + #[test] | ||
| 7166 | + fn an_sb128_rect_strip_with_intrabc_decodes_pixel_exact() { | ||
| 7167 | + const NAME: &str = "an_sb128_rect_strip_with_intrabc_decodes_pixel_exact"; | ||
| 7168 | + let _gate_lock = lock_gate_counters(); | ||
| 7169 | + if !have_ffmpeg() { | ||
| 7170 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 7171 | + return; | ||
| 7172 | + } | ||
| 7173 | + if !have_aomenc() { | ||
| 7174 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 7175 | + return; | ||
| 7176 | + } | ||
| 7177 | + // (tag, width, height, cq, geq luma, 10-bit) | ||
| 7178 | + // The geq sources are the hunt's GEO_SMOOTH / GEO_SMOOTH_512, | ||
| 7179 | + // byte-identical across runs (see the sb128 intra-rect gate's note). | ||
| 7180 | + let arms: [(u32, usize, usize, &str, &str, bool); 3] = [ | ||
| 7181 | + ( | ||
| 7182 | + 1, | ||
| 7183 | + 384, | ||
| 7184 | + 320, | ||
| 7185 | + "32", | ||
| 7186 | + "128+90*sin((X+2*N)/37)+30*sin(Y/29)", | ||
| 7187 | + false, | ||
| 7188 | + ), | ||
| 7189 | + ( | ||
| 7190 | + 2, | ||
| 7191 | + 512, | ||
| 7192 | + 512, | ||
| 7193 | + "45", | ||
| 7194 | + "128+80*sin((X+3*N)/17)+50*sin(Y/29)+30*sin((X+Y)/13)", | ||
| 7195 | + false, | ||
| 7196 | + ), | ||
| 7197 | + (3, 384, 320, "32", "128+90*sin((X+2*N)/37)+30*sin(Y/29)", true), | ||
| 7198 | + ]; | ||
| 7199 | + let mut engaged_arms = 0u32; | ||
| 7200 | + let mut vert_arms = 0u32; | ||
| 7201 | + for (tag, width, height, cq, lum, ten_bit) in arms { | ||
| 7202 | + let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" }; | ||
| 7203 | + let y4m = Command::new("ffmpeg") | ||
| 7204 | + .args([ | ||
| 7205 | + "-v", | ||
| 7206 | + "error", | ||
| 7207 | + "-f", | ||
| 7208 | + "lavfi", | ||
| 7209 | + "-i", | ||
| 7210 | + &format!( | ||
| 7211 | + "nullsrc=size={width}x{height}:rate=25,format=yuv420p,\ | ||
| 7212 | + geq=lum='{lum}':\ | ||
| 7213 | + cb='128+30*sin(X/23)':cr='128+30*sin((Y+N)/19)'" | ||
| 7214 | + ), | ||
| 7215 | + "-pix_fmt", | ||
| 7216 | + pix, | ||
| 7217 | + "-strict", | ||
| 7218 | + "-1", | ||
| 7219 | + "-t", | ||
| 7220 | + "0.2", | ||
| 7221 | + "-f", | ||
| 7222 | + "yuv4mpegpipe", | ||
| 7223 | + "-", | ||
| 7224 | + ]) | ||
| 7225 | + .stdin(Stdio::null()) | ||
| 7226 | + .stdout(Stdio::piped()) | ||
| 7227 | + .stderr(Stdio::piped()) | ||
| 7228 | + .output() | ||
| 7229 | + .expect("ffmpeg failed to run"); | ||
| 7230 | + assert!( | ||
| 7231 | + y4m.status.success(), | ||
| 7232 | + "{NAME}: ffmpeg fixture: {}", | ||
| 7233 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 7234 | + ); | ||
| 7235 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 7236 | + let mut args: Vec<&str> = vec![ | ||
| 7237 | + "--codec=av1", | ||
| 7238 | + "--passes=1", | ||
| 7239 | + "--end-usage=q", | ||
| 7240 | + &cq_arg, | ||
| 7241 | + "--cpu-used=0", | ||
| 7242 | + "--threads=1", | ||
| 7243 | + "--row-mt=0", | ||
| 7244 | + "--lag-in-frames=0", | ||
| 7245 | + "--kf-max-dist=1", | ||
| 7246 | + "--limit=5", | ||
| 7247 | + "--tile-columns=0", | ||
| 7248 | + "--sb-size=128", | ||
| 7249 | + "--min-partition-size=64", | ||
| 7250 | + "--enable-rect-partitions=1", | ||
| 7251 | + "--enable-ab-partitions=0", | ||
| 7252 | + "--enable-1to4-partitions=0", | ||
| 7253 | + "--enable-palette=0", | ||
| 7254 | + "--tune-content=screen", | ||
| 7255 | + "--enable-intrabc=1", | ||
| 7256 | + "--deltaq-mode=0", | ||
| 7257 | + "--enable-tx-size-search=0", | ||
| 7258 | + ]; | ||
| 7259 | + if ten_bit { | ||
| 7260 | + args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]); | ||
| 7261 | + } | ||
| 7262 | + args.extend_from_slice(&["--obu", "-o", "-", "-"]); | ||
| 7263 | + let out = run_with_stdin(Command::new(aomenc_path()).args(&args), &y4m.stdout); | ||
| 7264 | + assert!( | ||
| 7265 | + out.status.success(), | ||
| 7266 | + "{NAME}: aomenc refused the arm {tag} fixture: {}", | ||
| 7267 | + String::from_utf8_lossy(&out.stderr) | ||
| 7268 | + ); | ||
| 7269 | + let stream = out.stdout; | ||
| 7270 | + let before = crate::decode::intrabc_128rect_hits(); | ||
| 7271 | + let (frames, hidden) = decode_all_frames_vs_oracle( | ||
| 7272 | + &stream, | ||
| 7273 | + &format!("ibcrect-strip-{tag}-{width}x{height}"), | ||
| 7274 | + ); | ||
| 7275 | + let hits = crate::decode::intrabc_128rect_hits() - before; | ||
| 7276 | + eprintln!( | ||
| 7277 | + "{NAME}: arm {tag} {width}x{height} cq={cq} {}bit: {frames} decode-order frames \ | ||
| 7278 | + pixel-exact ({hidden} hidden), intrabc_128rect_hits=+{hits}", | ||
| 7279 | + if ten_bit { 10 } else { 8 }, | ||
| 7280 | + ); | ||
| 7281 | + if hits > 0 { | ||
| 7282 | + engaged_arms += 1; | ||
| 7283 | + // The VERT arm is tag 2; its engagement is what proves the | ||
| 7284 | + // 64x128 orientation, not just 128x64. | ||
| 7285 | + if tag == 2 { | ||
| 7286 | + vert_arms += 1; | ||
| 7287 | + } | ||
| 7288 | + } | ||
| 7289 | + } | ||
| 7290 | + assert!( | ||
| 7291 | + engaged_arms > 0, | ||
| 7292 | + "{NAME}: {engaged_arms} arm(s) decoded pixel-exact but NOT ONE decoded a 128-root \ | ||
| 7293 | + rect-strip intrabc block -- the shape this gate exists for was never engaged" | ||
| 7294 | + ); | ||
| 7295 | + assert!( | ||
| 7296 | + vert_arms > 0, | ||
| 7297 | + "{NAME}: the VERT (64x128) orientation was never engaged -- only 128x64 HORZ strips \ | ||
| 7298 | + proved the lift" | ||
| 7299 | + ); | ||
| 7300 | + } | ||
| 7301 | + | ||
| 7101 | /// lane-t900 r33, CENSUS for "a sub-8x8 leaf that uses intrabc". | 7302 | /// lane-t900 r33, CENSUS for "a sub-8x8 leaf that uses intrabc". |
| 7102 | /// | 7303 | /// |
| 7103 | /// The `use_intrabc` symbol IS read at that reader for every sub-8x8 leaf | 7304 | /// The `use_intrabc` symbol IS read at that reader for every sub-8x8 leaf |