forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-t900' (f90d83a1): intrabc under 128x128 superblocks (fallback DV keyed on the sequence SB size) and palette blocks with residual on superblock-level strips (chroma palette override on the non-skip arm); both refusals lifted and gated

Browse files at this commit

16ae97f167b73e3f520b090e4ff471d07d669b7fAhmet Kaan GümüşParent: e5de66d3a302e7
crates/ec-av1/src/decode.rsmodified+24 -24
@@ -10416,24 +10416,11 @@ fn decode_block_rect64(
10416 c * (SUB / MI), fctx,10416 c * (SUB / MI), fctx,
10417 )?;10417 )?;
10418 if (palette_y.is_some() || palette_uv.is_some()) && !skip {10418 if (palette_y.is_some() || palette_uv.is_some()) && !skip {
10419- // The luma coefficient path here is the corner-cropped 32x32 real10419+ // lane-t900 r34: a non-skip palette block on a superblock-level strip
10420- // transform embedded in a 64x32/32x64 grid ([`decode_block_rect64`]'s10420+ // -- counted so its gate cannot go vacuous (this was a refusal until
10421- // own doc comment) -- a real (non-skip) palette block's residual10421+ // r34; see the gate `a_real_aomenc_palette_stream_with_8x8_leaves_
10422- // needs the plain, uncropped rect reader [`decode_block_rect`] already10422+ // decodes_pixel_exact`).
10423- // has, not this one's truncation. `skip` (no residual at all) is
10424- // still supported below (lane-palette2 r4).
10425- //
10426- // lane-pal8 r1 MEASURED the lift and it is NOT free: dropping this
10427- // refusal decodes `testsrc2` 128x128 10-bit cq55 `--enable-palette=1
10428- // --min-partition-size=8 --tile-columns=1` with a whole-frame pixel
10429- // mismatch (the arm the gate below counts). Something in this shape's
10430- // palette prediction or its corner-cropped residual is wrong, and the
10431- // refusal stays until that is found -- it is counted, never skipped.
10432 PALETTE_SB_STRIP_HITS.with(|c| c.set(c.get() + 1));10423 PALETTE_SB_STRIP_HITS.with(|c| c.set(c.get() + 1));
10433- return Err(unsupported(
10434- "a palette block with a real transform on a superblock-level HORZ/VERT \
10435- strip (corner-cropped luma coefficients not ported for palette)",
10436- ));
10437 }10424 }
10438 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);10425 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
10439 if smooth_neighbor {10426 if smooth_neighbor {
@@ -10817,6 +10804,16 @@ fn decode_block_rect64(
10817 plane_q_delta(1, fctx).1,10804 plane_q_delta(1, fctx).1,
10818 u_tx_type,10805 u_tx_type,
10819 );10806 );
10807+ // lane-t900 r34: the UV-palette prediction override, exactly as the
10808+ // `skip` arm above installs it. The [`PALETTE_PRED`] slot is a
10809+ // set-then-take, so it must be filled again right before each plane's
10810+ // own reconstruct; leaving this out of the non-skip arm predicted a
10811+ // palette block's chroma off its block edges (measured: testsrc2
10812+ // 128x128 10-bit cq55 `--tile-columns=1`, the 32x64 strip at px=96 --
10813+ // luma exact, both chroma planes wrong over its whole 16x32).
10814+ if let Some((ub, _)) = &palette_uv_bufs {
10815+ set_palette_pred(ub.clone(), fctx);
10816+ }
10820 u.reconstruct_rect(10817 u.reconstruct_rect(
10821 cpx,10818 cpx,
10822 cpy,10819 cpy,
@@ -10871,6 +10868,9 @@ fn decode_block_rect64(
10871 plane_q_delta(2, fctx).1,10868 plane_q_delta(2, fctx).1,
10872 v_tx_type,10869 v_tx_type,
10873 );10870 );
10871+ if let Some((_, vb)) = &palette_uv_bufs {
10872+ set_palette_pred(vb.clone(), fctx);
10873+ }
10874 v.reconstruct_rect(10874 v.reconstruct_rect(
10875 cpx,10875 cpx,
10876 cpy,10876 cpy,
@@ -17971,11 +17971,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
17971 }17971 }
17972 fctx.enable_edge_filter.with(|f| f.set(enable_edge_filter));17972 fctx.enable_edge_filter.with(|f| f.set(enable_edge_filter));
17973 let sb128 = sb128(fctx);17973 let sb128 = sb128(fctx);
17974- if sb128 && allow_intrabc {
17975- return Err(unsupported(
17976- "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)",
17977- ));
17978- }
17979 let (sb_cols, sb_rows) = (mi_cols.div_ceil(SB_MI), mi_rows.div_ceil(SB_MI));17974 let (sb_cols, sb_rows) = (mi_cols.div_ceil(SB_MI), mi_rows.div_ceil(SB_MI));
17980 fctx.intrabc_mi_grid.with(|g| {17975 fctx.intrabc_mi_grid.with(|g| {
17981 *g.borrow_mut() = allow_intrabc.then(|| {17976 *g.borrow_mut() = allow_intrabc.then(|| {
@@ -20327,8 +20322,13 @@ fn read_intrabc_dv(
20327 if pred == (0, 0) {20322 if pred == (0, 0) {
20328 // `av1_find_ref_dv` (mvref_common.c). Tile row start is 0 here (the20323 // `av1_find_ref_dv` (mvref_common.c). Tile row start is 0 here (the
20329 // single-tile-row case every intrabc gate stream is).20324 // single-tile-row case every intrabc gate stream is).
20330- let sb_px = SB_MI as i32 * MI as i32;20325+ // lane-t900 r34: `av1_find_ref_dv` takes `mib_size` -- the SEQUENCE's
20331- pred = if mi_r < SB_MI as usize {20326+ // superblock size in mi units -- so a 128x128 superblock stream's
20327+ // fallback DV is one 128-px superblock up (or 128+256 px left on the
20328+ // tile's first superblock row), never the 64 this hardcoded.
20329+ let sb_mi = sb_mi_cur(fctx) as i32;
20330+ let sb_px = sb_mi * MI as i32;
20331+ pred = if (mi_r as i32) < sb_mi {
20332 (0, -(sb_px + INTRABC_DELAY_PIXELS) * 8)20332 (0, -(sb_px + INTRABC_DELAY_PIXELS) * 8)
20333 } else {20333 } else {
20334 (-sb_px * 8, 0)20334 (-sb_px * 8, 0)
crates/ec-av1/src/refusal_inventory.rsmodified+0 -22
@@ -43,8 +43,6 @@ const REFUSALS: &[&str] = &[
43 "a 128x128 superblock partition value outside the 8-symbol alphabet",43 "a 128x128 superblock partition value outside the 8-symbol alphabet",
44 "an inter var-tx tree with a leaf transform larger than 64x64",44 "an inter var-tx tree with a leaf transform larger than 64x64",
45 "CfL, filter intra or a palette on a 128-root HORZ/VERT intra block (every one of their size gates caps at 64x64 or below, so none of these symbols exists there)",45 "CfL, filter intra or a palette on a 128-root HORZ/VERT intra block (every one of their size gates caps at 64x64 or below, so none of these symbols exists there)",
46- "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)",
47- "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",
48 // lane-t900 r23: palette RECONSTRUCTION now covers the key-frame paths46 // lane-t900 r23: palette RECONSTRUCTION now covers the key-frame paths
49 // (earlier lanes), the intra-in-inter square/rect paths (r22) and the47 // (earlier lanes), the intra-in-inter square/rect paths (r22) and the
50 // 8x8 LEAF inside an inter frame (this round, gate48 // 8x8 LEAF inside an inter frame (this round, gate
@@ -372,26 +370,6 @@ const PROVEN: &[(&str, &str)] = &[
372 "CfL, filter intra or a palette on a 128-root HORZ/VERT intra block (every one of their size gates caps at 64x64 or below, so none of these symbols exists there)",370 "CfL, filter intra or a palette on a 128-root HORZ/VERT intra block (every one of their size gates caps at 64x64 or below, so none of these symbols exists there)",
373 "no_128_root_half_reads_a_cfl_filter_intra_or_palette_symbol",371 "no_128_root_half_reads_a_cfl_filter_intra_or_palette_symbol",
374 ),372 ),
375- // lane-t900 r33, WITNESS of a capability gap: the refusal is REACHED by
376- // real `--tune-content=screen --enable-palette=1` streams, counted
377- // (`palette_sb_strip_hits`) and hard-asserted non-zero by its gate, which
378- // also decodes the arms that do not reach it pixel-exact. lane-pal8 r1
379- // measured the lift and it mismatches whole-frame, so the string names a
380- // real shape a real encoder writes -- an open capability, not a claim.
381- (
382- "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",
383- "a_real_aomenc_palette_stream_with_8x8_leaves_decodes_pixel_exact",
384- ),
385- // lane-t900 r33, CENSUS (reached -- a pinned capability gap): all four
386- // `--sb-size=128` exact-repetition screen arms code
387- // `use_128x128_superblock && allow_intrabc`, and every one of them reaches
388- // this refusal by name. The lift is a decode.rs change (the block-vector
389- // delay of `av1_is_dv_valid` is superblock-sized) with a waiting witness,
390- // `an_sb128_screen_stream_with_intrabc_decodes_pixel_exact` (ignored).
391- (
392- "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)",
393- "an_sb128_screen_census_measures_the_sb128_intrabc_refusal",
394- ),
395 // lane-t900 r33, CENSUS: the `use_intrabc` symbol IS read at the sub-8373 // lane-t900 r33, CENSUS: the `use_intrabc` symbol IS read at the sub-8
396 // reader for every sub-8x8 leaf of an `allow_intrabc` frame, and over the374 // reader for every sub-8x8 leaf of an `allow_intrabc` frame, and over the
397 // `--min-partition-size=4` exact-repetition screen arms every such symbol375 // `--min-partition-size=4` exact-repetition screen arms every such symbol
crates/ec-av1/src/stream.rsmodified+39 -101
@@ -4141,8 +4141,8 @@ mod tests {
4141 (0usize, 0u32, 0u32, 0usize);4141 (0usize, 0u32, 0u32, 0usize);
4142 let (mut out_of_scope, mut out_of_scope_mismatch, mut refusals) = (0u32, 0u32, 0u32);4142 let (mut out_of_scope, mut out_of_scope_mismatch, mut refusals) = (0u32, 0u32, 0u32);
4143 let (mut sb_strip_total, mut sb_strip_arms) = (0usize, 0u32);4143 let (mut sb_strip_total, mut sb_strip_arms) = (0usize, 0u32);
4144- // The one palette shape this round did NOT lift (measured: lifting it4144+ // lane-t900 r34 LIFTED this shape; the counter stays so the gate
4145- // mismatches -- see [`decode_block_rect64`]'s own comment).4145+ // fails loudly if the refusal ever comes back.
4146 let mut sb_strip_refusals = 0u32;4146 let mut sb_strip_refusals = 0u32;
4147 for src in ["testsrc2", "smptebars"] {4147 for src in ["testsrc2", "smptebars"] {
4148 for depth in [8usize, 10usize] {4148 for depth in [8usize, 10usize] {
@@ -4322,10 +4322,14 @@ mod tests {
4322 leaf8_total > 0 && fired_arms > 0,4322 leaf8_total > 0 && fired_arms > 0,
4323 "{NAME}: gate is vacuous -- no compared arm decoded an 8x8-leaf palette block"4323 "{NAME}: gate is vacuous -- no compared arm decoded an 8x8-leaf palette block"
4324 );4324 );
4325+ assert_eq!(
4326+ sb_strip_refusals, 0,
4327+ "{NAME}: the superblock-strip palette refusal is back (lane-t900 r34 lifted it)"
4328+ );
4325 assert!(4329 assert!(
4326- sb_strip_refusals > 0,4330+ sb_strip_arms > 0 && sb_strip_total > 0,
4327- "{NAME}: no arm reached the superblock-strip palette refusal -- the open residue \4331+ "{NAME}: no arm decoded a non-skip palette block on a superblock-level strip -- \
4328- this gate documents is no longer exercised"4332+ the shape r34 lifted is no longer exercised"
4329 );4333 );
4330 assert_eq!(4334 assert_eq!(
4331 out_of_scope_mismatch, 0,4335 out_of_scope_mismatch, 0,
@@ -4694,31 +4698,32 @@ mod tests {
4694 (sb128, intrabc)4698 (sb128, intrabc)
4695 }4699 }
4696 4700
4697- /// lane-t900 r33, CENSUS for "intrabc under a 128x128 superblock".4701+ /// lane-t900 r34, the WITNESS (r33 pinned it ignored) that intrabc under
4702+ /// a 128x128 superblock decodes pixel-exact.
4698 ///4703 ///
4699- /// Unlike every other refusal in the inventory this one is decided in the4704+ /// All four arms of r33's census -- `--sb-size=128 --tune-content=screen
4700- /// FRAME HEADER, before a single block symbol: `use_128x128_superblock &&4705+ /// --enable-intrabc=1` over both `--enable-tx-size-search` settings and
4701- /// allow_intrabc`. So the census question is only whether a real encoder4706+ /// two quantisers, on a 2x2 tiling of a 128x96 bar pattern (256x192,
4702- /// writes that conjunction -- if it does, the refusal is a capability gap4707+ /// 8-bit, `--cpu-used=0 --min-partition-size=8 --max-partition-size=32`,
4703- /// (this decoder hardcodes the block-vector delay of `av1_is_dv_valid` to4708+ /// rect and 1:4 off) -- code `use_128x128_superblock && allow_intrabc`.
4704- /// a 64-px superblock) and the arm that reaches it is pinned here; if no
4705- /// arm does, the string is measured against the domain instead of assumed.
4706 ///4709 ///
4707- /// The four arms are the exact-repetition recipe that is the ONLY shape4710+ /// The lift was one constant: `av1_find_ref_dv` (mvref_common.c) takes
4708- /// known to keep `allow_intrabc` past libaom's own RD (lane-t900 r31: on4711+ /// `mib_size`, the SEQUENCE's superblock size in mi units, so the
4709- /// non-repeating content, `--enable-tx-size-search=1` makes RD drop4712+ /// fallback DV is one 128-px superblock up (or 128 + `INTRABC_DELAY_PIXELS`
4710- /// intrabc and libaom clears the bit again), with `--sb-size=128` and both4713+ /// left on the tile's first superblock row) under a 128 superblock, where
4711- /// tx-size-search settings over two quantisers.4714+ /// [`crate::decode::read_intrabc_dv`] hardcoded 64. Every arm is compared
4715+ /// to ffmpeg and the decoded-intrabc-block counter is asserted non-zero,
4716+ /// so a stream that stopped using intrabc could not make this vacuous.
4712 #[test]4717 #[test]
4713- fn an_sb128_screen_census_measures_the_sb128_intrabc_refusal() {4718+ fn an_sb128_screen_stream_with_intrabc_decodes_pixel_exact() {
4714- const NAME: &str = "an_sb128_screen_census_measures_the_sb128_intrabc_refusal";4719+ const NAME: &str = "an_sb128_screen_stream_with_intrabc_decodes_pixel_exact";
4715 if !have_ffmpeg() || !have_aomenc() {4720 if !have_ffmpeg() || !have_aomenc() {
4716 eprintln!("SKIP {NAME}: no ffmpeg/aomenc");4721 eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
4717 return;4722 return;
4718 }4723 }
4719 let (width, height) = (256usize, 192usize);4724 let (width, height) = (256usize, 192usize);
4720- let (mut premise_arms, mut reached, mut decoded_arms, mut frames_compared) =4725+ let _guard = lock_gate_counters();
4721- (0u32, 0u32, 0u32, 0u32);4726+ let (mut blocks_total, mut frames_compared) = (0usize, 0u32);
4722 for txs in ["0", "1"] {4727 for txs in ["0", "1"] {
4723 for cq in ["30", "45"] {4728 for cq in ["30", "45"] {
4724 let arm = format!("sb128 txs={txs} cq={cq}");4729 let arm = format!("sb128 txs={txs} cq={cq}");
@@ -4731,13 +4736,14 @@ mod tests {
4731 &["--sb-size=128"],4736 &["--sb-size=128"],
4732 );4737 );
4733 let (sb128, intrabc_frames) = sb128_and_intrabc_frames(&stream);4738 let (sb128, intrabc_frames) = sb128_and_intrabc_frames(&stream);
4734- assert!(sb128, "{NAME}: {arm}: aomenc ignored --sb-size=128");4739+ assert!(
4735- if intrabc_frames > 0 {4740+ sb128 && intrabc_frames > 0,
4736- premise_arms += 1;4741+ "{NAME}: {arm} no longer codes sb128 + allow_intrabc"
4737- }4742+ );
4738- match decode_stream(&stream) {4743+ crate::decode::reset_intrabc_hits();
4739- Ok(frames) => {4744+ let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: {arm}: {e}"));
4740- decoded_arms += 1;4745+ let blocks = crate::decode::intrabc_hits();
4746+ blocks_total += blocks;
4741 let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len());4747 let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len());
4742 assert_eq!(frames.len(), theirs.len(), "{NAME}: {arm} frame count");4748 assert_eq!(frames.len(), theirs.len(), "{NAME}: {arm} frame count");
4743 for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {4749 for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {
@@ -4748,85 +4754,17 @@ mod tests {
4748 frames_compared += 1;4754 frames_compared += 1;
4749 }4755 }
4750 eprintln!(4756 eprintln!(
4751- "{NAME}: {arm} sb128={sb128} intrabc_frames={intrabc_frames} \4757+ "{NAME}: {arm} intrabc_frames={intrabc_frames} intrabc_blocks={blocks} \
4752 DECODED {} frame(s) exact",4758 DECODED {} frame(s) exact",
4753 frames.len()4759 frames.len()
4754 );4760 );
4755 }4761 }
4756- Err(e) => {
4757- let msg = e.to_string();
4758- assert!(msg.contains("unsupported"), "{NAME}: {arm} decode failed: {e}");
4759- if msg.contains("intrabc under a 128x128 superblock") {
4760- reached += 1;
4761- }
4762- eprintln!(
4763- "{NAME}: {arm} sb128={sb128} intrabc_frames={intrabc_frames} \
4764- REFUSED: {e}"
4765- );
4766- }
4767- }
4768 }4762 }
4769- }4763+ assert!(frames_compared > 0, "{NAME}: no frame was compared");
4770- eprintln!(
4771- "{NAME}: {premise_arms}/4 arm(s) code allow_intrabc under a 128x128 superblock, \
4772- {reached} reach the refusal, {decoded_arms} arm(s) decoded \
4773- ({frames_compared} frames exact)"
4774- );
4775 assert!(4764 assert!(
4776- premise_arms + decoded_arms > 0,4765+ blocks_total > 0,
4777- "{NAME}: census is vacuous -- no arm produced a decodable or premise-carrying stream"4766+ "{NAME}: gate is vacuous -- no arm decoded a single intrabc block"
4778 );4767 );
4779- assert_eq!(
4780- reached, premise_arms,
4781- "{NAME}: the refusal is the CONJUNCTION of the two header bits, so every arm \
4782- carrying it must reach the refusal and no other arm may"
4783- );
4784- }
4785-
4786- /// lane-t900 r33, the WAITING witness for the capability gap
4787- /// [`an_sb128_screen_census_measures_the_sb128_intrabc_refusal`] pins:
4788- /// FIRST BAD is `--sb-size=128 --tune-content=screen --enable-intrabc=1
4789- /// --enable-tx-size-search=0 --cq-level=30` on a 2x2 tiling of a 128x96
4790- /// bar pattern (256x192, 8-bit, `--cpu-used=0 --min-partition-size=8
4791- /// --max-partition-size=32 --enable-rect-partitions=0
4792- /// --enable-1to4-partitions=0`) -- all four arms of the census code
4793- /// `use_128x128_superblock && allow_intrabc`, so the refusal names a
4794- /// configuration real aomenc writes at its FIRST attempt, not a corner.
4795- ///
4796- /// Lifting it is a `decode.rs` change this lane is not allowed to make:
4797- /// `av1_is_dv_valid` derives the block-vector delay (`sb_size` wide
4798- /// `INTRABC_DELAY_PIXELS`, the wavefront the valid-DV region is offset
4799- /// by) from the SUPERBLOCK SIZE, which this decoder hardcodes to 64, so
4800- /// every DV bound and every intrabc source fetch under a 128 superblock
4801- /// is computed against the wrong wavefront. Ignored until that lands.
4802- #[test]
4803- #[ignore = "capability gap: intrabc's block-vector delay is hardcoded to a 64-px superblock"]
4804- fn an_sb128_screen_stream_with_intrabc_decodes_pixel_exact() {
4805- const NAME: &str = "an_sb128_screen_stream_with_intrabc_decodes_pixel_exact";
4806- if !have_ffmpeg() || !have_aomenc() {
4807- eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
4808- return;
4809- }
4810- let (width, height) = (256usize, 192usize);
4811- let stream = screen_intrabc_stream_with(
4812- "smptebars=size=128x96:rate=25",
4813- "30",
4814- "0",
4815- true,
4816- true,
4817- &["--sb-size=128"],
4818- );
4819- let (sb128, intrabc_frames) = sb128_and_intrabc_frames(&stream);
4820- assert!(sb128 && intrabc_frames > 0, "{NAME}: the first-bad recipe no longer codes it");
4821- let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: {e}"));
4822- let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len());
4823- assert_eq!(frames.len(), theirs.len(), "{NAME}: frame count");
4824- for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {
4825- assert!(
4826- ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v,
4827- "{NAME}: frame {i} does not match ffmpeg"
4828- );
4829- }
4830 }4768 }
4831 4769
4832 /// lane-t900 r33, CENSUS for "a sub-8x8 leaf that uses intrabc".4770 /// lane-t900 r33, CENSUS for "a sub-8x8 leaf that uses intrabc".