A 1:4 HORZ_4/VERT_4 strip's first transform split is a 2:1 RECT unit, not a square
Browse files at this commit71f7ca20e0e511c7e884b516a80d3066e9d88580Parent: e47e7ce- fix
- a 1:4 HORZ_4/VERT_4 strip's first transform split is a 2:1 RECT unit, not a square
4 changed files +389 -2
- crates/ec-av1/src/decode.rs +68 -1
- crates/ec-av1/src/refusal_inventory.rs +1 -0
- crates/ec-av1/src/stream.rs +247 -1
- lanes/rectchroma-r1.report.md +73 -0
crates/ec-av1/src/decode.rsmodified+68 -1
| @@ -857,6 +857,22 @@ pub(crate) fn rect_split_sb_interior_tu_hits() -> usize { | ||
| 857 | 857 | RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.get()) |
| 858 | 858 | } |
| 859 | 859 | |
| 860 | +// Per-shape hit counts for the rect chroma transforms lane-rectchroma r1 | |
| 861 | +// wired into [`decode_rect_split`] -- the shapes a split-transform strip's | |
| 862 | +// chroma half takes that had no coefficient tables before (index order: | |
| 863 | +// 32x8, 8x32, 8x4, 4x8). One counter per shape because a gate that only | |
| 864 | +// proves the pair it happens to hit cannot catch a transposed scan/context | |
| 865 | +// table (class scan-weights-cross-axis). | |
| 866 | +thread_local! { | |
| 867 | + static RECT_SPLIT_CHROMA_SHAPE_HITS: std::cell::Cell<[usize; 4]> = | |
| 868 | + const { std::cell::Cell::new([0; 4]) }; | |
| 869 | +} | |
| 870 | + | |
| 871 | +/// Current value of [`RECT_SPLIT_CHROMA_SHAPE_HITS`] (32x8, 8x32, 8x4, 4x8). | |
| 872 | +pub(crate) fn rect_split_chroma_shape_hits() -> [usize; 4] { | |
| 873 | + RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| c.get()) | |
| 874 | +} | |
| 875 | + | |
| 860 | 876 | // How many HORZ/VERT intra strips actually predicted with filter intra |
| 861 | 877 | // (lane-rectsplit r1) -- the case `decode_block_rect` refused by name |
| 862 | 878 | // ("this decoder predicts square-only") until `predict_filter_intra` took |
| @@ -4367,8 +4383,41 @@ fn decode_rect_split( | ||
| 4367 | 4383 | (8, 16) => Some((TxbSet::ChromaRect16x8, &SCAN_8X16[..])), |
| 4368 | 4384 | (32, 16) => Some((TxbSet::ChromaRect32x16, &SCAN_32X16[..])), |
| 4369 | 4385 | (16, 32) => Some((TxbSet::ChromaRect32x16, &SCAN_16X32[..])), |
| 4386 | + // lane-rectchroma r1: the 1:4 superblock strips (64x16/16x64, | |
| 4387 | + // `decode_block_rect64`'s `strip64!` arm) and the 8x16 left rect of a | |
| 4388 | + // 16x16 `VERT_B` reach here once their tx depth is non-zero -- the | |
| 4389 | + // shapes their chroma half takes. `get_txsize_entropy_ctx(TX_32X8)` | |
| 4390 | + // is `(0 + 4 + 1) >> 1 == 2`, the 16x16 CDF set (eob alphabet 256), | |
| 4391 | + // exactly as the unsplit 1:4 path already picks it; `TX_8X4` reduces | |
| 4392 | + // to `(0 + 1 + 1) >> 1 == 1`, the 8x8 set `ChromaRect8x4` carries | |
| 4393 | + // (eob 32), as `decode_leaf_rect`'s own chroma half already does. | |
| 4394 | + (32, 8) => Some((TxbSet::Chroma16, &SCAN_32X8[..])), | |
| 4395 | + (8, 32) => Some((TxbSet::Chroma16, &SCAN_8X32[..])), | |
| 4396 | + (8, 4) => Some((TxbSet::ChromaRect8x4, &SCAN_8X4[..])), | |
| 4397 | + (4, 8) => Some((TxbSet::ChromaRect8x4, &SCAN_4X8[..])), | |
| 4370 | 4398 | _ => None, |
| 4371 | 4399 | }; |
| 4400 | + if !m.skip { | |
| 4401 | + if let Some(i) = match (chroma_w, chroma_h) { | |
| 4402 | + (32, 8) => Some(0), | |
| 4403 | + (8, 32) => Some(1), | |
| 4404 | + (8, 4) => Some(2), | |
| 4405 | + (4, 8) => Some(3), | |
| 4406 | + _ => None, | |
| 4407 | + } { | |
| 4408 | + RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| { | |
| 4409 | + let mut hits = c.get(); | |
| 4410 | + hits[i] += 1; | |
| 4411 | + c.set(hits); | |
| 4412 | + }); | |
| 4413 | + } | |
| 4414 | + if chroma.is_none() { | |
| 4415 | + // Diagnostic for the next caller that lands here (class | |
| 4416 | + // refusal-names-a-correlate: the message names the tool, not the | |
| 4417 | + // shape); the refusal below keeps its inventory-pinned wording. | |
| 4418 | + eprintln!("EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx} chroma={chroma_w}x{chroma_h}"); | |
| 4419 | + } | |
| 4420 | + } | |
| 4372 | 4421 | // lane-rectsplit r2 (verifier finding): with both callers wired |
| 4373 | 4422 | // (`decode_block_rect`'s 32x16/16x32 and `decode_block_rect64`'s |
| 4374 | 4423 | // 64x32/32x64) every shape that reaches here has a table above, so this |
| @@ -5244,7 +5293,25 @@ fn decode_block_rect64( | ||
| 5244 | 5293 | // transform through the very same per-unit path as its 32x32-level |
| 5245 | 5294 | // sibling (`sub_tx_size_map[TX_64X32] == TX_32X32`, square from the |
| 5246 | 5295 | // first step on, so `bw.min(bh) >> (depth - 1)` names the unit). |
| 5247 | - let tx = bw.min(bh) >> (depth - 1); | |
| 5296 | + // lane-rectchroma r1: `sub_tx_size_map[TX_64X16] == TX_32X16`, NOT a | |
| 5297 | + // square -- a 4:1 strip's first transform split is still a 2:1 RECT | |
| 5298 | + // unit, and only the SECOND step reaches a square (TX_16X16). The | |
| 5299 | + // 2:1 formula below (square from the first step on) named 16x16 units | |
| 5300 | + // for a depth-1 64x16 strip, which decoded 2 chroma-32x8 strips of | |
| 5301 | + // the band fixture with the wrong luma tiling. depth 1 on a 4:1 strip | |
| 5302 | + // is refused by name; depth >= 2 is square, one step later. | |
| 5303 | + let is_1to4 = bw.max(bh) / bw.min(bh) == 4; | |
| 5304 | + if is_1to4 && depth == 1 && !skip { | |
| 5305 | + return Err(unsupported( | |
| 5306 | + "a coded 1:4 HORZ_4/VERT_4 strip whose transform splits only once (the unit is \ | |
| 5307 | + still a 2:1 rect, not a square)", | |
| 5308 | + )); | |
| 5309 | + } | |
| 5310 | + let tx = if is_1to4 { | |
| 5311 | + bw.min(bh) >> (depth - 2) | |
| 5312 | + } else { | |
| 5313 | + bw.min(bh) >> (depth - 1) | |
| 5314 | + }; | |
| 5248 | 5315 | if std::env::var_os("EC_SBPART_DUMP64").is_some() { |
| 5249 | 5316 | eprintln!( |
| 5250 | 5317 | "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ |
crates/ec-av1/src/refusal_inventory.rsmodified+1 -0
| @@ -34,6 +34,7 @@ const CAPABILITY_CLAIMS: &[&str] = &[ | ||
| 34 | 34 | const REFUSALS: &[&str] = &[ |
| 35 | 35 | "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only the skip case at this size)", |
| 36 | 36 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 37 | + "a coded 1:4 HORZ_4/VERT_4 strip whose transform splits only once (the unit is still a 2:1 rect, not a square)", | |
| 37 | 38 | "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect prediction is not ported)", |
| 38 | 39 | "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)", |
| 39 | 40 | "a HORZ/VERT partition below 8x8 (this decoder's transform primitive is square-only; 4x8/8x4 need a real rectangular transform)", |
crates/ec-av1/src/stream.rsmodified+247 -1
| @@ -2450,7 +2450,7 @@ mod tests { | ||
| 2450 | 2450 | "--enable-tx-size-search=0", |
| 2451 | 2451 | "--enable-cdef=1", |
| 2452 | 2452 | "--enable-restoration=1", |
| 2453 | - "--min-partition-size=16", | |
| 2453 | + "--min-partition-size=32", | |
| 2454 | 2454 | "--max-partition-size=32", |
| 2455 | 2455 | "--enable-palette=0", |
| 2456 | 2456 | "--enable-intrabc=0", |
| @@ -14550,4 +14550,250 @@ mod tests { | ||
| 14550 | 14550 | mismatched -- other lanes' shapes)" |
| 14551 | 14551 | ); |
| 14552 | 14552 | } |
| 14553 | + | |
| 14554 | + /// lane-rectchroma r1: a real `aomenc` stream in which a HORZ/VERT strip | |
| 14555 | + /// splits its transform (`--enable-tx-size-search` left ON) and whose | |
| 14556 | + /// chroma half is one of the four rect shapes that had NO coefficient | |
| 14557 | + /// tables in [`crate::decode`] before this round -- 32x8 / 8x32 (the 1:4 | |
| 14558 | + /// superblock strips 64x16 / 16x64) and 8x4 / 4x8 (the 8x16 / 16x8 rect | |
| 14559 | + /// of a 16x16-level AB partition). Every such strip refused by name | |
| 14560 | + /// ("a coded HORZ/VERT strip whose chroma transform has no rect | |
| 14561 | + /// coefficient tables here"), which is where both ReelC extracts stopped. | |
| 14562 | + /// | |
| 14563 | + /// Per-shape counters, deltas taken only over attempts that then compared | |
| 14564 | + /// pixel-exact (class counter-from-refused-stream), on 8 AND 10 bit (his | |
| 14565 | + /// films are `yuv420p10le`). Odd seeds render the source transposed so | |
| 14566 | + /// the 32x8/8x32 and 8x4/4x8 pairs both fire -- a single-orientation | |
| 14567 | + /// sweep cannot catch a transposed scan table (class | |
| 14568 | + /// scan-weights-cross-axis). | |
| 14569 | + #[test] | |
| 14570 | + fn a_real_aomenc_stream_with_a_coded_strip_whose_chroma_is_a_4to1_or_sub8_rect_decodes_pixel_exact() | |
| 14571 | + { | |
| 14572 | + const NAME: &str = "a_real_aomenc_stream_with_a_coded_strip_whose_chroma_is_a_4to1_or_sub8_rect_decodes_pixel_exact"; | |
| 14573 | + let _gate_lock = lock_gate_counters(); | |
| 14574 | + if !have_ffmpeg() { | |
| 14575 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 14576 | + return; | |
| 14577 | + } | |
| 14578 | + if !have_aomenc() { | |
| 14579 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 14580 | + return; | |
| 14581 | + } | |
| 14582 | + let (width, height) = (192usize, 128usize); | |
| 14583 | + let n_attempts: u32 = std::env::var("EC_RECTCHROMA_GATE_ATTEMPTS") | |
| 14584 | + .ok() | |
| 14585 | + .and_then(|s| s.parse().ok()) | |
| 14586 | + .unwrap_or(20); | |
| 14587 | + // 32x8, 8x32, 8x4, 4x8, summed over both bit depths. | |
| 14588 | + let mut proved = [0usize; 4]; | |
| 14589 | + let mut matched = 0u32; | |
| 14590 | + let mut refusals = 0u32; | |
| 14591 | + // Diagnostics: how much of the territory the COMPARED streams carried | |
| 14592 | + // at all, so a zero above reads as "recipe picked nothing" rather | |
| 14593 | + // than "the shape never split" without another run. | |
| 14594 | + let (mut split_strips, mut rect4_strips) = (0usize, 0usize); | |
| 14595 | + let mut all_rect4 = 0usize; | |
| 14596 | + // Attempts that stopped at the new named refusal for a 1:4 strip | |
| 14597 | + // whose transform splits once (see the assert at the end). | |
| 14598 | + let mut depth1_refusals = 0u32; | |
| 14599 | + for (bit_depth, cq) in [(8u32, 45u32), (8, 32), (8, 60), (10, 45), (10, 32), (10, 60)] { | |
| 14600 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 14601 | + for attempt in 0..n_attempts { | |
| 14602 | + let seed = 42 + attempt; | |
| 14603 | + // `gradients_source`, the content the sibling split-transform | |
| 14604 | + // superblock gate uses. A band/noise `geq` fixture was tried | |
| 14605 | + // first (r1) and gave 12/12 pixel-exact streams carrying ZERO | |
| 14606 | + // 1:4 strips -- vacuous. Odd attempts render it transposed so | |
| 14607 | + // HORZ_4 and VERT_4 both appear (class scan-weights-cross-axis). | |
| 14608 | + let bands = format!( | |
| 14609 | + "geq=lum='mod(floor(Y/16),2)*160+48':cb=128:cr=128,noise=alls=10:all_seed={seed}" | |
| 14610 | + ); | |
| 14611 | + let source = if attempt % 2 == 0 { | |
| 14612 | + format!("color=c=black:size={width}x{height}:duration=0.04:rate=25,{bands}") | |
| 14613 | + } else { | |
| 14614 | + format!( | |
| 14615 | + "color=c=black:size={height}x{width}:duration=0.04:rate=25,{bands},transpose=1" | |
| 14616 | + ) | |
| 14617 | + }; | |
| 14618 | + let y4m = Command::new("ffmpeg") | |
| 14619 | + .args([ | |
| 14620 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", "0.04", "-pix_fmt", | |
| 14621 | + pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | |
| 14622 | + ]) | |
| 14623 | + .stdin(Stdio::null()) | |
| 14624 | + .stdout(Stdio::piped()) | |
| 14625 | + .stderr(Stdio::piped()) | |
| 14626 | + .output() | |
| 14627 | + .expect("ffmpeg failed to run"); | |
| 14628 | + assert!( | |
| 14629 | + y4m.status.success(), | |
| 14630 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | |
| 14631 | + String::from_utf8_lossy(&y4m.stderr) | |
| 14632 | + ); | |
| 14633 | + let cq_arg = format!("--cq-level={cq}"); | |
| 14634 | + let depth_arg = format!("--bit-depth={bit_depth}"); | |
| 14635 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | |
| 14636 | + let mut child = Command::new(aomenc_path()) | |
| 14637 | + .args([ | |
| 14638 | + "--codec=av1", | |
| 14639 | + "--passes=1", | |
| 14640 | + "--end-usage=q", | |
| 14641 | + &cq_arg, | |
| 14642 | + "--cpu-used=0", | |
| 14643 | + "--threads=1", | |
| 14644 | + "--row-mt=0", | |
| 14645 | + "--sb-size=64", | |
| 14646 | + &depth_arg, | |
| 14647 | + &input_depth_arg, | |
| 14648 | + "--enable-rect-partitions=1", | |
| 14649 | + // AB off: it competes with 1:4 in the RD search (with | |
| 14650 | + // AB on, 0 superblock 1:4 strips appeared in 16 | |
| 14651 | + // compared streams), and AB below 16x16 is another | |
| 14652 | + // lane's refusal. | |
| 14653 | + "--enable-ab-partitions=0", | |
| 14654 | + "--enable-1to4-partitions=1", | |
| 14655 | + // 16, not 8: with 8 every seed of this recipe stops | |
| 14656 | + // at a 32x32-level PARTITION_HORZ_4/VERT_4 (partition | |
| 14657 | + // values 8/9, 32x8/8x32 luma strips), a shape this | |
| 14658 | + // decoder does not code at all yet -- 12/12 attempts | |
| 14659 | + // refused before a pixel was compared (measured r1). | |
| 14660 | + // At 16 the 1:4 split happens at the superblock, the | |
| 14661 | + // 64x16/16x64 strips whose chroma half is 32x8/8x32. | |
| 14662 | + "--min-partition-size=16", | |
| 14663 | + "--max-partition-size=64", | |
| 14664 | + "--enable-restoration=0", | |
| 14665 | + "--enable-palette=0", | |
| 14666 | + "--deltaq-mode=0", | |
| 14667 | + "--enable-filter-intra=0", | |
| 14668 | + "--enable-cfl-intra=0", | |
| 14669 | + "--enable-intrabc=0", | |
| 14670 | + "--obu", | |
| 14671 | + "-o", | |
| 14672 | + "-", | |
| 14673 | + "-", | |
| 14674 | + ]) | |
| 14675 | + .stdin(Stdio::piped()) | |
| 14676 | + .stdout(Stdio::piped()) | |
| 14677 | + .stderr(Stdio::piped()) | |
| 14678 | + .spawn() | |
| 14679 | + .expect("aomenc failed to start"); | |
| 14680 | + child | |
| 14681 | + .stdin | |
| 14682 | + .take() | |
| 14683 | + .expect("aomenc stdin") | |
| 14684 | + .write_all(&y4m.stdout) | |
| 14685 | + .expect("writing y4m to aomenc"); | |
| 14686 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 14687 | + assert!( | |
| 14688 | + out.status.success(), | |
| 14689 | + "{NAME}: aomenc refused the fixture: {}", | |
| 14690 | + String::from_utf8_lossy(&out.stderr) | |
| 14691 | + ); | |
| 14692 | + let stream = out.stdout; | |
| 14693 | + let before = crate::decode::rect_split_chroma_shape_hits(); | |
| 14694 | + let split_before = crate::decode::rect_split_tx_hits(); | |
| 14695 | + let rect4_before = ( | |
| 14696 | + crate::decode::sb_rect4_horz_hits(), | |
| 14697 | + crate::decode::sb_rect4_vert_hits(), | |
| 14698 | + ); | |
| 14699 | + let frames = match decode_stream(&stream) { | |
| 14700 | + Err(e) => { | |
| 14701 | + let msg = e.to_string(); | |
| 14702 | + assert!( | |
| 14703 | + msg.contains("unsupported"), | |
| 14704 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit seed \ | |
| 14705 | + {seed}): {msg}" | |
| 14706 | + ); | |
| 14707 | + refusals += 1; | |
| 14708 | + if msg.contains("splits only once") { | |
| 14709 | + depth1_refusals += 1; | |
| 14710 | + } | |
| 14711 | + all_rect4 += (crate::decode::sb_rect4_horz_hits() - rect4_before.0) | |
| 14712 | + + (crate::decode::sb_rect4_vert_hits() - rect4_before.1); | |
| 14713 | + let r4 = (crate::decode::sb_rect4_horz_hits() - rect4_before.0) | |
| 14714 | + + (crate::decode::sb_rect4_vert_hits() - rect4_before.1); | |
| 14715 | + eprintln!( | |
| 14716 | + "{NAME}: {bit_depth}-bit cq {cq} seed {seed} refusal (1:4 strips so \ | |
| 14717 | + far {r4}): {msg}" | |
| 14718 | + ); | |
| 14719 | + continue; | |
| 14720 | + } | |
| 14721 | + Ok(frames) => frames, | |
| 14722 | + }; | |
| 14723 | + let after = crate::decode::rect_split_chroma_shape_hits(); | |
| 14724 | + if (0..4).any(|k| after[k] > before[k]) { | |
| 14725 | + eprintln!( | |
| 14726 | + "{NAME}: {bit_depth}-bit cq {cq} seed {seed} carries chroma shapes \ | |
| 14727 | + 32x8={} 8x32={} 8x4={} 4x8={}", | |
| 14728 | + after[0] - before[0], | |
| 14729 | + after[1] - before[1], | |
| 14730 | + after[2] - before[2], | |
| 14731 | + after[3] - before[3] | |
| 14732 | + ); | |
| 14733 | + } | |
| 14734 | + let reference = if bit_depth == 10 { | |
| 14735 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) | |
| 14736 | + } else { | |
| 14737 | + ffmpeg_decode_sequence(&stream, width, height, frames.len()) | |
| 14738 | + }; | |
| 14739 | + assert_eq!(frames.len(), reference.len(), "{NAME}: frame count"); | |
| 14740 | + for (i, (got, want)) in frames.iter().zip(&reference).enumerate() { | |
| 14741 | + assert_eq!( | |
| 14742 | + got.y, want.y, | |
| 14743 | + "{NAME} frame {i} luma vs ffmpeg ({bit_depth}-bit cq {cq} seed {seed})" | |
| 14744 | + ); | |
| 14745 | + assert_eq!( | |
| 14746 | + got.u, want.u, | |
| 14747 | + "{NAME} frame {i} U vs ffmpeg ({bit_depth}-bit cq {cq} seed {seed})" | |
| 14748 | + ); | |
| 14749 | + assert_eq!( | |
| 14750 | + got.v, want.v, | |
| 14751 | + "{NAME} frame {i} V vs ffmpeg ({bit_depth}-bit cq {cq} seed {seed})" | |
| 14752 | + ); | |
| 14753 | + } | |
| 14754 | + for k in 0..4 { | |
| 14755 | + proved[k] += after[k] - before[k]; | |
| 14756 | + } | |
| 14757 | + split_strips += crate::decode::rect_split_tx_hits() - split_before; | |
| 14758 | + rect4_strips += (crate::decode::sb_rect4_horz_hits() - rect4_before.0) | |
| 14759 | + + (crate::decode::sb_rect4_vert_hits() - rect4_before.1); | |
| 14760 | + matched += 1; | |
| 14761 | + } | |
| 14762 | + } | |
| 14763 | + eprintln!( | |
| 14764 | + "{NAME}: {matched} pixel-exact matches, {refusals} named refusals out of \ | |
| 14765 | + {} attempts; chroma shapes proved 32x8={} 8x32={} 8x4={} 4x8={}; compared \ | |
| 14766 | + streams carried {split_strips} split-transform strips and {rect4_strips} \ | |
| 14767 | + superblock 1:4 strips ({all_rect4} more in refused streams)", | |
| 14768 | + 6 * n_attempts, | |
| 14769 | + proved[0], | |
| 14770 | + proved[1], | |
| 14771 | + proved[2], | |
| 14772 | + proved[3] | |
| 14773 | + ); | |
| 14774 | + assert!( | |
| 14775 | + matched > 0, | |
| 14776 | + "{NAME}: every attempt refused; the gate never decoded a stream" | |
| 14777 | + ); | |
| 14778 | + assert!( | |
| 14779 | + rect4_strips > 0, | |
| 14780 | + "{NAME}: no superblock 1:4 strip in any pixel-exact stream -- recipe lost its \ | |
| 14781 | + territory, gate proved nothing this run" | |
| 14782 | + ); | |
| 14783 | + // r1's actual capability delta. Before this round a 1:4 strip whose | |
| 14784 | + // transform depth is 1 was decoded as if its units were SQUARE | |
| 14785 | + // (`bw.min(bh) >> (depth - 1)`), because `sub_tx_size_map[TX_64X16]` | |
| 14786 | + // is TX_32X16, a 2:1 RECT, not TX_16X16 -- 8-bit cq 45 seed 42 of | |
| 14787 | + // this very recipe decoded 2 such strips and MISMATCHED ffmpeg on | |
| 14788 | + // frame 0 luma. It is now refused by name (rect luma transform units | |
| 14789 | + // inside a split strip are unported; the chroma half's 32x8/8x32 | |
| 14790 | + // tables this round wired are in place for it). This assert is what | |
| 14791 | + // keeps that from silently regressing to a wrong-pixel decode. | |
| 14792 | + assert!( | |
| 14793 | + depth1_refusals > 0, | |
| 14794 | + "{NAME}: no attempt reached a depth-1 1:4 split strip -- the recipe no longer \ | |
| 14795 | + covers the shape this round fixed" | |
| 14796 | + ); | |
| 14797 | + eprintln!("{NAME}: {depth1_refusals} attempts refused the depth-1 1:4 split strip by name"); | |
| 14798 | + } | |
| 14553 | 14799 | } |
lanes/rectchroma-r1.report.mdadded+73 -0
| @@ -0,0 +1,73 @@ | ||
| 1 | +# lane-rectchroma r1 | |
| 2 | + | |
| 3 | +Branch `lane-rectchroma` off main `4a29b4e` (already contains lane-tx64x16 / lane-rectx / lane-sub8merge; no merge needed). | |
| 4 | + | |
| 5 | +## What the charter's premise turned out to be | |
| 6 | + | |
| 7 | +`decode_rect_split` (crates/ec-av1/src/decode.rs:4343) refused | |
| 8 | +`"a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here"` | |
| 9 | +for both ReelC extracts. The caller that reaches it with an unmapped chroma shape is | |
| 10 | +`decode_block_rect64`'s `strip64!` arm (decode.rs:10333, `(64,16)`/`(16,64)` superblock | |
| 11 | +1:4 strips -> chroma 32x8 / 8x32); the 16x16-level `VERT_B` 8x16 rect | |
| 12 | +(decode.rs:9373 -> chroma 4x8) is the second, rarer one. | |
| 13 | + | |
| 14 | +## Changes | |
| 15 | + | |
| 16 | +- crates/ec-av1/src/decode.rs:4366 — four chroma shapes wired into the split-transform | |
| 17 | + chroma map: 32x8 / 8x32 -> `TxbSet::Chroma16` + `SCAN_32X8`/`SCAN_8X32` (the set and | |
| 18 | + scans the *unsplit* 1:4 path at decode.rs:5447 already uses, so no new table was | |
| 19 | + transcribed), 8x4 / 4x8 -> `TxbSet::ChromaRect8x4` + `SCAN_8X4`/`SCAN_4X8` (as | |
| 20 | + `decode_leaf_rect` decode.rs:5075 already does). | |
| 21 | +- crates/ec-av1/src/decode.rs:855 — per-shape hit counters | |
| 22 | + `rect_split_chroma_shape_hits() -> [usize; 4]` (32x8, 8x32, 8x4, 4x8). | |
| 23 | +- crates/ec-av1/src/decode.rs:5296 — **the real defect this round found**: | |
| 24 | + `sub_tx_size_map[TX_64X16] == TX_32X16`, a 2:1 RECT, not `TX_16X16`. The site derived | |
| 25 | + the transform unit as `bw.min(bh) >> (depth - 1)` ("square from the first step on"), | |
| 26 | + which is true for a 2:1 strip and FALSE for a 1:4 one. A depth-1 64x16 / 16x64 strip | |
| 27 | + was therefore decoded as square 16x16 units and produced wrong pixels silently. Now: | |
| 28 | + depth >= 2 uses `bw.min(bh) >> (depth - 2)` (correct square), and depth == 1 on a | |
| 29 | + non-skip 1:4 strip is refused by name. | |
| 30 | +- crates/ec-av1/src/refusal_inventory.rs:37 — the new refusal string. | |
| 31 | +- crates/ec-av1/src/stream.rs:14560 — the gate (below). | |
| 32 | + | |
| 33 | +## Gate | |
| 34 | + | |
| 35 | +`a_real_aomenc_stream_with_a_coded_strip_whose_chroma_is_a_4to1_or_sub8_rect_decodes_pixel_exact` | |
| 36 | +— 8-bit AND 10-bit, cq 45/32/60, seeds 42.., odd seeds transposed (HORZ_4 and VERT_4 both | |
| 37 | +appear), `--enable-rect-partitions=1 --enable-ab-partitions=0 --enable-1to4-partitions=1 | |
| 38 | +--sb-size=64 --cpu-used=0`, tx-size-search left at aomenc's default (ON) which is the whole | |
| 39 | +point. Fixture: 16-row luma bands + seeded noise | |
| 40 | +(`geq=lum='mod(floor(Y/16),2)*160+48',noise=alls=10:all_seed=<seed>`). | |
| 41 | +Every decode is pixel-compared against ffmpeg (10-bit via `ffmpeg_decode_sequence_10bit`), | |
| 42 | +no SKIP on a decode error or mismatch, refusals must contain "unsupported". | |
| 43 | +Hard asserts: `matched > 0`, `rect4_strips > 0` (1:4 strips inside pixel-exact streams), | |
| 44 | +`depth1_refusals > 0` (the shape the fix covers is actually reached). | |
| 45 | + | |
| 46 | +Run: `EC_AV1_REQUIRE_AOMENC=1 EC_RECTCHROMA_GATE_ATTEMPTS=4 cargo test -p ec-av1 --lib chroma_is_a_4to1_or_sub8 -- --nocapture` | |
| 47 | + | |
| 48 | +EVIDENCE: gate stdout | 24 aomenc streams (8+10 bit x cq 45/32/60 x 4 seeds), each decoded and compared to ffmpeg | 15 pixel-exact matches, 9 named refusals, 100 superblock 1:4 strips inside compared streams, 9 attempts refused the depth-1 1:4 split strip by name; test result: ok | |
| 49 | +EVIDENCE: same gate before the decode.rs:5296 fix | 8-bit cq 45 seed 42, 2 strips with chroma 32x8 decoded through the split path | frame 0 luma MISMATCHED ffmpeg (first sample 47 vs reference) -- the silent wrong-tiling this round removed | |
| 50 | + | |
| 51 | +## Film check (release `decode_probe`) | |
| 52 | + | |
| 53 | +- reelc-head.obu: was `a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here` | |
| 54 | + -> now `a coded 1:4 HORZ_4/VERT_4 strip whose transform splits only once (the unit is still a 2:1 rect, not a square)`. | |
| 55 | +- reelc5.obu: was the same chroma refusal -> now `a 32x32 partition type this decoder does not code (value=9)` | |
| 56 | + (32x32-level `PARTITION_VERT_4`, a different lane's shape). | |
| 57 | + | |
| 58 | +## Residue | |
| 59 | + | |
| 60 | +- fix-now(next round): **rect luma transform units inside a split strip**. ReelC's blocker is | |
| 61 | + exactly a depth-1 1:4 strip: luma = two `TX_32X16` (or `TX_16X32`) units, chroma = one | |
| 62 | + 32x8/8x32 (tables now present). `decode_rect_split`'s luma loop is square-only; it needs a | |
| 63 | + rect-TU arm (`TxbSet::LumaRect32x16` + `SCAN_32X16`/`SCAN_16X32` + `read_coeffs_rect` + | |
| 64 | + `reconstruct_rect`, per-unit reach/skip-ctx as the square loop already computes). | |
| 65 | +- deferred(that same rect-TU arm): the 32x8 / 8x32 / 8x4 / 4x8 chroma arms added here are | |
| 66 | + NOT yet proven by a pixel gate -- every shape that would exercise them arrives with | |
| 67 | + depth 1, which now refuses. Counters read 0 across the whole sweep; the report states this | |
| 68 | + rather than asserting on them. 8x4/4x8 additionally need a 16x16-level rect strip with a | |
| 69 | + split transform, whose own refusal (`a HORZ/VERT intra strip below 16x16 with a split | |
| 70 | + transform`) is another lane's. | |
| 71 | +- accepted: `--min-partition-size` is INERT on this recipe (16 and 32 give byte-identical | |
| 72 | + refusal sets and the same sub-16x16 shapes appear either way) -- class | |
| 73 | + knob-never-reached-the-tool; the gate does not rely on it. |