forge
Explore
Log in

Don't you dare go Hollow

Witness the lifted 128-root screen-strip refusal with a real screen stream

Browse files at this commit

0b83527e82e23baf764c8358d53355de716b8da7Ahmet Kaan GümüşParent: bbe0850
  • test
    • witness the lifted 128-root screen-strip refusal with a real screen stream
Show full message
test(av1): witness the lifted 128-root screen-strip refusal with a real screen stream

r18's edge-forced 704x320 recipe re-encoded with `--tune-content=screen
--enable-palette=0 --enable-intrabc=0` DOES code 128-root HORZ/VERT halves
inside its inter frames -- r23's census missed them because it never tried
this source. Six encodes: cq 20/35/50 fire 15x 128x64 plus 8/10/6x 64x128
and decode all 15 frames byte-exact on every plane, and each one's
`--enable-rect-partitions=0` twin codes zero 128-root halves, which is what
says the shape is the coded HORZ/VERT arm.

cq20 is pinned as `fixtures/intra128_in_inter_screen_witness.obu` (119048
bytes, sha256 c84a493f...). The gate reads `allow_screen_content_tools` out
of the frame headers rather than trusting the encoder flag, so it cannot go
vacuous against the condition the deleted refusal named.
crates/ec-av1/fixtures/intra128_in_inter_screen_witness.obuadded+0 -0

Binary file changed

crates/ec-av1/src/stream.rsmodified+87 -0
@@ -32194,6 +32194,93 @@ mod tests {
32194 );32194 );
32195 }32195 }
32196 32196
32197+ /// lane-t900 r32 GATE for the LIFTED refusal "a HORZ/VERT intra strip in
32198+ /// a screen-content frame (palette syntax is consumed for square blocks
32199+ /// only)": the r18 edge-forced recipe re-encoded with
32200+ /// `--tune-content=screen`, i.e. the exact case that refusal guarded.
32201+ ///
32202+ /// `crates/ec-av1/fixtures/intra128_in_inter_screen_witness.obu`, 119048
32203+ /// bytes, sha256
32204+ /// `c84a493f90327f5d2bea038a42e87cbfe56762b5c6a856d76b4bff9797c5ea09`,
32205+ /// from this repository's aomenc oracle over r18's own 10-bit 704x320
32206+ /// source (`gen3.py`): the r18 flag set plus `--tune-content=screen
32207+ /// --enable-palette=0 --enable-intrabc=0 --cq-level=20`. Three cq levels
32208+ /// were swept (20/35/50); all three fire, and the `--enable-rect-\
32209+ /// partitions=0` twin of each codes ZERO 128-root halves, which is what
32210+ /// says the shape here is the coded HORZ/VERT arm and not an artefact.
32211+ ///
32212+ /// The lift's proof is r31's enumeration
32213+ /// (`no_block_footprint_with_a_128_pixel_side_can_carry_palette_syntax`):
32214+ /// `av1_allow_palette`'s `bw > 64 || bh > 64` bound means a 128x64/64x128
32215+ /// half codes no palette syntax at all, so the screen flag changes nothing
32216+ /// about its syntax. This is the WITNESS that the lifted arm is reachable
32217+ /// and decodes, which r23's census could not produce.
32218+ #[test]
32219+ fn an_intra_coded_128_half_in_a_screen_content_inter_frame_decodes_pixel_exact() {
32220+ const NAME: &str =
32221+ "an_intra_coded_128_half_in_a_screen_content_inter_frame_decodes_pixel_exact";
32222+ if !have_ffmpeg() {
32223+ eprintln!("SKIP {NAME}: no ffmpeg");
32224+ return;
32225+ }
32226+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
32227+ .join("fixtures/intra128_in_inter_screen_witness.obu");
32228+ let stream = std::fs::read(&path)
32229+ .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
32230+ let (width, height) = (704usize, 320usize);
32231+ // The refusal named `allow_screen_content_tools`, so the gate reads
32232+ // that bit out of the frame headers rather than trusting the encoder
32233+ // flag (class `gate-blind-to-feature`).
32234+ let mut screen_frames = 0u32;
32235+ {
32236+ let mut p = Av1Parser::new();
32237+ let mut pos = 0usize;
32238+ while pos < stream.len() {
32239+ let obu = p.parse_obu(&stream[pos..]).expect("parse");
32240+ pos += obu.total_size;
32241+ let header = match &obu.kind {
32242+ ObuKind::Frame(h, _) => Some(&**h),
32243+ ObuKind::FrameHeader(h) => Some(&**h),
32244+ _ => None,
32245+ };
32246+ if header.is_some_and(|h| h.allow_screen_content_tools) {
32247+ screen_frames += 1;
32248+ }
32249+ }
32250+ }
32251+ assert!(
32252+ screen_frames > 0,
32253+ "{NAME}: no frame sets allow_screen_content_tools -- the gate no longer \
32254+ exercises the lifted refusal's own condition"
32255+ );
32256+ let before = intra128_in_inter_counters();
32257+ let frames = match decode_stream(&stream) {
32258+ Ok(frames) => frames,
32259+ Err(e) => panic!("{NAME}: decode_stream refused: {e}"),
32260+ };
32261+ let after = intra128_in_inter_counters();
32262+ let fired = [after[0] - before[0], after[1] - before[1]];
32263+ assert!(
32264+ fired[0] > 0 && fired[1] > 0,
32265+ "{NAME}: intra-128-in-inter fired {fired:?} (128x64, 64x128) -- both arms \
32266+ must fire or the lift is unwitnessed at the one that did not"
32267+ );
32268+ assert_eq!(frames.len(), 15, "{NAME}: 15 shown frames");
32269+ assert_eq!((frames[0].width, frames[0].height), (width, height));
32270+ let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len());
32271+ assert_eq!(ffmpeg_frames.len(), frames.len(), "{NAME}: frame count vs ffmpeg");
32272+ for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
32273+ assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg");
32274+ assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg");
32275+ assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg");
32276+ }
32277+ eprintln!(
32278+ "{NAME}: {screen_frames} screen-content frame(s), 15 shown frames pixel-exact \
32279+ on every plane; intra128_in_inter 128x64={} 64x128={}",
32280+ fired[0], fired[1]
32281+ );
32282+ }
32283+
32197 /// lane-t900 r22 GATE: a real `aomenc --tune-content=screen32284 /// lane-t900 r22 GATE: a real `aomenc --tune-content=screen
32198 /// --enable-palette=1` stream whose INTER frames reconstruct palette32285 /// --enable-palette=1` stream whose INTER frames reconstruct palette
32199 /// blocks (Y and UV), at both bit depths.32286 /// blocks (Y and UV), at both bit depths.