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(
1041610416 c * (SUB / MI), fctx,
1041710417 )?;
1041810418 if (palette_y.is_some() || palette_uv.is_some()) && !skip {
10419- // The luma coefficient path here is the corner-cropped 32x32 real
10420- // transform embedded in a 64x32/32x64 grid ([`decode_block_rect64`]'s
10421- // own doc comment) -- a real (non-skip) palette block's residual
10422- // needs the plain, uncropped rect reader [`decode_block_rect`] already
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.
10419+ // lane-t900 r34: a non-skip palette block on a superblock-level strip
10420+ // -- counted so its gate cannot go vacuous (this was a refusal until
10421+ // r34; see the gate `a_real_aomenc_palette_stream_with_8x8_leaves_
10422+ // decodes_pixel_exact`).
1043210423 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- ));
1043710424 }
1043810425 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
1043910426 if smooth_neighbor {
@@ -10817,6 +10804,16 @@ fn decode_block_rect64(
1081710804 plane_q_delta(1, fctx).1,
1081810805 u_tx_type,
1081910806 );
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+ }
1082010817 u.reconstruct_rect(
1082110818 cpx,
1082210819 cpy,
@@ -10871,6 +10868,9 @@ fn decode_block_rect64(
1087110868 plane_q_delta(2, fctx).1,
1087210869 v_tx_type,
1087310870 );
10871+ if let Some((_, vb)) = &palette_uv_bufs {
10872+ set_palette_pred(vb.clone(), fctx);
10873+ }
1087410874 v.reconstruct_rect(
1087510875 cpx,
1087610876 cpy,
@@ -17971,11 +17971,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1797117971 }
1797217972 fctx.enable_edge_filter.with(|f| f.set(enable_edge_filter));
1797317973 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- }
1797917974 let (sb_cols, sb_rows) = (mi_cols.div_ceil(SB_MI), mi_rows.div_ceil(SB_MI));
1798017975 fctx.intrabc_mi_grid.with(|g| {
1798117976 *g.borrow_mut() = allow_intrabc.then(|| {
@@ -20327,8 +20322,13 @@ fn read_intrabc_dv(
2032720322 if pred == (0, 0) {
2032820323 // `av1_find_ref_dv` (mvref_common.c). Tile row start is 0 here (the
2032920324 // single-tile-row case every intrabc gate stream is).
20330- let sb_px = SB_MI as i32 * MI as i32;
20331- pred = if mi_r < SB_MI as usize {
20325+ // lane-t900 r34: `av1_find_ref_dv` takes `mib_size` -- the SEQUENCE's
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 {
2033220332 (0, -(sb_px + INTRABC_DELAY_PIXELS) * 8)
2033320333 } else {
2033420334 (-sb_px * 8, 0)
crates/ec-av1/src/refusal_inventory.rsmodified+0 -22
@@ -43,8 +43,6 @@ const REFUSALS: &[&str] = &[
4343 "a 128x128 superblock partition value outside the 8-symbol alphabet",
4444 "an inter var-tx tree with a leaf transform larger than 64x64",
4545 "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)",
4846 // lane-t900 r23: palette RECONSTRUCTION now covers the key-frame paths
4947 // (earlier lanes), the intra-in-inter square/rect paths (r22) and the
5048 // 8x8 LEAF inside an inter frame (this round, gate
@@ -372,26 +370,6 @@ const PROVEN: &[(&str, &str)] = &[
372370 "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)",
373371 "no_128_root_half_reads_a_cfl_filter_intra_or_palette_symbol",
374372 ),
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- ),
395373 // lane-t900 r33, CENSUS: the `use_intrabc` symbol IS read at the sub-8
396374 // reader for every sub-8x8 leaf of an `allow_intrabc` frame, and over the
397375 // `--min-partition-size=4` exact-repetition screen arms every such symbol
crates/ec-av1/src/stream.rsmodified+51 -113
@@ -4141,8 +4141,8 @@ mod tests {
41414141 (0usize, 0u32, 0u32, 0usize);
41424142 let (mut out_of_scope, mut out_of_scope_mismatch, mut refusals) = (0u32, 0u32, 0u32);
41434143 let (mut sb_strip_total, mut sb_strip_arms) = (0usize, 0u32);
4144- // The one palette shape this round did NOT lift (measured: lifting it
4145- // mismatches -- see [`decode_block_rect64`]'s own comment).
4144+ // lane-t900 r34 LIFTED this shape; the counter stays so the gate
4145+ // fails loudly if the refusal ever comes back.
41464146 let mut sb_strip_refusals = 0u32;
41474147 for src in ["testsrc2", "smptebars"] {
41484148 for depth in [8usize, 10usize] {
@@ -4322,10 +4322,14 @@ mod tests {
43224322 leaf8_total > 0 && fired_arms > 0,
43234323 "{NAME}: gate is vacuous -- no compared arm decoded an 8x8-leaf palette block"
43244324 );
4325+ assert_eq!(
4326+ sb_strip_refusals, 0,
4327+ "{NAME}: the superblock-strip palette refusal is back (lane-t900 r34 lifted it)"
4328+ );
43254329 assert!(
4326- sb_strip_refusals > 0,
4327- "{NAME}: no arm reached the superblock-strip palette refusal -- the open residue \
4328- this gate documents is no longer exercised"
4330+ sb_strip_arms > 0 && sb_strip_total > 0,
4331+ "{NAME}: no arm decoded a non-skip palette block on a superblock-level strip -- \
4332+ the shape r34 lifted is no longer exercised"
43294333 );
43304334 assert_eq!(
43314335 out_of_scope_mismatch, 0,
@@ -4694,31 +4698,32 @@ mod tests {
46944698 (sb128, intrabc)
46954699 }
46964700
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.
46984703 ///
4699- /// Unlike every other refusal in the inventory this one is decided in the
4700- /// FRAME HEADER, before a single block symbol: `use_128x128_superblock &&
4701- /// allow_intrabc`. So the census question is only whether a real encoder
4702- /// writes that conjunction -- if it does, the refusal is a capability gap
4703- /// (this decoder hardcodes the block-vector delay of `av1_is_dv_valid` to
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.
4704+ /// All four arms of r33's census -- `--sb-size=128 --tune-content=screen
4705+ /// --enable-intrabc=1` over both `--enable-tx-size-search` settings and
4706+ /// two quantisers, on a 2x2 tiling of a 128x96 bar pattern (256x192,
4707+ /// 8-bit, `--cpu-used=0 --min-partition-size=8 --max-partition-size=32`,
4708+ /// rect and 1:4 off) -- code `use_128x128_superblock && allow_intrabc`.
47064709 ///
4707- /// The four arms are the exact-repetition recipe that is the ONLY shape
4708- /// known to keep `allow_intrabc` past libaom's own RD (lane-t900 r31: on
4709- /// non-repeating content, `--enable-tx-size-search=1` makes RD drop
4710- /// intrabc and libaom clears the bit again), with `--sb-size=128` and both
4711- /// tx-size-search settings over two quantisers.
4710+ /// The lift was one constant: `av1_find_ref_dv` (mvref_common.c) takes
4711+ /// `mib_size`, the SEQUENCE's superblock size in mi units, so the
4712+ /// fallback DV is one 128-px superblock up (or 128 + `INTRABC_DELAY_PIXELS`
4713+ /// left on the tile's first superblock row) under a 128 superblock, where
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.
47124717 #[test]
4713- fn an_sb128_screen_census_measures_the_sb128_intrabc_refusal() {
4714- const NAME: &str = "an_sb128_screen_census_measures_the_sb128_intrabc_refusal";
4718+ fn an_sb128_screen_stream_with_intrabc_decodes_pixel_exact() {
4719+ const NAME: &str = "an_sb128_screen_stream_with_intrabc_decodes_pixel_exact";
47154720 if !have_ffmpeg() || !have_aomenc() {
47164721 eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
47174722 return;
47184723 }
47194724 let (width, height) = (256usize, 192usize);
4720- let (mut premise_arms, mut reached, mut decoded_arms, mut frames_compared) =
4721- (0u32, 0u32, 0u32, 0u32);
4725+ let _guard = lock_gate_counters();
4726+ let (mut blocks_total, mut frames_compared) = (0usize, 0u32);
47224727 for txs in ["0", "1"] {
47234728 for cq in ["30", "45"] {
47244729 let arm = format!("sb128 txs={txs} cq={cq}");
@@ -4731,104 +4736,37 @@ mod tests {
47314736 &["--sb-size=128"],
47324737 );
47334738 let (sb128, intrabc_frames) = sb128_and_intrabc_frames(&stream);
4734- assert!(sb128, "{NAME}: {arm}: aomenc ignored --sb-size=128");
4735- if intrabc_frames > 0 {
4736- premise_arms += 1;
4737- }
4738- match decode_stream(&stream) {
4739- Ok(frames) => {
4740- decoded_arms += 1;
4741- let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len());
4742- assert_eq!(frames.len(), theirs.len(), "{NAME}: {arm} frame count");
4743- for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {
4744- assert!(
4745- ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v,
4746- "{NAME}: {arm} frame {i} does not match ffmpeg"
4747- );
4748- frames_compared += 1;
4749- }
4750- eprintln!(
4751- "{NAME}: {arm} sb128={sb128} intrabc_frames={intrabc_frames} \
4752- DECODED {} frame(s) exact",
4753- frames.len()
4754- );
4755- }
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- }
4739+ assert!(
4740+ sb128 && intrabc_frames > 0,
4741+ "{NAME}: {arm} no longer codes sb128 + allow_intrabc"
4742+ );
4743+ crate::decode::reset_intrabc_hits();
4744+ let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: {arm}: {e}"));
4745+ let blocks = crate::decode::intrabc_hits();
4746+ blocks_total += blocks;
4747+ let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len());
4748+ assert_eq!(frames.len(), theirs.len(), "{NAME}: {arm} frame count");
4749+ for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {
4750+ assert!(
4751+ ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v,
4752+ "{NAME}: {arm} frame {i} does not match ffmpeg"
4753+ );
4754+ frames_compared += 1;
47674755 }
4756+ eprintln!(
4757+ "{NAME}: {arm} intrabc_frames={intrabc_frames} intrabc_blocks={blocks} \
4758+ DECODED {} frame(s) exact",
4759+ frames.len()
4760+ );
47684761 }
47694762 }
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- );
4763+ assert!(frames_compared > 0, "{NAME}: no frame was compared");
47754764 assert!(
4776- premise_arms + decoded_arms > 0,
4777- "{NAME}: census is vacuous -- no arm produced a decodable or premise-carrying stream"
4778- );
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"
4765+ blocks_total > 0,
4766+ "{NAME}: gate is vacuous -- no arm decoded a single intrabc block"
47834767 );
47844768 }
47854769
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- }
4831-
48324770 /// lane-t900 r33, CENSUS for "a sub-8x8 leaf that uses intrabc".
48334771 ///
48344772 /// The `use_intrabc` symbol IS read at that reader for every sub-8x8 leaf