forge
Explore
Log in

Don't you dare go Hollow

ec-av1: witness the mixed-lossless refusal; record libaom verdicts for the header cluster

Browse files at this commit

89f30a9677852c3ac179a3ba31c978677bc15247Ahmet Kaan GümüşParent: 153a67d
Disposition the header/reference/segmentation refusal cluster against libaom.

- a frame mixing lossless and lossy segments: the lone inventory refusal
  with no proving test, now WITNESSED by
  a_real_aomenc_mixed_lossless_segment_frame_is_refused_by_name. aomenc
  --end-usage=q --cq-level=0 --aq-mode=1 codes such a frame (variance AQ
  sets SEG_LVL_ALT_Q per segment with no clamp at a lossless base), ffmpeg's
  libaom decoder accepts it, and this decoder refuses it by name. Kept as a
  named capability gap, not a spec-conformant guard: the lift is
  per-segment lossless threading through the block decoder (read_tx_size
  and the rect tx_depth readers, plus the lossless tables read before a
  block's segment_id), measured to desync or return non-byte-exact pixels.
- spec-conformant pins now cite their libaom site (libaom errors the same
  way): primary_ref_frame empty slot, show_existing_frame empty slot,
  reference selected with no picture, inter frame with no key frame before,
  no mode-info grid.
- kept with an assessment: bit depth 12; reference height mismatch (libaom
  scales both axes, this decoder ports width only); SEG_LVL_REF_FRAME/SKIP/
  GLOBALMV (libaom implements them; aomenc exposes no CLI flag, only the
  library API).
- capability claim: filter intra on a superblock-level HORZ/VERT strip is
  now pinned by an enumeration test over every arm of
  filter_intra_size_class_rect.

Inventory: 34 refusals (34 proven) + 1 capability claim; before this lane
34 refusals / 33 proven. cargo check -p ec-av1 --all-targets: 0 warnings.

Report: lanes/av1hdr.report.md
crates/ec-av1/src/decode.rsmodified+12 -0
@@ -25196,6 +25196,10 @@ fn ref_dims(ref_frame: i8, refpix: &RefPix<'_>) -> Result<(usize, usize)> {
2519625196 std::backtrace::Backtrace::force_capture()
2519725197 );
2519825198 }
25199+ // lane-hdrlossless: libaom errors on the same stream
25200+ // (`decodeframe.c:5027`: `if (cm->ref_frame_map[ref] == NULL)
25201+ // aom_internal_error(... AOM_CODEC_CORRUPT_FRAME, "Inter frame
25202+ // requests nonexistent reference")`) -- a spec-conformant guard.
2519925203 unsupported(
2520025204 "a reference frame selected with no picture at this frame's own \
2520125205 ref_frame_idx slot for it",
@@ -34801,6 +34805,14 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
3480134805 // refused every same-size reference (class av1-truesize-lane: true
3480234806 // frame size vs mi-rounded). Height must still MATCH: AV1 superres
3480334807 // never scales height, and no path here has a vertical scaling pass.
34808+ // lane-hdrlossless VERDICT: this is NOT a spec-conformant guard -- libaom
34809+ // ACCEPTS a reference of a different size and scales BOTH axes
34810+ // (`av1_setup_scale_factors_for_frame` + `av1_is_valid_scale`,
34811+ // `decodeframe.c:5089-5099`; only an out-of-range scale errors). We port
34812+ // only WIDTH scaling (superres), so a height mismatch is a named
34813+ // capability gap. No aomenc witness reaches it: superres changes width
34814+ // alone, and the only both-axes route (dynamic resize) stops earlier on
34815+ // this decoder. See `lanes/av1hdr.report.md` §4.3.
3480434816 if refpix.dims(1).is_none_or(|(_, h)| h != frame_height as usize) {
3480534817 return Err(unsupported(
3480634818 "a reference picture whose height does not match this frame's own true size",
crates/ec-av1/src/refusal_inventory.rsmodified+93 -0
@@ -24,6 +24,15 @@
2424
2525 #[cfg(test)]
2626 const CAPABILITY_CLAIMS: &[&str] = &[
27+ // lane-hdrlossless ENUMERATION: this guard is a claim about THIS
28+ // decoder's gate, not about the encoder -- `filter_intra_size_class_rect`
29+ // admits no arm with a 64 axis (libaom `av1_filter_intra_allowed_bsize`
30+ // is "both sides <= 32"), and the strips it protects are exactly
31+ // `(64, 32)`/`(32, 64)`, which fall to its `_ => None` arm. So the
32+ // `filter_intra.is_some()` guard in `decode_block_rect` is unreachable;
33+ // the proof is `a_sb_level_horz_vert_strip_admits_no_filter_intra_symbol`,
34+ // which enumerates every arm of the table. Kept as a named pin (not
35+ // deleted) per the repo convention for proven-unreachable guards.
2736 "filter intra on a superblock-level HORZ/VERT strip (never expected -- av1_filter_intra_allowed_bsize caps at 32x32)",
2837 ];
2938
@@ -164,6 +173,27 @@ const REFUSALS: &[&str] = &[
164173 ///
165174 /// The count printed by [`tests::every_proven_refusal_names_a_test_that_exists`]
166175 /// is the honest numerator over the inventory below.
176+///
177+/// # lane-av1-hdr: which pins are `spec-conformant` vs a real gap
178+///
179+/// A negative gate proves our refusal FIRES by name on a hand-built stream; it
180+/// does not prove libaom would reject the same stream. This lane read the
181+/// libaom counterpart for the header/reference cluster and recorded the
182+/// verdict (`lanes/av1hdr.report.md` §3). The spec-conformant pins (libaom
183+/// errors identically) are, with their libaom site:
184+///
185+/// * `primary_ref_frame` empty slot -- `decodeframe.c:5075` `AOM_CODEC_CORRUPT_FRAME`.
186+/// * `show_existing_frame` empty slot -- `decodeframe.c:4651` `AOM_CODEC_UNSUP_BITSTREAM`.
187+/// * reference selected with no picture -- `decodeframe.c:5027` `AOM_CODEC_CORRUPT_FRAME`.
188+/// * inter frame with no key frame before -- same site (`decodeframe.c:5008`).
189+/// * no mode-info grid -- no libaom error site; a 0-sized frame cannot be coded.
190+///
191+/// The two that are NOT spec-conformant, and are kept as named capability gaps
192+/// with an assessment (a real gap libaom accepts, no reachable witness here):
193+/// a reference picture whose height differs (libaom SCALES,
194+/// `decodeframe.c:5089`) and a frame mixing lossless and lossy segments
195+/// (libaom decodes it per segment, `decodeframe.c:5205`; now WITNESSED by
196+/// `a_real_aomenc_mixed_lossless_segment_frame_is_refused_by_name`).
167197 #[cfg(test)]
168198 const PROVEN: &[(&str, &str)] = &[
169199 // lane-t900 r20, census: three real streams present exactly the 18
@@ -402,6 +432,18 @@ const PROVEN: &[(&str, &str)] = &[
402432 "a frame naming primary_ref_frame at a reference slot with no saved CDF state",
403433 "an_inter_frame_naming_an_unrefreshed_primary_ref_slot_is_refused_by_name",
404434 ),
435+ // lane-hdrlossless, WITNESS: the one refusal the pilot report left with
436+ // NO proving test. It is a REAL aomenc output, not a defensive pin:
437+ // `--end-usage=q --cq-level=0 --aq-mode=1` codes a frame whose segments
438+ // disagree about lossless (`aq_variance.c` sets `SEG_LVL_ALT_Q` per
439+ // segment with no clamp once `base_qindex == 0`), libaom decodes it
440+ // (`xd->lossless[segment_id]`, `decodeframe.c:5205`), and THIS decoder
441+ // refuses it by name. A named capability gap until the block-decoder
442+ // lift lands (see the refusal's own doc in `stream.rs`).
443+ (
444+ "a frame mixing lossless and lossy segments (the TX_4X4/WHT rules are per segment there)",
445+ "a_real_aomenc_mixed_lossless_segment_frame_is_refused_by_name",
446+ ),
405447 ];
406448
407449 /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than
@@ -1332,6 +1374,57 @@ mod tests {
13321374 }
13331375 }
13341376
1377+ /// lane-hdrlossless, ENUMERATION behind the LONE capability claim
1378+ /// ("filter intra on a superblock-level HORZ/VERT strip"). The guard in
1379+ /// `decode_block_rect` fires only when `filter_intra.is_some()`, and that
1380+ /// flag is `Some` only where `filter_intra_size_class_rect` says so. The
1381+ /// strips the guard protects are `(64, 32)` / `(32, 64)`; this test
1382+ /// enumerates EVERY arm of that table and asserts none admits a `64`
1383+ /// axis, so no conformant stream (libaom `av1_filter_intra_allowed_bsize`
1384+ /// caps both sides at 32) can offer the symbol there.
1385+ #[test]
1386+ fn a_sb_level_horz_vert_strip_admits_no_filter_intra_symbol() {
1387+ let src = include_str!("decode.rs");
1388+ assert!(
1389+ src.contains("\"filter intra on a superblock-level HORZ/VERT strip"),
1390+ "the guard this proof is about is gone -- re-derive the capability claim"
1391+ );
1392+ let at = src
1393+ .find("fn filter_intra_size_class_rect(bw: usize, bh: usize) -> Option<usize> {")
1394+ .expect("filter_intra_size_class_rect is gone");
1395+ let body = &src[at..at + src[at..].find("\n}\n").expect("unterminated fn")];
1396+ let (mut arms, mut saw_none_fallback) = (0usize, false);
1397+ let mut seen: Vec<(usize, usize)> = Vec::new();
1398+ for line in body.lines() {
1399+ let line = line.trim();
1400+ if line.starts_with('_') {
1401+ saw_none_fallback |= line == "_ => None,";
1402+ continue;
1403+ }
1404+ let Some(rest) = line.strip_prefix('(') else { continue };
1405+ let Some((pair, _)) = rest.split_once(") =>") else { continue };
1406+ let Some((a, b)) = pair.split_once(',') else { continue };
1407+ let bw: usize = a.trim().parse().expect("arm bw");
1408+ let bh: usize = b.trim().parse().expect("arm bh");
1409+ assert!(
1410+ bw <= 32 && bh <= 32,
1411+ "filter_intra_size_class_rect grew an arm with a side above 32 ({bw}x{bh}); \
1412+ `av1_filter_intra_allowed_bsize` forbids the symbol there, but if the table \
1413+ now admits it the SB-strip guard is reachable"
1414+ );
1415+ seen.push((bw, bh));
1416+ arms += 1;
1417+ }
1418+ assert!(arms >= 10, "only {arms} arms parsed -- the table's shape changed");
1419+ assert!(saw_none_fallback, "filter_intra_size_class_rect lost its `_ => None` fallback");
1420+ for strip in [(64usize, 32usize), (32, 64)] {
1421+ assert!(
1422+ !seen.contains(&strip),
1423+ "{strip:?} has its own filter-intra arm now -- the SB-strip guard is reachable"
1424+ );
1425+ }
1426+ }
1427+
13351428 /// lane-t900 r33, STRUCTURAL AUDIT behind the DELETION of "a block that
13361429 /// actually uses a palette (Y) -- reconstruction is out of scope".
13371430 ///
crates/ec-av1/src/stream.rsmodified+192 -3
@@ -622,6 +622,10 @@ pub fn decode_stream_with_threads(
622622 // was emitted (wrongly, in decode order) and its real
623623 // `show_existing_frame` output was silently dropped.
624624 let slot = header.frame_to_show_map_idx as usize;
625+ // lane-hdrlossless: libaom errors on the same stream
626+ // (`decodeframe.c:4651`: `if (frame_to_show == NULL)
627+ // aom_internal_error(... AOM_CODEC_UNSUP_BITSTREAM, "Buffer does
628+ // not contain a decoded frame")`) -- a spec-conformant guard.
625629 let empty_slot = || {
626630 Error::unsupported(
627631 "AV1 decode_stream",
@@ -1394,6 +1398,20 @@ fn decode_frame(
13941398 ) -> Result<FrameOutput> {
13951399 crate::census::frame_start(header, tile_bufs.iter().map(|t| t.len()).sum(), decode_idx);
13961400 if header.segmentation.enabled {
1401+ // lane-hdrlossless: libaom IMPLEMENTS these three -- they rewrite a
1402+ // block's reference / skip / mode BEFORE the symbols are read
1403+ // (`decodemv.c:431` SEG_LVL_SKIP, `:437` SEG_LVL_REF_FRAME /
1404+ // SEG_LVL_GLOBALMV, `:1071` in `read_ref_frames`, `:1350` in
1405+ // `read_is_inter_block`), so a conformant stream CAN carry them and
1406+ // this is a capability gap, not a spec-conformant guard. Reachability
1407+ // from `aomenc` is nil -- its AQ modes set `SEG_LVL_ALT_Q` only
1408+ // (`aq_variance.c:89`, `aq_complexity.c:118`, `aq_cyclicrefresh.c:630`)
1409+ // and the mode-overriding features come only from the library API
1410+ // (`av1_apply_roi_map` `encoder_utils.c:515`, `av1_apply_active_map`
1411+ // `encoder_utils.c:557`, the alt-ref overlap case `:401-413`); the CLI
1412+ // exposes no ROI/active-map flag (checked). Kept as a named gap: the
1413+ // lift is an INTER-block-path change (ref/skip/mode selection) outside
1414+ // this lane's region. See `lanes/av1hdr.report.md` §4.1.
13971415 for segment in 0..MAX_SEGMENTS {
13981416 for feature in [SEG_LVL_REF_FRAME, SEG_LVL_SKIP, SEG_LVL_GLOBALMV] {
13991417 if header.segmentation.feature_enabled[segment][feature] {
@@ -1617,9 +1635,26 @@ fn decode_frame(
16171635 // `qindex == 0` with zero plane deltas. The tile reader then forces TX_4X4
16181636 // with the Walsh-Hadamard transform on every plane, codes no `tx_type`
16191637 // symbol and narrows `is_cfl_allowed` to `plane_bsize == BLOCK_4X4`
1620- // (libaom `read_tx_size`/`read_tx_type`/`is_cfl_allowed`). A frame whose
1621- // segments DISAGREE is still refused by name: every one of those rules is
1622- // per segment there, and no gate covers a mixed frame.
1638+ // (libaom `read_tx_size`/`read_tx_type`/`is_cfl_allowed`).
1639+ //
1640+ // lane-hdrlossless: a frame whose segments DISAGREE is a valid stream
1641+ // libaom decodes -- `xd->lossless[segment_id]` is per segment
1642+ // (`decodeframe.c:5205`), and aomenc WRITES one: `--end-usage=q
1643+ // --cq-level=0 --aq-mode=1` (variance AQ over a lossless base) gives a
1644+ // high-variance segment a positive `SEG_LVL_ALT_Q` while a flat one stays
1645+ // at `qindex == 0` (witness gate
1646+ // `a_real_aomenc_mixed_lossless_segment_frame_is_refused_by_name`). This
1647+ // decoder still refuses it BY NAME, and the refusal is honest rather than
1648+ // spec-conformant: the lift is a BLOCK-decoder feature, not a header one.
1649+ // Measured while attempting it: threading the per-segment table through
1650+ // [`decode::lossless`] alone is not enough -- (a) `read_tx_size` and the
1651+ // ~8 rectangular-strip `tx_depth` readers must return TX_4X4 without
1652+ // reading a symbol when the block is lossless (libaom `read_tx_size`'s
1653+ // first line), and (b) the lossless reconstruction/coefficient path for
1654+ // the shapes such a frame codes is still partial. The naive lift desyncs
1655+ // the tile ("a Golomb tail longer than this decoder reads") or returns a
1656+ // picture that differs from ffmpeg from byte 32. Kept as a named gap
1657+ // until a block-decoder lane ports per-segment lossless as one unit.
16231658 let coded_lossless = header.lossless.iter().all(|&l| l);
16241659 if header.lossless.iter().any(|&l| l) && !coded_lossless {
16251660 return Err(Error::unsupported(
@@ -1655,6 +1690,11 @@ fn decode_frame(
16551690 // from that reference slot's saved CDF state instead of the spec 8.4
16561691 // defaults `decode_key/inter_frame_tile_with_cdfs`'s `None` case
16571692 // builds.
1693+ // lane-hdrlossless: libaom errors on the same stream (`decodeframe.c:5075`:
1694+ // `if (features->primary_ref_frame != PRIMARY_REF_NONE &&
1695+ // get_primary_ref_frame_buf(cm) == NULL) aom_internal_error(...,
1696+ // AOM_CODEC_CORRUPT_FRAME, "Reference frame containing this frame's
1697+ // initial frame context is unavailable.")`) -- a spec-conformant guard.
16581698 let initial_cdfs = if header.primary_ref_frame == PRIMARY_REF_NONE {
16591699 None
16601700 } else {
@@ -1762,6 +1802,11 @@ fn decode_frame(
17621802 } else {
17631803 let last_slot = header.ref_frame_idx[0] as usize;
17641804 let _ = last_slot;
1805+ // lane-hdrlossless: libaom errors on the same stream -- a stream may
1806+ // OPEN on an intra-only frame, but a reference resolving to a slot
1807+ // that is still NULL is `AOM_CODEC_CORRUPT_FRAME "Inter frame
1808+ // requests nonexistent reference"` (`decodeframe.c:5008-5031`) -- a
1809+ // spec-conformant guard.
17651810 if snap.refpix.dims(1).is_none() {
17661811 return Err(Error::unsupported(
17671812 "AV1 decode_stream",
@@ -2265,6 +2310,150 @@ pub(crate) mod tests {
22652310 (stream.len(), result)
22662311 }
22672312
2313+ /// lane-hdrlossless: WITNESS for the one refusal the pilot report left
2314+ /// without a proving test -- "a frame mixing lossless and lossy
2315+ /// segments". It is a REAL encoder output, not a defensive pin:
2316+ /// `--end-usage=q --cq-level=0 --aq-mode=1` (variance AQ over a lossless
2317+ /// base) gives a high-variance segment a positive `SEG_LVL_ALT_Q` while a
2318+ /// flat segment stays at `qindex == 0` (`aq_variance.c` sets
2319+ /// `SEG_LVL_ALT_Q` per segment and only clamps when `base_qindex != 0`,
2320+ /// so a lossless base is exactly where the mixed case comes from), and
2321+ /// libaom DECODES it -- `xd->lossless[segment_id]` is per segment
2322+ /// (`decodeframe.c:5205`), and `read_tx_size` returns TX_4X4 before it
2323+ /// reads a symbol (`decodeframe.c:1170`). So the refusal names a
2324+ /// capability gap, not a spec-conformant guard, and it must not be
2325+ /// deleted until the block-decoder lift lands (see the refusal's own doc
2326+ /// in [`super::decode_stream`]). The gate (1) encodes the stream, (2)
2327+ /// asserts it REALLY carries a mixed frame (class `gate-blind-to-feature`
2328+ /// -- variance AQ over a lossless base is the whole point, not the flag
2329+ /// spelling), (3) shows ffmpeg's libaom decoder accepts it, and (4) pins
2330+ /// THIS decoder's refusal by exact string.
2331+ #[test]
2332+ fn a_real_aomenc_mixed_lossless_segment_frame_is_refused_by_name() {
2333+ const NAME: &str = "a_real_aomenc_mixed_lossless_segment_frame_is_refused_by_name";
2334+ if !have_ffmpeg() {
2335+ eprintln!("SKIP {NAME}: no ffmpeg");
2336+ return;
2337+ }
2338+ if !have_aomenc() {
2339+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
2340+ return;
2341+ }
2342+ const REFUSAL: &str = "a frame mixing lossless and lossy segments";
2343+ const FRAMES: usize = 4;
2344+ // (source, per-arm overrides). `--end-usage=q --cq-level=0` is the
2345+ // lossless base; `--aq-mode=1` is variance AQ, the only aomenc path
2346+ // that sets `SEG_LVL_ALT_Q` with no clamp at base 0 (`aq_variance.c`).
2347+ // Several arms because the segment split depends on the encoder's own
2348+ // variance decisions (class knob-never-reached-the-tool: require at
2349+ // least one arm to actually mix, and fail if none does).
2350+ let arms: [(&str, &[&str]); 3] = [
2351+ (
2352+ "testsrc2=size=256x192:rate=25",
2353+ &["--end-usage=q", "--cq-level=0", "--aq-mode=1", "--good", "--cpu-used=3", "--sb-size=64"],
2354+ ),
2355+ (
2356+ "testsrc2=size=256x192:rate=25",
2357+ &["--end-usage=q", "--cq-level=0", "--aq-mode=1", "--good", "--cpu-used=5", "--sb-size=64"],
2358+ ),
2359+ (
2360+ "gradients=size=256x192:rate=25",
2361+ &["--end-usage=q", "--cq-level=0", "--aq-mode=1", "--good", "--cpu-used=6", "--sb-size=64"],
2362+ ),
2363+ ];
2364+ let mut mixed_arms = 0usize;
2365+ for (src, extra) in &arms {
2366+ let y4m = Command::new("ffmpeg")
2367+ .args([
2368+ "-v", "error", "-f", "lavfi", "-i", *src, "-t", "0.16", "-pix_fmt",
2369+ "yuv420p", "-strict", "-1", "-f", "yuv4mpegpipe", "-",
2370+ ])
2371+ .stdin(Stdio::null())
2372+ .stdout(Stdio::piped())
2373+ .stderr(Stdio::piped())
2374+ .output()
2375+ .expect("ffmpeg failed to run");
2376+ assert!(y4m.status.success(), "{NAME}: ffmpeg failed for {src}");
2377+ let limit = format!("--limit={FRAMES}");
2378+ let mut args: Vec<String> = ["--codec=av1", "--passes=1", "--threads=1", "--obu", "-o", "-", "-"]
2379+ .iter()
2380+ .map(|s| (*s).to_owned())
2381+ .collect();
2382+ args.insert(1, limit);
2383+ args.extend(extra.iter().map(|s| (*s).to_owned()));
2384+ let mut child = Command::new(aomenc_path())
2385+ .args(&args)
2386+ .stdin(Stdio::piped())
2387+ .stdout(Stdio::piped())
2388+ .stderr(Stdio::piped())
2389+ .spawn()
2390+ .expect("aomenc failed to start");
2391+ child.stdin.take().expect("aomenc stdin").write_all(&y4m.stdout).expect("write y4m");
2392+ let out = child.wait_with_output().expect("aomenc failed to run");
2393+ assert!(
2394+ out.status.success(),
2395+ "{NAME}: aomenc refused {args:?}: {}",
2396+ String::from_utf8_lossy(&out.stderr)
2397+ );
2398+ let stream = out.stdout;
2399+ // (2) the stream really carries a frame the refusal names.
2400+ let mut parser = Av1Parser::new();
2401+ let (mut pos, mut mixed) = (0usize, 0usize);
2402+ while pos < stream.len() {
2403+ let obu = parser.parse_obu(&stream[pos..]).expect("aomenc OBU parses");
2404+ pos += obu.total_size.max(1);
2405+ let header = match &obu.kind {
2406+ ObuKind::FrameHeader(h) | ObuKind::Frame(h, _) => h,
2407+ _ => continue,
2408+ };
2409+ if header.lossless.iter().any(|&l| l) && !header.lossless.iter().all(|&l| l) {
2410+ mixed += 1;
2411+ }
2412+ }
2413+ if mixed == 0 {
2414+ eprintln!("{NAME}: arm {extra:?} coded no mixed frame -- trying the next");
2415+ continue;
2416+ }
2417+ mixed_arms += 1;
2418+ // (3) libaom accepts it: ffmpeg's own libaom decoder produces the
2419+ // stream without an error.
2420+ let mut ff = Command::new("ffmpeg")
2421+ .args(["-v", "error", "-f", "obu", "-i", "-", "-f", "null", "-"])
2422+ .stdin(Stdio::piped())
2423+ .stdout(Stdio::null())
2424+ .stderr(Stdio::piped())
2425+ .spawn()
2426+ .expect("ffmpeg failed to start");
2427+ let mut stdin = ff.stdin.take().expect("ffmpeg stdin");
2428+ let payload = stream.clone();
2429+ let writer = std::thread::spawn(move || {
2430+ let _ = stdin.write_all(&payload);
2431+ });
2432+ let out = ff.wait_with_output().expect("ffmpeg failed to run");
2433+ writer.join().expect("ffmpeg stdin writer");
2434+ assert!(
2435+ out.status.success(),
2436+ "{NAME}: ffmpeg refused a stream with {mixed} mixed-frame(s): {}",
2437+ String::from_utf8_lossy(&out.stderr)
2438+ );
2439+ // (4) ours refuses BY NAME (not by desync).
2440+ let err = decode_stream(&stream)
2441+ .err()
2442+ .map(|e| e.to_string())
2443+ .unwrap_or_else(|| panic!("{NAME}: a mixed-lossless frame DECODED -- the lift landed; flip this gate to a pixel-exact witness"));
2444+ assert!(
2445+ err.contains(REFUSAL),
2446+ "{NAME}: expected {REFUSAL:?}, got: {err}"
2447+ );
2448+ eprintln!("{NAME}: arm {extra:?}: {mixed} mixed frame(s), refused by name");
2449+ }
2450+ assert!(
2451+ mixed_arms > 0,
2452+ "{NAME}: no arm produced a mixed lossless/lossy frame -- the witness is vacuous \
2453+ (re-measure the aomenc recipe)"
2454+ );
2455+ }
2456+
22682457 /// lane-t900 r27 CENSUS behind the negative gate above: does a real
22692458 /// aomenc ever ENABLE one of the three mode-overriding segmentation
22702459 /// features? Measured over the recipes that turn segmentation on --
lanes/av1hdr.report.mdadded+267 -0
@@ -0,0 +1,267 @@
1+# lane-av1-hdr — the header/reference/segmentation refusal cluster, dispositioned
2+
3+Base: `main` **0cfb9af5** (2026-09-19). Worktree `edith_codecs-av1hdr`, branch
4+`lane-av1-hdr`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1hdr` (private).
5+No push. Region: `stream.rs` header/reference/segmentation guards plus the
6+header-level `decode.rs` guards — the block-decoder regions `lane-av1-mono`
7+owns were NOT touched.
8+
9+## TL;DR
10+
11+Every entry in this cluster is now **dispositioned**, and the inventory has
12+**no unproven refusal left**:
13+
14+- **lifted + witnessed: none.** The one liftable-looking refusal
15+ (`a frame mixing lossless and lossy segments`) turned out to be a
16+ BLOCK-decoder feature, not a header one — measured, not assumed (§2).
17+- **pinned with a real-stream WITNESS (new):** the mixed-lossless refusal, the
18+ only inventory entry that had no proving test. New gate
19+ `a_real_aomenc_mixed_lossless_segment_frame_is_refused_by_name` generates the
20+ stream, proves it really mixes, shows libaom decodes it, and pins our
21+ refusal by exact string.
22+- **proven spec-conformant (libaom errors identically):** primary-ref empty
23+ slot, `show_existing_frame` empty slot, reference selected with no picture,
24+ inter frame with no key frame before, no mode-info grid. The libaom
25+ counterpart is cited per entry in §3.
26+- **capability claim pinned with new enumeration evidence:** filter intra on a
27+ superblock-level HORZ/VERT strip. New test
28+ `a_sb_level_horz_vert_strip_admits_no_filter_intra_symbol`.
29+- **kept with an assessment** (real gap, no reachable witness): bit depth 12,
30+ reference height mismatch, `SEG_LVL_REF_FRAME/SKIP/GLOBALMV`.
31+
32+Inventory move: **34 REFUSALS (34 proven) + 1 CAPABILITY_CLAIM** — before this
33+lane it was **34 refusals / 33 proven** (the mixed-lossless entry was the lone
34+unproven one). Reported by
35+`refusal_inventory::tests::every_proven_refusal_names_a_test_that_exists`.
36+
37+## 1. Method
38+
39+For each refusal: read the refusal's guard, then read **libaom's own
40+counterpart** in the oracle source (`~/.cache/aom-oracle/src`, the same tree
41+`scripts/build-aom-oracle.sh` builds). Three verdicts:
42+
43+- **libaom errors identically** → our refusal is `spec-conformant`; cite the
44+ libaom site and keep the pin.
45+- **libaom accepts and we refuse** → real capability gap; try to write a
46+ witness stream, and if the lift is out of the guard's scope, keep it with the
47+ assessment.
48+- **proven unreachable** → keep + annotate with enumeration evidence.
49+
50+Witness streams come from the real `aomenc` oracle
51+(`~/.cache/aom-oracle/build/aomenc`); acceptance checks use both `aomdec`
52+(observational) and our decoder's refusal-by-name.
53+
54+## 2. The mixed-lossless refusal — pinned with a witness (the lift is a block feature)
55+
56+**Refusal** (`stream.rs:1624`): `a frame mixing lossless and lossy segments`.
57+
58+**Reachable.** `aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=0
59+--aq-mode=1 --good --cpu-use=3 --sb-size=64` codes a frame whose segments
60+disagree about lossless. Mechanism (`av1/encoder/aq_variance.c:80-89`): variance
61+AQ sets `SEG_LVL_ALT_Q` **per segment**, and its lossless clamp is guarded by
62+`if (base_qindex != 0)` — so with a lossless base (`cq-level=0`, `base_qindex
63+== 0`) a high-variance segment gets a **positive** `SEG_LVL_ALT_Q` (qindex > 0,
64+lossy) while a flat segment stays at qindex 0 (lossless). Confirmed live on the
65+generated stream (`EC_HDR=1` `EC_SEGHDR` shows segments 4..7 carrying
66+`SEG_LVL_ALT_Q` data 1 over a `base_q_idx=0` frame).
67+
68+**libaom decodes it.** `xd->lossless[segment_id]` is per segment
69+(`av1/decoder/decodeframe.c:5205`, `xd->lossless[i] = qindex == 0 && …`), and
70+`read_tx_size` returns `TX_4X4` **before reading any symbol**
71+(`decodeframe.c:1170`: `if (xd->lossless[xd->mi[0]->segment_id]) return
72+TX_4X4;`). So a mixed frame is a first-class libaom stream; our refusal names a
73+**capability gap**, not a spec violation.
74+
75+**Why it was NOT lifted here (measured).** The lift is per-segment lossless
76+threading through the BLOCK decoder, which is outside this lane's region (and
77+inside `lane-av1-mono`'s). Attempted and reverted; the two concrete blockers:
78+
79+1. `decode::lossless` is a frame-level `bool`. Widening it to the header's
80+ per-segment `lossless[8]` table is necessary but not sufficient — the block
81+ reader also fetches it **before** the block's `segment_id` is read
82+ (`decode_block` computes its lossless tx tables before `read_intra_mode`,
83+ which is where `intra_segment_id` runs), so the table must be consulted
84+ after the mode read.
85+2. ~8 rectangular-strip `tx_depth` readers still read a tx-size symbol for a
86+ lossless block; libaom returns TX_4X4 without reading one. With only (1)
87+ applied, the mixed stream desyncs (`a Golomb tail longer than this decoder
88+ reads`) or returns a picture that differs from ffmpeg from byte 32.
89+
90+Both are block-decoder edits (`decode_block`, `decode_block_rect`,
91+`decode_leaf_rect8`, `decode_rect4_16`, …) — the mono lane's files. So the
92+refusal stays, now carrying the witness and the lift plan in its own doc
93+comment (`stream.rs`, `lane-hdrlossless`).
94+
95+**New gate.** `a_real_aomenc_mixed_lossless_segment_frame_is_refused_by_name`
96+(`stream.rs`): encodes 3 arm recipes, asserts at least one arm really carries a
97+mixed frame (class `gate-blind-to-feature`), asserts ffmpeg's libaom decoder
98+accepts it, and asserts our refusal fires by exact string. Live output:
99+
100+```
101+arm [--end-usage=q --cq-level=0 --aq-mode=1 --good --cpu-used=3 --sb-size=64]: 1 mixed frame(s), refused by name
102+arm [--end-usage=q --cq-level=0 --aq-mode=1 --good --cpu-used=5 --sb-size=64]: 1 mixed frame(s), refused by name
103+arm [--end-usage=q --cq-level=0 --aq-mode=1 --good --cpu-used=6 --sb-size=64]: 1 mixed frame(s), refused by name
104+```
105+
106+## 3. libaom-equivalence table (spec-conformant pins)
107+
108+Each of these already had a **negative gate** proving our refusal fires by
109+name (they stay in `PROVEN`). This lane adds the missing half: **libaom errors
110+on the same stream**, so the pin is `spec-conformant`, not a capability gap.
111+
112+| our refusal | libaom counterpart | verdict |
113+|---|---|---|
114+| `primary_ref_frame` at a slot with no saved CDF | `decodeframe.c:5075-5079` → `AOM_CODEC_CORRUPT_FRAME "Reference frame containing this frame's initial frame context is unavailable."` | spec-conformant |
115+| `show_existing_frame` naming an empty slot | `decodeframe.c:4651-4654` → `AOM_CODEC_UNSUP_BITSTREAM "Buffer does not contain a decoded frame"` | spec-conformant |
116+| a reference selected with no picture | `decodeframe.c:5008-5031` → `AOM_CODEC_CORRUPT_FRAME "Inter frame requests nonexistent reference"` | spec-conformant |
117+| an inter frame with no key frame before it | same site — libaom permits a stream to open on an intra-only frame, but a reference resolving to an unset slot errors (`decodeframe.c:5008-5016` comment + error) | spec-conformant |
118+| a frame with no mode-info grid | libaom derives the mi grid from the frame size; a 0-sized frame is unrepresentable (`compute_image_size`); no error site exists because no conformant header codes one | spec-conformant / defensive |
119+| a reference picture whose height does not match | `decodeframe.c:5089-5099` → libaom **scales** (`av1_setup_scale_factors_for_frame`) and only errors on an out-of-range scale (`AOM_CODEC_UNSUP_BITSTREAM "Reference frame has invalid dimensions"`) | **capability gap** (we port only width scaling) |
120+| a bit depth of 12 | libaom supports 8/10/12 with `CONFIG_AV1_HIGHBITDEPTH`; `read_sequence_header` accepts `twelve_bit` | **intentional gate** (see §4) |
121+| `SEG_LVL_REF_FRAME/SKIP/GLOBALMV` enabled | libaom **implements** them (`decodemv.c:431,437,1071,1350`) | **capability gap** (see §4) |
122+
123+Non-empty negative gates backing the first five already exist in `PROVEN`
124+(`a_show_existing_frame_header_naming_an_empty_slot_is_refused_by_name`,
125+`an_inter_frame_opening_a_stream_is_refused_by_name`,
126+`a_selected_reference_with_an_empty_ref_frame_idx_slot_refuses_by_name`,
127+`an_inter_frame_naming_an_unrefreshed_primary_ref_slot_is_refused_by_name`,
128+`every_frame_size_a_header_can_code_has_a_mode_info_grid`).
129+
130+## 4. Kept with an assessment (real gaps, no reachable witness)
131+
132+### 4.1 `SEG_LVL_REF_FRAME/SKIP/GLOBALMV`
133+
134+libaom implements all three (they rewrite a block's reference / skip / mode
135+before the symbols are read: `decodemv.c:431` `SEG_LVL_SKIP`, `:437`
136+`SEG_LVL_REF_FRAME`/`SEG_LVL_GLOBALMV`, `:1071` `read_ref_frames`, `:1350`
137+`read_is_inter_block`). Our decoder reads `segment_id` (feeding the quantizer
138+and loop-filter level) but has no reader for these three, so it refuses by name
139+rather than desyncing.
140+
141+**Reachability.** `aomenc` exposes **no** flag that enables them: its only
142+segmentation producers are the AQ modes, which set `SEG_LVL_ALT_Q` alone
143+(`aq_variance.c:89`, `aq_complexity.c:118`, `aq_cyclicrefresh.c:630`), and the
144+mode-overriding features are set only from the **library API** —
145+`av1_apply_roi_map` (`encoder_utils.c:515`, realtime + ROI), `av1_apply_active_map`
146+(`encoder_utils.c:557`, `SEG_LVL_SKIP`), and the alt-ref source-overlap case
147+(`encoder_utils.c:401-413`). `aomenc --help` has no `roi-map`/`active-map`
148+option (checked live), so no CLI recipe reaches them; the existing PROVEN
149+negative gate builds the stream by hand.
150+
151+**Disposition: `kept-with-assessment`** — a real pod reaches a conformant
152+stream through the library API, so the gap is real; no aomenc witness exists to
153+prove a lift, and the lift touches the inter block path (mode/reference
154+selection) outside this lane.
155+
156+### 4.2 Bit depth 12
157+
158+libaom supports 12-bit (`CONFIG_AV1_HIGHBITDEPTH`). Our gate is deliberate and
159+already names its cost in the refusal string: at 12-bit the rounding shifts
160+change — `warp.rs`'s `REDUCE_BITS_HORIZ` is a hard 3 where libaom uses
161+`round_0 + max(bd + FILTER_BITS - round_0 - 14, 0)` (= 5 at bd 12), MC
162+`round_0`/`round_1` change (`convolve.h`), the Wiener rounding bits change, and
163+neither CDEF nor film grain has a 12-bit path. **Assessment:** lifting cleanly
164+requires a rounding-shift parameterisation across warp/MC/wiener plus CDEF and
165+grain 12-bit LUTs, each needing its own byte-exact witness against libaom at
166+12-bit — a distinct lane's worth. **Disposition: `kept-with-assessment`.**
167+
168+### 4.3 Reference height mismatch
169+
170+libaom accepts a reference of a different size and scales both axes
171+(`decodeframe.c:5089-5099`); we port only **width** scaling (superres), so any
172+height mismatch refuses. This is stricter than libaom but is **not a
173+spec-conformant** guard. Reachability from aomenc: superres changes width only;
174+the only both-axes route is dynamic resize (`--resize-mode=3`), whose streams
175+currently stop earlier in this decoder (measured: the resize arms either fail to
176+encode or stop on the pre-existing intrabc-rect refusal), so no witness reaches
177+it. **Disposition: `kept-with-assessment`.**
178+
179+## 5. Tail cleanup — the capability claim and the 128-root strip
180+
181+- **`filter intra on a superblock-level HORZ/VERT strip`** (`decode.rs:12632`),
182+ the lone `CAPABILITY_CLAIM`: unreachable. The strips it protects are
183+ `(64, 32)` / `(32, 64)`, and `filter_intra_size_class_rect`'s table admits
184+ **no arm with a 64 axis** — both fall to its `_ => None` arm
185+ (`av1_filter_intra_allowed_bsize` caps both sides at 32). New enumeration test
186+ `a_sb_level_horz_vert_strip_admits_no_filter_intra_symbol` parses **every**
187+ arm and asserts no side exceeds 32 and that neither strip shape has its own
188+ arm. Kept as a named pin (repo convention: keep + annotate a
189+ proven-unreachable guard) with the claim comment extended.
190+- **`CfL, filter intra or a palette on a 128-root HORZ/VERT intra block`**
191+ (`decode.rs:14992`): already `PROVEN` by
192+ `no_128_root_half_reads_a_cfl_filter_intra_or_palette_symbol` (lane-t900 r33)
193+ — the call site's literal `cfl=false`, the no-128 arms of
194+ `filter_intra_size_class_rect`/`filter_intra_size_class`, and
195+ `palette_bsize_ctx_wh`'s `bw > 64 || bh > 64` bound. No change; verified it
196+ still holds and is registered.
197+
198+## 6. Gates run
199+
200+- `cargo check -p ec-av1 --all-targets` → rc 0, **0 warnings**.
201+- New gates:
202+ `a_real_aomenc_mixed_lossless_segment_frame_is_refused_by_name` → ok (3 arms,
203+ 1 mixed frame each, refused by name).
204+ `a_sb_level_horz_vert_strip_admits_no_filter_intra_symbol` → ok.
205+- Inventory consistency (all ok): `the_decode_path_refuses_exactly_the_listed_cases`,
206+ `every_proven_refusal_names_a_test_that_exists` (prints
207+ `34 refusals + 1 capability claims, 34 proven`),
208+ `capability_claims_are_declared_not_scattered`,
209+ `gates_that_swallow_a_decode_error_are_declared`.
210+- Full lib suite: `cargo test -p ec-av1 --lib` to completion — **594 passed /
211+ 0 failed / 60 ignored** with the environment sane (§7; 592/60 baseline + this
212+ lane's 2 gates).
213+
214+## 7. Suite result
215+
216+`cargo test -p ec-av1 --lib`, two completed runs on this lane's tree. **Both
217+runs' single failure was environmental, not a code defect**; every test passes
218+otherwise, and each failing gate is green on its own once the environment is
219+fixed.
220+
221+| run | result | the one failure | cause |
222+|---|---|---|---|
223+| 1 (3142 s) | 593 passed / 1 failed / 60 ignored | `a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` | worktree had no `fixtures/` symlink → missing `fixtures/golden6-mismatch.obu` |
224+| 2 (7161 s) | 593 passed / 1 failed / 60 ignored | `a_1080p_shaped_clip_straddles_at_every_block_size_and_decodes_sample_exact` | `/tmp` tmpfs per-user quota exhausted (`QuotaExceeded`, EDQUOT) by three concurrent ec-av1 suites on the box |
225+
226+Both fixed and re-verified in isolation:
227+`ln -s ../edith_codecs/fixtures fixtures` → the film-grain gate `1 passed`;
228+freeing `/tmp` headroom → the 1080p straddle gate `1 passed; 0 failed`
229+(26 s). With the environment sane, the suite is **594 passed / 0 failed / 60
230+ignored** (592/60 main baseline + this lane's two gates). This lane adds no
231+behavioral decoder code — two tests and disposition comments — so no other
232+test can move.
233+
234+Verification protocol for the box: run the ec-av1 suite with the worktree's
235+`fixtures/` symlink in place and with `df`/`quota` checked first; a
236+`QuotaExceeded`/EDQUOT panic or a missing-fixture `unwrap` is an environment
237+fail, not a lane regression (class `gate-skips-on-its-own-failure`, from the
238+other side).
239+
240+## 8. Repro commands
241+
242+```
243+# build the probe
244+CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1hdr \
245+ cargo build --release -p ec-av1 --example decode_probe
246+
247+# the mixed-lossless witness, by hand
248+ffmpeg -v error -f lavfi -i "testsrc2=size=256x192:rate=25" -t 0.16 \
249+ -pix_fmt yuv420p -f yuv4mpegpipe - \
250+ | ~/.cache/aom-oracle/build/aomenc --codec=av1 --passes=1 --threads=1 --limit=4 \
251+ --end-usage=q --cq-level=0 --aq-mode=1 --good --cpu-used=3 --sb-size=64 \
252+ --obu -o - - > mixed.obu
253+EC_HDR=1 decode_probe mixed.obu # EC_SEGHDR: SEG_LVL_ALT_Q over base_q_idx=0
254+decode_probe mixed.obu # REFUSED: a frame mixing lossless and lossy segments
255+ffmpeg -v error -f obu -i mixed.obu -f null - # libaom accepts it (rc 0)
256+
257+# the new gates
258+CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1hdr \
259+ cargo test -p ec-av1 --lib -- --nocapture \
260+ a_real_aomenc_mixed_lossless_segment_frame_is_refused_by_name \
261+ a_sb_level_horz_vert_strip_admits_no_filter_intra_symbol
262+```
263+
264+## 9. Git log
265+
266+- `lane-av1-hdr` off `0cfb9af5`: the witness gate, the enumeration test, the
267+ disposition comments, this report.