forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-t900' (f44314e9): four more refusals proven (empty ref slot, segmentation overrides, OBMC filter band audit, superres 8x8-leaf census); 29 of 40 proven

Browse files at this commit

aa49092e7399c964373c1e0d0c6ea4f8ad84f295Ahmet Kaan GümüşParent: 1a91a88baa89bd
crates/ec-av1/src/decode.rsmodified+141 -0
@@ -2016,6 +2016,21 @@ pub(crate) fn obmc_hits() -> usize {
2016 OBMC_HITS.with(|c| c.get())2016 OBMC_HITS.with(|c| c.get())
2017 }2017 }
2018 2018
2019+// lane-t900 r27: OBMC blends that actually READ a recorded switchable filter
2020+// off the neighbour band -- the positive half of the proof for "an OBMC
2021+// neighbour whose switchable interp filter was never recorded". A
2022+// fixed-filter frame returns before this point (its neighbours legitimately
2023+// carry the `[3, 3]` sentinel), so every bump is a neighbour whose own
2024+// `interp_filter` symbols were published by `record_inter_rect_mi`.
2025+thread_local! {
2026+ static OBMC_FILTER_BAND_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2027+}
2028+
2029+/// Current value of [`OBMC_FILTER_BAND_READS`].
2030+pub(crate) fn obmc_filter_band_reads() -> usize {
2031+ OBMC_FILTER_BAND_READS.with(|c| c.get())
2032+}
2033+
2019 // lane-scaledref r1: per-case firing counts for the scaled-reference gate2034 // lane-scaledref r1: per-case firing counts for the scaled-reference gate
2020 // (class `gate-blind-to-feature`) -- a pixel match under an UNSCALED2035 // (class `gate-blind-to-feature`) -- a pixel match under an UNSCALED
2021 // reference would pass just as well and prove nothing, so the gate2036 // reference would pass just as well and prove nothing, so the gate
@@ -19723,6 +19738,7 @@ fn neighbour_filter(
19723 "an OBMC neighbour whose switchable interp filter was never recorded",19738 "an OBMC neighbour whose switchable interp filter was never recorded",
19724 ));19739 ));
19725 }19740 }
19741+ OBMC_FILTER_BAND_READS.with(|c| c.set(c.get() + 1));
19726 Ok((19742 Ok((
19727 mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize),19743 mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize),
19728 mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize),19744 mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize),
@@ -31104,6 +31120,131 @@ mod tests {
31104 assert_eq!((h, v), (mc::InterpFilterKind::Smooth, mc::InterpFilterKind::Smooth));31120 assert_eq!((h, v), (mc::InterpFilterKind::Smooth, mc::InterpFilterKind::Smooth));
31105 }31121 }
31106 31122
31123+ /// lane-t900 r27, structural audit for "an OBMC neighbour whose switchable
31124+ /// interp filter was never recorded": the `[3, 3]` sentinel is only ever
31125+ /// PUBLISHED for a cell an OBMC blend cannot pick up.
31126+ ///
31127+ /// `Neighbours::record_inter_rect_mi` is the single writer of
31128+ /// `above_filter`/`left_filter` (every other recorder routes through it),
31129+ /// so the whole domain of published values is its call sites' 7th
31130+ /// argument. Two publications are safe: an INTRA cell (`is_inter = false`,
31131+ /// skipped by `overlappable_above`/`overlappable_left`'s own `is_inter`
31132+ /// gate) and a fixed-filter frame (`resolve_interp_filter` returns the
31133+ /// sentinel when `interp_fixed` is `Some`, which `neighbour_filter`
31134+ /// answers before ever looking at the symbols). What this scans for is the
31135+ /// third case -- an INTER cell stamped with a literal sentinel, which is
31136+ /// what the refusal actually fires on. Arguments are tokenised
31137+ /// positionally, never `contains()`d.
31138+ #[test]
31139+ fn every_inter_record_publishes_an_obmc_readable_filter() {
31140+ let src = include_str!("decode.rs");
31141+ let mut calls = 0usize;
31142+ for (start, _) in src.match_indices("record_inter_rect_mi(") {
31143+ // Skip the definition and the wrapper's own forwarding call.
31144+ let line_start = src[..start].rfind('\n').map_or(0, |i| i + 1);
31145+ let head = &src[line_start..start];
31146+ // The definition, the wrapper's own forwarding call, and this
31147+ // test's own mentions of the name (doc comment, scan pattern,
31148+ // assert message) are not publication sites.
31149+ if head.contains("fn ") || head.contains("///") || head.ends_with('"') {
31150+ continue;
31151+ }
31152+ let mut i = start + "record_inter_rect_mi(".len();
31153+ let (mut depth, mut arg, mut args) = (0i32, String::new(), Vec::new());
31154+ let bytes = src.as_bytes();
31155+ while i < bytes.len() {
31156+ let c = bytes[i] as char;
31157+ match c {
31158+ '(' | '[' => depth += 1,
31159+ ')' | ']' if depth == 0 && c == ')' => break,
31160+ ')' | ']' => depth -= 1,
31161+ ',' if depth == 0 => {
31162+ args.push(std::mem::take(&mut arg));
31163+ i += 1;
31164+ continue;
31165+ }
31166+ _ => {}
31167+ }
31168+ arg.push(c);
31169+ i += 1;
31170+ }
31171+ if !arg.trim().is_empty() {
31172+ args.push(arg);
31173+ }
31174+ assert_eq!(
31175+ args.len(),
31176+ 8,
31177+ "record_inter_rect_mi gained an argument -- re-index this audit: {args:?}"
31178+ );
31179+ calls += 1;
31180+ let (is_inter, filter) = (args[4].trim(), args[6].trim());
31181+ if filter.starts_with('[') {
31182+ assert_eq!(
31183+ filter.replace(' ', ""),
31184+ "[3,3]",
31185+ "a literal filter other than the sentinel is published at call {calls}"
31186+ );
31187+ assert_eq!(
31188+ is_inter, "false",
31189+ "an INTER cell is stamped with the [3, 3] sentinel (call {calls}): an OBMC \
31190+ blend picking it up refuses by name. Publish the block's own resolved \
31191+ switchable symbols instead."
31192+ );
31193+ }
31194+ }
31195+ assert!(
31196+ calls >= 6,
31197+ "the audit found only {calls} publication sites -- it is broken, not the decoder"
31198+ );
31199+ }
31200+
31201+ /// lane-t900 r27, negative gate for "a reference frame selected with no
31202+ /// picture at this frame's own ref_frame_idx slot for it": every
31203+ /// non-`LAST_FRAME` reference resolves through `ref_planes`, and an empty
31204+ /// slot is refused BY NAME there rather than predicting from `LAST`.
31205+ ///
31206+ /// Direct-call, not a stream: with this crate's writers the case is
31207+ /// unreachable end to end. A SHOWN key frame refreshes all eight slots
31208+ /// (spec 5.9.2 forces `refresh_frame_flags`, `write_frame_header` does the
31209+ /// same) and nothing ever clears a slot, so once a stream has a key frame
31210+ /// every slot holds a picture; a stream that OPENS on an inter frame is
31211+ /// stopped one guard earlier, by `decode_stream`'s own `LAST` lookup
31212+ /// ("an inter frame with no key frame before it", gated by
31213+ /// `an_inter_frame_opening_a_stream_is_refused_by_name`). The reachable
31214+ /// premise is a HIDDEN key frame refreshing only some slots, which
31215+ /// `write_frame_header` refuses to write (`show_frame` must be set) --
31216+ /// so the stream-level witness needs a hidden-frame writer, noted as the
31217+ /// open half of this proof.
31218+ #[test]
31219+ fn a_selected_reference_with_an_empty_ref_frame_idx_slot_refuses_by_name() {
31220+ const REFUSAL: &str =
31221+ "a reference frame selected with no picture at this frame's own ref_frame_idx slot";
31222+ let plane = PlaneBuf {
31223+ data: vec![0u16; 16],
31224+ width: 4,
31225+ height: 4,
31226+ true_width: 4,
31227+ true_height: 4,
31228+ tile_x0: 0,
31229+ tile_y0: 0,
31230+ tile_x1: 4,
31231+ tile_y1: 4,
31232+ };
31233+ let empty: RefSlots = [None; 8];
31234+ for ref_frame in [LAST2_FRAME, LAST3_FRAME, GOLDEN_FRAME, BWDREF_FRAME, ALTREF2_FRAME, ALTREF_FRAME] {
31235+ let err = match ref_planes(ref_frame, &plane, &plane, &plane, &empty) {
31236+ Ok(_) => panic!("ref {ref_frame}: an empty slot resolved to a picture"),
31237+ Err(e) => e.to_string(),
31238+ };
31239+ assert!(err.contains(REFUSAL), "ref {ref_frame}: expected {REFUSAL:?}, got: {err}");
31240+ }
31241+ // `LAST_FRAME` never consults the slots: `decode_stream` checked it.
31242+ let Ok((y, _, _)) = ref_planes(LAST_FRAME, &plane, &plane, &plane, &empty) else {
31243+ panic!("LAST_FRAME resolves to the frame's own reference planes")
31244+ };
31245+ assert_eq!(y.width, 4);
31246+ }
31247+
31107 #[test]31248 #[test]
31108 fn record_compound_ctx_stamps_ref1_for_the_next_block_to_read() {31249 fn record_compound_ctx_stamps_ref1_for_the_next_block_to_read() {
31109 let mut n = Neighbours::new(4, 4, 16, 16);31250 let mut n = Neighbours::new(4, 4, 16, 16);
crates/ec-av1/src/refusal_inventory.rsmodified+47 -0
@@ -314,6 +314,53 @@ const PROVEN: &[(&str, &str)] = &[
314 // by name (a 64x32 inter frame over a 64x64 reference; a stream opening on314 // by name (a 64x32 inter frame over a 64x64 reference; a stream opening on
315 // a non-error-resilient inter frame whose primary_ref slot is empty, over315 // a non-error-resilient inter frame whose primary_ref slot is empty, over
316 // all 8 slots) with the picture/CDF slot invariant enumerated alongside.316 // all 8 slots) with the picture/CDF slot invariant enumerated alongside.
317+ // lane-t900 r27, negative gate + structural note: every non-`LAST_FRAME`
318+ // reference resolves through `ref_planes`, where an empty slot refuses by
319+ // name (swept over all six such references). The STREAM-level witness is
320+ // out of reach of this crate's writers -- a shown key frame refreshes all
321+ // eight slots and nothing ever clears one, and a stream opening on an
322+ // inter frame is stopped one guard earlier -- so the reachable premise is
323+ // a HIDDEN key frame with a partial `refresh_frame_flags`, which
324+ // `write_frame_header` cannot write. That gap is the open half.
325+ (
326+ "a reference frame selected with no picture at this frame's own ref_frame_idx slot for it",
327+ "a_selected_reference_with_an_empty_ref_frame_idx_slot_refuses_by_name",
328+ ),
329+ // lane-t900 r27, negative gate + census: a written key frame carrying
330+ // each of the three mode-overriding features (over three segment ids) is
331+ // refused by name with no picture; and six real aomenc recipes
332+ // (`--aq-mode=1/2/3`, `--deltaq-mode=1`, plus a baseline for arrival)
333+ // never enable one -- only `--aq-mode=3` changes the stream at all, and
334+ // what it codes is `segment_id` symbols under `SEG_LVL_ALT_Q`.
335+ (
336+ "a frame whose segmentation enables SEG_LVL_REF_FRAME/SKIP/GLOBALMV (this decoder reads segment_id but never lets a segment override a block's reference, skip or mode)",
337+ "a_frame_whose_segmentation_overrides_a_block_mode_is_refused_by_name",
338+ ),
339+ // lane-t900 r27, structural audit + witness: `record_inter_rect_mi` is the
340+ // single writer of the interp-filter neighbour band, and no call site
341+ // stamps the `[3, 3]` sentinel on an INTER cell (the audit tokenises each
342+ // site's arguments); two real `--enable-obmc=1 --enable-dual-filter=1
343+ // --cpu-used=0` streams then decode with 237 band reads over ~115 OBMC
344+ // blocks each and the refusal firing 0 times (gate
345+ // `a_real_obmc_stream_reads_a_recorded_switchable_filter_for_every_neighbour`).
346+ // At `--cpu-used=4` aomenc settles on a frame-level fixed filter and the
347+ // band is never read -- the speed is load-bearing in that gate.
348+ (
349+ "an OBMC neighbour whose switchable interp filter was never recorded",
350+ "every_inter_record_publishes_an_obmc_readable_filter",
351+ ),
352+ // lane-t900 r27, census: this one is a REAL capability gap, and the gate
353+ // proves it fires by name on real streams -- four fixed-denominator
354+ // `--superres-mode=1` encodes (denoms 10/12/16, warped motion and OBMC
355+ // on) all stop here, while the two `--superres-mode=3` auto encodes pick
356+ // denominator 8 and carry no scaling at all. Its two siblings ("warp
357+ // prediction with a scaled reference", "a sub-8x8 inter block under a
358+ // scaled reference") stay UNPROVEN: this refusal sits in front of them,
359+ // so nothing measures them until the 8x8-leaf gap is lifted.
360+ (
361+ "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
362+ "a_superres_census_over_six_real_streams_records_which_scaled_refusals_fire",
363+ ),
317 (364 (
318 "a reference picture whose height does not match this frame's own true size",365 "a reference picture whose height does not match this frame's own true size",
319 "an_inter_frame_shorter_than_its_reference_is_refused_by_name",366 "an_inter_frame_shorter_than_its_reference_is_refused_by_name",
crates/ec-av1/src/stream.rsmodified+334 -0
@@ -1228,6 +1228,340 @@ mod tests {
1228 );1228 );
1229 }1229 }
1230 1230
1231+ /// lane-t900 r27, negative gate: a frame whose segmentation enables one of
1232+ /// the three MODE-OVERRIDING features -- `SEG_LVL_REF_FRAME` (forces a
1233+ /// block's reference), `SEG_LVL_SKIP` and `SEG_LVL_GLOBALMV` (both
1234+ /// suppress symbols `decode_inter_block` reads unconditionally) -- is
1235+ /// refused BY NAME and outputs no picture, rather than desyncing on the
1236+ /// first block that would have obeyed the override.
1237+ ///
1238+ /// Written, not hand-built: `write_segmentation_params` (spec 5.9.14)
1239+ /// codes `feature_enabled`/`feature_data` for every segment, so a real
1240+ /// key frame carrying the flag is a two-line change to the header the
1241+ /// encoder already produced. Swept over all three features and over the
1242+ /// first, a middle and the last segment id.
1243+ #[test]
1244+ fn a_frame_whose_segmentation_overrides_a_block_mode_is_refused_by_name() {
1245+ const REFUSAL: &str =
1246+ "a frame whose segmentation enables SEG_LVL_REF_FRAME/SKIP/GLOBALMV";
1247+ let picture = test_card(64, 64);
1248+ let encoded = encode_key_frame(&picture, 100, 0.5).unwrap();
1249+ let (seq, key) = crate::encode::key_frame_headers(64, 64, 100).unwrap();
1250+ for feature in [SEG_LVL_REF_FRAME, SEG_LVL_SKIP, SEG_LVL_GLOBALMV] {
1251+ for segment in [0usize, 3, 7] {
1252+ let mut header = key.clone();
1253+ header.segmentation.enabled = true;
1254+ header.segmentation.update_map = true;
1255+ header.segmentation.update_data = true;
1256+ header.segmentation.feature_enabled[segment][feature] = true;
1257+ header.segmentation.feature_data[segment][feature] = 1;
1258+ let mut stream = crate::sequence::sequence_header_obu(&seq).unwrap();
1259+ stream.extend_from_slice(
1260+ &crate::frame::frame_obu(&seq, &header, &encoded.tile).unwrap(),
1261+ );
1262+ let mut shown = 0;
1263+ let err = decode_stream_with(&stream, |_, _, _| {
1264+ shown += 1;
1265+ Ok(())
1266+ })
1267+ .unwrap_err()
1268+ .to_string();
1269+ assert!(
1270+ err.contains(REFUSAL),
1271+ "feature {feature} segment {segment}: expected {REFUSAL:?}, got: {err}"
1272+ );
1273+ assert_eq!(
1274+ shown, 0,
1275+ "feature {feature} segment {segment}: a refused frame produced a picture"
1276+ );
1277+ }
1278+ }
1279+ }
1280+
1281+ /// One census attempt: encode `frames` frames of `source` with real
1282+ /// aomenc plus `extra` args, decode with THIS decoder, and return the
1283+ /// stream's byte length with either the picture count or the refusal (any
1284+ /// decode error) it produced. A census is about what the encoder emits,
1285+ /// so a refusal is data here, not a failure.
1286+ fn census_attempt(
1287+ source: &str,
1288+ width: usize,
1289+ height: usize,
1290+ frames: usize,
1291+ extra: &[&str],
1292+ ) -> (usize, std::result::Result<usize, String>) {
1293+ let duration = format!("{}", frames as f64 / 25.0);
1294+ let src = format!("{source}=size={width}x{height}:rate=25");
1295+ let y4m = Command::new("ffmpeg")
1296+ .args([
1297+ "-v", "error", "-f", "lavfi", "-i", &src, "-t", &duration, "-pix_fmt", "yuv420p",
1298+ "-strict", "-1", "-f", "yuv4mpegpipe", "-",
1299+ ])
1300+ .stdin(Stdio::null())
1301+ .stdout(Stdio::piped())
1302+ .stderr(Stdio::piped())
1303+ .output()
1304+ .expect("ffmpeg failed to run");
1305+ assert!(y4m.status.success(), "ffmpeg refused the {width}x{height} fixture");
1306+ let limit = format!("--limit={frames}");
1307+ let mut args: Vec<String> = [
1308+ "--codec=av1",
1309+ "--passes=1",
1310+ "--end-usage=q",
1311+ "--threads=1",
1312+ "--row-mt=0",
1313+ "--kf-max-dist=9999",
1314+ "--lag-in-frames=0",
1315+ ]
1316+ .iter()
1317+ .map(|s| (*s).to_owned())
1318+ .collect();
1319+ args.push(limit);
1320+ args.extend(extra.iter().map(|s| (*s).to_owned()));
1321+ args.extend(["--obu".to_owned(), "-o".to_owned(), "-".to_owned(), "-".to_owned()]);
1322+ let mut child = Command::new(aomenc_path())
1323+ .args(&args)
1324+ .stdin(Stdio::piped())
1325+ .stdout(Stdio::piped())
1326+ .stderr(Stdio::piped())
1327+ .spawn()
1328+ .expect("aomenc failed to start");
1329+ child.stdin.take().expect("aomenc stdin").write_all(&y4m.stdout).expect("write y4m");
1330+ let out = child.wait_with_output().expect("aomenc failed to run");
1331+ assert!(out.status.success(), "aomenc refused {args:?}: {}", String::from_utf8_lossy(&out.stderr));
1332+ let stream = out.stdout;
1333+ let result = match decode_stream(&stream) {
1334+ Ok(pictures) => Ok(pictures.len()),
1335+ Err(e) => Err(e.to_string()),
1336+ };
1337+ (stream.len(), result)
1338+ }
1339+
1340+ /// lane-t900 r27 CENSUS behind the negative gate above: does a real
1341+ /// aomenc ever ENABLE one of the three mode-overriding segmentation
1342+ /// features? Measured over the recipes that turn segmentation on --
1343+ /// `--aq-mode=1/2/3` (variance, complexity and cyclic-refresh AQ) and
1344+ /// `--deltaq-mode=1` -- with the refusal as the instrument: if one of
1345+ /// those features appeared, the decode would stop by name.
1346+ #[test]
1347+ fn a_segmentation_census_over_real_aq_streams_finds_no_mode_overriding_feature() {
1348+ if !have_aomenc() {
1349+ eprintln!("SKIP a_segmentation_census_over_real_aq_streams: no aomenc");
1350+ return;
1351+ }
1352+ const REFUSAL: &str =
1353+ "a frame whose segmentation enables SEG_LVL_REF_FRAME/SKIP/GLOBALMV";
1354+ let recipes: [(&str, Vec<&str>); 6] = [
1355+ ("baseline", vec!["--cpu-used=4", "--cq-level=40"]),
1356+ ("aq-mode=1", vec!["--cpu-used=4", "--aq-mode=1", "--cq-level=40"]),
1357+ ("aq-mode=2", vec!["--cpu-used=4", "--aq-mode=2", "--cq-level=40"]),
1358+ ("aq-mode=3", vec!["--cpu-used=4", "--aq-mode=3", "--cq-level=40"]),
1359+ ("aq-mode=3 cq10", vec!["--cpu-used=4", "--aq-mode=3", "--cq-level=10"]),
1360+ ("deltaq-mode=1", vec!["--cpu-used=4", "--deltaq-mode=1", "--cq-level=40"]),
1361+ ];
1362+ // Arrival, not intent (class knob-never-reached-the-tool): a recipe
1363+ // whose stream is byte-for-byte the baseline's changed nothing, and a
1364+ // census over such arms would be vacuous. Measured r27: only
1365+ // `--aq-mode=3` (cyclic refresh) does -- aq-mode 1/2 and deltaq-mode=1
1366+ // all reproduce the baseline's 7147 B at this recipe.
1367+ let mut baseline_bytes = 0usize;
1368+ let mut segment_symbols = 0usize;
1369+ let mut refused = 0usize;
1370+ let mut decoded = 0usize;
1371+ for (name, extra) in &recipes {
1372+ let before = crate::decode::segment_id_hits();
1373+ let (bytes, result) = census_attempt("mandelbrot", 192, 128, 8, extra);
1374+ match result {
1375+ Ok(pictures) => {
1376+ decoded += 1;
1377+ let symbols = crate::decode::segment_id_hits() - before;
1378+ segment_symbols += symbols;
1379+ if *name == "baseline" {
1380+ baseline_bytes = bytes;
1381+ }
1382+ eprintln!(
1383+ "SEGCENSUS {name}: {bytes} B{}, {pictures} pictures, segment_id symbols {symbols}",
1384+ if bytes == baseline_bytes && *name != "baseline" {
1385+ " (== baseline: the flag changed nothing)"
1386+ } else {
1387+ ""
1388+ }
1389+ );
1390+ }
1391+ Err(e) => {
1392+ eprintln!("SEGCENSUS {name}: {bytes} B, refused: {e}");
1393+ assert!(
1394+ !e.contains(REFUSAL),
1395+ "{name}: a real aomenc stream DOES enable a mode-overriding \
1396+ segmentation feature -- the refusal is a capability gap, not a \
1397+ claim about the encoder: {e}"
1398+ );
1399+ refused += 1;
1400+ }
1401+ }
1402+ }
1403+ eprintln!(
1404+ "SEGCENSUS: {} recipes, {decoded} decoded, {refused} refused for other reasons",
1405+ recipes.len()
1406+ );
1407+ assert_eq!(decoded, recipes.len(), "every recipe must decode; {refused} refused");
1408+ assert!(
1409+ segment_symbols > 0,
1410+ "no recipe coded a single segment_id symbol -- segmentation never arrived, so \
1411+ this census measures nothing about the three mode-overriding features"
1412+ );
1413+ }
1414+
1415+ /// lane-t900 r27, WITNESS half of the proof for "an OBMC neighbour whose
1416+ /// switchable interp filter was never recorded" (the structural half is
1417+ /// `decode::tests::every_inter_record_publishes_an_obmc_readable_filter`,
1418+ /// which shows no INTER cell is ever stamped with the `[3, 3]`
1419+ /// sentinel): real OBMC streams whose frames use a SWITCHABLE (and dual)
1420+ /// interp filter decode with the refusal firing 0 times while OBMC blends
1421+ /// really read the neighbour band -- a decode that never read one would
1422+ /// pass just as well and prove nothing (class gate-blind-to-feature).
1423+ #[test]
1424+ fn a_real_obmc_stream_reads_a_recorded_switchable_filter_for_every_neighbour() {
1425+ if !have_aomenc() {
1426+ eprintln!("SKIP a_real_obmc_stream_reads_a_recorded_switchable_filter: no aomenc");
1427+ return;
1428+ }
1429+ // `--cpu-used=0` is load-bearing: at speed 4 aomenc settles on a
1430+ // FRAME-level fixed interp filter, every neighbour then legitimately
1431+ // carries the sentinel, and the band is never read at all (measured
1432+ // r27: 0 reads over two speed-4 streams).
1433+ let base = vec![
1434+ "--cpu-used=0",
1435+ "--enable-obmc=1",
1436+ "--enable-dual-filter=1",
1437+ "--min-partition-size=8",
1438+ "--max-partition-size=16",
1439+ "--enable-palette=0",
1440+ "--enable-intrabc=0",
1441+ ];
1442+ let recipes: [(&str, usize, usize, Vec<&str>); 2] = [
1443+ ("obmc dual cq40", 192, 128, [vec!["--cq-level=40"], base.clone()].concat()),
1444+ ("obmc dual cq20", 192, 128, [vec!["--cq-level=20"], base.clone()].concat()),
1445+ ];
1446+ let mut reads = 0usize;
1447+ let mut decoded = 0usize;
1448+ for (name, w, h, extra) in &recipes {
1449+ let before = crate::decode::obmc_filter_band_reads();
1450+ let obmc_before = crate::decode::obmc_hits();
1451+ let (bytes, result) = census_attempt("mandelbrot", *w, *h, 8, extra);
1452+ match result {
1453+ Ok(pictures) => {
1454+ decoded += 1;
1455+ let got = crate::decode::obmc_filter_band_reads() - before;
1456+ reads += got;
1457+ eprintln!(
1458+ "OBMCFILT {name}: {bytes} B, {pictures} pictures, {got} band reads, \
1459+ {} OBMC blocks",
1460+ crate::decode::obmc_hits() - obmc_before
1461+ );
1462+ }
1463+ Err(e) => {
1464+ assert!(
1465+ !e.contains("an OBMC neighbour whose switchable interp filter was never recorded"),
1466+ "{name}: a real OBMC stream reached the unrecorded-filter refusal -- \
1467+ a publication site is missing: {e}"
1468+ );
1469+ eprintln!("OBMCFILT {name}: {bytes} B, refused for another reason: {e}");
1470+ }
1471+ }
1472+ }
1473+ assert!(decoded > 0, "no OBMC recipe decoded -- the witness is vacuous");
1474+ assert!(
1475+ reads > 0,
1476+ "every OBMC blend took the fixed-filter path: the band was never read, so this \
1477+ proves nothing about the refusal"
1478+ );
1479+ }
1480+
1481+ /// lane-t900 r27 CENSUS for the three SUPERRES refusals -- "warp
1482+ /// prediction with a scaled reference", "a sub-8x8 inter block under a
1483+ /// scaled reference" and "an 8x8 partition leaf under a scaled reference".
1484+ /// Six real `--superres-mode` encodes (fixed denominators and the auto
1485+ /// mode, warped motion and OBMC on), decoded by this decoder: the table it
1486+ /// prints is which of the three a real encoder actually reaches.
1487+ ///
1488+ /// Every one of them is a REAL capability gap (unlike the enumerated
1489+ /// refusals elsewhere in the inventory), so this gate asserts the measured
1490+ /// shape rather than "no refusal": at least one recipe must decode (else
1491+ /// the census says nothing), and any refusal must be one of the three
1492+ /// named superres ones -- a fourth string would be a new gap this round
1493+ /// did not measure.
1494+ #[test]
1495+ fn a_superres_census_over_six_real_streams_records_which_scaled_refusals_fire() {
1496+ if !have_aomenc() {
1497+ eprintln!("SKIP a_superres_census_over_six_real_streams: no aomenc");
1498+ return;
1499+ }
1500+ const WARP: &str = "warp prediction with a scaled reference";
1501+ const SUB8: &str = "a sub-8x8 inter block under a scaled reference";
1502+ const LEAF8: &str = "an 8x8 partition leaf under a scaled reference";
1503+ let common = [
1504+ "--enable-warped-motion=1",
1505+ "--enable-obmc=1",
1506+ "--enable-palette=0",
1507+ "--enable-intrabc=0",
1508+ ];
1509+ let recipes: [(&str, usize, usize, Vec<&str>); 6] = [
1510+ ("denom12 320x180 cq32", 320, 180, vec!["--cpu-used=4", "--superres-mode=1", "--superres-denominator=12", "--cq-level=32"]),
1511+ ("denom12 320x180 cq50", 320, 180, vec!["--cpu-used=4", "--superres-mode=1", "--superres-denominator=12", "--cq-level=50"]),
1512+ ("denom16 320x180 cq32", 320, 180, vec!["--cpu-used=4", "--superres-mode=1", "--superres-denominator=16", "--cq-level=32"]),
1513+ ("denom10 192x128 cq32", 192, 128, vec!["--cpu-used=4", "--superres-mode=1", "--superres-denominator=10", "--cq-level=32"]),
1514+ ("auto 320x180 cq50", 320, 180, vec!["--cpu-used=4", "--superres-mode=3", "--cq-level=50"]),
1515+ ("auto 192x128 cq50", 192, 128, vec!["--cpu-used=4", "--superres-mode=3", "--cq-level=50"]),
1516+ ];
1517+ let (mut decoded, mut warp, mut sub8, mut leaf8, mut other) = (0, 0, 0, 0, 0);
1518+ for (name, w, h, extra) in &recipes {
1519+ let mut args = extra.clone();
1520+ args.extend_from_slice(&common);
1521+ let before = crate::mc::predict_scaled_hits();
1522+ let (bytes, result) = census_attempt("mandelbrot", *w, *h, 10, &args);
1523+ match result {
1524+ Ok(pictures) => {
1525+ decoded += 1;
1526+ eprintln!(
1527+ "SUPERRES {name}: {bytes} B, {pictures} pictures, scaled MC blocks {}",
1528+ crate::mc::predict_scaled_hits() - before
1529+ );
1530+ }
1531+ Err(e) => {
1532+ eprintln!("SUPERRES {name}: {bytes} B, refused: {e}");
1533+ if e.contains(WARP) {
1534+ warp += 1;
1535+ } else if e.contains(SUB8) {
1536+ sub8 += 1;
1537+ } else if e.contains(LEAF8) {
1538+ leaf8 += 1;
1539+ } else {
1540+ other += 1;
1541+ panic!("{name}: a superres stream stopped on a string this census does not know: {e}");
1542+ }
1543+ }
1544+ }
1545+ }
1546+ eprintln!(
1547+ "SUPERRES CENSUS: 6 streams, {decoded} decoded, warp {warp}x, sub8 {sub8}x, leaf8 {leaf8}x, other {other}x"
1548+ );
1549+ // Measured r27: the four FIXED-denominator recipes all stop at the
1550+ // 8x8-leaf refusal, and the two `--superres-mode=3` (auto) streams
1551+ // decode with ZERO scaled MC blocks -- auto picked denominator 8, so
1552+ // those two arms carry no scaling at all and prove nothing. The warp
1553+ // and sub-8x8 refusals never fire because the 8x8-leaf one sits in
1554+ // front of them: whichever partition path a scaled frame takes, the
1555+ // leaf guard is reached first. Lifting the leaf gap is what makes the
1556+ // other two measurable, so this gate pins the ORDER, not just a count.
1557+ assert!(decoded > 0, "no superres recipe decoded -- the census is vacuous");
1558+ assert!(
1559+ leaf8 > 0,
1560+ "no fixed-denominator recipe reached the 8x8-leaf refusal any more: either the \
1561+ capability landed (drop the refusal) or the recipes stopped scaling"
1562+ );
1563+ }
1564+
1231 /// lane-t900 r25, negative gate: a `show_existing_frame` header naming a1565 /// lane-t900 r25, negative gate: a `show_existing_frame` header naming a
1232 /// slot no frame has refreshed is refused BY NAME, and outputs no picture.1566 /// slot no frame has refreshed is refused BY NAME, and outputs no picture.
1233 ///1567 ///