forge
Explore
Log in

Don't you dare go Hollow

lane-av1screen12: lift the 12-bit screen-content refusal; three 12-bit palette/intrabc witnesses

Browse files at this commit

eeb5937cdbf00bd87919e5268c45fa8fe7c94d40Ahmet Kaan GümüşParent: f7f488f
The guard read `bit_depth == 12 && header.allow_screen_content_tools` and its
string claimed "neither palette nor intrabc has a 12-bit witness". Both halves
were wrong: the bit only opens the palette-mode and `use_intrabc` SYMBOLS, and
both reconstructions are already depth-parameterised (`read_palette_colors_y` /
`_uv` read at `bit_depth(fctx)`, the colour-index map writes u16 samples).

Measured, guard lifted, each arm byte-exact against the instrumented aomdec
--rawvideo AND ffmpeg, 0 wrong samples, with a +1 control on the oracle's own
frame-0 luma high byte (exactly +1 wrong luma byte, one fewer exact frame):

  arm                  pin                          frames  palette/uv/intrabc
  palette              screen12_palette.obu         2       76 / 43 / 0
  palette + intrabc    screen12_intrabc.obu         1       36 / 34 / 11
  lossless + palette   screen12_lossless_palette.obu 2       80 / 59 / 0

The "12-bit intrabc has no producer" note was a RECIPE artefact:
--tune-content=screen does not decide that frame-header bit in this oracle
build (libaom's content detector does, encoder.c:2404). An untiled
smptebars=size=128x96 source reads allow_intrabc=0 with and without the flag;
the 256x192 -vf tile=2x2 source the repo's own intrabc census uses reads =1 at
8, 10 and 12 bits.

Mutation proof: truncating read_palette_colors_y's first colour to 8 bits
(bit-preserving) reds the palette gate with 119726 differing bytes, first at
byte 1.

Inventory: both copies of the string (REFUSALS row and its PROVEN pair) are
gone -- 33 refusals + 33 proven -> 32 + 32. refus: 56 passed; gate_coverage:
20 passed, 282 gates, NEVER_EXERCISED_8BIT 0 of 26, NEVER_EXERCISED_10BIT
0 of 26.
crates/ec-av1/fixtures/screen12_intrabc.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/screen12_lossless_palette.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/screen12_palette.obuadded+0 -0

Binary file changed

crates/ec-av1/src/refusal_inventory.rsmodified+24 -5
@@ -110,7 +110,30 @@ const REFUSALS: &[&str] = &[
110 // compound-warp witness110 // compound-warp witness
111 // (`a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`, 28111 // (`a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`, 28
112 // compound warp blocks) are byte-exact vs ffmpeg.112 // compound warp blocks) are byte-exact vs ffmpeg.
113- "a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)",113+ // lane-av1screen12: screen content tools LEFT the 12-bit refusal set. The
114+ // string was "a 12-bit frame with screen content tools
115+ // (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit
116+ // witness)" -- a guard BROADER than the gap it named, because
117+ // `allow_screen_content_tools` only opens the `palette_y_mode` /
118+ // `palette_uv_mode` symbols and the leaf `use_intrabc` symbol, and both
119+ // reconstructions are already depth-parameterised
120+ // (`read_palette_colors_y` / `_uv` read at `bit_depth(fctx)`, the
121+ // colour-index map writes u16 samples). Three 12-bit arms decode
122+ // BYTE-EXACT against the instrumented `aomdec --rawvideo` and against
123+ // ffmpeg, each with a +1 control on the oracle's own bytes:
124+ // `a_real_aomenc_12bit_screen_content_palette_stream_decodes_pixel_exact`
125+ // (pin `screen12_palette.obu`, 2 frames, 76 palette / 43 palette-UV),
126+ // `a_real_aomenc_12bit_intrabc_screen_stream_decodes_pixel_exact` (pin
127+ // `screen12_intrabc.obu`, 1 frame, `allow_intrabc = 1`, 36 palette /
128+ // 34 palette-UV / 11 intrabc blocks) and
129+ // `a_real_aomenc_12bit_lossless_screen_content_stream_decodes_pixel_exact`
130+ // (pin `screen12_lossless_palette.obu`, 2 frames, 80 palette /
131+ // 59 palette-UV, `CodedLossless` AND screen content in the same frame).
132+ // The companion "12-bit intrabc has no producer" note was a RECIPE
133+ // artefact: libaom sets that frame-header bit from its content detector
134+ // (`encoder.c:2404`), so an untiled `smptebars=size=128x96` source gives
135+ // `allow_intrabc = 0` with AND without `--tune-content=screen`, while the
136+ // 256x192 `-vf tile=2x2` source gives `= 1` at 8, 10 and 12 bits.
114 // lane-av1txr: the silent-garbage guard. A 4:4:4/4:2:2 stream used to137 // lane-av1txr: the silent-garbage guard. A 4:4:4/4:2:2 stream used to
115 // decode with no refusal and wrong pixels (every chroma extent is138 // decode with no refusal and wrong pixels (every chroma extent is
116 // hardcoded 4:2:0, the probe emits 4:2:0 planes only); it is now refused139 // hardcoded 4:2:0, the probe emits 4:2:0 planes only); it is now refused
@@ -438,10 +461,6 @@ const PROVEN: &[(&str, &str)] = &[
438 // that refused pre-lift) and the compound-warp arm witnesses through461 // that refused pre-lift) and the compound-warp arm witnesses through
439 // `a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`462 // `a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`
440 // (hard `compound_warp_hits > 0`).463 // (hard `compound_warp_hits > 0`).
441- (
442- "a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)",
443- "a_12bit_screen_content_stream_is_refused_by_name",
444- ),
445 // lane-av1txr: the guard's own gate builds a profile-1 and a profile-2464 // lane-av1txr: the guard's own gate builds a profile-1 and a profile-2
446 // sequence header by hand and asserts each refuses by name while the465 // sequence header by hand and asserts each refuses by name while the
447 // profile-0 CONTROL still decodes -- the refusal is exercised, not merely466 // profile-0 CONTROL still decodes -- the refusal is exercised, not merely
crates/ec-av1/src/stream.rsmodified+390 -50
@@ -1831,20 +1831,39 @@ fn decode_frame(
1831 [flat; 3]1831 [flat; 3]
1832 };1832 };
1833 crate::decode::set_qm_levels(levels, fctx);1833 crate::decode::set_qm_levels(levels, fctx);
1834- // lane-av112bit: the frame-level half of the 12-bit gate -- screen1834+ // lane-av112bit's screen-content refusal is LIFTED by lane-av1screen12.
1835- // content tools. Neither palette nor intrabc has a 12-bit witness (the1835+ // The claim it carried -- "a 12-bit frame with screen content tools
1836- // 12-bit gates are natural content), and both hang off this header bit:1836+ // (allow_screen_content_tools=1: neither palette nor intrabc has a
1837- // `allow_screen_content_tools` is what lets a block code a palette or1837+ // 12-bit witness)" -- named a gap WIDER than the one it was written for:
1838- // read a `use_intrabc` symbol. Refusing the FRAME by name keeps every1838+ // `allow_screen_content_tools` only decides whether an intra block reads
1839- // palette/intrabc code path 12-bit-unreachable rather than unwitnessed1839+ // the `palette_y_mode`/`palette_uv_mode` symbols and whether a leaf reads
1840- // and trusted. Gate:1840+ // `use_intrabc`, and BOTH of those reconstructions read their colours and
1841- // `a_12bit_screen_content_stream_is_refused_by_name`.1841+ // their frame copy at the frame's own `bit_depth` (`read_palette_colors_y`
1842- if bit_depth == 12 && header.allow_screen_content_tools {1842+ // / `_uv` take `bit_depth(fctx)`, the colour-index map writes u16 samples).
1843- return Err(Error::unsupported(1843+ // Nothing about them is 8/10-bit-shaped.
1844- "AV1 decode_stream",1844+ //
1845- "a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)",1845+ // Measured, with this guard lifted, all three arms decode BYTE-EXACT
1846- ));1846+ // against the instrumented `aomdec --rawvideo` AND against ffmpeg, each
1847- }1847+ // with a +1 control on the oracle's own bytes:
1848+ //
1849+ // | arm | pin | frames | screen | allow_intrabc | palette / palette-UV / intrabc |
1850+ // | --- | --- | --- | --- | --- | --- |
1851+ // | palette | `screen12_palette.obu` | 2 | 2 | 0 | 76 / 43 / 0 |
1852+ // | palette+intrabc | `screen12_intrabc.obu` | 1 | 1 | 1 | 36 / 34 / 11 |
1853+ // | lossless+palette | `screen12_lossless_palette.obu` | 2 | 2 | 0 | 80 / 59 / 0 |
1854+ //
1855+ // Gates: `a_real_aomenc_12bit_screen_content_palette_stream_decodes_pixel_exact`,
1856+ // `a_real_aomenc_12bit_intrabc_screen_stream_decodes_pixel_exact`,
1857+ // `a_real_aomenc_12bit_lossless_screen_content_stream_decodes_pixel_exact`.
1858+ //
1859+ // ON THE OLD "INTRABC IS UNPRODUCIBLE" NOTE: the earlier claim that
1860+ // 12-bit `allow_intrabc` has no producer was a RECIPE artefact, not an
1861+ // encoder limit. libaom decides that frame-header bit from its own
1862+ // content detector (`encoder.c:2404`), not from `--tune-content=screen`:
1863+ // an untiled `smptebars=size=128x96` source reads `allow_intrabc = 0`
1864+ // with AND without the flag, while the 256x192 `-vf tile=2x2` source the
1865+ // 8/10-bit intrabc census already uses reads `allow_intrabc = 1` with
1866+ // and without it -- at 8, at 10 AND at 12 bits (measured).
1848 // lane-dpm1: a LOSSLESS frame (`qindex == 0` with zero deltas, spec 5.9.12)1867 // lane-dpm1: a LOSSLESS frame (`qindex == 0` with zero deltas, spec 5.9.12)
1849 // is a different tile syntax, and this decoder has none of it: libaom1868 // is a different tile syntax, and this decoder has none of it: libaom
1850 // forces TX_4X4 with the WALSH-HADAMARD transform over every block (so no1869 // forces TX_4X4 with the WALSH-HADAMARD transform over every block (so no
@@ -13587,9 +13606,28 @@ exit 0
13587 depth: usize,13606 depth: usize,
13588 extra: &[&str],13607 extra: &[&str],
13589 ) -> Vec<u8> {13608 ) -> Vec<u8> {
13590- assert!(depth == 8 || depth == 10, "unsupported bit depth {depth}");13609+ // lane-av1screen12: depth 12 joins 8 and 10. The SAME recipe (`-vf
13610+ // tile=2x2` over `smptebars=size=128x96:rate=25`,
13611+ // `--tune-content=screen --enable-intrabc=1`, cq30,
13612+ // `--enable-tx-size-search=0`) that keeps `allow_intrabc` at 8 and 10
13613+ // bits keeps it at 12 bits too -- measured, and pinned by
13614+ // `a_real_aomenc_12bit_intrabc_screen_stream_decodes_pixel_exact`.
13615+ // That is why "neither palette nor intrabc has a 12-bit witness" was
13616+ // false: the intrabc half WAS producible, `--tune-content=screen`
13617+ // alone just is not what decides the frame-header bit (libaom's
13618+ // content detector is).
13619+ assert!(
13620+ depth == 8 || depth == 10 || depth == 12,
13621+ "unsupported bit depth {depth}"
13622+ );
13623+ // `if depth == 10` is SPELLED, not matched, because
13624+ // `gate_coverage::covers_both_depths` recognises this two-depth
13625+ // helper by that literal (the lane-defon/reelckf blind spot with
13626+ // `depth` spelled instead of `bit_depth`).
13591 let pix_fmt = if depth == 10 {13627 let pix_fmt = if depth == 10 {
13592 "yuv420p10le"13628 "yuv420p10le"
13629+ } else if depth == 12 {
13630+ "yuv420p12le"
13593 } else {13631 } else {
13594 "yuv420p"13632 "yuv420p"
13595 };13633 };
@@ -15595,36 +15633,229 @@ exit 0
15595 );15633 );
15596 }15634 }
15597 15635
15598- /// The 12-bit screen-content refusal: a real `--tune-content=screen15636+ /// lane-av1screen12: how many frames of `stream` carry
15599- /// --enable-palette=1 --enable-intrabc=1` frame carries15637+ /// `allow_screen_content_tools`, and how many of THOSE carry
15600- /// `allow_screen_content_tools = 1` and is refused by name at the frame15638+ /// `allow_intrabc`. Both are read out of the frame headers this crate
15601- /// gate -- palette and intrabc have no 12-bit witness.15639+ /// parsed, never taken from the flags handed to the encoder (class
15602- #[test]15640+ /// `tool-disabled-in-every-gate`): on this oracle build
15603- fn a_12bit_screen_content_stream_is_refused_by_name() {15641+ /// `--tune-content=screen` does NOT by itself decide the frame-header
15604- const NAME: &str = "a_12bit_screen_content_stream_is_refused_by_name";15642+ /// `allow_intrabc` bit -- an untiled `smptebars=size=128x96` source reads
15605- let _gate_lock = lock_gate_counters();15643+ /// `false` with and without the flag, while the 256x192 `tile=2x2` source
15606- if !have_ffmpeg() {15644+ /// the intrabc census uses reads `true` with and without it (measured;
15607- eprintln!("SKIP {NAME}: no ffmpeg");15645+ /// libaom's content detector, `encoder.c:2404`, is what decides it).
15608- return;15646+ fn screen_and_intrabc_frame_counts(stream: &[u8]) -> (u32, u32) {
15647+ let mut parser = Av1Parser::new();
15648+ let mut pos = 0usize;
15649+ let (mut screen, mut intrabc) = (0u32, 0u32);
15650+ while pos < stream.len() {
15651+ let Ok(obu) = parser.parse_obu(&stream[pos..]) else {
15652+ break;
15653+ };
15654+ pos += obu.total_size.max(1);
15655+ let header = match &obu.kind {
15656+ ObuKind::Frame(h, _) => Some(&**h),
15657+ ObuKind::FrameHeader(h) => Some(&**h),
15658+ _ => None,
15659+ };
15660+ if let Some(h) = header
15661+ && h.allow_screen_content_tools
15662+ {
15663+ screen += 1;
15664+ if h.allow_intrabc {
15665+ intrabc += 1;
15609 }15666 }
15610- if !have_aomenc() {
15611- eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
15612- return;
15613 }15667 }
15614- let y4m = Command::new("ffmpeg")15668+ }
15669+ (screen, intrabc)
15670+ }
15671+
15672+ /// The three committed 12-bit screen-content witnesses, by literal name
15673+ /// (a pin name built from a loop variable leaves the pin census
15674+ /// unproven), with the length and `fnv1a64` each gate asserts. sha256,
15675+ /// recorded in the gates' doc comments and in
15676+ /// `lanes/av1screen12.report.md`:
15677+ ///
15678+ /// * `screen12_palette.obu` 3616 bytes,
15679+ /// `adfe26c67c08a7e986db2743b914ecc3e214c56dd2abbdfd17ebf99f06de64c8`
15680+ /// * `screen12_intrabc.obu` 482 bytes,
15681+ /// `a3b6b94cabdd09a12057c4688990d55495826b87a14332c386d319629070382e`
15682+ /// * `screen12_lossless_palette.obu` 11698 bytes,
15683+ /// `ec7942c96763593e6d8e4b3fb23c03930bba3bb743102d0cf552fe73ae11c203`
15684+ const PIN_LEN_PALETTE: usize = 3616;
15685+ const PIN_FNV_PALETTE: u64 = 0xf9bb_d408_61d6_f0da;
15686+ const PIN_LEN_INTRABC: usize = 482;
15687+ const PIN_FNV_INTRABC: u64 = 0xae83_3eb7_9380_263b;
15688+ const PIN_LEN_LOSSLESS: usize = 11698;
15689+ const PIN_FNV_LOSSLESS: u64 = 0x6e28_41c7_7b0a_f9db;
15690+
15691+ /// lane-av1screen12: the shared body of the three 12-bit screen-content
15692+ /// gates. Every assertion a "this arm really is 12-bit screen content,
15693+ /// and this decoder reproduces it" claim needs, in one place:
15694+ ///
15695+ /// 1. the committed PIN is the witness -- its length and fnv1a64 are
15696+ /// pinned, and `require_pin` HARD-fails on a missing copy rather than
15697+ /// testing nothing;
15698+ /// 2. the live recipe reproduces that pin byte for byte (aomenc present),
15699+ /// so the recipe in the doc comment is not decoration;
15700+ /// 3. the stream's OWN sequence header says 12-bit and its frame headers
15701+ /// say `allow_screen_content_tools` (and `allow_intrabc` for the arm
15702+ /// that wants it);
15703+ /// 4. the decode ENGAGED the feature -- `palette_hits()` /
15704+ /// `palette_uv_hits()` / `intrabc_hits()` deltas are hard-asserted,
15705+ /// because a stream that merely carries the header bit would leave the
15706+ /// arm it claims to witness untested (class `gate-blind-to-feature`);
15707+ /// 5. every sample of every frame matches the instrumented `aomdec
15708+ /// --rawvideo` (`assert_rawvideo_matches`), and independently ffmpeg;
15709+ /// 6. THE CONTROL: the same counting comparator, run twice -- clean it
15710+ /// must report zero wrong samples in all three planes, and with ONE
15711+ /// bit flipped in the ORACLE's own frame-0 luma high byte it must
15712+ /// report exactly one wrong luma byte and one fewer exact frame. That
15713+ /// is the proof the comparator READS the oracle side: a comparator
15714+ /// that compared our samples with themselves would report 0 both
15715+ /// times (class `oracle-diff-counter-tautology`).
15716+ ///
15717+ /// Flip index 1 is the high byte of the first luma sample of frame 0.
15718+ /// A 12-bit sample's high byte holds bits 8..15 only, so flipping its low
15719+ /// bit can never carry into another byte: the move is exactly +1 wrong
15720+ /// byte in the Y plane, which is what makes "+1 in the right plane and
15721+ /// frame" a real statement rather than a hope.
15722+ #[allow(clippy::too_many_arguments)]
15723+ fn assert_12bit_screen_content_arm(
15724+ name: &str,
15725+ pin: &'static str,
15726+ live: Vec<u8>,
15727+ pin_len: usize,
15728+ pin_fnv: u64,
15729+ frames: usize,
15730+ width: usize,
15731+ height: usize,
15732+ want_intrabc: bool,
15733+ ) {
15734+ let path = crate_pin(pin);
15735+ let stream = require_pin(&path, pin);
15736+ assert_eq!(
15737+ stream.len(),
15738+ pin_len,
15739+ "{name}: the committed pin {pin} is {} bytes, this gate names {pin_len}",
15740+ stream.len()
15741+ );
15742+ assert_eq!(fnv1a64(&stream), pin_fnv, "{name}: the committed pin {pin} moved");
15743+ if have_aomenc() {
15744+ assert_eq!(
15745+ live.len(),
15746+ pin_len,
15747+ "{name}: the live recipe produced {} bytes, the committed pin {pin} is \
15748+ {pin_len} -- aomenc changed, re-pin it",
15749+ live.len()
15750+ );
15751+ assert_eq!(
15752+ fnv1a64(&live),
15753+ pin_fnv,
15754+ "{name}: the live recipe no longer reproduces the committed pin {pin}"
15755+ );
15756+ }
15757+ assert_12bit_sequence_header(&stream, name);
15758+ let (screen_frames, intrabc_frames) = screen_and_intrabc_frame_counts(&stream);
15759+ assert!(
15760+ screen_frames > 0,
15761+ "{name}: no frame carries allow_screen_content_tools -- this is not a \
15762+ screen-content stream and the arm would prove nothing"
15763+ );
15764+ assert_eq!(
15765+ intrabc_frames > 0,
15766+ want_intrabc,
15767+ "{name}: {intrabc_frames} frame(s) carry allow_intrabc, the gate wants {}",
15768+ u32::from(want_intrabc)
15769+ );
15770+
15771+ let pal_before = crate::decode::palette_hits();
15772+ let paluv_before = crate::decode::palette_uv_hits();
15773+ let ibc_before = crate::decode::intrabc_hits();
15774+ let decoded = decode_stream(&stream).unwrap_or_else(|e| panic!("{name}: {e}"));
15775+ assert_eq!(decoded.len(), frames, "{name}: frame count");
15776+ let palette = crate::decode::palette_hits() - pal_before;
15777+ let palette_uv = crate::decode::palette_uv_hits() - paluv_before;
15778+ let intrabc = crate::decode::intrabc_hits() - ibc_before;
15779+ assert!(
15780+ palette > 0,
15781+ "{name}: the stream decoded no palette block -- the 12-bit palette syntax \
15782+ would be untested (class gate-blind-to-feature)"
15783+ );
15784+ assert!(
15785+ palette_uv > 0,
15786+ "{name}: the stream decoded no chroma palette block -- the 12-bit palette-UV \
15787+ syntax would be untested (class gate-blind-to-feature)"
15788+ );
15789+ if want_intrabc {
15790+ assert!(
15791+ intrabc > 0,
15792+ "{name}: allow_intrabc is set but no block decoded use_intrabc=1 -- the \
15793+ 12-bit intra-block-copy syntax would be untested (class \
15794+ gate-blind-to-feature)"
15795+ );
15796+ }
15797+
15798+ if aomdec_available(name) {
15799+ let dir = std::env::temp_dir().join(format!("ec-av1-{name}-arm"));
15800+ let _ = std::fs::remove_dir_all(&dir);
15801+ std::fs::create_dir_all(&dir).expect("scratch dir");
15802+ let obu = dir.join("in.obu");
15803+ std::fs::write(&obu, &stream).expect("writing the stream");
15804+ assert_rawvideo_matches(&obu, &stream, name, frames, 12);
15805+ let _ = std::fs::remove_dir_all(&dir);
15806+ // The +1 control (part 6): clean is all-zero, one flipped oracle
15807+ // byte is exactly +1 luma byte and one fewer exact frame.
15808+ let clean = count_rawvideo_diffs(&stream, name, None)
15809+ .unwrap_or_else(|| panic!("{name}: our packed output and the oracle's rawvideo differ in SIZE"));
15810+ assert_eq!(
15811+ clean,
15812+ (0, 0, 0, frames, frames),
15813+ "{name}: {frames} frame(s) must be byte-exact against the oracle before the \
15814+ control arm means anything"
15815+ );
15816+ let flipped = count_rawvideo_diffs(&stream, name, Some(1))
15817+ .unwrap_or_else(|| panic!("{name}: the control arm lost the size check"));
15818+ assert_eq!(
15819+ flipped,
15820+ (1, 0, 0, frames, frames - 1),
15821+ "{name}: flipping bit 0 of the ORACLE's frame-0 luma high byte must move the \
15822+ count by exactly +1 luma byte and cost exactly one exact frame -- if this \
15823+ reports 0 the comparator never read the oracle (class \
15824+ oracle-diff-counter-tautology)"
15825+ );
15826+ }
15827+ if have_ffmpeg() {
15828+ let theirs = ffmpeg_decode_sequence_12bit(&stream, width, height, frames);
15829+ assert_eq!(theirs.len(), frames, "{name}: ffmpeg frame count");
15830+ for (i, (ours, want)) in decoded.iter().zip(&theirs).enumerate() {
15831+ assert_eq!(ours.y, want.y, "{name}: 12-bit luma vs ffmpeg (frame {i})");
15832+ assert_eq!(ours.u, want.u, "{name}: 12-bit U vs ffmpeg (frame {i})");
15833+ assert_eq!(ours.v, want.v, "{name}: 12-bit V vs ffmpeg (frame {i})");
15834+ }
15835+ }
15836+ eprintln!(
15837+ "{name}: {frames} 12-bit frame(s) byte-exact vs aomdec --rawvideo and ffmpeg, \
15838+ {screen_frames} screen frame(s), {intrabc_frames} allow_intrabc, {palette} palette \
15839+ + {palette_uv} palette-UV + {intrabc} intrabc block(s)"
15840+ );
15841+ }
15842+
15843+ /// Renders a 12-bit y4m for the 12-bit screen-content gates. `tiled`
15844+ /// applies `-vf tile=2x2`, which is what takes the source from 128x96 to
15845+ /// the 256x192 shape libaom's content detector clears the (stricter)
15846+ /// IntraBC threshold on.
15847+ fn y4m_12bit_screen_source(src: &str, tiled: bool) -> Vec<u8> {
15848+ let mut ff = Command::new("ffmpeg");
15849+ ff.args(["-v", "error", "-f", "lavfi", "-i", src, "-t", "0.2"]);
15850+ if tiled {
15851+ ff.args(["-vf", "tile=2x2"]);
15852+ }
15853+ let out = ff
15615 .args([15854 .args([
15616- "-v",
15617- "error",
15618- "-f",
15619- "lavfi",
15620- "-i",
15621- "smptebars=s=128x128:r=25",
15622 "-pix_fmt",15855 "-pix_fmt",
15623 "yuv420p12le",15856 "yuv420p12le",
15624 "-strict",15857 "-strict",
15625 "-1",15858 "-1",
15626- "-frames:v",
15627- "2",
15628 "-f",15859 "-f",
15629 "yuv4mpegpipe",15860 "yuv4mpegpipe",
15630 "-",15861 "-",
@@ -15635,25 +15866,134 @@ exit 0
15635 .output()15866 .output()
15636 .expect("ffmpeg failed to run");15867 .expect("ffmpeg failed to run");
15637 assert!(15868 assert!(
15638- y4m.status.success(),15869+ out.status.success(),
15639- "ffmpeg failed to render the 12-bit screen fixture: {}",15870+ "ffmpeg failed for the 12-bit screen source {src}: {}",
15640- String::from_utf8_lossy(&y4m.stderr)15871+ String::from_utf8_lossy(&out.stderr)
15641 );15872 );
15642- let stream = encode_12bit(15873+ out.stdout
15643- &y4m.stdout,15874+ }
15644- 1,15875+
15876+ /// lane-av1screen12: a 12-bit PALETTE screen-content stream, palette on
15877+ /// and palette-UV on, `allow_intrabc` off.
15878+ ///
15879+ /// Recipe: `ffmpeg -f lavfi -i testsrc2=s=160x128:r=25 -pix_fmt
15880+ /// yuv420p12le -strict -1` (2 frames, 160x128 4:2:0) piped to
15881+ /// [`encode_12bit`] with `--tune-content=screen --enable-palette=1
15882+ /// `--enable-intrabc=1`; pin `screen12_palette.obu` (3616 bytes, sha256
15883+ /// `adfe26c67c08a7e986db2743b914ecc3e214c56dd2abbdfd17ebf99f06de64c8`).
15884+ ///
15885+ /// What it replaces: this is the arm the blanket refusal "a 12-bit frame
15886+ /// with screen content tools" blocked while decoding exactly.
15887+ #[test]
15888+ fn a_real_aomenc_12bit_screen_content_palette_stream_decodes_pixel_exact() {
15889+ const NAME: &str =
15890+ "a_real_aomenc_12bit_screen_content_palette_stream_decodes_pixel_exact";
15891+ const PIN: &str = "screen12_palette.obu";
15892+ let _gate_lock = lock_gate_counters();
15893+ if !have_ffmpeg() {
15894+ eprintln!("SKIP {NAME}: no ffmpeg");
15895+ return;
15896+ }
15897+ let y4m = y4m_12bit_screen_source("testsrc2=s=160x128:r=25", false);
15898+ let live = if have_aomenc() {
15899+ encode_12bit(
15900+ &y4m,
15901+ 2,
15645 &[15902 &[
15646 "--tune-content=screen",15903 "--tune-content=screen",
15647 "--enable-palette=1",15904 "--enable-palette=1",
15648 "--enable-intrabc=1",15905 "--enable-intrabc=1",
15649 ],15906 ],
15907+ )
15908+ } else {
15909+ Vec::new()
15910+ };
15911+ assert_12bit_screen_content_arm(
15912+ NAME, PIN, live, PIN_LEN_PALETTE, PIN_FNV_PALETTE, 2, 160, 128, false,
15650 );15913 );
15651- let err = decode_stream(&stream).unwrap_err().to_string();15914+ }
15652- assert!(15915+
15653- err.contains(15916+ /// lane-av1screen12: a 12-bit screen-content stream whose KEY frame sets
15654- "a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)"15917+ /// `allow_intrabc = 1` and really codes `use_intrabc` blocks.
15655- ),15918+ ///
15656- "{NAME}: expected the 12-bit screen content refusal, got: {err}"15919+ /// Recipe: [`screen_intrabc_stream_at_depth`] at depth 12 -- the same
15920+ /// shape the 8/10-bit intrabc census and the sb128 intrabc witness use:
15921+ /// `-vf tile=2x2` over `smptebars=size=128x96:rate=25` (256x192),
15922+ /// `--tune-content=screen --enable-intrabc=1 --enable-palette=1
15923+ /// --cq-level=30 --enable-tx-size-search=0 --min-partition-size=8
15924+ /// --max-partition-size=32 --sb-size=64 --kf-max-dist=1 --limit=1`, so
15925+ /// ONE 12-bit key frame; pin `screen12_intrabc.obu` (482 bytes, sha256
15926+ /// `a3b6b94cabdd09a12057c4688990d55495826b87a14332c386d319629070382e`).
15927+ ///
15928+ /// This arm is the one the old refusal's "nor intrabc" half named, and it
15929+ /// is why the refusal could be LIFTED rather than narrowed: it decodes
15930+ /// byte-exact at 12 bits and `intrabc_hits()` proves the blocks really
15931+ /// reconstructed from the current frame.
15932+ #[test]
15933+ fn a_real_aomenc_12bit_intrabc_screen_stream_decodes_pixel_exact() {
15934+ const NAME: &str = "a_real_aomenc_12bit_intrabc_screen_stream_decodes_pixel_exact";
15935+ const PIN: &str = "screen12_intrabc.obu";
15936+ let _gate_lock = lock_gate_counters();
15937+ if !have_ffmpeg() {
15938+ eprintln!("SKIP {NAME}: no ffmpeg");
15939+ return;
15940+ }
15941+ let live = if have_aomenc() {
15942+ // `--enable-palette=1` LAST (aomenc keeps the last occurrence), so
15943+ // this 12-bit arm carries BOTH screen-content syntaxes rather than
15944+ // intra-block copy alone.
15945+ screen_intrabc_stream_at_depth(
15946+ "smptebars=size=128x96:rate=25",
15947+ "30",
15948+ "0",
15949+ true,
15950+ false,
15951+ 12,
15952+ &["--enable-palette=1"],
15953+ )
15954+ } else {
15955+ Vec::new()
15956+ };
15957+ assert_12bit_screen_content_arm(
15958+ NAME, PIN, live, PIN_LEN_INTRABC, PIN_FNV_INTRABC, 1, 256, 192, true,
15959+ );
15960+ }
15961+
15962+ /// lane-av1screen12: a 12-bit LOSSLESS screen-content stream with
15963+ /// palette and palette-UV on.
15964+ ///
15965+ /// Recipe: the palette arm's source and flags plus `--lossless=1`, so the
15966+ /// frame is `CodedLossless` (base_q_idx 0, WHT on every plane) AND
15967+ /// screen-content -- two 12-bit tile-syntax interactions in one frame;
15968+ /// pin `screen12_lossless_palette.obu` (11698 bytes, sha256
15969+ /// `ec7942c96763593e6d8e4b3fb23c03930bba3bb743102d0cf552fe73ae11c203`).
15970+ #[test]
15971+ fn a_real_aomenc_12bit_lossless_screen_content_stream_decodes_pixel_exact() {
15972+ const NAME: &str =
15973+ "a_real_aomenc_12bit_lossless_screen_content_stream_decodes_pixel_exact";
15974+ const PIN: &str = "screen12_lossless_palette.obu";
15975+ let _gate_lock = lock_gate_counters();
15976+ if !have_ffmpeg() {
15977+ eprintln!("SKIP {NAME}: no ffmpeg");
15978+ return;
15979+ }
15980+ let y4m = y4m_12bit_screen_source("testsrc2=s=160x128:r=25", false);
15981+ let live = if have_aomenc() {
15982+ encode_12bit(
15983+ &y4m,
15984+ 2,
15985+ &[
15986+ "--tune-content=screen",
15987+ "--enable-palette=1",
15988+ "--enable-intrabc=1",
15989+ "--lossless=1",
15990+ ],
15991+ )
15992+ } else {
15993+ Vec::new()
15994+ };
15995+ assert_12bit_screen_content_arm(
15996+ NAME, PIN, live, PIN_LEN_LOSSLESS, PIN_FNV_LOSSLESS, 2, 160, 128, false,
15657 );15997 );
15658 }15998 }
15659 15999
lanes/av1screen12.report.mdadded+166 -0
@@ -0,0 +1,166 @@
1+# lane-av1screen12 -- the 12-bit `allow_screen_content_tools` refusal is BROADER than the gap it names
2+
3+Base `2d8851c0`, branch `lane-av1screen12`.
4+
5+## 1. The claim under test
6+
7+`crates/ec-av1/src/stream.rs` (frame gate, was `:1842`) refused any frame with
8+`bit_depth == 12 && header.allow_screen_content_tools`, by the string
9+
10+```
11+a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)
12+```
13+
14+`allow_screen_content_tools` is a single header bit that opens two things: the
15+`palette_y_mode`/`palette_uv_mode` symbols on an intra block, and the leaf
16+`use_intrabc` symbol. The string conflated "the frame sets the bit" with "a
17+block actually used a palette or intrabc", and asserted an encoder-side
18+production gap ("neither ... has a 12-bit witness") that this lane re-measured.
19+
20+## 2. Reproduction on base (live)
21+
22+Six live `aomenc --bit-depth=12` encodes, `testsrc2=s=160x128:r=25` and
23+`smptebars=s=160x128:r=25` x {screen-only, palette+intrabc, lossless+palette},
24+recipe `--profile=2 --passes=1 --end-usage=q --cq-level=20 --cpu-used=0
25+--threads=1 --row-mt=0 --sb-size=64 --lag-in-frames=0 --auto-alt-ref=0
26+--kf-max-dist=1000 --input-bit-depth=12 --bit-depth=12 --enable-cdef=1
27+--enable-restoration=1 --obu` plus `--tune-content=screen --enable-palette=1
28+--enable-intrabc=1` (+ `--lossless=1`).
29+
30+BEFORE: all 6 refused, by that string.
31+
32+Frame headers read back through this crate's own parser:
33+
34+| stream | frames | `allow_screen_content_tools` | `allow_intrabc` |
35+| --- | --- | --- | --- |
36+| all six 12-bit arms | 2 | true | **false** |
37+
38+8-BIT control with the same recipe: `allow_intrabc` also false.
39+
40+## 3. What is actually unproducible -- and what is not
41+
42+The "no producer" half was a RECIPE artefact, not an encoder limit.
43+`--tune-content=screen` does NOT decide that frame-header bit in this oracle
44+build; libaom's content detector does (`av1/encoder/encoder.c:2404`). Measured,
45+same source, with and without the flag:
46+
47+| source (8-bit) | `allow_screen_content_tools` | `allow_intrabc` |
48+| --- | --- | --- |
49+| `smptebars=size=128x96` | true | **false** |
50+| `smptebars=size=128x96` + `-vf tile=2x2` (256x192) | true | **true** |
51+
52+and the tiled shape gives `allow_intrabc = 1` at 8, 10 AND 12 bits -- it is
53+exactly the source the repo's own intrabc census
54+(`a_sub8_leaf_census_over_intrabc_screen_streams_measures_the_sub8_refusal`)
55+already uses. So the 12-bit intrabc half was always producible; only the
56+"simple recipe" hunt missed it.
57+
58+## 4. After the lift, per arm
59+
60+Guard removed (patch-run-restore: `if false && bit_depth == 12 && ...` during
61+measurement, deleted for the commit). Three arms, all measured against the
62+INSTRUMENTED `aomdec --rawvideo` **and** ffmpeg, 0 wrong samples:
63+
64+| arm | pin | frames | screen frames | `allow_intrabc` frames | palette / palette-UV / intrabc blocks | wrong vs aomdec | wrong vs ffmpeg |
65+| --- | --- | --- | --- | --- | --- | --- | --- |
66+| palette | `screen12_palette.obu` | 2 | 2 | 0 | 76 / 43 / 0 | 0 | 0 |
67+| palette + intrabc | `screen12_intrabc.obu` | 1 | 1 | 1 | 36 / 34 / 11 | 0 | 0 |
68+| lossless + palette | `screen12_lossless_palette.obu` | 2 | 2 | 0 | 80 / 59 / 0 | 0 | 0 |
69+
70+### Pins (sha256)
71+
72+| pin | bytes | sha256 |
73+| --- | --- | --- |
74+| `crates/ec-av1/fixtures/screen12_palette.obu` | 3616 | `adfe26c67c08a7e986db2743b914ecc3e214c56dd2abbdfd17ebf99f06de64c8` |
75+| `crates/ec-av1/fixtures/screen12_intrabc.obu` | 482 | `a3b6b94cabdd09a12057c4688990d55495826b87a14332c386d319629070382e` |
76+| `crates/ec-av1/fixtures/screen12_lossless_palette.obu` | 11698 | `ec7942c96763593e6d8e4b3fb23c03930bba3bb743102d0cf552fe73ae11c203` |
77+
78+### Recipes
79+
80+* **palette** -- `ffmpeg -f lavfi -i testsrc2=s=160x128:r=25 -t 0.2 -pix_fmt
81+ yuv420p12le -strict -1 -f yuv4mpegpipe -` piped to `encode_12bit` with
82+ `--tune-content=screen --enable-palette=1 --enable-intrabc=1`, `--limit=2`.
83+* **palette + intrabc** -- `screen_intrabc_stream_at_depth("smptebars=size=128x96:rate=25", "30", "0", tiled, square_only=false, 12, ["--enable-palette=1"])`
84+ (`-vf tile=2x2` -> 256x192, `--tune-content=screen --enable-intrabc=1
85+ --enable-palette=0` + `--enable-palette=1` last, `--cq-level=30
86+ --enable-tx-size-search=0 --min-partition-size=8 --max-partition-size=32
87+ --sb-size=64 --kf-max-dist=1 --limit=1`): ONE 12-bit key frame.
88+* **lossless + palette** -- the palette recipe plus `--lossless=1`, so the frame
89+ is `CodedLossless` (WHT on every plane) AND screen-content.
90+
91+Each gate re-runs its live recipe and asserts it reproduces the pin byte for
92+byte (length + `fnv1a64`), so the recipe above is not decoration.
93+
94+## 5. The control (every claim carries one)
95+
96+Each gate runs `count_rawvideo_diffs` twice on the SAME stream:
97+
98+* clean: `(wrong_y, wrong_u, wrong_v, frames, exact) == (0, 0, 0, F, F)`;
99+* one bit flipped in the ORACLE's own frame-0 luma HIGH byte (index 1):
100+ `(1, 0, 0, F, F-1)` -- **exactly +1 wrong luma byte and exactly one fewer
101+ exact frame**. Index 1 is chosen because a 12-bit sample's high byte holds
102+ bits 8..15 only, so flipping its low bit can never carry: "+1 in the right
103+ plane and frame" is exact by construction, not hoped for.
104+
105+A comparator that compared our samples with themselves would report 0 in both
106+arms (class `oracle-diff-counter-tautology`).
107+
108+## 6. Mutation proof (gate bites)
109+
110+`read_palette_colors_y` (`decode.rs`), one line:
111+
112+```rust
113+- let first = dec.literal(bd) as u16;
114++ let first = (dec.literal(bd) as u16) & 0x00ff; // 12-bit colours truncated to 8
115+```
116+
117+Bit-preserving (the same number of bits is read, so no desync -- only palette
118+pixels are wrong). Result:
119+`a_real_aomenc_12bit_screen_content_palette_stream_decodes_pixel_exact` RED --
120+`119726 bytes of decoded output differ from aomdec (first at 1)`. Reverted; the
121+gate is green again.
122+
123+## 7. Inventory and census
124+
125+Both copies of the string in `crates/ec-av1/src/refusal_inventory.rs` were
126+removed -- the `REFUSALS` row and its `PROVEN` `(string, gate)` pair -- and
127+replaced by a comment recording the lift, the three witnesses and the
128+encoder-side measurement.
129+
130+```
131+refusal inventory: 33 refusals + 1 capability claims, 33 proven (before)
132+refusal inventory: 32 refusals + 1 capability claims, 32 proven (after)
133+anchor strength: 25 rows quote the WHOLE refusal string, 7 quote its LEADING CLAUSE, 0 match neither
134+```
135+
136+Green after the change:
137+
138+* `cargo test -p ec-av1 --lib -- refus` -- 56 passed, 0 failed
139+* `cargo test -p ec-av1 --lib -- gate_coverage` -- 20 passed; `282 real-aomenc
140+ gates, 119 of them 10-bit`, `NEVER_EXERCISED_8BIT (0 of 26)`,
141+ `NEVER_EXERCISED_10BIT (0 of 26)`, and
142+ `every_pin_a_gate_reads_is_committed_under_the_crate` (the three new pins).
143+
144+The removed gate `a_12bit_screen_content_stream_is_refused_by_name` had no other
145+referrer in `crates/`.
146+
147+## 8. `not_done`
148+
149+Nothing in the 12-bit screen-content surface still refuses. Named caveats:
150+
151+1. **`--tune-content=screen` is a no-op for the `allow_intrabc` decision in this
152+ oracle build** and this lane did not chase libaom's override further than the
153+ measurement (with/without the flag, both readings identical at 128x96 and at
154+ 256x192). The gates read the bit out of the header, so they cannot go
155+ vacuous on it, but a future libaom that honours the flag could move the
156+ 256x192 recipe.
157+2. **12-bit `palette` on a rect HORZ/VERT intra strip and on an intra-in-inter
158+ block** is not separately witnessed at 12 bits; the arms here cover the
159+ square key-frame palette, the chroma palette, and intra-block copy. The
160+ rect/intra-in-inter palette syntaxes are depth-parameterised the same way
161+ (`read_palette_colors_*` at `bit_depth(fctx)`), so this is untested-cell, not
162+ a known-diverging cell. No claim is made for it.
163+3. **No 12-bit 4:4:4 screen-content arm**: the 12-bit 4:4:4 witness
164+ `a_444_12bit_inter_sequence_decodes_pixel_exact` uses smooth content that
165+ leaves `allow_screen_content_tools = 0`, and the recipe hunt for a 12-bit
166+ 4:4:4 screen stream was not run in this lane.