forge
Explore
Log in

Don't you dare go Hollow

Intrabc under a 128x128 superblock decodes by default

Browse files at this commit

c4ca926071234899805fddda95e31fcd5a61ca04Ahmet Kaan GümüşParent: e5de66d
  • feat
    • intrabc under a 128x128 superblock decodes by default
Show full message
feat(av1): intrabc under a 128x128 superblock decodes by default

`av1_find_ref_dv` (mvref_common.c) takes `mib_size` -- the sequence's
superblock size in mi units -- so under `use_128x128_superblock` the
fallback block vector is one 128-px superblock up, or 128 +
INTRABC_DELAY_PIXELS to the left on the tile's first superblock row.
`read_intrabc_dv` hardcoded the 64-px superblock, which is why the
frame-header refusal "intrabc under a 128x128 superblock" existed.

Reading it off `sb_mi_cur` lifts the refusal: all four arms of r33's
census (`--sb-size=128 --tune-content=screen --enable-intrabc=1`, both
`--enable-tx-size-search` settings, cq 30/45, 2x2-tiled 128x96 bars at
256x192) now decode pixel-exact against ffmpeg, so the r33 census is
replaced by the un-ignored witness it pinned, which additionally
asserts a non-zero decoded-intrabc-block count so a stream that stopped
using intrabc cannot make it vacuous. Inventory row deleted.
crates/ec-av1/src/decode.rsmodified+7 -7
@@ -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 -11
@@ -43,7 +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)",46 "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 paths47 // lane-t900 r23: palette RECONSTRUCTION now covers the key-frame paths
49 // (earlier lanes), the intra-in-inter square/rect paths (r22) and the48 // (earlier lanes), the intra-in-inter square/rect paths (r22) and the
@@ -382,16 +381,6 @@ const PROVEN: &[(&str, &str)] = &[
382 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",381 "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",382 "a_real_aomenc_palette_stream_with_8x8_leaves_decodes_pixel_exact",
384 ),383 ),
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-8384 // 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 the385 // 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 symbol386 // `--min-partition-size=4` exact-repetition screen arms every such symbol
crates/ec-av1/src/stream.rsmodified+42 -108
@@ -4694,31 +4694,32 @@ mod tests {
4694 (sb128, intrabc)4694 (sb128, intrabc)
4695 }4695 }
4696 4696
4697- /// lane-t900 r33, CENSUS for "intrabc under a 128x128 superblock".4697+ /// lane-t900 r34, the WITNESS (r33 pinned it ignored) that intrabc under
4698+ /// a 128x128 superblock decodes pixel-exact.
4698 ///4699 ///
4699- /// Unlike every other refusal in the inventory this one is decided in the4700+ /// All four arms of r33's census -- `--sb-size=128 --tune-content=screen
4700- /// FRAME HEADER, before a single block symbol: `use_128x128_superblock &&4701+ /// --enable-intrabc=1` over both `--enable-tx-size-search` settings and
4701- /// allow_intrabc`. So the census question is only whether a real encoder4702+ /// two quantisers, on a 2x2 tiling of a 128x96 bar pattern (256x192,
4702- /// writes that conjunction -- if it does, the refusal is a capability gap4703+ /// 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` to4704+ /// 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 ///4705 ///
4707- /// The four arms are the exact-repetition recipe that is the ONLY shape4706+ /// 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: on4707+ /// `mib_size`, the SEQUENCE's superblock size in mi units, so the
4709- /// non-repeating content, `--enable-tx-size-search=1` makes RD drop4708+ /// 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 both4709+ /// left on the tile's first superblock row) under a 128 superblock, where
4711- /// tx-size-search settings over two quantisers.4710+ /// [`crate::decode::read_intrabc_dv`] hardcoded 64. Every arm is compared
4711+ /// to ffmpeg and the decoded-intrabc-block counter is asserted non-zero,
4712+ /// so a stream that stopped using intrabc could not make this vacuous.
4712 #[test]4713 #[test]
4713- fn an_sb128_screen_census_measures_the_sb128_intrabc_refusal() {4714+ fn an_sb128_screen_stream_with_intrabc_decodes_pixel_exact() {
4714- const NAME: &str = "an_sb128_screen_census_measures_the_sb128_intrabc_refusal";4715+ const NAME: &str = "an_sb128_screen_stream_with_intrabc_decodes_pixel_exact";
4715 if !have_ffmpeg() || !have_aomenc() {4716 if !have_ffmpeg() || !have_aomenc() {
4716 eprintln!("SKIP {NAME}: no ffmpeg/aomenc");4717 eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
4717 return;4718 return;
4718 }4719 }
4719 let (width, height) = (256usize, 192usize);4720 let (width, height) = (256usize, 192usize);
4720- let (mut premise_arms, mut reached, mut decoded_arms, mut frames_compared) =4721+ let _guard = lock_gate_counters();
4721- (0u32, 0u32, 0u32, 0u32);4722+ let (mut blocks_total, mut frames_compared) = (0usize, 0u32);
4722 for txs in ["0", "1"] {4723 for txs in ["0", "1"] {
4723 for cq in ["30", "45"] {4724 for cq in ["30", "45"] {
4724 let arm = format!("sb128 txs={txs} cq={cq}");4725 let arm = format!("sb128 txs={txs} cq={cq}");
@@ -4731,102 +4732,35 @@ mod tests {
4731 &["--sb-size=128"],4732 &["--sb-size=128"],
4732 );4733 );
4733 let (sb128, intrabc_frames) = sb128_and_intrabc_frames(&stream);4734 let (sb128, intrabc_frames) = sb128_and_intrabc_frames(&stream);
4734- assert!(sb128, "{NAME}: {arm}: aomenc ignored --sb-size=128");4735+ assert!(
4735- if intrabc_frames > 0 {4736+ sb128 && intrabc_frames > 0,
4736- premise_arms += 1;4737+ "{NAME}: {arm} no longer codes sb128 + allow_intrabc"
4737- }4738+ );
4738- match decode_stream(&stream) {4739+ crate::decode::reset_intrabc_hits();
4739- Ok(frames) => {4740+ let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: {arm}: {e}"));
4740- decoded_arms += 1;4741+ let blocks = crate::decode::intrabc_hits();
4741- let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len());4742+ blocks_total += blocks;
4742- assert_eq!(frames.len(), theirs.len(), "{NAME}: {arm} frame count");4743+ let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len());
4743- for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {4744+ assert_eq!(frames.len(), theirs.len(), "{NAME}: {arm} frame count");
4744- assert!(4745+ for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {
4745- ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v,4746+ assert!(
4746- "{NAME}: {arm} frame {i} does not match ffmpeg"4747+ ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v,
4747- );4748+ "{NAME}: {arm} frame {i} does not match ffmpeg"
4748- frames_compared += 1;4749+ );
4749- }4750+ frames_compared += 1;
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- }
4767 }4751 }
4752+ eprintln!(
4753+ "{NAME}: {arm} intrabc_frames={intrabc_frames} intrabc_blocks={blocks} \
4754+ DECODED {} frame(s) exact",
4755+ frames.len()
4756+ );
4768 }4757 }
4769 }4758 }
4770- eprintln!(4759+ assert!(frames_compared > 0, "{NAME}: no frame was compared");
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!(4760 assert!(
4776- premise_arms + decoded_arms > 0,4761+ blocks_total > 0,
4777- "{NAME}: census is vacuous -- no arm produced a decodable or premise-carrying stream"4762+ "{NAME}: gate is vacuous -- no arm decoded a single intrabc block"
4778 );4763 );
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 }4764 }
4831 4765
4832 /// lane-t900 r33, CENSUS for "a sub-8x8 leaf that uses intrabc".4766 /// lane-t900 r33, CENSUS for "a sub-8x8 leaf that uses intrabc".