forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1screen12: LIFT the 12-bit screen-content refusal -- both halves of its claim were false

Browse files at this commit

236ebb27d1d06081b7ddaacd9747faddad21f7a0Ahmet Kaan GümüşParent: 1766d69eeb5937
The refusal said a 12-bit frame with allow_screen_content_tools=1 is unsupported because 'neither
palette nor intrabc has a 12-bit witness'. Both halves were false, and both are now witnessed:
- 12-bit PALETTE (screen=true, allow_intrabc=false): screen12_palette.obu 3616 B sha256 adfe26c6...,
  2 frames, 76 palette / 43 palette-UV blocks, 0 wrong vs BOTH the instrumented aomdec and ffmpeg.
- 12-bit INTRABC: the standing note '12-bit intrabc has no producer' was a RECIPE artefact, then
  refuted -- --tune-content=screen does not decide the frame-header bit in this oracle build (libaom's
  content detector does, av1/encoder/encoder.c:2404); the same 8-bit source tiled with -vf tile=2x2
  gives allow_intrabc=true at 8, 10 AND 12 bits. screen12_intrabc.obu 482 B sha256 a3b6b94c..., 1
  frame, 11 intrabc / 36 palette blocks, 0 wrong vs aomdec and ffmpeg.
- 12-bit LOSSLESS + palette (CodedLossless and screen content in one frame):
  screen12_lossless_palette.obu 11698 B sha256 ec7942c9..., 2 frames, 80 palette / 59 palette-UV, 0
  wrong.
Three gates, each asserting the stream's OWN sequence header is 12-bit, that a frame header really
carries allow_screen_content_tools (and allow_intrabc for that arm), that the palette/palette-UV/
intrabc hit DELTAS are non-zero, and that the live recipe reproduces the committed pin byte for byte
(length + fnv1a64) -- so a stream that merely set the header bit fails instead of passing untested.
Pin names are literals. Control: flipping bit 0 of the ORACLE's 12-bit high byte (index 1, a bit that
can never carry) gives exactly (1,0,0,frames,frames-1) -- +1 wrong luma, one fewer exact frame.
Refusal inventory updated in both copies; 56 refusal-census tests green.
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+395 -55
@@ -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
@@ -13786,9 +13805,28 @@ exit 0
13786 depth: usize,13805 depth: usize,
13787 extra: &[&str],13806 extra: &[&str],
13788 ) -> Vec<u8> {13807 ) -> Vec<u8> {
13789- assert!(depth == 8 || depth == 10, "unsupported bit depth {depth}");13808+ // lane-av1screen12: depth 12 joins 8 and 10. The SAME recipe (`-vf
13809+ // tile=2x2` over `smptebars=size=128x96:rate=25`,
13810+ // `--tune-content=screen --enable-intrabc=1`, cq30,
13811+ // `--enable-tx-size-search=0`) that keeps `allow_intrabc` at 8 and 10
13812+ // bits keeps it at 12 bits too -- measured, and pinned by
13813+ // `a_real_aomenc_12bit_intrabc_screen_stream_decodes_pixel_exact`.
13814+ // That is why "neither palette nor intrabc has a 12-bit witness" was
13815+ // false: the intrabc half WAS producible, `--tune-content=screen`
13816+ // alone just is not what decides the frame-header bit (libaom's
13817+ // content detector is).
13818+ assert!(
13819+ depth == 8 || depth == 10 || depth == 12,
13820+ "unsupported bit depth {depth}"
13821+ );
13822+ // `if depth == 10` is SPELLED, not matched, because
13823+ // `gate_coverage::covers_both_depths` recognises this two-depth
13824+ // helper by that literal (the lane-defon/reelckf blind spot with
13825+ // `depth` spelled instead of `bit_depth`).
13790 let pix_fmt = if depth == 10 {13826 let pix_fmt = if depth == 10 {
13791 "yuv420p10le"13827 "yuv420p10le"
13828+ } else if depth == 12 {
13829+ "yuv420p12le"
13792 } else {13830 } else {
13793 "yuv420p"13831 "yuv420p"
13794 };13832 };
@@ -15794,36 +15832,229 @@ exit 0
15794 );15832 );
15795 }15833 }
15796 15834
15797- /// The 12-bit screen-content refusal: a real `--tune-content=screen15835+ /// lane-av1screen12: how many frames of `stream` carry
15798- /// --enable-palette=1 --enable-intrabc=1` frame carries15836+ /// `allow_screen_content_tools`, and how many of THOSE carry
15799- /// `allow_screen_content_tools = 1` and is refused by name at the frame15837+ /// `allow_intrabc`. Both are read out of the frame headers this crate
15800- /// gate -- palette and intrabc have no 12-bit witness.15838+ /// parsed, never taken from the flags handed to the encoder (class
15801- #[test]15839+ /// `tool-disabled-in-every-gate`): on this oracle build
15802- fn a_12bit_screen_content_stream_is_refused_by_name() {15840+ /// `--tune-content=screen` does NOT by itself decide the frame-header
15803- const NAME: &str = "a_12bit_screen_content_stream_is_refused_by_name";15841+ /// `allow_intrabc` bit -- an untiled `smptebars=size=128x96` source reads
15804- let _gate_lock = lock_gate_counters();15842+ /// `false` with and without the flag, while the 256x192 `tile=2x2` source
15805- if !have_ffmpeg() {15843+ /// the intrabc census uses reads `true` with and without it (measured;
15806- eprintln!("SKIP {NAME}: no ffmpeg");15844+ /// libaom's content detector, `encoder.c:2404`, is what decides it).
15807- return;15845+ fn screen_and_intrabc_frame_counts(stream: &[u8]) -> (u32, u32) {
15846+ let mut parser = Av1Parser::new();
15847+ let mut pos = 0usize;
15848+ let (mut screen, mut intrabc) = (0u32, 0u32);
15849+ while pos < stream.len() {
15850+ let Ok(obu) = parser.parse_obu(&stream[pos..]) else {
15851+ break;
15852+ };
15853+ pos += obu.total_size.max(1);
15854+ let header = match &obu.kind {
15855+ ObuKind::Frame(h, _) => Some(&**h),
15856+ ObuKind::FrameHeader(h) => Some(&**h),
15857+ _ => None,
15858+ };
15859+ if let Some(h) = header
15860+ && h.allow_screen_content_tools
15861+ {
15862+ screen += 1;
15863+ if h.allow_intrabc {
15864+ intrabc += 1;
15865+ }
15866+ }
15867+ }
15868+ (screen, intrabc)
15869+ }
15870+
15871+ /// The three committed 12-bit screen-content witnesses, by literal name
15872+ /// (a pin name built from a loop variable leaves the pin census
15873+ /// unproven), with the length and `fnv1a64` each gate asserts. sha256,
15874+ /// recorded in the gates' doc comments and in
15875+ /// `lanes/av1screen12.report.md`:
15876+ ///
15877+ /// * `screen12_palette.obu` 3616 bytes,
15878+ /// `adfe26c67c08a7e986db2743b914ecc3e214c56dd2abbdfd17ebf99f06de64c8`
15879+ /// * `screen12_intrabc.obu` 482 bytes,
15880+ /// `a3b6b94cabdd09a12057c4688990d55495826b87a14332c386d319629070382e`
15881+ /// * `screen12_lossless_palette.obu` 11698 bytes,
15882+ /// `ec7942c96763593e6d8e4b3fb23c03930bba3bb743102d0cf552fe73ae11c203`
15883+ const PIN_LEN_PALETTE: usize = 3616;
15884+ const PIN_FNV_PALETTE: u64 = 0xf9bb_d408_61d6_f0da;
15885+ const PIN_LEN_INTRABC: usize = 482;
15886+ const PIN_FNV_INTRABC: u64 = 0xae83_3eb7_9380_263b;
15887+ const PIN_LEN_LOSSLESS: usize = 11698;
15888+ const PIN_FNV_LOSSLESS: u64 = 0x6e28_41c7_7b0a_f9db;
15889+
15890+ /// lane-av1screen12: the shared body of the three 12-bit screen-content
15891+ /// gates. Every assertion a "this arm really is 12-bit screen content,
15892+ /// and this decoder reproduces it" claim needs, in one place:
15893+ ///
15894+ /// 1. the committed PIN is the witness -- its length and fnv1a64 are
15895+ /// pinned, and `require_pin` HARD-fails on a missing copy rather than
15896+ /// testing nothing;
15897+ /// 2. the live recipe reproduces that pin byte for byte (aomenc present),
15898+ /// so the recipe in the doc comment is not decoration;
15899+ /// 3. the stream's OWN sequence header says 12-bit and its frame headers
15900+ /// say `allow_screen_content_tools` (and `allow_intrabc` for the arm
15901+ /// that wants it);
15902+ /// 4. the decode ENGAGED the feature -- `palette_hits()` /
15903+ /// `palette_uv_hits()` / `intrabc_hits()` deltas are hard-asserted,
15904+ /// because a stream that merely carries the header bit would leave the
15905+ /// arm it claims to witness untested (class `gate-blind-to-feature`);
15906+ /// 5. every sample of every frame matches the instrumented `aomdec
15907+ /// --rawvideo` (`assert_rawvideo_matches`), and independently ffmpeg;
15908+ /// 6. THE CONTROL: the same counting comparator, run twice -- clean it
15909+ /// must report zero wrong samples in all three planes, and with ONE
15910+ /// bit flipped in the ORACLE's own frame-0 luma high byte it must
15911+ /// report exactly one wrong luma byte and one fewer exact frame. That
15912+ /// is the proof the comparator READS the oracle side: a comparator
15913+ /// that compared our samples with themselves would report 0 both
15914+ /// times (class `oracle-diff-counter-tautology`).
15915+ ///
15916+ /// Flip index 1 is the high byte of the first luma sample of frame 0.
15917+ /// A 12-bit sample's high byte holds bits 8..15 only, so flipping its low
15918+ /// bit can never carry into another byte: the move is exactly +1 wrong
15919+ /// byte in the Y plane, which is what makes "+1 in the right plane and
15920+ /// frame" a real statement rather than a hope.
15921+ #[allow(clippy::too_many_arguments)]
15922+ fn assert_12bit_screen_content_arm(
15923+ name: &str,
15924+ pin: &'static str,
15925+ live: Vec<u8>,
15926+ pin_len: usize,
15927+ pin_fnv: u64,
15928+ frames: usize,
15929+ width: usize,
15930+ height: usize,
15931+ want_intrabc: bool,
15932+ ) {
15933+ let path = crate_pin(pin);
15934+ let stream = require_pin(&path, pin);
15935+ assert_eq!(
15936+ stream.len(),
15937+ pin_len,
15938+ "{name}: the committed pin {pin} is {} bytes, this gate names {pin_len}",
15939+ stream.len()
15940+ );
15941+ assert_eq!(fnv1a64(&stream), pin_fnv, "{name}: the committed pin {pin} moved");
15942+ if have_aomenc() {
15943+ assert_eq!(
15944+ live.len(),
15945+ pin_len,
15946+ "{name}: the live recipe produced {} bytes, the committed pin {pin} is \
15947+ {pin_len} -- aomenc changed, re-pin it",
15948+ live.len()
15949+ );
15950+ assert_eq!(
15951+ fnv1a64(&live),
15952+ pin_fnv,
15953+ "{name}: the live recipe no longer reproduces the committed pin {pin}"
15954+ );
15808 }15955 }
15809- if !have_aomenc() {15956+ assert_12bit_sequence_header(&stream, name);
15810- eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());15957+ let (screen_frames, intrabc_frames) = screen_and_intrabc_frame_counts(&stream);
15811- return;15958+ assert!(
15959+ screen_frames > 0,
15960+ "{name}: no frame carries allow_screen_content_tools -- this is not a \
15961+ screen-content stream and the arm would prove nothing"
15962+ );
15963+ assert_eq!(
15964+ intrabc_frames > 0,
15965+ want_intrabc,
15966+ "{name}: {intrabc_frames} frame(s) carry allow_intrabc, the gate wants {}",
15967+ u32::from(want_intrabc)
15968+ );
15969+
15970+ let pal_before = crate::decode::palette_hits();
15971+ let paluv_before = crate::decode::palette_uv_hits();
15972+ let ibc_before = crate::decode::intrabc_hits();
15973+ let decoded = decode_stream(&stream).unwrap_or_else(|e| panic!("{name}: {e}"));
15974+ assert_eq!(decoded.len(), frames, "{name}: frame count");
15975+ let palette = crate::decode::palette_hits() - pal_before;
15976+ let palette_uv = crate::decode::palette_uv_hits() - paluv_before;
15977+ let intrabc = crate::decode::intrabc_hits() - ibc_before;
15978+ assert!(
15979+ palette > 0,
15980+ "{name}: the stream decoded no palette block -- the 12-bit palette syntax \
15981+ would be untested (class gate-blind-to-feature)"
15982+ );
15983+ assert!(
15984+ palette_uv > 0,
15985+ "{name}: the stream decoded no chroma palette block -- the 12-bit palette-UV \
15986+ syntax would be untested (class gate-blind-to-feature)"
15987+ );
15988+ if want_intrabc {
15989+ assert!(
15990+ intrabc > 0,
15991+ "{name}: allow_intrabc is set but no block decoded use_intrabc=1 -- the \
15992+ 12-bit intra-block-copy syntax would be untested (class \
15993+ gate-blind-to-feature)"
15994+ );
15812 }15995 }
15813- let y4m = Command::new("ffmpeg")15996+
15997+ if aomdec_available(name) {
15998+ let dir = std::env::temp_dir().join(format!("ec-av1-{name}-arm"));
15999+ let _ = std::fs::remove_dir_all(&dir);
16000+ std::fs::create_dir_all(&dir).expect("scratch dir");
16001+ let obu = dir.join("in.obu");
16002+ std::fs::write(&obu, &stream).expect("writing the stream");
16003+ assert_rawvideo_matches(&obu, &stream, name, frames, 12);
16004+ let _ = std::fs::remove_dir_all(&dir);
16005+ // The +1 control (part 6): clean is all-zero, one flipped oracle
16006+ // byte is exactly +1 luma byte and one fewer exact frame.
16007+ let clean = count_rawvideo_diffs(&stream, name, None)
16008+ .unwrap_or_else(|| panic!("{name}: our packed output and the oracle's rawvideo differ in SIZE"));
16009+ assert_eq!(
16010+ clean,
16011+ (0, 0, 0, frames, frames),
16012+ "{name}: {frames} frame(s) must be byte-exact against the oracle before the \
16013+ control arm means anything"
16014+ );
16015+ let flipped = count_rawvideo_diffs(&stream, name, Some(1))
16016+ .unwrap_or_else(|| panic!("{name}: the control arm lost the size check"));
16017+ assert_eq!(
16018+ flipped,
16019+ (1, 0, 0, frames, frames - 1),
16020+ "{name}: flipping bit 0 of the ORACLE's frame-0 luma high byte must move the \
16021+ count by exactly +1 luma byte and cost exactly one exact frame -- if this \
16022+ reports 0 the comparator never read the oracle (class \
16023+ oracle-diff-counter-tautology)"
16024+ );
16025+ }
16026+ if have_ffmpeg() {
16027+ let theirs = ffmpeg_decode_sequence_12bit(&stream, width, height, frames);
16028+ assert_eq!(theirs.len(), frames, "{name}: ffmpeg frame count");
16029+ for (i, (ours, want)) in decoded.iter().zip(&theirs).enumerate() {
16030+ assert_eq!(ours.y, want.y, "{name}: 12-bit luma vs ffmpeg (frame {i})");
16031+ assert_eq!(ours.u, want.u, "{name}: 12-bit U vs ffmpeg (frame {i})");
16032+ assert_eq!(ours.v, want.v, "{name}: 12-bit V vs ffmpeg (frame {i})");
16033+ }
16034+ }
16035+ eprintln!(
16036+ "{name}: {frames} 12-bit frame(s) byte-exact vs aomdec --rawvideo and ffmpeg, \
16037+ {screen_frames} screen frame(s), {intrabc_frames} allow_intrabc, {palette} palette \
16038+ + {palette_uv} palette-UV + {intrabc} intrabc block(s)"
16039+ );
16040+ }
16041+
16042+ /// Renders a 12-bit y4m for the 12-bit screen-content gates. `tiled`
16043+ /// applies `-vf tile=2x2`, which is what takes the source from 128x96 to
16044+ /// the 256x192 shape libaom's content detector clears the (stricter)
16045+ /// IntraBC threshold on.
16046+ fn y4m_12bit_screen_source(src: &str, tiled: bool) -> Vec<u8> {
16047+ let mut ff = Command::new("ffmpeg");
16048+ ff.args(["-v", "error", "-f", "lavfi", "-i", src, "-t", "0.2"]);
16049+ if tiled {
16050+ ff.args(["-vf", "tile=2x2"]);
16051+ }
16052+ let out = ff
15814 .args([16053 .args([
15815- "-v",
15816- "error",
15817- "-f",
15818- "lavfi",
15819- "-i",
15820- "smptebars=s=128x128:r=25",
15821 "-pix_fmt",16054 "-pix_fmt",
15822 "yuv420p12le",16055 "yuv420p12le",
15823 "-strict",16056 "-strict",
15824 "-1",16057 "-1",
15825- "-frames:v",
15826- "2",
15827 "-f",16058 "-f",
15828 "yuv4mpegpipe",16059 "yuv4mpegpipe",
15829 "-",16060 "-",
@@ -15834,25 +16065,134 @@ exit 0
15834 .output()16065 .output()
15835 .expect("ffmpeg failed to run");16066 .expect("ffmpeg failed to run");
15836 assert!(16067 assert!(
15837- y4m.status.success(),16068+ out.status.success(),
15838- "ffmpeg failed to render the 12-bit screen fixture: {}",16069+ "ffmpeg failed for the 12-bit screen source {src}: {}",
15839- String::from_utf8_lossy(&y4m.stderr)16070+ String::from_utf8_lossy(&out.stderr)
15840 );16071 );
15841- let stream = encode_12bit(16072+ out.stdout
15842- &y4m.stdout,16073+ }
15843- 1,16074+
15844- &[16075+ /// lane-av1screen12: a 12-bit PALETTE screen-content stream, palette on
15845- "--tune-content=screen",16076+ /// and palette-UV on, `allow_intrabc` off.
15846- "--enable-palette=1",16077+ ///
15847- "--enable-intrabc=1",16078+ /// Recipe: `ffmpeg -f lavfi -i testsrc2=s=160x128:r=25 -pix_fmt
15848- ],16079+ /// yuv420p12le -strict -1` (2 frames, 160x128 4:2:0) piped to
16080+ /// [`encode_12bit`] with `--tune-content=screen --enable-palette=1
16081+ /// `--enable-intrabc=1`; pin `screen12_palette.obu` (3616 bytes, sha256
16082+ /// `adfe26c67c08a7e986db2743b914ecc3e214c56dd2abbdfd17ebf99f06de64c8`).
16083+ ///
16084+ /// What it replaces: this is the arm the blanket refusal "a 12-bit frame
16085+ /// with screen content tools" blocked while decoding exactly.
16086+ #[test]
16087+ fn a_real_aomenc_12bit_screen_content_palette_stream_decodes_pixel_exact() {
16088+ const NAME: &str =
16089+ "a_real_aomenc_12bit_screen_content_palette_stream_decodes_pixel_exact";
16090+ const PIN: &str = "screen12_palette.obu";
16091+ let _gate_lock = lock_gate_counters();
16092+ if !have_ffmpeg() {
16093+ eprintln!("SKIP {NAME}: no ffmpeg");
16094+ return;
16095+ }
16096+ let y4m = y4m_12bit_screen_source("testsrc2=s=160x128:r=25", false);
16097+ let live = if have_aomenc() {
16098+ encode_12bit(
16099+ &y4m,
16100+ 2,
16101+ &[
16102+ "--tune-content=screen",
16103+ "--enable-palette=1",
16104+ "--enable-intrabc=1",
16105+ ],
16106+ )
16107+ } else {
16108+ Vec::new()
16109+ };
16110+ assert_12bit_screen_content_arm(
16111+ NAME, PIN, live, PIN_LEN_PALETTE, PIN_FNV_PALETTE, 2, 160, 128, false,
15849 );16112 );
15850- let err = decode_stream(&stream).unwrap_err().to_string();16113+ }
15851- assert!(16114+
15852- err.contains(16115+ /// lane-av1screen12: a 12-bit screen-content stream whose KEY frame sets
15853- "a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)"16116+ /// `allow_intrabc = 1` and really codes `use_intrabc` blocks.
15854- ),16117+ ///
15855- "{NAME}: expected the 12-bit screen content refusal, got: {err}"16118+ /// Recipe: [`screen_intrabc_stream_at_depth`] at depth 12 -- the same
16119+ /// shape the 8/10-bit intrabc census and the sb128 intrabc witness use:
16120+ /// `-vf tile=2x2` over `smptebars=size=128x96:rate=25` (256x192),
16121+ /// `--tune-content=screen --enable-intrabc=1 --enable-palette=1
16122+ /// --cq-level=30 --enable-tx-size-search=0 --min-partition-size=8
16123+ /// --max-partition-size=32 --sb-size=64 --kf-max-dist=1 --limit=1`, so
16124+ /// ONE 12-bit key frame; pin `screen12_intrabc.obu` (482 bytes, sha256
16125+ /// `a3b6b94cabdd09a12057c4688990d55495826b87a14332c386d319629070382e`).
16126+ ///
16127+ /// This arm is the one the old refusal's "nor intrabc" half named, and it
16128+ /// is why the refusal could be LIFTED rather than narrowed: it decodes
16129+ /// byte-exact at 12 bits and `intrabc_hits()` proves the blocks really
16130+ /// reconstructed from the current frame.
16131+ #[test]
16132+ fn a_real_aomenc_12bit_intrabc_screen_stream_decodes_pixel_exact() {
16133+ const NAME: &str = "a_real_aomenc_12bit_intrabc_screen_stream_decodes_pixel_exact";
16134+ const PIN: &str = "screen12_intrabc.obu";
16135+ let _gate_lock = lock_gate_counters();
16136+ if !have_ffmpeg() {
16137+ eprintln!("SKIP {NAME}: no ffmpeg");
16138+ return;
16139+ }
16140+ let live = if have_aomenc() {
16141+ // `--enable-palette=1` LAST (aomenc keeps the last occurrence), so
16142+ // this 12-bit arm carries BOTH screen-content syntaxes rather than
16143+ // intra-block copy alone.
16144+ screen_intrabc_stream_at_depth(
16145+ "smptebars=size=128x96:rate=25",
16146+ "30",
16147+ "0",
16148+ true,
16149+ false,
16150+ 12,
16151+ &["--enable-palette=1"],
16152+ )
16153+ } else {
16154+ Vec::new()
16155+ };
16156+ assert_12bit_screen_content_arm(
16157+ NAME, PIN, live, PIN_LEN_INTRABC, PIN_FNV_INTRABC, 1, 256, 192, true,
16158+ );
16159+ }
16160+
16161+ /// lane-av1screen12: a 12-bit LOSSLESS screen-content stream with
16162+ /// palette and palette-UV on.
16163+ ///
16164+ /// Recipe: the palette arm's source and flags plus `--lossless=1`, so the
16165+ /// frame is `CodedLossless` (base_q_idx 0, WHT on every plane) AND
16166+ /// screen-content -- two 12-bit tile-syntax interactions in one frame;
16167+ /// pin `screen12_lossless_palette.obu` (11698 bytes, sha256
16168+ /// `ec7942c96763593e6d8e4b3fb23c03930bba3bb743102d0cf552fe73ae11c203`).
16169+ #[test]
16170+ fn a_real_aomenc_12bit_lossless_screen_content_stream_decodes_pixel_exact() {
16171+ const NAME: &str =
16172+ "a_real_aomenc_12bit_lossless_screen_content_stream_decodes_pixel_exact";
16173+ const PIN: &str = "screen12_lossless_palette.obu";
16174+ let _gate_lock = lock_gate_counters();
16175+ if !have_ffmpeg() {
16176+ eprintln!("SKIP {NAME}: no ffmpeg");
16177+ return;
16178+ }
16179+ let y4m = y4m_12bit_screen_source("testsrc2=s=160x128:r=25", false);
16180+ let live = if have_aomenc() {
16181+ encode_12bit(
16182+ &y4m,
16183+ 2,
16184+ &[
16185+ "--tune-content=screen",
16186+ "--enable-palette=1",
16187+ "--enable-intrabc=1",
16188+ "--lossless=1",
16189+ ],
16190+ )
16191+ } else {
16192+ Vec::new()
16193+ };
16194+ assert_12bit_screen_content_arm(
16195+ NAME, PIN, live, PIN_LEN_LOSSLESS, PIN_FNV_LOSSLESS, 2, 160, 128, false,
15856 );16196 );
15857 }16197 }
15858 16198
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.