diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index f1d75a25..a5a3b0c6 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -1838,6 +1838,21 @@ pub(crate) fn masked_compound_hits() -> usize { MASKED_COMPOUND_HITS.with(|c| c.get()) } +// lane-intersub8 r4/r5: the NON-SQUARE half of `MASKED_COMPOUND_HITS` -- a +// masked-compound block whose true footprint is rectangular, i.e. the case +// whose `compound_type`/`wedge_idx` CDF row r4 fixed (it used to read the +// square envelope's `BLOCK_SIZES_ALL` index). Square blocks cannot show that +// defect, so a gate asserting `masked_compound_hits` alone stays vacuous for it. +thread_local! { + static RECT_MASKED_COMPOUND_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; +} + +/// Current value of [`RECT_MASKED_COMPOUND_HITS`]. +pub(crate) fn rect_masked_compound_hits() -> usize { + RECT_MASKED_COMPOUND_HITS.with(|c| c.get()) +} + // How many blocks decoded a real `COMPOUND_WEDGE` block (`comp_group_idx == // 1`, `compound_type == 0`) -- lane-wedge r3's proof a gate fixture // actually exercised the wedge blend, not just the DIFFWTD half of @@ -16995,6 +17010,9 @@ fn decode_inter_block( } } MASKED_COMPOUND_HITS.with(|c| c.set(c.get() + 1)); + if write_w != write_h { + RECT_MASKED_COMPOUND_HITS.with(|c| c.set(c.get() + 1)); + } } // corner-cut (lane-av1comp r16/r17, lane-av1blend r1): r16/r17 // called this a `predict_compound_intermediate`/`combine_compound` @@ -22835,38 +22853,17 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( )?; continue; } - if part8 == PARTITION_HORZ - && std::env::var_os("EC_AV1_SUB8_HORZ").is_none() - { - // lane-intersub8 r4: the r3 desync IS - // root-caused and fixed (rect masked - // compound read `BLOCK_16X16`'s - // `compound_type`/`wedge_idx` CDF row - // for a 16x8 block); every mode-info - // range on the 28-arm transposed - // sweep now matches aomdec element - // for element. What is left is a - // POST-ENTROPY pixel band: 3 of 28 - // arms (8-bit cq32 sp9, 10-bit cq12 - // sp3, 10-bit cq16 sp3) differ by - // |d| <= 2 in luma only, scattered - // over the bottom-left corner - // (x < 48, y >= 112) from the first - // frame that references an 8x4 group - // -- a filter/reconstruction defect, - // not a desync. Still refused by name - // rather than shipped as silent pixel - // drift; `EC_AV1_SUB8_HORZ=1` decodes - // it for the r5 bisect. - return Err(unsupported( - "an inter 8x8 HORZ partition (two BLOCK_8X4 inter leaves; entropy-exact now, but a measured sweep still drifts |d|<=2 in luma after the filters)", - )); - } if part8 == PARTITION_VERT || part8 == PARTITION_HORZ { - // lane-intersub8 r3/r4: two BLOCK_8X4 - // (HORZ) / BLOCK_4X8 (VERT) inter - // leaves, chroma once per 8x8 on the - // second of them. + // lane-intersub8 r3/r4/r5: two + // BLOCK_8X4 (HORZ) / BLOCK_4X8 (VERT) + // inter leaves, chroma once per 8x8 on + // the second of them. HORZ was refused + // by name through r4 over a |d| <= 2 + // luma band; r5 merged lane-cdef + // 8c6065e, whose `decode_inter_block8` + // skip-band write is that band's root + // cause, and the 56-arm sweep went 3 + // mismatching arms -> 0. decode_inter_sub8_rect2( &mut dec, &mut cdfs, diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 7033ebec..8b9ddf64 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -36,7 +36,6 @@ const REFUSALS: &[&str] = &[ "an intra 4x4 block inside an inter frame's sub-8x8 split (this decoder codes only inter 4x4 sub-blocks there)", "an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition (this decoder codes only inter sub-blocks there)", "a sub-8x8 inter block under a scaled reference (superres, unimplemented)", - "an inter 8x8 HORZ partition (two BLOCK_8X4 inter leaves; entropy-exact now, but a measured sweep still drifts |d|<=2 in luma after the filters)", "a COMPOUND_WEDGE mask on a non-square inter block (rect wedge codebook unimplemented)", "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 3a354da6..ade4d0ac 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -7586,11 +7586,24 @@ mod tests { // 8x8 (two BLOCK_4X8 inter leaves, one shared 4x4 chroma unit predicted // from BOTH sub-blocks' mvs). The HORZ twin is still refused by name. let mut rect_fired = 0u32; + // lane-intersub8 r5: the two rect axes counted apart. Attempts 16..23 + // are the same recipe family with the geq source TRANSPOSED (the sine + // that moves runs along Y, not X): measured over a 56-arm sweep + // (~/.cache/intersub8-sweep-r5.log, cq {8,12,14,16,20,26,32} x sp + // {3,6,9,12} x both depths, rect on), aomenc picks PARTITION_HORZ + // below 8x8 on that source and PARTITION_VERT on the untransposed one + // -- neither schedule reaches the other axis, so both are needed. + let (mut horz_fired, mut vert_fired) = (0u32, 0u32); + // Rect (non-square) masked-compound blocks on attempts that DECODED + // and were pixel-compared -- never off a refused stream (class + // counter-from-refused-stream). This is the shape whose + // `compound_type`/`wedge_idx` CDF row lane-intersub8 r4 fixed. + let mut rect_masked = 0usize; let mut refusals: Vec = Vec::new(); let mut out_of_scope_mismatch = 0u32; for bit_depth in [8u32, 10u32] { - for attempt in 0..16u32 { - let rect = attempt / 8; + for attempt in 0..24u32 { + let rect = if attempt >= 16 { 1 } else { attempt / 8 }; let rect_arg = format!("--enable-rect-partitions={rect}"); // lane-intersub8 r2, measured schedule (sweep of cq // {8,10,12,14,16,18,20} x sp {3,6,9,12} x both depths, @@ -7606,13 +7619,30 @@ mod tests { // rather than hidden: cq 16..20 are all exact, so this gate // is not selecting quantizers that hide a defect of its own // shape. - let cq = [12, 14][(attempt % 2) as usize]; - let sp = 3 + ((attempt % 8) / 2) * 3; + // Attempts 16..23: the (cq, sp) pairs the r5 sweep measured + // as HORZ-firing on the transposed source -- 8-bit + // (14,3)/(20,3)/(32,9), 10-bit (12,3)/(16,3); the rest of the + // eight are non-firing neighbours kept so a schedule that + // stops firing shows up as out-of-scope, not as a silent pass. + const HORZ_SCHEDULE: [(u32, u32); 8] = + [(14, 3), (20, 3), (32, 9), (12, 3), (16, 3), (12, 9), (14, 9), (26, 3)]; + let (cq, sp) = if attempt >= 16 { + HORZ_SCHEDULE[(attempt - 16) as usize] + } else { + ([12, 14][(attempt % 2) as usize], 3 + ((attempt % 8) / 2) * 3) + }; let duration = frame_count as f64 / 25.0; - let source = format!( - "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ - geq=lum='128+58*sin((X+N*{sp})/6)+18*sin(Y/23)',format=yuv420p" - ); + let source = if attempt >= 16 { + format!( + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ + geq=lum='128+58*sin((Y+N*{sp})/6)+18*sin(X/23)',format=yuv420p" + ) + } else { + format!( + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ + geq=lum='128+58*sin((X+N*{sp})/6)+18*sin(Y/23)',format=yuv420p" + ) + }; let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; let y4m = Command::new("ffmpeg") .args([ @@ -7667,6 +7697,7 @@ mod tests { let stream = out.stdout; let before = decode::sub8_inter_split_hits(); let before_rect = decode::sub8_inter_rect_hits(); + let before_masked = decode::rect_masked_compound_hits(); let frames = match decode_stream(&stream) { Err(e) => { let msg = e.to_string(); @@ -7721,8 +7752,20 @@ mod tests { if rect_groups > 0 { rect_fired += 1; } + if rect_now.0 - before_rect.0 > 0 { + horz_fired += 1; + } + if rect_now.1 - before_rect.1 > 0 { + vert_fired += 1; + } + // Only now, past the pixel compare, is this attempt's + // masked-compound count admissible. + rect_masked += decode::rect_masked_compound_hits() - before_masked; } } + eprintln!( + "{NAME}: fired={fired} horz={horz_fired} vert={vert_fired} rect_masked={rect_masked}" + ); assert_eq!( out_of_scope_mismatch, 0, "{NAME}: attempts mismatched with no sub-8x8 inter group" @@ -7738,6 +7781,27 @@ mod tests { inter leaf (4x8):\n{}", refusals.join("\n") ); + assert!( + vert_fired >= 2, + "{NAME}: fewer than 2 firing+pixel-exact attempts with a sub-8x8 inter VERT \ + pair (two BLOCK_4X8 leaves):\n{}", + refusals.join("\n") + ); + // lane-intersub8 r5, measured `rect_masked=2` over the 48 attempts: + // the rect masked-compound blocks whose `compound_type`/`wedge_idx` + // CDF row r4 corrected, counted only on pixel-compared attempts. + assert!( + rect_masked >= 1, + "{NAME}: no RECTANGULAR masked-compound block on any pixel-compared attempt -- \ + the r4 compound_type/wedge_idx CDF-row fix is unexercised:\n{}", + refusals.join("\n") + ); + assert!( + horz_fired >= 2, + "{NAME}: fewer than 2 firing+pixel-exact attempts with a sub-8x8 inter HORZ \ + pair (two BLOCK_8X4 leaves):\n{}", + refusals.join("\n") + ); } #[test]