forge
Explore
Log in

Don't you dare go Hollow

Census the last three unproven refusals

Browse files at this commit

da8c1a6e8e9c590ab947a4d55128531cc44ae5f2Ahmet Kaan GümüşParent: 2937d25
  • test
    • census the last three unproven refusals
    • pin the sb128-intrabc gap
Show full message
test(av1): census the last three unproven refusals; pin the sb128-intrabc gap

The three intrabc refusals are the inventory's residue, and all three are now
measured against real aomenc streams rather than asserted:

* sb128 + intrabc is REACHED -- all four `--sb-size=128` exact-repetition
  screen arms code `use_128x128_superblock && allow_intrabc` and every one of
  them refuses by name. A capability gap, pinned with its first-bad recipe and
  a waiting (ignored) pixel-exact witness;
* a sub-8x8 leaf's `use_intrabc` symbol is read 38 times over two
  `--min-partition-size=4` arms and comes back 0 every time, frames exact;
* the intrabc var-tx tree is read for 5 blocks over four quantisers, every one
  resolving to a uniform leaf size, frames exact.

refusal inventory: 35 refusals / 32 proven -> 35 refusals / 35 proven.
crates/ec-av1/src/refusal_inventory.rsmodified+25 -0
@@ -382,6 +382,31 @@ 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)",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",383 "a_real_aomenc_palette_stream_with_8x8_leaves_decodes_pixel_exact",
384 ),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-8
396+ // 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 symbol
398+ // came back 0 while the frames decode pixel-exact.
399+ (
400+ "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)",
401+ "a_sub8_leaf_census_over_intrabc_screen_streams_measures_the_sub8_refusal",
402+ ),
403+ // lane-t900 r33, CENSUS: four quantisers of the recipe that reaches the
404+ // intrabc var-tx tree at all read it for 5 blocks in total, every one of
405+ // which resolved to a UNIFORM leaf size, with the frames pixel-exact.
406+ (
407+ "an intrabc block whose var-tx tree resolved to mixed leaf transform sizes",
408+ "an_intrabc_vartx_census_measures_the_mixed_leaf_refusal",
409+ ),
385 (410 (
386 "a reference picture whose height does not match this frame's own true size",411 "a reference picture whose height does not match this frame's own true size",
387 "an_inter_frame_shorter_than_its_reference_is_refused_by_name",412 "an_inter_frame_shorter_than_its_reference_is_refused_by_name",
crates/ec-av1/src/stream.rsmodified+334 -0
@@ -4224,6 +4224,20 @@ mod tests {
4224 /// and 1:4 partitions off so an intrabc block lands on a SQUARE block4224 /// and 1:4 partitions off so an intrabc block lands on a SQUARE block
4225 /// instead of stopping on the rect-strip intrabc refusal first.4225 /// instead of stopping on the rect-strip intrabc refusal first.
4226 fn screen_intrabc_stream(src: &str, cq: &str, txs: &str, tiled: bool, square_only: bool) -> Vec<u8> {4226 fn screen_intrabc_stream(src: &str, cq: &str, txs: &str, tiled: bool, square_only: bool) -> Vec<u8> {
4227+ screen_intrabc_stream_with(src, cq, txs, tiled, square_only, &[])
4228+ }
4229+
4230+ /// [`screen_intrabc_stream`] with per-arm flags appended AFTER the base
4231+ /// recipe -- aomenc keeps the LAST occurrence of a repeated flag, so an
4232+ /// arm can override `--sb-size` / `--min-partition-size` here.
4233+ fn screen_intrabc_stream_with(
4234+ src: &str,
4235+ cq: &str,
4236+ txs: &str,
4237+ tiled: bool,
4238+ square_only: bool,
4239+ extra: &[&str],
4240+ ) -> Vec<u8> {
4227 let mut ff = Command::new("ffmpeg");4241 let mut ff = Command::new("ffmpeg");
4228 ff.args(["-v", "error", "-f", "lavfi", "-i", src, "-t", "0.2"]);4242 ff.args(["-v", "error", "-f", "lavfi", "-i", src, "-t", "0.2"]);
4229 if tiled {4243 if tiled {
@@ -4265,6 +4279,7 @@ mod tests {
4265 } else {4279 } else {
4266 &[][..]4280 &[][..]
4267 })4281 })
4282+ .args(extra)
4268 .args(["--obu", "-o", "-", "-"])4283 .args(["--obu", "-o", "-", "-"])
4269 .stdin(Stdio::piped())4284 .stdin(Stdio::piped())
4270 .stdout(Stdio::piped())4285 .stdout(Stdio::piped())
@@ -4290,6 +4305,325 @@ mod tests {
4290 enc.stdout4305 enc.stdout
4291 }4306 }
4292 4307
4308+ /// The sequence header's `use_128x128_superblock`, and how many frames of
4309+ /// `stream` keep `allow_intrabc` -- the two bits the refusal "intrabc
4310+ /// under a 128x128 superblock" is the conjunction of, read out of the
4311+ /// headers rather than assumed from the flags handed to the encoder.
4312+ fn sb128_and_intrabc_frames(stream: &[u8]) -> (bool, u32) {
4313+ let mut parser = Av1Parser::new();
4314+ let mut pos = 0usize;
4315+ let (mut sb128, mut intrabc) = (false, 0u32);
4316+ while pos < stream.len() {
4317+ let Ok(obu) = parser.parse_obu(&stream[pos..]) else {
4318+ break;
4319+ };
4320+ pos += obu.total_size.max(1);
4321+ if let Some(seq) = parser.sequence_header() {
4322+ sb128 = seq.use_128x128_superblock;
4323+ }
4324+ let header = match &obu.kind {
4325+ ObuKind::Frame(h, _) => Some(&**h),
4326+ ObuKind::FrameHeader(h) => Some(&**h),
4327+ _ => None,
4328+ };
4329+ if header.is_some_and(|h| h.allow_intrabc) {
4330+ intrabc += 1;
4331+ }
4332+ }
4333+ (sb128, intrabc)
4334+ }
4335+
4336+ /// lane-t900 r33, CENSUS for "intrabc under a 128x128 superblock".
4337+ ///
4338+ /// Unlike every other refusal in the inventory this one is decided in the
4339+ /// FRAME HEADER, before a single block symbol: `use_128x128_superblock &&
4340+ /// allow_intrabc`. So the census question is only whether a real encoder
4341+ /// writes that conjunction -- if it does, the refusal is a capability gap
4342+ /// (this decoder hardcodes the block-vector delay of `av1_is_dv_valid` to
4343+ /// a 64-px superblock) and the arm that reaches it is pinned here; if no
4344+ /// arm does, the string is measured against the domain instead of assumed.
4345+ ///
4346+ /// The four arms are the exact-repetition recipe that is the ONLY shape
4347+ /// known to keep `allow_intrabc` past libaom's own RD (lane-t900 r31: on
4348+ /// non-repeating content, `--enable-tx-size-search=1` makes RD drop
4349+ /// intrabc and libaom clears the bit again), with `--sb-size=128` and both
4350+ /// tx-size-search settings over two quantisers.
4351+ #[test]
4352+ fn an_sb128_screen_census_measures_the_sb128_intrabc_refusal() {
4353+ const NAME: &str = "an_sb128_screen_census_measures_the_sb128_intrabc_refusal";
4354+ if !have_ffmpeg() || !have_aomenc() {
4355+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
4356+ return;
4357+ }
4358+ let (width, height) = (256usize, 192usize);
4359+ let (mut premise_arms, mut reached, mut decoded_arms, mut frames_compared) =
4360+ (0u32, 0u32, 0u32, 0u32);
4361+ for txs in ["0", "1"] {
4362+ for cq in ["30", "45"] {
4363+ let arm = format!("sb128 txs={txs} cq={cq}");
4364+ let stream = screen_intrabc_stream_with(
4365+ "smptebars=size=128x96:rate=25",
4366+ cq,
4367+ txs,
4368+ true,
4369+ true,
4370+ &["--sb-size=128"],
4371+ );
4372+ let (sb128, intrabc_frames) = sb128_and_intrabc_frames(&stream);
4373+ assert!(sb128, "{NAME}: {arm}: aomenc ignored --sb-size=128");
4374+ if intrabc_frames > 0 {
4375+ premise_arms += 1;
4376+ }
4377+ match decode_stream(&stream) {
4378+ Ok(frames) => {
4379+ decoded_arms += 1;
4380+ let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len());
4381+ assert_eq!(frames.len(), theirs.len(), "{NAME}: {arm} frame count");
4382+ for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {
4383+ assert!(
4384+ ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v,
4385+ "{NAME}: {arm} frame {i} does not match ffmpeg"
4386+ );
4387+ frames_compared += 1;
4388+ }
4389+ eprintln!(
4390+ "{NAME}: {arm} sb128={sb128} intrabc_frames={intrabc_frames} \
4391+ DECODED {} frame(s) exact",
4392+ frames.len()
4393+ );
4394+ }
4395+ Err(e) => {
4396+ let msg = e.to_string();
4397+ assert!(msg.contains("unsupported"), "{NAME}: {arm} decode failed: {e}");
4398+ if msg.contains("intrabc under a 128x128 superblock") {
4399+ reached += 1;
4400+ }
4401+ eprintln!(
4402+ "{NAME}: {arm} sb128={sb128} intrabc_frames={intrabc_frames} \
4403+ REFUSED: {e}"
4404+ );
4405+ }
4406+ }
4407+ }
4408+ }
4409+ eprintln!(
4410+ "{NAME}: {premise_arms}/4 arm(s) code allow_intrabc under a 128x128 superblock, \
4411+ {reached} reach the refusal, {decoded_arms} arm(s) decoded \
4412+ ({frames_compared} frames exact)"
4413+ );
4414+ assert!(
4415+ premise_arms + decoded_arms > 0,
4416+ "{NAME}: census is vacuous -- no arm produced a decodable or premise-carrying stream"
4417+ );
4418+ assert_eq!(
4419+ reached, premise_arms,
4420+ "{NAME}: the refusal is the CONJUNCTION of the two header bits, so every arm \
4421+ carrying it must reach the refusal and no other arm may"
4422+ );
4423+ }
4424+
4425+ /// lane-t900 r33, the WAITING witness for the capability gap
4426+ /// [`an_sb128_screen_census_measures_the_sb128_intrabc_refusal`] pins:
4427+ /// FIRST BAD is `--sb-size=128 --tune-content=screen --enable-intrabc=1
4428+ /// --enable-tx-size-search=0 --cq-level=30` on a 2x2 tiling of a 128x96
4429+ /// bar pattern (256x192, 8-bit, `--cpu-used=0 --min-partition-size=8
4430+ /// --max-partition-size=32 --enable-rect-partitions=0
4431+ /// --enable-1to4-partitions=0`) -- all four arms of the census code
4432+ /// `use_128x128_superblock && allow_intrabc`, so the refusal names a
4433+ /// configuration real aomenc writes at its FIRST attempt, not a corner.
4434+ ///
4435+ /// Lifting it is a `decode.rs` change this lane is not allowed to make:
4436+ /// `av1_is_dv_valid` derives the block-vector delay (`sb_size` wide
4437+ /// `INTRABC_DELAY_PIXELS`, the wavefront the valid-DV region is offset
4438+ /// by) from the SUPERBLOCK SIZE, which this decoder hardcodes to 64, so
4439+ /// every DV bound and every intrabc source fetch under a 128 superblock
4440+ /// is computed against the wrong wavefront. Ignored until that lands.
4441+ #[test]
4442+ #[ignore = "capability gap: intrabc's block-vector delay is hardcoded to a 64-px superblock"]
4443+ fn an_sb128_screen_stream_with_intrabc_decodes_pixel_exact() {
4444+ const NAME: &str = "an_sb128_screen_stream_with_intrabc_decodes_pixel_exact";
4445+ if !have_ffmpeg() || !have_aomenc() {
4446+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
4447+ return;
4448+ }
4449+ let (width, height) = (256usize, 192usize);
4450+ let stream = screen_intrabc_stream_with(
4451+ "smptebars=size=128x96:rate=25",
4452+ "30",
4453+ "0",
4454+ true,
4455+ true,
4456+ &["--sb-size=128"],
4457+ );
4458+ let (sb128, intrabc_frames) = sb128_and_intrabc_frames(&stream);
4459+ assert!(sb128 && intrabc_frames > 0, "{NAME}: the first-bad recipe no longer codes it");
4460+ let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: {e}"));
4461+ let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len());
4462+ assert_eq!(frames.len(), theirs.len(), "{NAME}: frame count");
4463+ for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {
4464+ assert!(
4465+ ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v,
4466+ "{NAME}: frame {i} does not match ffmpeg"
4467+ );
4468+ }
4469+ }
4470+
4471+ /// lane-t900 r33, CENSUS for "a sub-8x8 leaf that uses intrabc".
4472+ ///
4473+ /// The `use_intrabc` symbol IS read at that reader for every sub-8x8 leaf
4474+ /// of an `allow_intrabc` frame, so arrival is provable rather than
4475+ /// assumed: the arms below force 4x4 leaves (`--min-partition-size=4`) on
4476+ /// the exact-repetition screen content that keeps `allow_intrabc`, and the
4477+ /// gate requires both counters -- `allow_intrabc` frames and decoded sub-8
4478+ /// leaves -- to be non-zero before it reads anything into the refusal
4479+ /// firing 0 times (class `gate-blind-to-feature`).
4480+ #[test]
4481+ fn a_sub8_leaf_census_over_intrabc_screen_streams_measures_the_sub8_refusal() {
4482+ const NAME: &str = "a_sub8_leaf_census_over_intrabc_screen_streams_measures_the_sub8_refusal";
4483+ if !have_ffmpeg() || !have_aomenc() {
4484+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
4485+ return;
4486+ }
4487+ let (width, height) = (256usize, 192usize);
4488+ let _guard = lock_gate_counters();
4489+ let (mut premise_arms, mut reached, mut sub8_total, mut frames_compared) =
4490+ (0u32, 0u32, 0usize, 0u32);
4491+ for cq in ["30", "45"] {
4492+ let arm = format!("sub8 cq={cq}");
4493+ let stream = screen_intrabc_stream_with(
4494+ "smptebars=size=128x96:rate=25",
4495+ cq,
4496+ "0",
4497+ true,
4498+ true,
4499+ &["--min-partition-size=4"],
4500+ );
4501+ let (_, intrabc_frames) = sb128_and_intrabc_frames(&stream);
4502+ if intrabc_frames > 0 {
4503+ premise_arms += 1;
4504+ }
4505+ // No reset for this counter, so measure the delta (the gate lock
4506+ // above keeps another gate's decode out of it).
4507+ let sub8_before = crate::decode::sub8_split_hits();
4508+ match decode_stream(&stream) {
4509+ Ok(frames) => {
4510+ let sub8 = crate::decode::sub8_split_hits() - sub8_before;
4511+ sub8_total += sub8;
4512+ let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len());
4513+ assert_eq!(frames.len(), theirs.len(), "{NAME}: {arm} frame count");
4514+ for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {
4515+ assert!(
4516+ ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v,
4517+ "{NAME}: {arm} frame {i} does not match ffmpeg"
4518+ );
4519+ frames_compared += 1;
4520+ }
4521+ eprintln!(
4522+ "{NAME}: {arm} intrabc_frames={intrabc_frames} sub8_leaves={sub8} \
4523+ DECODED {} frame(s) exact",
4524+ frames.len()
4525+ );
4526+ }
4527+ Err(e) => {
4528+ let msg = e.to_string();
4529+ assert!(msg.contains("unsupported"), "{NAME}: {arm} decode failed: {e}");
4530+ if msg.contains("a sub-8x8 leaf that uses intrabc") {
4531+ reached += 1;
4532+ }
4533+ sub8_total += crate::decode::sub8_split_hits() - sub8_before;
4534+ eprintln!(
4535+ "{NAME}: {arm} intrabc_frames={intrabc_frames} REFUSED: {e}"
4536+ );
4537+ }
4538+ }
4539+ }
4540+ eprintln!(
4541+ "{NAME}: {premise_arms}/2 arm(s) keep allow_intrabc, {sub8_total} sub-8 leaf/leaves \
4542+ decoded, {reached} reach the refusal, {frames_compared} frame(s) exact"
4543+ );
4544+ assert!(
4545+ premise_arms > 0,
4546+ "{NAME}: census is vacuous -- no arm kept allow_intrabc, so the refusal's own \
4547+ premise was never within reach"
4548+ );
4549+ assert!(
4550+ sub8_total > 0,
4551+ "{NAME}: census is vacuous -- no sub-8 leaf was decoded at all, so the \
4552+ `use_intrabc` symbol this refusal guards was never read"
4553+ );
4554+ }
4555+
4556+ /// lane-t900 r33, CENSUS for "an intrabc block whose var-tx tree resolved
4557+ /// to mixed leaf transform sizes" -- the residue lane-t900 r32 left when
4558+ /// it lifted the intrabc `TX_MODE_SELECT` refusal.
4559+ ///
4560+ /// The tree is read in full, but the luma reconstruct loop it feeds is a
4561+ /// UNIFORM grid of one square transform, so a tree that split unevenly
4562+ /// would be reconstructed at the wrong stride. This census sweeps the
4563+ /// quantiser across the exact-repetition recipe that reaches the tree at
4564+ /// all and requires the tree to actually be read (`intrabc_vartx_hits`)
4565+ /// before reading anything into the refusal firing 0 times.
4566+ #[test]
4567+ fn an_intrabc_vartx_census_measures_the_mixed_leaf_refusal() {
4568+ const NAME: &str = "an_intrabc_vartx_census_measures_the_mixed_leaf_refusal";
4569+ if !have_ffmpeg() || !have_aomenc() {
4570+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
4571+ return;
4572+ }
4573+ let (width, height) = (256usize, 192usize);
4574+ let _guard = lock_gate_counters();
4575+ let (mut vartx_total, mut reached, mut frames_compared) = (0usize, 0u32, 0u32);
4576+ for cq in ["20", "30", "45", "55"] {
4577+ let arm = format!("vartx cq={cq}");
4578+ let stream =
4579+ screen_intrabc_stream("smptebars=size=128x96:rate=25", cq, "1", true, true);
4580+ let (select, premise) = tx_select_and_intrabc_frames(&stream);
4581+ crate::decode::reset_intrabc_vartx_hits();
4582+ match decode_stream(&stream) {
4583+ Ok(frames) => {
4584+ let vartx = crate::decode::intrabc_vartx_hits();
4585+ vartx_total += vartx;
4586+ let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len());
4587+ assert_eq!(frames.len(), theirs.len(), "{NAME}: {arm} frame count");
4588+ for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {
4589+ assert!(
4590+ ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v,
4591+ "{NAME}: {arm} frame {i} does not match ffmpeg"
4592+ );
4593+ frames_compared += 1;
4594+ }
4595+ eprintln!(
4596+ "{NAME}: {arm} select={select} premise={premise} vartx_blocks={vartx} \
4597+ DECODED {} frame(s) exact",
4598+ frames.len()
4599+ );
4600+ }
4601+ Err(e) => {
4602+ let msg = e.to_string();
4603+ assert!(msg.contains("unsupported"), "{NAME}: {arm} decode failed: {e}");
4604+ vartx_total += crate::decode::intrabc_vartx_hits();
4605+ if msg.contains("mixed leaf transform sizes") {
4606+ reached += 1;
4607+ }
4608+ eprintln!("{NAME}: {arm} select={select} premise={premise} REFUSED: {e}");
4609+ }
4610+ }
4611+ }
4612+ eprintln!(
4613+ "{NAME}: {vartx_total} intrabc block(s) read the var-tx tree, {reached} resolved to \
4614+ mixed leaves, {frames_compared} frame(s) exact"
4615+ );
4616+ assert!(
4617+ vartx_total > 0,
4618+ "{NAME}: census is vacuous -- no intrabc block read the var-tx tree at all"
4619+ );
4620+ assert_eq!(
4621+ reached, 0,
4622+ "{NAME}: an intrabc var-tx tree resolved to mixed leaves -- the refusal is a live \
4623+ capability gap and needs a pinned witness, not this census"
4624+ );
4625+ }
4626+
4293 /// How many frames of `stream` carry `tx_mode == Select`, and how many of4627 /// How many frames of `stream` carry `tx_mode == Select`, and how many of
4294 /// those also keep `allow_intrabc` -- the frame-level premise of the4628 /// those also keep `allow_intrabc` -- the frame-level premise of the
4295 /// refusal "an intrabc block under TxMode::Select", read out of the4629 /// refusal "an intrabc block under TxMode::Select", read out of the