forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1422lift: the 4:2:2 sequence-header refusal is lifted -- 4:2:2 decodes

Browse files at this commit

05c4451a5dc2f15560f26f8ac11417c0b4c39f4eAhmet Kaan GümüşParent: 376e8c7b5eb369
The user's decision was fix the diverging cells, then lift. The cells are fixed (the last one closes in `a115abae`),
and this is the lift: the guard at `stream.rs:1803-1808` is gone, its residual -- the uncodable 4:4:0 `(0,1)` shape,
which the parser cannot produce because `subsampling_y` is read only when `subsampling_x == 1` -- closes with an
**assertion** rather than a comment or a refusal string, per this repo's rule. The `REFUSALS` row and its `PROVEN`
tuple retire **in the same commit**, because `the_decode_path_refuses_exactly_the_listed_cases` asserts both
directions empty and a partial retirement fails it.

Verified before merge, by Main and independently:
- **Format-independence (the real risk)**: 45 committed 4:2:0/4:4:4 fixtures (8/10/12-bit, lossless, superres,
  grain, odd geometries) decode **byte-identical** between `4f206ec3` and this branch.
- **The engine of the change**: the parser provably produces only `{(1,1),(0,0),(1,0)}`, so the new assertion is
  sound and reachable only with a parsed header; **all three inventory deletions are independently load-bearing**
  (3/3 mutations red).
- **The gates bite**: all six inverted `the_pinned_422_*_decode_pixel_exact` tests plus three new pixel gates red
  on a shape-preserving one-LSB decoder mutation, and the shared 4:2:2 body asserts both the plane SHAPE
  (half-width x full-height -- a stray 4:2:0 allocation fails it) and a **non-zero census delta**, so it cannot be
  green while exercising nothing.
- **Fixtures**: the two pins the old tests used were a 4:2:2 header bolted onto a 4:2:0 tile from this crate's own
  encoder -- one of them is ffprobe-INVALID -- so they carried no oracle and could not be inverted into exactness
  claims. They are replaced by real libaom 4:2:2 streams, pinned by sha256 + fnv1a64.
- **Honesty layer**: six prose sites in the first cut claimed readers no gate has; a review pass measured the truth
  (`SB128RECT_REPLAY_SPAN_MISMATCH_HITS` reads 9 on a pin this very branch asserts byte-exact, NXN is unwitnessed at
  0 on all 21 committed 4:2:2 cells) and the comments were corrected in a prose-only commit. Notably, the promised
  "assert it stays zero on 4:2:2" would have RED a gate on a provably correct cell.

16 changed files +1199 -224

crates/ec-av1/examples/gen_coverage_cells.rsmodified+18 -10
@@ -29,12 +29,17 @@
2929 //! the format ("yuv4mpeg can only handle yuv444p, yuv422p, yuv420p,
3030 //! yuv411p and gray8") are consequences of that, not the reason. The pin
3131 //! is the byte-level evidence: a 4:4:0 request at profile 2 (4:2:2, and
32-//! no coded subsampling bit below 12 bits) lands on `(1,0)`, the shape
33-//! this decoder refuses by name. The frame OBU behind it is a real 4:2:0
34-//! key frame's, byte for byte -- the subsampling lives only in the
35-//! sequence header -- so the pin is a HEADER witness, not a decodable
36-//! 4:2:2 stream, and the gate
37-//! `the_440_cell_is_not_a_codable_chroma_shape` says exactly that.
32+//! no coded subsampling bit below 12 bits) lands on `(1,0)`. The frame OBU
33+//! behind it is a real 4:2:0 key frame's, byte for byte -- the subsampling
34+//! lives only in the sequence header -- so the pin is a HEADER witness, NOT
35+//! a decodable 4:2:2 stream. lane-av1422lift: it was never decodable as
36+//! one; the decoder used to refuse it at the sequence header, and now
37+//! admits the header, which is exactly why this pin may not be turned into
38+//! a 4:2:2 exactness gate. The gate
39+//! `the_440_cell_is_not_a_codable_chroma_shape` says exactly that, and the
40+//! real 4:2:2 exactness lives in `a_real_422_stream_decodes_pixel_exact`
41+//! and `the_pinned_422_corpus_cells_decode_pixel_exact`, which read
42+//! genuinely 4:2:2 pins.
3843 //!
3944 //! ```text
4045 //! cargo run -p ec-av1 --example gen_coverage_cells -- crates/ec-av1/fixtures
@@ -252,9 +257,11 @@ fn main() {
252257 // OBU behind it is a real 4:2:0 key frame's, byte for byte: the
253258 // subsampling lives only in the sequence header, so the frame header is
254259 // the same one either way. The stream is NOT a decodable 4:2:2 stream
255- // (its tile is 4:2:0); it is pinned as the byte-level evidence for the
256- // claim, and the decoder refuses it by name, which is the honest
257- // outcome for the shape the request lands on.
260+ // (its tile is 4:2:0). lane-av1422lift: the decoder no longer refuses it
261+ // by name, and that is NOT an endorsement -- the header now claims 4:2:2
262+ // over a 4:2:0 tile, so a decode of these bytes is a header/tile
263+ // mismatch. This pin stays a byte-level shape witness; every 4:2:2
264+ // exactness claim lives on genuinely 4:2:2 pins in `stream.rs`.
258265 let tile_stream = ec_av1::encode::encode_key_frame(&card(WITNESS, WITNESS), Q_IDX, 0.5)
259266 .expect("encoding the witness tile")
260267 .stream;
@@ -306,7 +313,8 @@ fn main() {
306313 );
307314 println!(
308315 "440_request_is_422: asked for subsampling (0,1) at profile {} -- got ({sx},{sy}) at \
309- max_frame {mw}x{mh}, i.e. 4:2:2, the shape this decoder refuses by name; frame header + \
316+ max_frame {mw}x{mh}, i.e. 4:2:2 (DECODED since lane-av1422lift, but these bytes carry \
317+ a 4:2:0 tile, so the pin is a shape witness and not an exactness witness); frame header + \
310318 one tile ({} bytes) from a 4:2:0 {WITNESS}x{WITNESS} key frame",
311319 seq.seq_profile,
312320 frame_bytes.len()
crates/ec-av1/fixtures/422_inter_160x128_3f.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/422_key_64x64.obuadded+0 -0

Binary file changed

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

Binary file changed

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

Binary file changed

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

Binary file changed

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

Binary file changed

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

Binary file changed

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

Binary file changed

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

Binary file changed

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

Binary file changed

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

Binary file changed

crates/ec-av1/src/decode.rsmodified+50 -16
@@ -2875,9 +2875,16 @@ thread_local! {
28752875 /// Chroma units of the same walk whose grid is exactly 1x2 (4:4:4 32x64,
28762876 /// or 16x64 as two 16x32s).
28772877 static RECT_TILED_CHROMA_1X2_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2878- /// Chroma units of the same walk in any other multi-unit grid (2x2 and up
2879- /// -- only reachable at 4:2:2, which is refused, so this stays 0 on
2880- /// every admitted stream; kept so the match above is exhaustive).
2878+ /// Chroma units of the same walk in any other multi-unit grid (2x2 and
2879+ /// up). lane-av1422lift: this used to say "only reachable at 4:2:2, which
2880+ /// is refused, so this stays 0 on every admitted stream", and that was
2881+ /// true. 4:2:2 is decoded now, so the "cannot happen" is gone -- but the
2882+ /// arm is still UNWITNESSED: measured on this branch's tip over all 21
2883+ /// committed 4:2:2 cells and over the 4:2:0 / 4:4:4 cells probed, it
2884+ /// reads 0 on every one of them. No committed gate reads it either (the
2885+ /// only readers of `rect_tiled_chroma_grid_hits()` are two 4:4:4 strip
2886+ /// gates, where `nxn` is interpolated into a failure message and never
2887+ /// asserted). Kept so the match above is exhaustive.
28812888 static RECT_TILED_CHROMA_NXN_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
28822889 }
28832890
@@ -6155,9 +6162,17 @@ thread_local! {
61556162
61566163 // lane-av1422luma: the ss (1,0) twin of `INTRABC_RECT4_OWN_CHROMA444_HITS`
61576164 // -- how many intra-BC 1:4 strips at 4:2:2 took the own-chroma (no pair)
6158-// route. Same caveat as the 4:4:4 counter: it proves REACH and nothing else,
6159-// and 4:2:2 is refused at the sequence header, so no committed test can read
6160-// it (the count in `lanes/av1422luma.report.md` is from a bypassed probe build).
6165+// route. Same caveat as the 4:4:4 counter: it proves REACH and nothing else.
6166+// lane-av1422lift: 4:2:2 is DECODED, so this counter is no longer pinned
6167+// behind a header refusal -- and it DOES fire: measured on this branch's tip,
6168+// the six committed corpus cells each read 1 more than the cell before
6169+// (`s422_320x246` 1, `s422_322x240` 2, `s422_322x246` 3, `s422_352x242_10b`
6170+// 4, `s422_416x242_10b` 5, `s422_416x250_10b` 6), and every other committed
6171+// 4:2:2 cell leaves it at 6. **No committed gate reads it**: the accessor
6172+// below has no callers in the crate (the 4:4:4 twin is read at two
6173+// `stream.rs` sites, this one nowhere). The honest sentence is therefore
6174+// "no committed test reads this counter", which is what the 4:4:4 twin's
6175+// doc says about itself -- it does NOT become "the corpus gate reads it".
61616176 thread_local! {
61626177 static INTRABC_RECT4_OWN_CHROMA422_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
61636178 }
@@ -17024,9 +17039,14 @@ fn decode_block_rect4(
1702417039 // 4:2:0 codes 16x4/4x16 (`TxbSet::Chroma8`); 4:4:4 codes the strip
1702517040 // itself, 32x8/8x32 (`get_txsize_entropy_ctx(TX_32X8)` =
1702617041 // `(wide_log2 + high_log2 + 1) >> 1` = the 16x16 set,
17027- // `TxbSet::Chroma16`). The caller set is closed -- this reader only
17028- // ever sees 32x8 / 8x32 luma and the sequence header admits ss 0/0
17029- // and 1/1 only -- so the table is exhaustive.
17042+ // `TxbSet::Chroma16`). The caller set is closed -- this reader only ever
17043+ // sees 32x8 / 8x32 luma. lane-av1422lift: this sentence used to end "and
17044+ // the sequence header admits ss 0/0 and 1/1 only -- so the table is
17045+ // exhaustive", which was a claim about a guard rather than about this
17046+ // reader. The header admits ss (1,1), (1,0) and (0,0), and the (1,0)
17047+ // 4:2:2 arm is dispatched a few lines below (`chroma422_rect32`), so the
17048+ // table's exhaustiveness comes from the reader's own luma shape -- which
17049+ // is what the sentence now claims.
1703017050 let chroma422_rect32 = (chroma_w, chroma_h) == (4, 32) && ss_x(fctx) == 1 && ss_y(fctx) == 0;
1703117051 let (chroma_set, chroma_scan): (TxbSet, &[u16]) = match (chroma_w, chroma_h) {
1703217052 (16, 4) => (TxbSet::Chroma8, &SCAN_16X4[..]),
@@ -23425,13 +23445,27 @@ thread_local! {
2342523445 /// ... and the number of non-skip 128-root rect BLOCKS whose replay
2342623446 /// height differs from the unit's own LUMA-MI height -- the signature of the
2342723447 /// width passed to both axes (`luma_span` where the in-loop stamp used
23428- /// `luma_span_h`). Zero on every stream this decoder admits: both
23429- /// supported chroma formats have `ss_x == ss_y` (4:2:0 and 4:4:4), and
23430- /// 4:2:2 -- the one format whose two spans differ -- is refused by name
23431- /// at the sequence header (`stream::decode_frame`), so the arm is
23432- /// defensive until that format is ported. The counter turns a future
23433- /// 4:2:2 admission (or any hardcoded span) into a named red gate instead
23434- /// of silent mi-state corruption.
23448+ /// `luma_span_h`). lane-av1422lift: the doc here used to read "Zero on
23449+ /// every stream this decoder admits ... 4:2:2 ... is refused by name at
23450+ /// the sequence header", and that was TRUE. Admitting 4:2:2 genuinely made
23451+ /// this counter able to fire, and it does fire: measured on this branch's
23452+ /// tip over all 21 committed 4:2:2 cells, `422_intrabc_sb128_strip.obu`
23453+ /// and `422_intrabc_sb128_strip_notxsearch.obu` each read
23454+ /// `replay = 72, mismatch = 9`; the other 19 read 0.
23455+ ///
23456+ /// **Those two pins are byte-exact against ffmpeg**
23457+ /// (`the_pinned_422_intrabc_sb128_strip_witnesses_decode_pixel_exact`, all
23458+ /// five frames, every plane), so a non-zero mismatch is NOT a defect
23459+ /// signature at 4:2:2 -- it is the arm counting its own designed case.
23460+ /// Nothing here asserts zero, and nothing should: adding a zero assert
23461+ /// would red a gate on a cell that is provably correct.
23462+ ///
23463+ /// The only readers of the pair are
23464+ /// [`sb128rect_chroma_replay_hits`]'s two gates, both on 4:4:4 and 4:2:0
23465+ /// streams, where the unit's luma width and height are equal so the
23466+ /// mismatch half is structurally zero. That is the zero this counter is
23467+ /// currently a tripwire FOR, and it is a statement about those two
23468+ /// streams, not about the format.
2343523469 pub(crate) static SB128RECT_REPLAY_SPAN_MISMATCH_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2343623470 }
2343723471
crates/ec-av1/src/refusal_inventory.rsmodified+24 -33
@@ -84,9 +84,9 @@ const REFUSALS: &[&str] = &[
8484 // pixel-exact vs ffmpeg).
8585 // lane-av1txr: `a sub-8x8 leaf that uses intrabc (…)` is GONE -- the
8686 // capability landed in this lane (4x4 / 4x8 / 8x4 intrabc leaves read the
87- // DV and reconstruct a frame copy + the INTER residual; gates
88- // `a_non_420_subsampled_sequence_header_is_refused_by_name`'s sibling
89- // witnesses and the `warped.obu`/`allintra.obu` traces). Its census gate
87+ // DV and reconstruct a frame copy + the INTER residual; the sub-8x8
88+ // intrabc leaf witnesses in `stream.rs` and the `warped.obu` /
89+ // `allintra.obu` traces). Its census gate
9090 // (`a_sub8_leaf_census_over_intrabc_screen_streams_measures_the_sub8_refusal`)
9191 // still runs: it now reports `reached = 0` with the same non-vacuous
9292 // premise (allow_intrabc frames + decoded sub-8 leaves).
@@ -134,20 +134,6 @@ const REFUSALS: &[&str] = &[
134134 // (`encoder.c:2404`), so an untiled `smptebars=size=128x96` source gives
135135 // `allow_intrabc = 0` with AND without `--tune-content=screen`, while the
136136 // 256x192 `-vf tile=2x2` source gives `= 1` at 8, 10 and 12 bits.
137- // lane-av1txr: the silent-garbage guard. A 4:4:4/4:2:2 stream used to
138- // decode with no refusal and wrong pixels (every chroma extent is
139- // hardcoded 4:2:0, the probe emits 4:2:0 planes only); it is now refused
140- // at the sequence header. Gate:
141- // `a_non_420_subsampled_sequence_header_is_refused_by_name`.
142- // lane-av1odd440: the string gained its 4:4:0 clause. `subsampling_y` is
143- // coded only when `subsampling_x` is 1 (spec 5.5.2; libaom
144- // `av1_read_color_config`, `av1/decoder/decodeframe.c:4171-4175`, and its
145- // writer's own `assert(..., "4:4:0 subsampling not allowed in AV1")` at
146- // `av1/encoder/bitstream.c:2467-2468`), so (0,1) cannot reach this check --
147- // the reachable set is 4:2:0, 4:2:2 and 4:4:4, and only 4:2:2 lands here.
148- // Gate: `the_440_cell_is_not_a_codable_chroma_shape`, which enumerates
149- // the whole reachable set through this crate's own writer AND reader.
150- "a chroma format of 4:2:2 (subsampling_x != subsampling_y): this decoder decodes 4:2:0 and 4:4:4; 4:2:2 is not ported, and 4:4:0 (0,1) is not a codable cell",
151137 // lane-av1txr-r2 added, lane-av1-qmatrix RETIRED: the third member of the
152138 // silent-garbage family (`using_qmatrix`/`qm_y`/`qm_u`/`qm_v`, refused by
153139 // name at the frame header) now DEQUANTISES through libaom's
@@ -520,17 +506,16 @@ const PROVEN: &[(&str, &str, Proof)] = &[
520506 // that refused pre-lift) and the compound-warp arm witnesses through
521507 // `a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`
522508 // (hard `compound_warp_hits > 0`).
523- // lane-av1txr: the guard's own gate builds a profile-1 and a profile-2
524- // sequence header by hand and asserts each refuses by name while the
525- // profile-0 CONTROL still decodes -- the refusal is exercised, not merely
526- // present. lane-av1odd440 adds the second gate named here, which
527- // enumerates every chroma shape a `color_config` can code and pins the
528- // bytes a 4:4:0 request actually produces (`440_request_is_422.obu`).
529- (
530- "a chroma format of 4:2:2 (subsampling_x != subsampling_y): this decoder decodes 4:2:0 and 4:4:4; 4:2:2 is not ported, and 4:4:0 (0,1) is not a codable cell",
531- "a_non_420_subsampled_sequence_header_is_refused_by_name",
532- Proof::NegativeGate,
533- ),
509+ // lane-av1422lift: the 4:2:2 sequence-header refusal is GONE and so is
510+ // this pairing. The tuple named `a_non_420_subsampled_sequence_header_is_
511+ // refused_by_name` as the gate that refused (1,0); that gate asserted a
512+ // REFUSAL STRING, so it could not fail on a tree where 4:2:2 decode was
513+ // completely broken -- it passed unchanged on the broken tree and would
514+ // have kept passing if the port had been reverted. Its replacement
515+ // `a_real_422_key_frame_and_inter_sequence_decode_pixel_exact` (and the
516+ // corpus battery `the_pinned_422_corpus_cells_decode_pixel_exact`) assert
517+ // BYTE-EXACT planes against ffmpeg on real 4:2:2 streams, with the
518+ // per-plane coefficient-unit census as the non-vacuity arm.
534519 // lane-av1txr-r2 paired, lane-av1-qmatrix RETIRED with its gate: the
535520 // refusal's witness is now
536521 // `a_real_aomenc_quantisation_matrix_stream_decodes_pixel_exact`, which
@@ -1731,10 +1716,13 @@ mod tests {
17311716 /// The subsampling domain is `{(0,0), (1,0), (1,1)}` and excludes
17321717 /// `(0,1)`: `ec-av1-syntax`'s `color_config` only ever READS
17331718 /// `subsampling_y` when `subsampling_x == 1` (sequence.rs:481), so
1734- /// `(0,1)` is uncodable. `(1,0)` is 4:2:2, refused at the sequence
1735- /// header by `a_non_420_subsampled_sequence_header_is_refused_by_name`
1736- /// -- it is walked anyway, so the proof does not depend on that guard
1737- /// staying in place.
1719+ /// `(0,1)` is uncodable. `(1,0)` is 4:2:2. It is walked because that is
1720+ /// the codable domain, NOT because a guard stands in the way: as of
1721+ /// lane-av1422lift the sequence header no longer refuses 4:2:2 at all, so
1722+ /// the sentence this replaces ("refused at the sequence header by
1723+ /// `a_non_420_subsampled_sequence_header_is_refused_by_name`") names a
1724+ /// gate that no longer exists. The walk was already right; its stated
1725+ /// reason was not.
17381726 #[test]
17391727 fn every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table() {
17401728 let src = include_str!("decode.rs");
@@ -2023,7 +2011,10 @@ mod tests {
20232011 /// this half was wrong: "the header refuses it" is a statement about
20242012 /// today's tree, not about the strip domain, and a domain that shrinks
20252013 /// silently when a guard moves is not an enumeration. `(1,0)` is walked
2026- /// here anyway, so this proof does not depend on the guard staying.
2014+ /// here anyway, so this proof does not depend on the guard staying -- and
2015+ /// as of lane-av1422lift it does not depend on the guard EXISTING: 4:2:2
2016+ /// decodes, and this enumeration is what says the decode has a
2017+ /// coefficient table for every chroma unit it can present.
20272018 ///
20282019 /// The 32-per-axis cap is what keeps 4:2:2 covered without new table
20292020 /// arms: a 4:2:0 32x64 strip is a 16x32 chroma unit and its 4:2:2
crates/ec-av1/src/stream.rsmodified+819 -165
@@ -318,9 +318,16 @@ pub fn intra128_lossless_counters() -> usize {
318318
319319 /// lane-av1-128rectspan: chroma transform units re-stamped by
320320 /// `decode_block_128rect`'s end-of-block replay, and how many of those
321-/// replays stamped a height that was not the unit's own (the 4:2:2 signature
322-/// -- zero on every stream this decoder admits, since 4:2:2 is refused by
323-/// name at the sequence header).
321+/// replays stamped a height that was not the unit's own.
322+/// lane-av1422lift: the second half was described as "the 4:2:2 signature --
323+/// zero on every stream this decoder admits, since 4:2:2 is refused by name
324+/// at the sequence header", and that was TRUE. 4:2:2 is decoded now and the
325+/// mismatch is NOT zero: measured on this branch's tip, the two
326+/// `422_intrabc_sb128_strip*` pins each read `(72, 9)` while the other 19
327+/// committed 4:2:2 cells read `(0, 0)`. Those two pins are byte-exact
328+/// against ffmpeg, so the non-zero half counts the arm's own designed case
329+/// and is not a defect. No 4:2:2 gate reads this pair; the two gates that do
330+/// are on 4:2:0 and 4:4:4 streams, where the half is structurally zero.
324331 pub fn sb128rect_chroma_replay_counters() -> (usize, usize) {
325332 crate::decode::sb128rect_chroma_replay_hits()
326333 }
@@ -1381,11 +1388,15 @@ pub(crate) struct SeqFlags {
13811388 pub(crate) mono_chrome: bool,
13821389 pub(crate) order_hint_bits: u32,
13831390 pub(crate) mc_identity: bool,
1384- /// lane-av1txr: `color_config.subsampling_x/y` (spec 5.5.2). The decoder
1385- /// itself hardcodes 4:2:0 everywhere, so these exist only for the
1386- /// sequence-level refusal in [`decode_stream_with`] -- nothing downstream
1387- /// reads them. A monochrome header parses as 1,1, so `!(1,1)` singles out
1388- /// 4:4:4 (profile 1 / sRGB) and 4:2:2 (profile 2 below 12-bit).
1391+ /// lane-av1txr: `color_config.subsampling_x/y` (spec 5.5.2). These used
1392+ /// to exist only for the sequence-level refusal -- the decoder hardcoded
1393+ /// 4:2:0 at every chroma extent. lane-av1422lift: that is no longer true
1394+ /// and these are load-bearing on the DECODE path: `decode_stream_with`
1395+ /// publishes both through `decode::set_subsampling` into `FrameCtx`, and
1396+ /// every chroma extent, plane allocation, output crop, deblock/CDEF crop
1397+ /// and restoration grid below reads them PER AXIS. A monochrome header
1398+ /// parses as 1,1 and is unaffected. The only shape these cannot carry is
1399+ /// (0,1) 4:4:0, which the header cannot code.
13891400 pub(crate) subsampling_x: u8,
13901401 pub(crate) subsampling_y: u8,
13911402 }
@@ -1774,38 +1785,36 @@ fn decode_frame(
17741785 // deleted; the two-arm witness is
17751786 // `a_real_aomenc_12bit_film_grain_stream_decodes_pixel_exact`).
17761787 // lane-av1txr: `color_config.subsampling_x/y` (spec 5.5.2) are parsed by
1777- // `ec-av1-syntax` -- profile 1 forces 4:4:4, profile 2 below 12-bit forces
1778- // 4:2:2, and the sRGB identity description forces full-range 4:4:4 -- but
1779- // the decoder reads them NOWHERE: every chroma extent is hardcoded 4:2:0
1780- // (`let (chroma_w, chroma_h) = (bw / 2, bh / 2)` at every rect site,
1781- // `chroma_side = side / 2` in `decode_block`) and the probe emits 4:2:0
1782- // planes only. Measured consequence: EVERY 4:4:4 stream desyncs at the
1783- // first chroma transform (a444-cu6 block (0,0): aomdec reads
1784- // `EC_COEFF plane=1 tx=TX_8X16` at rng 39857 where ours reads a 4-wide,
1785- // 8-high 4:2:0 chroma block at the same rng) and then decodes pixels that
1786- // are silently wrong. Refuse by name rather than return garbage. A
1787- // `num_planes == 1` (monochrome) header keeps its parsed 1,1 and is
1788- // unaffected. Gates: `a_non_420_subsampled_sequence_header_is_refused_by_
1789- // name` below (hand-built profile 1/2 headers plus a real aomenc 4:4:4
1790- // stream).
1791- // lane-av1-444: 4:4:4 (ss 0,0) is decoded. 4:2:2 (ss_x != ss_y) is not.
1792- // lane-av1odd440: the CONDITION is left as `ss_x != ss_y` because that is
1793- // what a parsed header can violate, but the STRING now names the only
1794- // shape that can: `subsampling_y` is coded ONLY when `subsampling_x` is
1795- // 1 (spec 5.5.2's `color_config`; libaom `av1_read_color_config`,
1796- // `av1/decoder/decodeframe.c:4171-4175`, and its writer's own
1797- // `assert(seq_params->subsampling_y == 0 && "4:4:0 subsampling not
1798- // allowed in AV1")`, `av1/encoder/bitstream.c:2467-2468`), so a header can
1799- // carry (1,1), (1,0) or (0,0) and never (0,1) -- 4:4:0 is not a cell a
1800- // decoder can be handed at all. The gate
1801- // `the_440_cell_is_not_a_codable_chroma_shape` proves the whole reachable
1802- // set, so this string is not a claim about a shape that cannot arrive.
1803- if seq.subsampling_x != seq.subsampling_y {
1804- return Err(Error::unsupported(
1805- "AV1 decode_stream",
1806- "a chroma format of 4:2:2 (subsampling_x != subsampling_y): this decoder decodes 4:2:0 and 4:4:4; 4:2:2 is not ported, and 4:4:0 (0,1) is not a codable cell",
1807- ));
1808- }
1788+ // `ec-av1-syntax`. This block used to REFUSE every `ss_x != ss_y` header by
1789+ // name, on the theory that every chroma extent was hardcoded 4:2:0
1790+ // (`bw / 2, bh / 2` at every rect site, `chroma_side = side / 2` in
1791+ // `decode_block`). Both halves of that theory are now false: the per-axis
1792+ // port replaced every one of those extents with `>> ss_x` / `>> ss_y`
1793+ // reads, and 4:4:4 (0,0) already decoded through them.
1794+ // lane-av1422lift: 4:2:2 (1,0) is DECODED. The refusal string, its
1795+ // `refusal_inventory.rs` row and its `Proof::NegativeGate` pairing are
1796+ // deleted in this commit -- a refused format that decodes is a false
1797+ // claim, and the gate that asserted the refusal could not fail on a tree
1798+ // where 4:2:2 decode was completely broken.
1799+ // lane-av1odd440, kept as an ASSERTION: `subsampling_y` is coded ONLY when
1800+ // `subsampling_x` is 1 (spec 5.5.2's `color_config`; libaom
1801+ // `av1_read_color_config`, `av1/decoder/decodeframe.c:4171-4175`, and its
1802+ // writer's own `assert(seq_params->subsampling_y == 0 && "4:4:0
1803+ // subsampling not allowed in AV1")`, `av1/encoder/bitstream.c:2467-2468`),
1804+ // so a parsed header can carry (1,1), (1,0) or (0,0) and never (0,1):
1805+ // 4:4:0 is not a cell a decoder can be handed at all. That used to be a
1806+ // comment plus a refusal string naming the shape; with the refusal gone
1807+ // the residual is an unreachable arm, and this repo closes those with an
1808+ // assertion, never prose. The gate `the_440_cell_is_not_a_codable_chroma_
1809+ // shape` proves the whole reachable set through this crate's own writer
1810+ // AND reader.
1811+ assert!(
1812+ !(seq.subsampling_x == 0 && seq.subsampling_y == 1),
1813+ "AV1 decode_stream: a parsed color_config carried 4:4:0 (subsampling_x=0, \
1814+ subsampling_y=1); subsampling_y is coded only when subsampling_x is 1 \
1815+ (spec 5.5.2), so this shape cannot be produced by ec-av1-syntax's \
1816+ sequence_header -- the parser is wrong, not the caller"
1817+ );
18091818 // lane-av1-qmatrix: `quantization_params.using_qmatrix` + `qm_y`/`qm_u`/
18101819 // `qm_v` (spec 5.9.12) select per-plane INVERSE QUANTISATION MATRICES --
18111820 // spec 7.12.3's per-position `dqv` scale, libaom `get_dqv` over
@@ -2301,55 +2310,138 @@ pub(crate) mod tests {
23012310 picture
23022311 }
23032312
2304- /// lane-av1txr: a sequence header describing any chroma shape but 4:2:0 is
2305- /// refused by name, because the decoder reconstructs every chroma extent
2306- /// at hardcoded 4:2:0 (`bw / 2, bh / 2` at every rect site) and the probe
2307- /// emits 4:2:0 planes only -- a 4:4:4 stream "decodes" into silently wrong
2308- /// pixels (measured: a444-cu6's first chroma transform reads a 4x2-wide/
2309- /// 8-high 4:2:0 chroma at aomdec's `TX_8X16` entry rng 39857, then
2310- /// desyncs; every 4:4:4 fixture measured byte-differs from ffmpeg).
2313+ /// lane-av1422lift: THE 4:2:2 LIFT, in two pins. This test is the renamed,
2314+ /// inverted replacement for `a_non_420_subsampled_sequence_header_is_
2315+ /// refused_by_name`, and the two fixtures replace that gate's fixture --
2316+ /// a hand-built profile-2 header bolted onto a 4:2:0 TILE from this
2317+ /// crate's own encoder, which could never be inverted into an exactness
2318+ /// claim no matter how the assert was flipped (class `refusal-lifted-
2319+ /// without-a-gate`, and the risk study's R6).
23112320 ///
2312- /// Reachability, not a pixel claim: the header is written at the two
2313- /// profiles that force a non-4:2:0 shape (spec 5.5.2 -- profile 1 forces
2314- /// 4:4:4 with no coded bit; profile 2 below 12-bit forces 4:2:2) and the
2315- /// tile is never reached. The 4:2:0 CONTROL below proves the refusal is
2316- /// about the shape, not about this construction.
2317- #[test]
2318- fn a_non_420_subsampled_sequence_header_is_refused_by_name() {
2319- const NAME: &str = "a_non_420_subsampled_sequence_header_is_refused_by_name";
2320- const REFUSAL: &str = "a chroma format of 4:2:2";
2321- let fctx = &crate::decode::FrameCtx::new();
2322- let picture = test_card(64, 64);
2323- let encoded = encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).unwrap();
2324- for (profile, label, sx, sy) in [(2u8, "4:2:2", 1u8, 0u8)] {
2325- let color = ec_av1_syntax::ColorConfig {
2326- num_planes: 3,
2327- subsampling_x: sx,
2328- subsampling_y: sy,
2329- ..Default::default()
2330- };
2331- let (mut seq, header) =
2332- crate::encode::key_frame_headers_colour(64, 64, 100, color).unwrap();
2333- seq.seq_profile = profile;
2334- let mut stream = crate::sequence::sequence_header_obu(&seq).unwrap();
2335- stream
2336- .extend_from_slice(&crate::frame::frame_obu(&seq, &header, &encoded.tile).unwrap());
2337- let err = decode_stream(&stream).unwrap_err().to_string();
2338- assert!(
2339- err.contains(REFUSAL),
2340- "{NAME}: expected the non-4:2:0 refusal for the {label} header, got: {err}"
2341- );
2321+ /// Both pins are REAL 4:2:2 streams from libaom's own writer over a
2322+ /// y4m whose header line is `C422`, so every chroma symbol in them is a
2323+ /// 4:2:2 chroma symbol. Provenance (both, verbatim, no other encoder):
2324+ ///
2325+ /// ```text
2326+ /// aomenc --codec=av1 --profile=2 \
2327+ /// --input-chroma-subsampling-x=1 --input-chroma-subsampling-y=0 \
2328+ /// --passes=1 --end-usage=q --cq-level=24 --cpu-used=0 \
2329+ /// --threads=1 --row-mt=0 --obu -o <pin> <source.y4m>
2330+ /// ```
2331+ ///
2332+ /// * `422_key_64x64.obu` -- 755 bytes, sha256
2333+ /// `3c9396c9e42701d720419ec2cb5577387e305482df0cb150f7f0b965edeaaffc`,
2334+ /// fnv1a64 `0x87fc569cf53bcbc6`. A single 64x64 8-bit KEY frame
2335+ /// (`--limit=1 --kf-min-dist=0 --kf-max-dist=0`) over a
2336+ /// hand-generated two-frame integer `C422` card source, the second
2337+ /// source frame unused by the `--limit=1`. The smallest thing that can
2338+ /// say "4:2:2 intra reconstructs".
2339+ /// * `422_inter_160x128_3f.obu` -- 6522 bytes, sha256
2340+ /// `7b54834c18f5fdc0e8606a6dc5bf4ff368402417d87fcfc2ab9758e4e9164902`,
2341+ /// fnv1a64 `0xf87eba3bf4fc2bb8`. Three 160x128 8-bit frames with a
2342+ /// panning square
2343+ /// (`--limit=3 --kf-min-dist=3 --kf-max-dist=3`, so frames 1 and 2 are
2344+ /// INTER), over a three-frame integer `C422` card source whose square
2345+ /// moves (6,4) -> (9,6) -> (12,8). This is what exercises the
2346+ /// inter-predicted 4:2:2 chroma reference: a decoder that walked the
2347+ /// key frame correctly and then predicted chroma from a 4:2:0-shaped
2348+ /// reference passes the first pin and reds here.
2349+ ///
2350+ /// Both are asserted BYTE-EXACT against ffmpeg 8.1.3's own rawvideo of
2351+ /// the same bytes at `yuv422p`, per plane and per frame, with the
2352+ /// per-plane coefficient-unit census as the non-vacuity arm (see
2353+ /// [`assert_422_stream_pixel_exact`]). A gate whose only assertion was
2354+ /// `err.contains(REFUSAL)` would have passed unchanged on a tree where
2355+ /// 4:2:2 decode was completely broken; that is what this replaces.
2356+ #[test]
2357+ fn a_real_422_key_frame_and_inter_sequence_decode_pixel_exact() {
2358+ const NAME: &str = "a_real_422_key_frame_and_inter_sequence_decode_pixel_exact";
2359+ if !have_ffmpeg() {
2360+ eprintln!("SKIP {NAME}: no ffmpeg");
2361+ return;
23422362 }
2343- // CONTROL: the same construction at profile 0 (4:2:0) still decodes.
2344- let (seq, header) = crate::encode::key_frame_headers(64, 64, 100).unwrap();
2345- let mut stream = crate::sequence::sequence_header_obu(&seq).unwrap();
2346- stream.extend_from_slice(&crate::frame::frame_obu(&seq, &header, &encoded.tile).unwrap());
2347- let frames = decode_stream(&stream).expect("the 4:2:0 control must decode");
2348- assert_eq!(
2349- frames.len(),
2350- 1,
2351- "{NAME}: the 4:2:0 control decoded no frame"
2363+ let key = crate_pin("422_key_64x64.obu");
2364+ let key_stream = read_pin(&key, 755, 0x87fc569cf53bcbc6, NAME);
2365+ let (units, _) = assert_422_stream_pixel_exact(NAME, &key_stream, 64, 64, 1, 8, true);
2366+ let (l, u, v) = (units[0], units[1], units[2]);
2367+ assert!(
2368+ l > 0 && u > 0 && v > 0,
2369+ "{NAME}: the key-frame pin walked no 4:2:2 chroma units [{l}, {u}, {v}]"
23522370 );
2371+
2372+ let inter = crate_pin("422_inter_160x128_3f.obu");
2373+ let inter_stream = read_pin(&inter, 6522, 0xf87eba3bf4fc2bb8, NAME);
2374+ let (units, _) = assert_422_stream_pixel_exact(NAME, &inter_stream, 160, 128, 3, 8, true);
2375+ let (l, u, v) = (units[0], units[1], units[2]);
2376+ assert!(
2377+ u > 0 && v > 0,
2378+ "{NAME}: the inter pin walked no 4:2:2 chroma units [{l}, {u}, {v}] -- the inter \
2379+ chroma reference path was never reached"
2380+ );
2381+ }
2382+
2383+ /// lane-av1422lift: 4:2:2 at 12 bits, and 4:2:2 with superres, are the two
2384+ /// cells the corpus had no coverage for at all (the risk study's R3 and
2385+ /// R9: the sweep recipe passed no 12-bit depth and no `--superres-mode`,
2386+ /// so every 4:2:2 measurement in the tree was 8- or 10-bit, none
2387+ /// superres). Both are pinned and both are byte-exact here.
2388+ ///
2389+ /// `s422_12bit_160x128.obu` -- 9214 bytes, sha256
2390+ /// `eacc70f75c82ad7d795efbd0242aa4ee33db917b8c1a3570ebce2570ee8bc245`,
2391+ /// fnv1a64 `0xa62b8e3fe6f60ae5`. 160x128, 12-bit, 3 frames,
2392+ /// `yuv422p12le` per ffprobe, profile 2 ("Professional").
2393+ ///
2394+ /// **Provenance is ffmpeg's libaom-av1 wrapper, not aomenc, and the
2395+ /// reason is measured, not preferred.** aomenc's own 12-bit y4m path
2396+ /// issues `AV1E_SET_CHROMA_SUBSAMPLING_X` (apps/aomenc.c:2272-2278,
2397+ /// reached whenever the input is not 4:2:0 and the bit depth is 12)
2398+ /// BEFORE `aom_codec_enc_config_set`, and on this libaom that control
2399+ /// returns `AOM_CODEC_INTERNAL_ERROR` for any non-4:2:0 shape -- measured
2400+ /// on four independently built trees
2401+ /// (`~/.cache/aom-oracle`, `aom-affine`, `aom-oracle2`, `aom-oracle3`):
2402+ /// `C422p12` and `C444p12` both die with "Failed to set chroma
2403+ /// subsampling x", while `C420p12` and the 8-bit `C422`/`C444` both
2404+ /// encode. It is not a 4:2:2-specific gap (12-bit 4:4:4 fails too) and
2405+ /// not a 4:2:0 gap (12-bit 4:2:0 encodes). The same control succeeds at
2406+ /// 8 bits, so the failure is the 12-bit configuration order, and the
2407+ /// workaround is a wrapper that sets the codec config first. ffmpeg's
2408+ /// libaom-av1 does exactly that:
2409+ ///
2410+ /// ```text
2411+ /// ffmpeg -f lavfi -i "testsrc2=size=160x128:rate=1:duration=3" \
2412+ /// -pix_fmt yuv422p12le -c:v libaom-av1 -profile:v 2 -b:v 0 -crf 30 \
2413+ /// -cpu-used 8 -auto-alt-ref 0 -lag-in-frames 0 \
2414+ /// -strict experimental -f obu s422_12bit_160x128.obu
2415+ /// ```
2416+ ///
2417+ /// That is libaom's encoder either way -- ffmpeg links it and calls
2418+ /// `aom_codec_encode` -- and the oracle side is ffmpeg's own
2419+ /// `yuv422p12le` rawvideo decode of the same bytes, so the pin and the
2420+ /// oracle come from the same library, which is the property that makes
2421+ /// byte-exactness a claim about OUR decoder rather than about a
2422+ /// disagreement between two encoders.
2423+ ///
2424+ /// `s422_superres_160x128.obu` -- 5304 bytes, sha256
2425+ /// `5852ff2c273cb773c4886762c6a6f2cce6e12065a690eb3a5ca2119c0b6f2957`,
2426+ /// fnv1a64 `0x0789d1b2851b94ae`. 160x128, 8-bit, 3 frames, `--superres-
2427+ /// mode=1` (fixed) over a `C422` testsrc2 source, encoded by the
2428+ /// aomenc recipe above plus `--superres-mode=1`. Superres is the one
2429+ /// 4:2:2 path whose output crop is `(round_ss(w,1) x round_ss(h,0))` at
2430+ /// the UPSCALED size, and it had no 4:2:2 cell anywhere.
2431+ #[test]
2432+ fn a_real_422_12bit_and_superres_stream_decode_pixel_exact() {
2433+ const NAME: &str = "a_real_422_12bit_and_superres_stream_decode_pixel_exact";
2434+ if !have_ffmpeg() {
2435+ eprintln!("SKIP {NAME}: no ffmpeg");
2436+ return;
2437+ }
2438+ let hbd = crate_pin("s422_12bit_160x128.obu");
2439+ let hbd_stream = read_pin(&hbd, 9214, 0xa62b8e3fe6f60ae5, NAME);
2440+ assert_422_stream_pixel_exact(NAME, &hbd_stream, 160, 128, 3, 12, true);
2441+
2442+ let sr = crate_pin("s422_superres_160x128.obu");
2443+ let sr_stream = read_pin(&sr, 5304, 0x0789d1b2851b94ae, NAME);
2444+ assert_422_stream_pixel_exact(NAME, &sr_stream, 160, 128, 3, 8, true);
23532445 }
23542446
23552447 /// lane-av1odd440, CELL 1 of 2: `4:2:0 with an ODD luma dimension`, the
@@ -2486,12 +2578,20 @@ pub(crate) mod tests {
24862578 /// when it is handed `subsampling (0,1)` at profile 2 -- profile 2
24872579 /// below 12 bits is 4:2:2 and codes no subsampling bit at all, so the
24882580 /// request lands on `(1,0)`. The pin is asserted to read back `(1,0)`,
2489- /// NOT `(0,1)`, and the decoder is asserted to refuse it by name,
2490- /// which is the honest outcome for the shape a 4:4:0 request actually
2491- /// yields. Its frame OBU is a 4:2:0 key frame's, so the pin is a HEADER
2492- /// witness, not a decodable 4:2:2 stream -- nothing here claims
2581+ /// NOT `(0,1)`. Its frame OBU is a 4:2:0 key frame's, so the pin is a
2582+ /// HEADER witness, not a decodable 4:2:2 stream -- nothing here claims
24932583 /// pixels for it. Provenance: `examples/gen_coverage_cells.rs`, `cargo
24942584 /// run -p ec-av1 --example gen_coverage_cells -- crates/ec-av1/fixtures`.
2585+ ///
2586+ /// lane-av1422lift: this arm used to end "and the decoder is asserted
2587+ /// to refuse it by name, which is the honest outcome for the shape a
2588+ /// 4:4:0 request actually yields". That was honest only because the
2589+ /// decoder refused EVERY (1,0) header -- the assertion was about the
2590+ /// guard, not about these bytes. With 4:2:2 admitted, refusing these
2591+ /// bytes would be wrong and accepting them without comment would be
2592+ /// worse, so the arm now asserts the one thing that IS true of them:
2593+ /// the SEQUENCE HEADER, not the tile, fixes the decode's chroma
2594+ /// geometry. The pixel claim moved to genuinely 4:2:2 pins.
24952595 #[test]
24962596 fn the_440_cell_is_not_a_codable_chroma_shape() {
24972597 const NAME: &str = "the_440_cell_is_not_a_codable_chroma_shape";
@@ -2729,10 +2829,38 @@ pub(crate) mod tests {
27292829 ever reads (0,1), a 4:4:0 cell became codable and this whole gate is wrong about the \
27302830 format."
27312831 );
2732- let err = decode_stream(&pinned).unwrap_err().to_string();
2832+ // lane-av1422lift: the refusal is gone, and the replacement is NOT
2833+ // "it decodes". This pin's TILE is a 4:2:0 key frame's, byte for
2834+ // byte -- only the sequence header carries 4:2:2 -- so it is a
2835+ // header/tile mismatch and there is no oracle that can say what the
2836+ // right pixels are. What IS assertable, and is what the pin is for,
2837+ // is that the SEQUENCE HEADER alone decides the decode's geometry:
2838+ // the decoded chroma planes are half-width and FULL height, exactly
2839+ // the `round_ss(w, 1) x round_ss(h, 0)` shape a real 4:2:2 stream
2840+ // produces (see `a_real_422_key_frame_and_inter_sequence_decode_
2841+ // pixel_exact` for the pixel claim on genuine 4:2:2 bytes), and that
2842+ // the 4:2:2 chroma walk really ran on it. A decoder that still
2843+ // allocated 4:2:0 planes here would give 32x32 chroma and red.
2844+ let frames = decode_stream(&pinned).unwrap_or_else(|e| {
2845+ panic!("{NAME}: a (1,0) header must decode now that 4:2:2 is admitted: {e}")
2846+ });
2847+ assert_eq!(
2848+ frames.len(),
2849+ 1,
2850+ "{NAME}: the pin must decode exactly one frame"
2851+ );
2852+ assert_eq!(
2853+ (frames[0].u.len(), frames[0].v.len()),
2854+ (32 * 64, 32 * 64),
2855+ "{NAME}: 64x64 4:2:2 is HALF WIDTH and FULL HEIGHT (32x64 chroma); {:?} means the \
2856+ plane geometry still came from the TILE's 4:2:0 shape rather than the HEADER's",
2857+ (frames[0].u.len(), frames[0].v.len())
2858+ );
27332859 assert!(
2734- err.contains("a chroma format of 4:2:2"),
2735- "{NAME}: the shape the 4:4:0 request lands on must still refuse by name, got: {err}"
2860+ crate::decode::census_nonsub_units()[1] > 0
2861+ && crate::decode::census_nonsub_units()[2] > 0,
2862+ "{NAME}: the pin walked zero 4:2:2 chroma coefficient units -- the per-axis walk never \
2863+ ran on it"
27362864 );
27372865 }
27382866 /// lane-av1-422bigblock: the two witnessed 4:2:2 big-block defects, pinned
@@ -2759,18 +2887,28 @@ pub(crate) mod tests {
27592887 /// `EC_AV1_ALLOW_422_PROBE` patch-run-restore build (recipe and measured
27602888 /// numbers in `lanes/av1422bigblock.report.md`).
27612889 ///
2762- /// `decode_stream` itself still refuses 4:2:2 at the sequence header --
2763- /// unconditionally, per the standing family rule -- so the committed
2764- /// assertion is the byte pin (fnv1a64, the same load-bearing-identity
2765- /// fingerprint as the cdf-forwarding gate) plus the refusal-by-name
2766- /// contract over the pinned bytes.
2890+ /// lane-av1422lift: `decode_stream` no longer refuses 4:2:2 at the
2891+ /// sequence header, so this gate stops being a refusal contract and
2892+ /// becomes the one it should have been: BOTH pins, byte-pinned AND
2893+ /// byte-exact against ffmpeg, with the per-plane coefficient-unit census
2894+ /// as the non-vacuity arm. The pins are unchanged and still load-bearing
2895+ /// (size + fnv1a64); only the assertion moved.
27672896 #[test]
2768- fn the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name() {
2769- const NAME: &str = "the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name";
2770- const REFUSAL: &str = "a chroma format of 4:2:2";
2771- for (file, bytes, fp) in [
2772- ("422_allskip_2f.obu", 62usize, 0x7e4d69d3c728c55f_u64),
2773- ("422_sb128_3f.obu", 12543, 0x5171e0aab8000da7),
2897+ fn the_pinned_422_bigblock_witnesses_decode_pixel_exact() {
2898+ const NAME: &str = "the_pinned_422_bigblock_witnesses_decode_pixel_exact";
2899+ if !have_ffmpeg() {
2900+ eprintln!("SKIP {NAME}: no ffmpeg");
2901+ return;
2902+ }
2903+ for (file, bytes, fp, frames, require_coded) in [
2904+ (
2905+ "422_allskip_2f.obu",
2906+ 62usize,
2907+ 0x7e4d69d3c728c55f_u64,
2908+ 2usize,
2909+ false,
2910+ ),
2911+ ("422_sb128_3f.obu", 12543, 0x5171e0aab8000da7, 3, true),
27742912 ] {
27752913 let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
27762914 .join("fixtures")
@@ -2783,11 +2921,24 @@ pub(crate) mod tests {
27832921 });
27842922 assert_eq!(data.len(), bytes, "{NAME}: {file} size drifted");
27852923 assert_eq!(fnv1a64(&data), fp, "{NAME}: {file} bytes drifted");
2786- let err = decode_stream(&data).unwrap_err().to_string();
2787- assert!(
2788- err.contains(REFUSAL),
2789- "{NAME}: {file} must refuse by name, got: {err}"
2790- );
2924+ let (_units, coded_delta) =
2925+ assert_422_stream_pixel_exact(NAME, &data, 128, 128, frames, 8, require_coded);
2926+ if !require_coded {
2927+ // `422_allskip_2f.obu` is named for what it does NOT code, and
2928+ // the pre-port defect was exactly that: the decoder read
2929+ // PHANTOM coefficient units in the all-skip inter frame and
2930+ // then panicked in `reconstruct_mc_rect` on a full-height
2931+ // 4:2:2 chroma rect. So the cell's non-vacuity is a NEGATIVE
2932+ // measurement on the CHROMA planes, asserted here rather than
2933+ // inherited: the walk ran (units > 0, which the shared body
2934+ // checks) and coded nothing on U or V.
2935+ assert_eq!(
2936+ (coded_delta[1], coded_delta[2]),
2937+ (0, 0),
2938+ "{NAME}: {file} CODED a chroma coefficient -- this is the all-skip inter-frame \
2939+ cell and a phantom residual read is exactly the defect it witnesses"
2940+ );
2941+ }
27912942 }
27922943 }
27932944
@@ -2909,15 +3060,22 @@ pub(crate) mod tests {
29093060 /// Green-after, same fixture: 48 chroma units stamped, all 6 blocks
29103061 /// decoded, and ALL FIVE frames byte-identical to `aomdec --rawvideo`.
29113062 ///
2912- /// Committed code refuses 4:2:2 at the sequence header, so the decode
2913- /// assertions above are probe-measured and reproducible from the lane
2914- /// report's recipe; what this gate can assert in committed code is the
2915- /// byte pin, the refusal-by-name contract, and -- in the arm below --
2916- /// that the per-axis walk is still spelled per-axis in the source.
2917- #[test]
2918- fn the_pinned_422_intrabc_sb128_strip_witnesses_refuse_by_name() {
2919- const NAME: &str = "the_pinned_422_intrabc_sb128_strip_witnesses_refuse_by_name";
2920- const REFUSAL: &str = "a chroma format of 4:2:2";
3063+ /// lane-av1422lift: committed code no longer refuses 4:2:2 at the
3064+ /// sequence header, so the red/green evidence above is no longer
3065+ /// probe-only: this gate is the one that asserts it. Both pins are
3066+ /// byte-pinned AND byte-exact against ffmpeg's `yuv422p` rawvideo of the
3067+ /// same bytes, per plane and per frame, with the per-plane
3068+ /// coefficient-unit census as the non-vacuity arm -- the census is what
3069+ /// makes "48 chroma units stamped" a committed, reproducible number here
3070+ /// instead of a sentence in a lane report. The source-scan arm below
3071+ /// keeps its own claim (the per-axis SPELLING) and does not overlap.
3072+ #[test]
3073+ fn the_pinned_422_intrabc_sb128_strip_witnesses_decode_pixel_exact() {
3074+ const NAME: &str = "the_pinned_422_intrabc_sb128_strip_witnesses_decode_pixel_exact";
3075+ if !have_ffmpeg() {
3076+ eprintln!("SKIP {NAME}: no ffmpeg");
3077+ return;
3078+ }
29213079 for (file, bytes, fp) in [
29223080 (
29233081 "422_intrabc_sb128_strip.obu",
@@ -2941,11 +3099,7 @@ pub(crate) mod tests {
29413099 });
29423100 assert_eq!(data.len(), bytes, "{NAME}: {file} size drifted");
29433101 assert_eq!(fnv1a64(&data), fp, "{NAME}: {file} bytes drifted");
2944- let err = decode_stream(&data).unwrap_err().to_string();
2945- assert!(
2946- err.contains(REFUSAL),
2947- "{NAME}: {file} must refuse by name, got: {err}"
2948- );
3102+ assert_422_stream_pixel_exact(NAME, &data, 384, 320, 5, 8, true);
29493103 }
29503104 }
29513105
@@ -3104,14 +3258,26 @@ pub(crate) mod tests {
31043258 /// `a Golomb tail longer than this decoder reads` at frame 2. That
31053259 /// refusal DOES NOT REPRODUCE on this tip: with the bypass applied, all
31063260 /// three cells DECODE 16/16 -- no panic and no second refusal.
3107- #[test]
3108- fn the_pinned_422_lossless_inter_witnesses_are_present_and_refuse_by_name() {
3109- const NAME: &str = "the_pinned_422_lossless_inter_witnesses_are_present_and_refuse_by_name";
3110- const REFUSAL: &str = "a chroma format of 4:2:2";
3111- for (file, bytes, fp) in [
3112- ("W_intrabc.obu", 130_320usize, 0xb6d5c4653a32567a_u64),
3113- ("X_intrabc_tiled.obu", 131_696, 0xb6e04621d2116ef7),
3114- ("Y_intrabc_10b.obu", 202_281, 0x2ecf03435a14dbf),
3261+ ///
3262+ /// lane-av1422lift: the three pins are asserted BYTE-EXACT against
3263+ /// ffmpeg's rawvideo of the same bytes, per plane and per frame, with the
3264+ /// per-plane coefficient-unit census as the non-vacuity arm -- so the
3265+ /// three DECODE 16/16 fact the paragraph above records from a bypassed
3266+ /// probe build is now a committed assertion. `Y` is the 10-bit member
3267+ /// and carries the depth-correct HBD compare (`yuv422p10le`, 16-bit
3268+ /// containers on both sides) rather than an 8-bit narrowing of a
3269+ /// high-bit-depth cell.
3270+ #[test]
3271+ fn the_pinned_422_lossless_inter_witnesses_decode_pixel_exact() {
3272+ const NAME: &str = "the_pinned_422_lossless_inter_witnesses_decode_pixel_exact";
3273+ if !have_ffmpeg() {
3274+ eprintln!("SKIP {NAME}: no ffmpeg");
3275+ return;
3276+ }
3277+ for (file, bytes, fp, depth) in [
3278+ ("W_intrabc.obu", 130_320usize, 0xb6d5c4653a32567a_u64, 8u8),
3279+ ("X_intrabc_tiled.obu", 131_696, 0xb6e04621d2116ef7, 8),
3280+ ("Y_intrabc_10b.obu", 202_281, 0x2ecf03435a14dbf, 10),
31153281 ] {
31163282 let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
31173283 .join("fixtures")
@@ -3121,11 +3287,7 @@ pub(crate) mod tests {
31213287 });
31223288 assert_eq!(data.len(), bytes, "{NAME}: {file} size drifted");
31233289 assert_eq!(fnv1a64(&data), fp, "{NAME}: {file} bytes drifted");
3124- let err = decode_stream(&data).unwrap_err().to_string();
3125- assert!(
3126- err.contains(REFUSAL),
3127- "{NAME}: {file} must refuse by name, got: {err}"
3128- );
3290+ assert_422_stream_pixel_exact(NAME, &data, 320, 240, 16, depth, true);
31293291 }
31303292 }
31313293
@@ -3416,15 +3578,20 @@ pub(crate) mod tests {
34163578 /// by it -- byte-identical to their pre-lane decodes, with the LR gate
34173579 /// family green.
34183580 ///
3419- /// Like its two siblings, the committed assertion is the byte pin plus
3420- /// the refusal-by-name contract: with the header refusal standing,
3421- /// NO committed test can decode a 4:2:2 stream, because the bypass that
3422- /// would allow it must never be committed.
3581+ /// lane-av1422lift: the committed assertion is now the byte pin AND
3582+ /// byte-exactness against ffmpeg's `yuv422p` rawvideo of the same bytes,
3583+ /// per plane and per frame, with the per-plane coefficient-unit census
3584+ /// as the non-vacuity arm. The paragraph above's coverage counts (25
3585+ /// compound-warp, 84 rotzoom global-warp, 22 Wiener, 10 SGRPROJ, CDEF
3586+ /// 39) are what make the row non-vacuous: without them a byte-exact
3587+ /// compare could be green over a stream that never entered a warp arm.
34233588 #[test]
3424- fn the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name() {
3425- const NAME: &str =
3426- "the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name";
3427- const REFUSAL: &str = "a chroma format of 4:2:2";
3589+ fn the_pinned_422_residual_compound_warp_witness_decodes_pixel_exact() {
3590+ const NAME: &str = "the_pinned_422_residual_compound_warp_witness_decodes_pixel_exact";
3591+ if !have_ffmpeg() {
3592+ eprintln!("SKIP {NAME}: no ffmpeg");
3593+ return;
3594+ }
34283595 const FILE: &str = "422_residual_compound_warp_16f.obu";
34293596 const BYTES: usize = 38845;
34303597 const FP: u64 = 0x0e73a51e2cc0c424;
@@ -3439,11 +3606,7 @@ pub(crate) mod tests {
34393606 });
34403607 assert_eq!(data.len(), BYTES, "{NAME}: {FILE} size drifted");
34413608 assert_eq!(fnv1a64(&data), FP, "{NAME}: {FILE} bytes drifted");
3442- let err = decode_stream(&data).unwrap_err().to_string();
3443- assert!(
3444- err.contains(REFUSAL),
3445- "{NAME}: {FILE} must refuse by name, got: {err}"
3446- );
3609+ assert_422_stream_pixel_exact(NAME, &data, 256, 288, 16, 8, true);
34473610 }
34483611 /// lane-av1422lrless: the LR-OFF half of the 4:2:2 coverage pair.
34493612 ///
@@ -3497,13 +3660,20 @@ pub(crate) mod tests {
34973660 /// the one where `read_lr` does nothing at all, so the engagement is
34983661 /// not an artefact of the code under test.
34993662 ///
3500- /// Same scope as its siblings, for the same reason: with the header
3501- /// refusal standing no committed test can decode a 4:2:2 stream,
3502- /// because the bypass that would allow it must never be committed.
3663+ /// lane-av1422lift: same scope change as its siblings, and this is the arm
3664+ /// where it matters most: this stream is the one where `read_lr` does
3665+ /// nothing at all, so a byte-exact green over it is a claim about the
3666+ /// per-axis path WITHOUT the loop-restoration corner fix carrying it.
3667+ /// The pin stays, the compare against ffmpeg's `yuv422p` rawvideo is
3668+ /// added per plane and per frame, and the per-plane coefficient-unit
3669+ /// census is the non-vacuity arm.
35033670 #[test]
3504- fn the_pinned_422_lr_off_witness_is_present_and_refuses_by_name() {
3505- const NAME: &str = "the_pinned_422_lr_off_witness_is_present_and_refuses_by_name";
3506- const REFUSAL: &str = "a chroma format of 4:2:2";
3671+ fn the_pinned_422_lr_off_witness_decodes_pixel_exact() {
3672+ const NAME: &str = "the_pinned_422_lr_off_witness_decodes_pixel_exact";
3673+ if !have_ffmpeg() {
3674+ eprintln!("SKIP {NAME}: no ffmpeg");
3675+ return;
3676+ }
35073677 const FILE: &str = "422_residual_compound_warp_nolr_16f.obu";
35083678 const BYTES: usize = 38538;
35093679 const FP: u64 = 0x4b8ff761701e2bef;
@@ -3518,13 +3688,253 @@ pub(crate) mod tests {
35183688 });
35193689 assert_eq!(data.len(), BYTES, "{NAME}: {FILE} size drifted");
35203690 assert_eq!(fnv1a64(&data), FP, "{NAME}: {FILE} bytes drifted");
3521- let err = decode_stream(&data).unwrap_err().to_string();
3691+ assert_422_stream_pixel_exact(NAME, &data, 256, 288, 16, 8, true);
3692+ }
3693+
3694+ /// lane-av1422lift: 4:2:2 FILM GRAIN, and why this one gate cannot use
3695+ /// the dump path or the shared body above.
3696+ ///
3697+ /// `EC_AV1_FINAL_DUMP` writes the picture "exactly as it is about to be
3698+ /// stored into the reference slots" (`stream.rs`, the dump site beside
3699+ /// the emit), which is BEFORE `apply_grain` runs on the output. ffmpeg's
3700+ /// rawvideo is POST-grain. So every grain cell -- 4:2:0, 4:2:2, 12-bit,
3701+ /// all of them -- is incomparable through the dump, and the corpus
3702+ /// comparator hits it as a hard error rather than as a clean red
3703+ /// (measured on `s422_grain_160x128.obu`: "luma identity never covers the
3704+ /// display side (3 decode frames, 3 display frames)"). This gate
3705+ /// therefore compares the IN-MEMORY `decode_stream` output, which is
3706+ /// post-grain, exactly like
3707+ /// `a_real_aomenc_12bit_film_grain_stream_decodes_pixel_exact` does for
3708+ /// 12-bit 4:2:0. Using the pre-grain dump here would make the gate
3709+ /// permanently red for a reason that has nothing to do with grain.
3710+ ///
3711+ /// The pin, `s422_grain_160x128.obu` (5433 bytes, sha256
3712+ /// `a4a6957b5e8298d9138f64498cab2d3008b3390fa73cd0d74aa0632b13d93d15`,
3713+ /// fnv1a64 `0x2aed47614b9461b8`), is aomenc profile 2 over a `C422`
3714+ /// testsrc2 160x128 3-frame source with `--film-grain-test=5`,
3715+ /// `--passes=1 --end-usage=q --cq-level=24 --cpu-used=0 --threads=1
3716+ /// --row-mt=0 --limit=3 --obu`.
3717+ ///
3718+ /// Two arms, because a green compare over a stream whose grain never ran
3719+ /// is the "params-without-apply" false green:
3720+ ///
3721+ /// 1. the stream's OWN frame headers carry `apply_grain` and scaling
3722+ /// points on all THREE planes -- at 4:2:2 that is the shape libaom's
3723+ /// `generate_grain_uv_422` exists for, and it is read out of the
3724+ /// bytes, not out of the flags handed to the encoder;
3725+ /// 2. `film_grain::grain_hits()` moves across the decode.
3726+ #[test]
3727+ fn a_real_422_film_grain_stream_decodes_pixel_exact() {
3728+ const NAME: &str = "a_real_422_film_grain_stream_decodes_pixel_exact";
3729+ if !have_ffmpeg() {
3730+ eprintln!("SKIP {NAME}: no ffmpeg");
3731+ return;
3732+ }
3733+ let _gate_lock = lock_gate_counters();
3734+ let path = crate_pin("s422_grain_160x128.obu");
3735+ let stream = read_pin(&path, 5433, 0x2aed47614b9461b8, NAME);
3736+ let mut probe = Av1Parser::new();
3737+ let mut pos = 0usize;
3738+ let mut grain_frames = 0usize;
3739+ while pos < stream.len() {
3740+ let obu = probe.parse_obu(&stream[pos..]).unwrap();
3741+ pos += obu.total_size;
3742+ if let ObuKind::Frame(header, _) = obu.kind {
3743+ let fg = &header.film_grain;
3744+ assert!(
3745+ fg.apply_grain,
3746+ "{NAME}: frame without apply_grain -- aomenc emitted params it does not apply"
3747+ );
3748+ assert!(
3749+ fg.num_y_points > 0 && fg.num_cb_points > 0 && fg.num_cr_points > 0,
3750+ "{NAME}: grain without all three planes' scaling points -- the per-axis \
3751+ `generate_grain_uv_422` geometry would not be exercised"
3752+ );
3753+ grain_frames += 1;
3754+ }
3755+ }
3756+ assert_eq!(
3757+ grain_frames, 3,
3758+ "{NAME}: expected grain on all three frames"
3759+ );
3760+ let before = crate::film_grain::grain_hits();
3761+ let units_before = crate::decode::census_nonsub_units();
3762+ let ours = decode_stream(&stream).unwrap_or_else(|e| {
3763+ panic!("{NAME}: decode_stream refused a real 4:2:2 grain stream: {e}")
3764+ });
3765+ assert_eq!(ours.len(), 3, "{NAME}: decoded frame count");
3766+ assert_eq!(
3767+ ours[0].u.len(),
3768+ 80 * 128,
3769+ "{NAME}: 160x128 4:2:2 chroma is 80x128; {} means a 4:2:0 plane",
3770+ ours[0].u.len()
3771+ );
35223772 assert!(
3523- err.contains(REFUSAL),
3524- "{NAME}: {FILE} must refuse by name, got: {err}"
3773+ crate::film_grain::grain_hits() > before,
3774+ "{NAME}: matched but zero grain_hits -- grain synthesis never ran"
3775+ );
3776+ let units = crate::decode::census_nonsub_units();
3777+ for (p, plane) in ["luma", "U", "V"].into_iter().enumerate() {
3778+ assert!(
3779+ units[p] > units_before[p],
3780+ "{NAME}: the {plane} plane walked ZERO coefficient units -- this byte-exact \
3781+ compare is vacuous with respect to 4:2:2"
3782+ );
3783+ }
3784+ let theirs = ffmpeg_decode_sequence_422(&stream, 160, 128, 3);
3785+ for (i, (a, b)) in ours.iter().zip(&theirs).enumerate() {
3786+ for (plane, ours_plane, theirs_plane) in
3787+ [("Y", &a.y, &b.y), ("U", &a.u, &b.u), ("V", &a.v, &b.v)]
3788+ {
3789+ if let Some(bad) = ours_plane
3790+ .iter()
3791+ .zip(theirs_plane)
3792+ .position(|(x, y)| x != y)
3793+ {
3794+ panic!(
3795+ "{NAME}: {plane} differs from ffmpeg at frame {i} sample {bad} ({} vs {})",
3796+ ours_plane[bad], theirs_plane[bad]
3797+ );
3798+ }
3799+ }
3800+ }
3801+ eprintln!(
3802+ "{NAME}: post-grain byte-exact vs ffmpeg; grain_hits={}",
3803+ crate::film_grain::grain_hits()
35253804 );
35263805 }
35273806
3807+ /// lane-av1422lift: THE CORPUS BATTERY -- the gate the 4:2:2 campaign
3808+ /// earned, and the one that replaces seven gates whose only behavioural
3809+ /// assertion was `err.contains(REFUSAL)`.
3810+ ///
3811+ /// **Why these six.** The measurement base
3812+ /// (`lanes/av1422ffmpegbase.report.md` section 2.1) recorded seven 4:2:2
3813+ /// cells that diverged from ffmpeg: `s422_320x246`, `s422_322x240`,
3814+ /// `s422_322x246`, `s422_352x242_10b`, `s422_384x240`,
3815+ /// `s422_416x242_10b`, `s422_416x250_10b`. Six are closed and are pinned
3816+ /// here, each byte-exact against ffmpeg with the per-plane
3817+ /// coefficient-unit census as its non-vacuity arm. All six are
3818+ /// CHROMA-only divergences at non-8-aligned geometries -- odd or
3819+ /// 2-mod-4 luma dimensions, where `round_ss` and the chroma block walk
3820+ /// disagree with a hardcoded `>> 1` -- which is why they are the rows a
3821+ /// lift cannot afford to leave unasserted: they are the cells that would
3822+ /// go quietly wrong again.
3823+ ///
3824+ /// **The seventh, `s422_384x240`, is NOT here, on purpose.** It is the
3825+ /// reserved group-tail chroma SKIP arm (`decode.rs`; the risk study R4
3826+ /// flags it as owned elsewhere), it is still red, and pinning a red cell
3827+ /// inside a green gate is how a gate stops being a gate.
3828+ /// **THIS BRANCH MUST NOT LAND UNTIL THAT CELL CLOSES AND THE CORPUS
3829+ /// RE-MEASURES 51/51** -- see `lanes/av1422lift.report.md`.
3830+ ///
3831+ /// **The census arm, per row.** `assert_422_stream_pixel_exact` asserts
3832+ /// that all three planes read a non-zero number of coefficient units AND
3833+ /// a non-zero number of units that coded at least one coefficient, on
3834+ /// this row's own bytes. That is the requirement R8 named as unwritable
3835+ /// before lane-av1422census422 armed the census for `(1,0)`; measured on
3836+ /// this tree the OLD arming read `[0, 0, 0]` on every 4:2:2 cell while
3837+ /// the same decode walked 4994 units, so a green here with no census
3838+ /// assert would have proven nothing about 4:2:2.
3839+ ///
3840+ /// **Provenance of the six pins.** All six are `aomenc --codec=av1
3841+ /// --profile=2 --input-bit-depth=<8|10> --cpu-used=0 --cq-level=24
3842+ /// --limit=16 --auto-alt-ref=1 --enable-global-motion=1 --passes=1
3843+ /// --obu` over a hand-built `C422` y4m (header line, then `FRAME\n` plus
3844+ /// one frame of planes per frame -- libaom's y4minput requires those six
3845+ /// bytes before EVERY frame), produced by the census sweep and copied in
3846+ /// from `~/.cache/census422b/sweep/`. They are ordinary libaom 4:2:2
3847+ /// streams with nothing bolted on.
3848+ #[test]
3849+ fn the_pinned_422_corpus_cells_decode_pixel_exact() {
3850+ const NAME: &str = "the_pinned_422_corpus_cells_decode_pixel_exact";
3851+ if !have_ffmpeg() {
3852+ eprintln!("SKIP {NAME}: no ffmpeg");
3853+ return;
3854+ }
3855+ // (file, bytes, fnv1a64, sha256, w, h, depth, frames)
3856+ for (file, bytes, fp, sha, w, h, depth, frames) in [
3857+ (
3858+ "s422_320x246.obu",
3859+ 20692usize,
3860+ 0x01e556015878e04eu64,
3861+ "aebd3a10d46e617b803579819f2502798076384be52e032b11b46f09eeb09a79",
3862+ 320usize,
3863+ 246usize,
3864+ 8u8,
3865+ 16usize,
3866+ ),
3867+ (
3868+ "s422_322x240.obu",
3869+ 21096,
3870+ 0x9a96dda2a19d47a6,
3871+ "e74bf7e91f23353986edf9380bcd6cb760194e619dbbdf6a239b7a05eff81799",
3872+ 322,
3873+ 240,
3874+ 8,
3875+ 16,
3876+ ),
3877+ (
3878+ "s422_322x246.obu",
3879+ 20528,
3880+ 0x2c6f8be6d30384ab,
3881+ "ee96617fe45ba963d3628f37086077a94806ef0465a74cb538a8e57d2ed900b3",
3882+ 322,
3883+ 246,
3884+ 8,
3885+ 16,
3886+ ),
3887+ (
3888+ "s422_352x242_10b.obu",
3889+ 20575,
3890+ 0xf1d370f80d8ddc6d,
3891+ "8893bbed108d7555e66c35f2f45d6e44044dcd6810b0510fb251be05dabaa2d0",
3892+ 352,
3893+ 242,
3894+ 10,
3895+ 16,
3896+ ),
3897+ (
3898+ "s422_416x242_10b.obu",
3899+ 20282,
3900+ 0x9826402d91abbc56,
3901+ "38d0b592e5e358901742122c590c8964b5d08d0ceccfa051e677c28f4b75d174",
3902+ 416,
3903+ 242,
3904+ 10,
3905+ 16,
3906+ ),
3907+ (
3908+ "s422_416x250_10b.obu",
3909+ 19967,
3910+ 0x6b07e837eae8a6be,
3911+ "d6aa7f450f54d6fb381400a0a0226da87599c00509eeb5031abe63383e272627",
3912+ 416,
3913+ 250,
3914+ 10,
3915+ 16,
3916+ ),
3917+ ] {
3918+ let row = format!("{NAME}[{file}]");
3919+ let path = crate_pin(file);
3920+ let data = std::fs::read(&path).unwrap_or_else(|e| {
3921+ panic!(
3922+ "{row}: pinned corpus cell {} is missing ({e}) -- the gate cannot run",
3923+ path.display()
3924+ )
3925+ });
3926+ assert_eq!(data.len(), bytes, "{row}: size drifted");
3927+ assert_eq!(fnv1a64(&data), fp, "{row}: bytes drifted");
3928+ // The sha256 is the corpus's own identity column (its
3929+ // `cells_422_3d56.json` records one per cell and the census
3930+ // verified zero drift); fnv1a64 is what `read_pin` can check
3931+ // in-process without spawning sha256sum, so both are named and
3932+ // the sha256 is what a re-capture must reproduce.
3933+ eprintln!("{row}: sha256 {sha}");
3934+ assert_422_stream_pixel_exact(&row, &data, w, h, frames, depth, true);
3935+ }
3936+ }
3937+
35283938 /// lane-av1-qmatrix: WITNESS for the lifted `using_qmatrix` refusal (the
35293939 /// old gate `a_frame_using_quantisation_matrices_is_refused_by_name` is
35303940 /// its mirror image -- its own panic said "flip this gate to a witness"
@@ -7828,6 +8238,234 @@ pub(crate) mod tests {
78288238 .collect()
78298239 }
78308240
8241+ /// lane-av1422lift: as [`ffmpeg_decode_sequence`] (4:2:0 8-bit) and
8242+ /// [`ffmpeg_decode_sequence_444`], for a 4:2:2 stream: `yuv422p`
8243+ /// rawvideo, whose chroma planes are HALF WIDTH and FULL HEIGHT -- the
8244+ /// `w/2 * h` shape the whole per-axis port exists to produce. A helper
8245+ /// that computed the chroma span 4:2:0-style would make every 4:2:2
8246+ /// gate compare half the oracle's bytes and pass, so the span is
8247+ /// asserted against the byte count below, not assumed.
8248+ fn ffmpeg_decode_sequence_422(
8249+ stream: &[u8],
8250+ width: usize,
8251+ height: usize,
8252+ frames: usize,
8253+ ) -> Vec<Pic> {
8254+ ffmpeg_decode_sequence_422_depth(stream, width, height, frames, 8, "yuv422p")
8255+ }
8256+
8257+ /// lane-av1422lift: the depth-generic 4:2:2 oracle comparator --
8258+ /// `yuv422p`, `yuv422p10le` or `yuv422p12le`, with the container width
8259+ /// taken from `depth` itself (8 -> one byte per sample; 10/12 -> a
8260+ /// 16-bit LE container on BOTH sides, so ours and ffmpeg's are directly
8261+ /// comparable sample for sample and nothing narrows).
8262+ fn ffmpeg_decode_sequence_422_depth(
8263+ stream: &[u8],
8264+ width: usize,
8265+ height: usize,
8266+ frames: usize,
8267+ depth: u8,
8268+ pix_fmt: &str,
8269+ ) -> Vec<Pic> {
8270+ assert!(
8271+ matches!(depth, 8 | 10 | 12),
8272+ "lane-av1422lift: ffmpeg_decode_sequence_422_depth takes 8, 10 or 12, got {depth}"
8273+ );
8274+ let out = run_with_stdin(
8275+ Command::new("ffmpeg").args([
8276+ "-v", "error", "-f", "obu", "-i", "-", "-f", "rawvideo", "-pix_fmt", pix_fmt, "-",
8277+ ]),
8278+ stream,
8279+ );
8280+ assert!(
8281+ out.status.success(),
8282+ "ffmpeg refused the 4:2:2 stream ({pix_fmt}): {}",
8283+ String::from_utf8_lossy(&out.stderr)
8284+ );
8285+ let (luma, chroma) = (width * height, width.div_ceil(2) * height);
8286+ let bps = if depth == 8 { 1 } else { 2 };
8287+ let frame_bytes = (luma + 2 * chroma) * bps;
8288+ assert_eq!(
8289+ out.stdout.len(),
8290+ frame_bytes * frames,
8291+ "{}",
8292+ frame_count_diagnosis(
8293+ "4:2:2",
8294+ frames,
8295+ width,
8296+ height,
8297+ frame_bytes,
8298+ out.stdout.len(),
8299+ &out.stderr
8300+ )
8301+ );
8302+ (0..frames)
8303+ .map(|i| {
8304+ let base = i * frame_bytes;
8305+ let samples = |off: usize, n: usize| -> Vec<u16> {
8306+ let slice = &out.stdout[base + off..base + off + n * bps];
8307+ if bps == 1 {
8308+ slice.iter().map(|&v| u16::from(v)).collect()
8309+ } else {
8310+ slice
8311+ .chunks_exact(2)
8312+ .map(|c| u16::from_le_bytes([c[0], c[1]]))
8313+ .collect()
8314+ }
8315+ };
8316+ Pic {
8317+ width,
8318+ height,
8319+ y: samples(0, luma),
8320+ u: samples(luma * bps, chroma),
8321+ v: samples((luma + chroma) * bps, chroma),
8322+ }
8323+ })
8324+ .collect()
8325+ }
8326+
8327+ /// lane-av1422lift: the shared body of every 4:2:2 exactness gate this
8328+ /// lane adds, and the answer to "a byte-exact 4:2:2 gate can still be
8329+ /// vacuous".
8330+ ///
8331+ /// Before lane-av1422census422 the per-plane coefficient-unit census was
8332+ /// armed at `ss_x == 0 && ss_y == 0` only, so on a 4:2:2 stream
8333+ /// `census_nonsub_units()` read `[0, 0, 0]` BY CONSTRUCTION -- a gate
8334+ /// could have been green while the decode walked nothing at all. The
8335+ /// census is now armed for `(ss_x == 0 || ss_y == 0)`, so the delta
8336+ /// asserted here is a real measurement of the walk this stream caused:
8337+ /// every plane must show a non-zero number of transform units AND of
8338+ /// units that coded at least one coefficient.
8339+ ///
8340+ /// Four things are asserted per frame, in this order:
8341+ ///
8342+ /// 1. the decoded frame's dimensions, and that its chroma planes are
8343+ /// `round_ss(w, 1) * round_ss(h, 0)` -- half width, FULL height. A
8344+ /// decoder that kept 4:2:0 plane allocation while walking 4:2:2
8345+ /// entropy would pass a per-sample compare against a 4:2:0-sized
8346+ /// oracle; this is the shape assertion that closes that hole, and it
8347+ /// is asserted against the DECODED frame, never against the gate's
8348+ /// own name.
8349+ /// 2. the depth, read out of the stream's own sequence header.
8350+ /// 3. per-plane, per-frame byte-exactness against ffmpeg's rawvideo of
8351+ /// the same bytes at the depth-correct pixel format. Frame N of ours
8352+ /// against frame N of ffmpeg's: `decode_stream` returns DISPLAY order
8353+ /// and so does ffmpeg's rawvideo muxer, so a hidden alt-ref does not
8354+ /// shift the pairing (the decode-order-vs-display-order trap the
8355+ /// out-of-process corpus comparator has to solve separately).
8356+ /// 4. the census delta, asserted once for the whole stream rather than
8357+ /// per frame, because the counters are cumulative per thread.
8358+ ///
8359+ /// `require_coded` is false ONLY for a cell whose identity IS that it
8360+ /// codes nothing -- `422_allskip_2f.obu`, whose whole point is that
8361+ /// the inter frame reads no residual and the pre-port decoder read
8362+ /// PHANTOM units there. Demanding coded units on it would be
8363+ /// demanding the defect; its caller asserts the all-skip property
8364+ /// directly instead.
8365+ fn assert_422_stream_pixel_exact(
8366+ name: &str,
8367+ stream: &[u8],
8368+ width: usize,
8369+ height: usize,
8370+ frames: usize,
8371+ depth: u8,
8372+ require_coded: bool,
8373+ ) -> ([usize; 3], [usize; 3]) {
8374+ let _gate_lock = lock_gate_counters();
8375+ assert_eq!(
8376+ stream_bit_depth(stream, name),
8377+ depth,
8378+ "{name}: the stream's OWN sequence header does not say {depth} bit"
8379+ );
8380+ let before = crate::decode::census_nonsub_units();
8381+ let before_coded = crate::decode::census_nonsub_coded();
8382+ let ours = decode_stream(stream)
8383+ .unwrap_or_else(|e| panic!("{name}: decode_stream refused a real 4:2:2 stream: {e}"));
8384+ assert_eq!(ours.len(), frames, "{name}: decoded frame count");
8385+ for (i, f) in ours.iter().enumerate() {
8386+ assert_eq!(
8387+ (f.width, f.height),
8388+ (width, height),
8389+ "{name}: frame {i} dimensions"
8390+ );
8391+ assert_eq!(
8392+ (f.u.len(), f.v.len()),
8393+ (width.div_ceil(2) * height, width.div_ceil(2) * height),
8394+ "{name}: frame {i} chroma planes are {}/{} samples -- 4:2:2 is HALF WIDTH and \
8395+ FULL HEIGHT ({width}/2 x {height}); a quarter-height plane means the decode kept \
8396+ a 4:2:0 allocation",
8397+ f.u.len(),
8398+ f.v.len()
8399+ );
8400+ }
8401+ let pix_fmt = match depth {
8402+ 8 => "yuv422p",
8403+ 10 => "yuv422p10le",
8404+ 12 => "yuv422p12le",
8405+ other => panic!("{name}: no ffmpeg pixel format mapped for depth {other}"),
8406+ };
8407+ let theirs =
8408+ ffmpeg_decode_sequence_422_depth(stream, width, height, frames, depth, pix_fmt);
8409+ for (i, (a, b)) in ours.iter().zip(&theirs).enumerate() {
8410+ for (plane, ours_plane, theirs_plane) in
8411+ [("Y", &a.y, &b.y), ("U", &a.u, &b.u), ("V", &a.v, &b.v)]
8412+ {
8413+ assert_eq!(
8414+ ours_plane.len(),
8415+ theirs_plane.len(),
8416+ "{name}: {plane} plane {i} is {} samples against ffmpeg's {} -- the 4:2:2 chroma \
8417+ span is wrong on one of the two sides",
8418+ ours_plane.len(),
8419+ theirs_plane.len()
8420+ );
8421+ if let Some(bad) = ours_plane
8422+ .iter()
8423+ .zip(theirs_plane)
8424+ .position(|(x, y)| x != y)
8425+ {
8426+ panic!(
8427+ "{name}: {plane} differs from ffmpeg at frame {i} sample {bad} ({} vs {}; \
8428+ {} of {} samples differ)",
8429+ ours_plane[bad],
8430+ theirs_plane[bad],
8431+ ours_plane
8432+ .iter()
8433+ .zip(theirs_plane)
8434+ .filter(|(x, y)| x != y)
8435+ .count(),
8436+ ours_plane.len()
8437+ );
8438+ }
8439+ }
8440+ }
8441+ let units = crate::decode::census_nonsub_units();
8442+ let coded = crate::decode::census_nonsub_coded();
8443+ let delta: [usize; 3] = std::array::from_fn(|p| units[p] - before[p]);
8444+ let coded_delta: [usize; 3] = std::array::from_fn(|p| coded[p] - before_coded[p]);
8445+ for (p, plane) in ["luma", "U", "V"].into_iter().enumerate() {
8446+ assert!(
8447+ delta[p] > 0,
8448+ "{name}: the {plane} plane read ZERO coefficient units across the whole stream -- \
8449+ this byte-exact compare is vacuous with respect to 4:2:2 (class \
8450+ gate-blind-to-feature)"
8451+ );
8452+ if require_coded {
8453+ assert!(
8454+ coded_delta[p] > 0,
8455+ "{name}: the {plane} plane coded ZERO coefficient units across the whole \
8456+ stream -- every unit took the all-zero early return, so no coefficient path \
8457+ was exercised"
8458+ );
8459+ }
8460+ }
8461+ eprintln!(
8462+ "{name}: byte-exact vs ffmpeg ({pix_fmt}, {frames} frames); census delta \
8463+ units=[{}, {}, {}] coded=[{}, {}, {}]",
8464+ delta[0], delta[1], delta[2], coded_delta[0], coded_delta[1], coded_delta[2]
8465+ );
8466+ (delta, coded_delta)
8467+ }
8468+
78318469 /// lane-av1-llinter: the firing gate for the lossless 4:4:4 INTER chroma
78328470 /// fix. The fixture is the report's dodge2 stream pinned into `fixtures/`:
78338471 /// aomenc profile 1 over testsrc2 128x96 yuv444p, `--lossless=1`,
@@ -8660,10 +9298,16 @@ pub(crate) mod tests {
86609298 // stopped replaying reads 0), and the mismatch half is the 4:2:2
86619299 // signature: this stream is 4:4:4 (ss 0,0), where the unit's luma
86629300 // width and height are equal, so a replay that stamped one axis with
8663- // the other's span would still read 0 here -- the counter is what
8664- // names the day 4:2:2 (ss 1,0, refused by name at the sequence
8665- // header) is admitted, rather than letting the 8-row spill below the
8666- // block corrupt the next block's `txb_skip` silently.
9301+ // decoded now, so this counter no longer "names the day 4:2:2 is
9302+ // admitted" -- it fires there. **DO NOT copy this zero assert onto a
9303+ // 4:2:2 stream**: measured on this branch's tip, the two
9304+ // `422_intrabc_sb128_strip*` pins each read `mismatch = 9` while
9305+ // being byte-exact against ffmpeg, because the mismatch half counts
9306+ // the replay's own designed 4:2:2 case rather than a defect. What
9307+ // stops the 8-row spill below the block from corrupting the next
9308+ // block's `txb_skip` is the per-axis span itself, and the 4:2:2
9309+ // exactness gates (`the_pinned_422_intrabc_sb128_strip_witnesses_
9310+ // decode_pixel_exact`) are what hold it -- not this counter.
86679311 let after_replay = crate::decode::sb128rect_chroma_replay_hits();
86689312 assert!(
86699313 after_replay.0 > before_replay.0,
@@ -10220,8 +10864,14 @@ pub(crate) mod tests {
1022010864 // TX_4X4 chroma units, so the end-of-block replay re-stamps each of
1022110865 // them over its own luma-mi rows -- the arm the span fix sits on, on
1022210866 // the OTHER admitted ss (1,1). The mismatch half is the 4:2:2
10223- // signature and reads 0 here because 4:2:2 is refused by name at the
10224- // sequence header; it is the tripwire for the day it is not.
10867+ // signature; lane-av1422lift: 4:2:2 is decoded now, so this is no
10868+ // longer "the tripwire for the day it is not". It is a zero this gate
10869+ // asserts about the stream in front of it, and nothing else.
10870+ // **DO NOT carry it to a 4:2:2 stream**: the two
10871+ // `422_intrabc_sb128_strip*` pins read `mismatch = 9` each and are
10872+ // byte-exact against ffmpeg, so a 4:2:2 zero assert would red on a
10873+ // provably correct cell. The 4:2:2 rows of the corpus gate read
10874+ // neither half of this counter.
1022510875 let after_replay = crate::decode::sb128rect_chroma_replay_hits();
1022610876 assert!(
1022710877 after_replay.0 > before_replay.0,
@@ -51511,7 +52161,11 @@ exit 0
5151152161 /// (0, 1) needs no arm: `ec-av1-syntax` reads `subsampling_y` only when
5151252162 /// `subsampling_x == 1` (`crates/ec-av1-syntax/src/sequence.rs:483-485`),
5151352163 /// so the pair is structurally uncodable and the 4:2:0 fallthrough is the
51514- /// only residual. 4:2:2 is refused at the sequence header.
52164+ /// only residual. lane-av1422lift: this sentence used to end "4:2:2 is
52165+ /// refused at the sequence header", which was the wrong reason -- the
52166+ /// claim holds because `cfl_ac_ss` DISPATCHES `ss (1,0)` before the 4:2:0
52167+ /// fallthrough, not because the format could not arrive. The gate's
52168+ /// mechanism is unchanged; only the reason was stale.
5151552169 #[test]
5151652170 fn cfl_ac_q3_at_is_reached_only_through_the_420_fallthrough_of_cfl_ac_ss() {
5151752171 const NAME: &str = "cfl_ac_q3_at_is_reached_only_through_the_420_fallthrough_of_cfl_ac_ss";
lanes/av1422lift.report.mdadded+288 -0
@@ -0,0 +1,288 @@
1+# lane-av1422lift — the 4:2:2 sequence-header refusal is lifted, and the lift is gated
2+
3+**Branch:** `lane/av1422lift`. **Base:** `main` = `4f206ec3`.
4+**Worktree:** `/home/user/.cache/wt/av1422lift`.
5+**Commit:** **`b7a36001`** — one commit, as specified.
6+**NOT MERGED, NOT PUSHED.** Main does the merge, and only after the gate in §7.
7+
8+---
9+
10+## 1. What landed, in one commit
11+
12+| step | what |
13+|---|---|
14+| guard | `stream.rs` `decode_frame`: `if seq.subsampling_x != seq.subsampling_y { return Err(...) }` **removed** |
15+| residual | the uncodable 4:4:0 `(0,1)` now closes with an **`assert!`** in the same place (repo rule: unreachable path ⇒ assertion, never a comment) |
16+| inventory | `refusal_inventory.rs`: the `REFUSALS` string row and its `Proof::NegativeGate` `PROVEN` tuple **deleted in the same commit** — `the_decode_path_refuses_exactly_the_listed_cases` asserts both directions, so a half-removal is red |
17+| tests | the seven refusal-asserting gates renamed and inverted into byte-exact decodes |
18+| fixtures | 11 new committed pins (2 replacement + 6 corpus + 12-bit + superres + grain) |
19+| prose | every site `lanes/av1422liftrisk.report.md` §4 named, corrected |
20+
21+---
22+
23+## 2. Prose corrected, file:line (line numbers as they were on `main` = `4f206ec3`)
24+
25+`stream.rs`
26+- `:1779-1791` — the guard's own doc block. Rewritten: it claimed "the decoder reads them NOWHERE: every chroma extent is hardcoded 4:2:0" and "4:2:2 (ss_x != ss_y) is not [decoded]". Both halves were already false; the block now states the port and the assertion.
27+- `:1384-1388` — `SeqFlags::subsampling_x/y` doc: "these exist only for the sequence-level refusal … nothing downstream reads them". Now says they are published through `decode::set_subsampling` and read per axis by every chroma extent, plane allocation, output crop, deblock/CDEF crop and restoration grid.
28+- `:2302-2308` — the refusal test's doc; deleted with the test, its content folded into the replacement's doc.
29+- `:2759-2763`, `:2816-2821`, `:2997-3002`, `:3323-3326`, `:3403-3406` — the five "with the header refusal standing, NO committed test can decode a 4:2:2 stream" doc blocks. Each replaced by the scope it actually has now.
30+- `:8556-8583` and `:10122-10141` — the two `sb128rect_chroma_replay_counters` tripwire gates' prose ("the counter is what names the day 4:2:2 is admitted", "the tripwire for the day it is not"). Both still assert zero; the reason changed from "it cannot happen" to "it does not happen here, and the 4:2:2 rows assert it there too".
31+- `:319-323` — `sb128rect_chroma_replay_counters`'s own doc ("zero on every stream this decoder admits, since 4:2:2 is refused by name").
32+- `:51426-51429` — `cfl_ac_q3_at_is_reached_only_through_the_420_fallthrough_of_cfl_ac_ss`. The **mechanism was already right** (`cfl_ac_ss` dispatches `(1,0)` before the 4:2:0 fallthrough); only the stated reason was stale. Prose fixed, gate untouched.
33+
34+`decode.rs`
35+- `:17008-17019` — the `TxbSet::Chroma16` reader's "the sequence header admits ss 0/0 and 1/1 only — so the table is exhaustive". The exhaustiveness now comes from the reader's own luma shape, which is what the sentence claims.
36+- `:23409-23419` — `SB128RECT_REPLAY_SPAN_MISMATCH_HITS`: "Zero on every stream this decoder admits … defensive until that format is ported". It is a **real detector** now.
37+- `:2859-2864` — `RECT_TILED_CHROMA_NXN_HITS`: "only reachable at 4:2:2, which is refused, so this stays 0 on every admitted stream". Also now reachable.
38+- `:6140-6145` — `INTRABC_RECT4_OWN_CHROMA422_HITS`: "4:2:2 is refused at the sequence header, so no committed test can read it".
39+
40+`refusal_inventory.rs`
41+- `:137-149` + `:150` — the refusal string row and its whole comment block. **Deleted.**
42+- `:509-519` — the `Proof::NegativeGate` tuple naming `a_non_420_subsampled_sequence_header_is_refused_by_name`. **Deleted**, replaced by a note saying what replaced it and why a `Proof::NegativeGate` on a refusal string could not fail on a broken decode.
43+- `:1719-1725` — `every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table`'s doc: `(1,0)` "is walked anyway, so the proof does not depend on that guard staying in place". The walk was already right; its stated reason named a gate that no longer exists. **The gate itself is unchanged and still passes.**
44+- `:2010-2017` — the strip enumeration's doc, same correction.
45+
46+`examples/gen_coverage_cells.rs`
47+- `:31-42` — module doc: "4:2:2, the shape this decoder refuses by name".
48+- `:259-263` — cell-2 comment: "the decoder refuses it by name, which is the honest outcome".
49+- `:316` — the `println!`: "i.e. 4:2:2, the shape this decoder refuses by name".
50+
51+`film_grain.rs`, `decode_rect4_16_intrabc`, and the reserved group-tail chroma SKIP arm were **not touched** (other lanes own them).
52+
53+---
54+
55+## 3. The two replacement fixtures
56+
57+The risk study's **R6**: the old gates' fixtures were a 4:2:2 *header* over a 4:2:0 *tile* from this crate's own encoder. `440_request_is_422.obu` is ffprobe-invalid (`Invalid data found when processing input`) — it is not a decodable 4:2:2 stream and could not be inverted into an exactness claim. Both replacements are real libaom 4:2:2 streams over a y4m whose header line is `C422`.
58+
59+| pin | bytes | sha256 | fnv1a64 | shape | recipe |
60+|---|---|---|---|---|---|
61+| `422_key_64x64.obu` | 755 | `3c9396c9e42701d720419ec2cb5577387e305482df0cb150f7f0b965edeaaffc` | `0x87fc569cf53bcbc6` | 64x64 8-bit, 1 KEY frame | aomenc `--profile=2 --input-chroma-subsampling-x=1 --input-chroma-subsampling-y=0 --passes=1 --end-usage=q --cq-level=24 --cpu-used=0 --threads=1 --row-mt=0 --limit=1 --kf-min-dist=0 --kf-max-dist=0 --obu` over a hand-generated 2-frame integer `C422` card |
62+| `422_inter_160x128_3f.obu` | 6522 | `7b54834c18f5fdc0e8606a6dc5bf4ff368402417d87fcfc2ab9758e4e9164902` | `0xf87eba3bf4fc2bb8` | 160x128 8-bit, 3 frames, frames 1–2 INTER | same base recipe + `--limit=3 --kf-min-dist=3 --kf-max-dist=3`, over a 3-frame `C422` card whose bright square moves (6,4) → (9,6) → (12,8) |
63+
64+The inter pin is what exercises the inter-predicted 4:2:2 chroma reference: a decoder that reconstructs the key frame correctly and then predicts chroma from a 4:2:0-shaped reference passes the key pin and reds here.
65+
66+Both are deterministic: fixed integer sources, fixed encoder flags, single-threaded, `--threads=1 --row-mt=0`.
67+
68+### `440_request_is_422.obu` is kept, and is explicitly NOT an exactness witness
69+
70+It stays a **shape** witness (arm 3 proves a 4:4:0 request lands on `(1,0)` and that `(0,1)` is unreachable). Its refusal assertion is replaced by the one thing true of its bytes: the decoded chroma planes are `32x64` — half width, **full height** — proving the sequence header and not the tile fixes the geometry. Its pixels are still unclaimed, and `examples/gen_coverage_cells.rs` now says so in both the doc and the printout.
71+
72+---
73+
74+## 4. The new gates
75+
76+| gate | what it asserts | non-vacuity arm |
77+|---|---|---|
78+| `a_real_422_key_frame_and_inter_sequence_decode_pixel_exact` | the two new pins, byte-exact per plane per frame vs ffmpeg `yuv422p` | census delta > 0 on **all three planes**, units and coded |
79+| `a_real_422_12bit_and_superres_stream_decode_pixel_exact` | 12-bit 4:2:2 and superres 4:2:2 — the two cells the corpus had **no coverage for at all** (R3, R9) | same |
80+| `a_real_422_film_grain_stream_decodes_pixel_exact` | 4:2:2 film grain, **post-grain** | `film_grain::grain_hits()` moves AND every frame header carries `apply_grain` with scaling points on all three planes AND census delta > 0 |
81+| `the_pinned_422_corpus_cells_decode_pixel_exact` | the **six closed corpus cells**, byte-exact per plane per frame | census delta > 0 per row, units and coded |
82+| `the_pinned_422_bigblock_witnesses_decode_pixel_exact` | `422_allskip_2f.obu` + `422_sb128_3f.obu` | per-row; the all-skip row's is a **negative** measurement (below) |
83+| `the_pinned_422_intrabc_sb128_strip_witnesses_decode_pixel_exact` | both 128-root intrabc strip pins | census delta > 0 |
84+| `the_pinned_422_lossless_inter_witnesses_decode_pixel_exact` | W / X / Y_intrabc (Y is 10-bit, `yuv422p10le`) | census delta > 0 |
85+| `the_pinned_422_residual_compound_warp_witness_decodes_pixel_exact` | 16-frame compound-warp + LR | census delta > 0 |
86+| `the_pinned_422_lr_off_witness_decodes_pixel_exact` | the LR-OFF twin | census delta > 0 |
87+| `the_440_cell_is_not_a_codable_chroma_shape` (arm 3) | header drives geometry; census walked chroma | census on U and V |
88+
89+### The non-vacuity arm, and why it is the one that counts
90+
91+`assert_422_stream_pixel_exact` asserts, per stream, that `census_nonsub_units()` and `census_nonsub_coded()` **both** rose on luma, U and V.
92+
93+Before lane-av1422census422 the census was armed at `ss_x == 0 && ss_y == 0` only, so on a 4:2:2 stream it read `[0, 0, 0]` **by construction** while the same decode walked 4994 units. A byte-exact 4:2:2 gate asserting those counters would have been green while proving nothing about 4:2:2. That is R8, and it is why the census is the arm named here rather than a 4:2:2 arm counter.
94+
95+### The all-skip row is the one exception, and it is asserted, not skipped
96+
97+`422_allskip_2f.obu` codes **zero** chroma coefficients across the whole stream (measured: `units luma=4 u=8 v=8 | coded luma=1 u=0 v=0`). That is the cell's identity — the pre-port defect was the decoder reading **phantom** coefficient units in the all-skip inter frame. Demanding coded units there would be demanding the defect, so the shared body's coded-unit requirement is parameterised and the row's own arm is a negative measurement, asserted directly: chroma units were **walked** (`units[1] > before[1] && units[2] > before[2]`) and **none was coded** (`coded_delta == (0, 0)`).
98+
99+### Depth correctness
100+
101+The 10-bit and 12-bit rows compare 16-bit containers on **both** sides (`yuv422p10le` / `yuv422p12le`), so nothing narrows — the u8-narrowing trap that makes an HBD cell red by construction does not apply. Depth itself is read out of the stream's own sequence header (`stream_bit_depth`), never from the gate's name.
102+
103+### Display order
104+
105+`decode_stream` returns display order and ffmpeg's rawvideo muxer outputs display order, so frame N pairs with frame N and a hidden alt-ref does not shift the pairing. (The out-of-process corpus comparator has to solve that separately, which is why it exists separately.)
106+
107+---
108+
109+## 5. The two cells that had no coverage, and one provenance finding
110+
111+`s422_12bit_160x128.obu` (9214 B, sha256 `eacc70f75c82ad7d795efbd0242aa4ee33db917b8c1a3570ebce2570ee8bc245`, fnv1a64 `0xa62b8e3fe6f60ae5`) is 12-bit, 160x128, 3 frames, `yuv422p12le`, profile 2.
112+
113+**Its encoder is ffmpeg's libaom-av1 wrapper, not aomenc, and the reason is measured rather than preferred.** aomenc's 12-bit y4m path issues `AV1E_SET_CHROMA_SUBSAMPLING_X` (`apps/aomenc.c:2272-2278`, reached whenever the input is not 4:2:0 and the bit depth is 12) **before** `aom_codec_enc_config_set`, and on this libaom that control returns `AOM_CODEC_INTERNAL_ERROR` for any non-4:2:0 shape. Measured on **four independently built trees** (`~/.cache/aom-oracle`, `aom-affine`, `aom-oracle2`, `aom-oracle3`):
114+
115+| y4m | result |
116+|---|---|
117+| `C422p12` | `Failed to set chroma subsampling x: Unspecified internal error` |
118+| `C444p12` | same failure — **so it is not a 4:2:2-specific gap** |
119+| `C420p12` | encodes (that path skips the control entirely) |
120+| `C422` (8-bit), `C444` (8-bit) | encode, with the same control succeeding |
121+
122+So 12-bit 4:2:2 is unreachable through `aomenc` on this libaom for a configuration-order reason, not a format reason. ffmpeg's libaom-av1 wrapper sets the codec config first and encodes the same library:
123+
124+```
125+ffmpeg -f lavfi -i "testsrc2=size=160x128:rate=1:duration=3" -pix_fmt yuv422p12le \
126+ -c:v libaom-av1 -profile:v 2 -b:v 0 -crf 30 -cpu-used 8 \
127+ -auto-alt-ref 0 -lag-in-frames 0 -strict experimental -f obu <pin>
128+```
129+
130+The pin and the oracle (`yuv422p12le` rawvideo) therefore come from the same library, which is what makes byte-exactness a claim about **our** decoder rather than about a disagreement between two encoders.
131+
132+`s422_superres_160x128.obu` (5304 B, sha256 `5852ff2c273cb773c4886762c6a6f2cce6e12065a690eb3a5ca2119c0b6f2957`, fnv1a64 `0x0789d1b2851b94ae`) is aomenc with `--superres-mode=1` over a `C422` testsrc2 source — the base recipe plus that flag. Superres is the one 4:2:2 path whose output crop is `(round_ss(w,1) x round_ss(h,0))` at the **upscaled** size, and it had no 4:2:2 cell anywhere.
133+
134+`s422_grain_160x128.obu` (5433 B, sha256 `a4a6957b5e8298d9138f64498cab2d3008b3390fa73cd0d74aa0632b13d93d15`, fnv1a64 `0x2aed47614b9461b8`) is aomenc with `--film-grain-test=5` over a `C422` testsrc2 source. **It cannot go through the dump path**: `EC_AV1_FINAL_DUMP` writes the picture as it is about to enter the reference slots (`stream.rs`, the dump site beside the emit), which is *before* `apply_grain` runs on the output, while ffmpeg's rawvideo is post-grain. The corpus comparator hits this as a hard error, not a clean red — measured: `luma identity never covers the display side (3 decode frames, 3 display frames)`. The grain gate therefore compares the **in-memory `decode_stream` output**, which is post-grain, exactly as `a_real_aomenc_12bit_film_grain_stream_decodes_pixel_exact` already does for 12-bit 4:2:0.
135+
136+### The six corpus pins
137+
138+All six are `aomenc --codec=av1 --profile=2 --input-bit-depth=<8|10> --cpu-used=0 --cq-level=24 --limit=16 --auto-alt-ref=1 --enable-global-motion=1 --passes=1 --obu` over a hand-built `C422` y4m (header line, then `FRAME\n` + one frame of planes **per frame**), produced by the census sweep and copied from `~/.cache/census422b/sweep/`. Nothing is bolted on.
139+
140+| pin | bytes | fnv1a64 | sha256 | geom | depth | frames |
141+|---|---|---|---|---|---|---|
142+| `s422_320x246.obu` | 20692 | `0x01e556015878e04e` | `aebd3a10d46e617b803579819f2502798076384be52e032b11b46f09eeb09a79` | 320x246 | 8 | 16 |
143+| `s422_322x240.obu` | 21096 | `0x9a96dda2a19d47a6` | `e74bf7e91f23353986edf9380bcd6cb760194e619dbbdf6a239b7a05eff81799` | 322x240 | 8 | 16 |
144+| `s422_322x246.obu` | 20528 | `0x2c6f8be6d30384ab` | `ee96617fe45ba963d3628f37086077a94806ef0465a74cb538a8e57d2ed900b3` | 322x246 | 8 | 16 |
145+| `s422_352x242_10b.obu` | 20575 | `0xf1d370f80d8ddc6d` | `8893bbed108d7555e66c35f2f45d6e44044dcd6810b0510fb251be05dabaa2d0` | 352x242 | 10 | 16 |
146+| `s422_416x242_10b.obu` | 20282 | `0x9826402d91abbc56` | `38d0b592e5e358901742122c590c8964b5d08d0ceccfa051e677c28f4b75d174` | 416x242 | 10 | 16 |
147+| `s422_416x250_10b.obu` | 19967 | `0x6b07e837eae8a6be` | `d6aa7f450f54d6fb381400a0a0226da87599c00509eeb5031abe63383e272627` | 416x250 | 10 | 16 |
148+
149+These six are the closed members of the seven the measurement base recorded as diverging (`lanes/av1422ffmpegbase.report.md` §2.1). All six were **chroma-only** divergences at non-8-aligned geometries — odd or 2-mod-4 luma dimensions, where `round_ss` and the chroma block walk disagree with a hardcoded `>> 1`. That is why they are the rows a lift cannot leave unasserted.
150+
151+---
152+
153+## 6. Commands and results
154+
155+```text
156+$ git worktree add -b lane/av1422lift /home/user/.cache/wt/av1422lift main
157+$ git log --oneline -1
158+b7a36001 lane-av1422lift: lift the 4:2:2 sequence-header refusal; 4:2:2 decodes
159+
160+$ CARGO_TARGET_DIR=/home/user/.cache/tgt/lift \
161+ cargo check -p ec-av1 --lib --tests --examples
162+Finished dev profile -- CLEAN, zero errors, zero warnings
163+
164+$ CARGO_TARGET_DIR=... EC_AV1_REQUIRE_FFMPEG=1 \
165+ cargo test -p ec-av1 --lib -- --test-threads=4 \
166+ a_real_422 the_pinned_422 the_440_cell
167+running 10 tests ... test result: ok. 10 passed; 0 failed; 0 ignored; 801 filtered out; 8.06s
168+
169+$ CARGO_TARGET_DIR=... EC_AV1_REQUIRE_FFMPEG=1 \
170+ cargo test -p ec-av1 --lib -- --test-threads=4 \
171+ film_grain census intrabc every_chroma_unit the_decode_path_refuses cfl_ac_q3
172+test result: ok. 48 passed; 0 failed; 4 ignored; 759 filtered out; 44.41s
173+```
174+
175+`cargo check --tests` is the command the assignment names; `--lib --tests --examples`
176+is a superset and was run clean, which covers it.
177+
178+### NOT run here, and why that is the correct call
179+
180+The **whole** `ec-av1` lib suite was NOT completed on this box. Two runs were
181+started and both were cut by my own wall-clock budget, not by a failure: the
182+suite's aomenc-encoded gates each take a minute or more and several print
183+"has been running for over 60 seconds", so the suite does not fit a local
184+foreground run. That is the standing project rule, not an excuse — full cargo
185+suites run on the server fleet only, never locally, and **three server suites are
186+already in flight for this campaign**, which will carry this branch.
187+
188+Everything this branch touched IS covered by the two scoped runs above: the
189+ten 4:2:2 gates, the renamed/inverted gates, `--lib film_grain`,
190+`--lib census`, the intrabc tests, both `every_chroma_unit_*` strip
191+enumerations, `the_decode_path_refuses_exactly_the_listed_cases` (the gate
192+that forces the guard and the two inventory rows into one commit), and
193+`cfl_ac_q3_at_is_reached_only_through_the_420_fallthrough_of_cfl_ac_ss`. All
194+green.
195+
196+A partial whole-suite run got **123 tests deep with zero failures** before I
197+cut it, which is a floor and not a green suite. `cargo check --lib --tests
198+--examples` is clean with zero warnings, so nothing fails to build.
199+**Main's server runs are the regression signal for the rest of the crate.**
200+
201+### The out-of-process corpus re-measurement on this branch
202+
203+Run against the **lifted** `decode_probe` (`/home/user/.cache/tgt/lift/debug/examples/decode_probe`, guard removed, no bypass anywhere), through the committed `scripts/run422-ffmpeg.py` + `scripts/cmp422-ffmpeg.py` comparator, per plane per frame, decode-order→display-order mapped, depth-correct on both sides:
204+
205+```text
206+24 cells completed of the 57-cell list; 23 BYTE-EXACT, 1 DIVERGES.
207+(the run was cut by my OWN `timeout 3000`, rc=124 -- not by a failure and
208+ not by a comparator error; no cell produced REFUSES or COMPARATOR-ERROR)
209+
210+s422_384x240: DIVERGES 17df/16shown hidden=[1] Y=0 U=1780 V=1871
211+ first: disp f7 (decode f2) U (r169,c30)
212+```
213+
214+The single divergence reproduces the census422 lane's figure exactly (`U=1780 V=1871`, Y=0, chroma-only) — the same residual that lane measured, unchanged by this lift, as expected: this lane does not touch the decode path of the reserved arm.
215+
216+### Probe-bypass hygiene
217+
218+**No bypass was ever applied on this branch.** `grep -c 'TEMP-PROBE-BYPASS\|if false &&'` is 0 in this worktree, and `git -C /home/user/Documents/Code/Rust/edith_codecs status --porcelain` is **empty** — the primary checkout is untouched. No scratch worktree was created for this lane, so none needed removing; the probe binary that `run422-ffmpeg.py` hardcodes (`/home/user/.cache/tgt/av1422seed/...`) was **not** used — the driver was re-pointed at this lane's own binary from `/home/user/.cache/lift422run.py`, outside the repo.
219+
220+---
221+
222+## 7. What is NOT closed
223+
224+**`s422_384x240` diverges and belongs to another lane.** Chroma-only, `U=1780 V=1871` on a 17-decode/16-display cell, reproduced identically by this lane's measurement and by `lanes/av1422census422.report.md` §3.4. It is the reserved group-tail chroma SKIP arm (`decode.rs`, the arm `lanes/av1422liftrisk.report.md` **R4** flags as owned elsewhere). This lane did not touch it.
225+
226+**The 51/51 corpus gate waits for it.** This lane pins six of the seven previously-diverging cells; the seventh is not pinned here, deliberately — pinning a red cell inside a green gate is how a gate stops being a gate. The gate's doc says so in the same words.
227+
228+### Therefore:
229+
230+> **THIS BRANCH MUST NOT LAND UNTIL `s422_384x240` CLOSES AND THE CORPUS RE-MEASURES 51/51.**
231+>
232+> The guard removal, the inventory retirement and the `(0,1)` assertion are safe to merge as they stand — they are one commit and the tree is green on every gate above. What is not safe is landing them as the *finished* 4:2:2 support claim while one corpus cell is still red. Main should hold `b7a36001` until the owning lane closes `s422_384x240`, then pin that cell into `the_pinned_422_corpus_cells_decode_pixel_exact` and re-run the 51-cell census to 51/51 before merging.
233+
234+## 8. Incidents and observations
235+
236+1. **aomenc cannot produce 12-bit 4:2:2 on this libaom** (§5). Not a 4:2:2 gap — 12-bit 4:4:4 fails identically, and the same control succeeds at 8 bits. The pin's encoder is ffmpeg's libaom-av1 wrapper; both the pin and the oracle come from libaom. Recorded here because the next lane that needs a 12-bit 4:2:2 cell will hit it too.
237+2. **`EC_AV1_FINAL_DUMP` is pre-grain**, so no grain cell — 4:2:0, 4:2:2, 12-bit — can ever be compared through it. The grain gate uses the in-memory decode. (Independently observed by `lanes/av1422census422.report.md` §7.2; confirmed here with a hard comparator error rather than a red.)
238+3. **The census's coded-unit arm cannot be uniform across the corpus.** `422_allskip_2f.obu` codes no chroma coefficient by construction. A blanket "coded > 0 on every plane" gate would have been red on the one cell whose identity is that it codes nothing — and turning it green by deleting the assertion would have been the wrong fix. It is parameterised, with the row's own negative assertion standing in.
239+4. **`cargo check --lib --tests --examples` is clean with zero warnings** on this branch — the three `dead_code` warnings the new helpers produced mid-edit are gone once the gates use them.
240+
241+---
242+
243+## 9. Refutation pass and the honesty correction (`d5422381`)
244+
245+`lanes/av1422liftverify.report.md` (`5ee10c61`) refuted exactly one thing about this branch: six prose sites where the lift replaced **true** "no committed test can read this counter" statements with **false** "the corpus gate reads this counter" statements. Everything else it checked held.
246+
247+**Confirmed by the verifier, not re-litigated here:** 45 committed 4:2:0/4:4:4 fixtures decode byte-identical between `4f206ec3` and this tip; the parser provably produces only `{(1,1),(0,0),(1,0)}` so the `assert!` is sound and reachable only with a parsed header; all three inventory deletions are independently load-bearing (3/3 mutations red); both new pins reproduce their sha256 and round-trip byte-exact against ffmpeg; all six renamed gates plus the three new pixel gates red on a shape-preserving one-LSB decoder mutation.
248+
249+**Re-measured here, independently** (throwaway probe appended inside `mod tests`, run, then removed; the tree was byte-identical to HEAD before the commit below). Over all 21 committed 4:2:2 cells:
250+
251+| counter | measured | verdict on my claim |
252+|---|---|---|
253+| `sb128rect_chroma_replay_hits().1` (span mismatch) | `422_intrabc_sb128_strip.obu` **9**, `..._notxsearch.obu` **9**, the other 19 cells **0** | my claim was false in both halves: no 4:2:2 gate reads it, and it does **not** stay zero |
254+| `rect_tiled_chroma_grid_hits().3` (NXN) | **0** on all 21, and on the 4:2:0/4:4:4 cells probed | false: unwitnessed, not gate-read |
255+| `intrabc_rect4_own_chroma422_hits()` | the six corpus cells step it **1..6**; every other cell leaves it at 6 | false: it fires, but the accessor has zero callers |
256+| `440_request_is_422.obu` (the header/tile pin) | `reach=4, 1x2=4`, `nxn=0` | — |
257+
258+### The one that mattered
259+
260+`SB128RECT_REPLAY_SPAN_MISMATCH_HITS` reads **9** on `422_intrabc_sb128_strip.obu`, and that pin is one `the_pinned_422_intrabc_sb128_strip_witnesses_decode_pixel_exact` asserts **byte-exact against ffmpeg**. So the non-zero mismatch is the arm counting its own designed 4:2:2 case, not a defect — and **adding the zero assert my own comment promised would have turned a green gate red on a provably correct cell.** The pre-lift sentence the lift deleted ("zero on every stream this decoder admits, because 4:2:2 is refused by name") was true; admitting 4:2:2 is exactly what let it fire.
261+
262+### What changed (`d5422381`)
263+
264+Six sites, each corrected to the measured truth:
265+
266+1. `decode.rs` — `SB128RECT_REPLAY_SPAN_MISMATCH_HITS`: carries the two numbers, names the actual readers (two 4:2:0/4:4:4 gates), and says outright that adding the promised zero assert would red a correct cell.
267+2. `decode.rs` — `RECT_TILED_CHROMA_NXN_HITS`: says **unwitnessed**, with `0` on all 21 cells, and names the only two readers.
268+3. `decode.rs` — `INTRABC_RECT4_OWN_CHROMA422_HITS`: carries the `1..6` measurement and states the true half — **no committed test reads it**.
269+4. `stream.rs` — `sb128rect_chroma_replay_counters` (the `pub` API doc): carries `(72, 9)`.
270+5. `stream.rs` — inside **both** tripwire gates' own comments (4:4:4 and the 4:2:0 twin). These were the worst two: those are the gates that *do* read the counter, so the text invited a future lane to add the missing 4:2:2 zero assert and land a red on a correct cell. Both now carry an explicit **"DO NOT copy this zero assert onto a 4:2:2 stream"** plus the `mismatch = 9` measurement.
271+6. `refusal_inventory.rs` — the retirement note named `a_real_422_stream_decodes_pixel_exact`, which does not exist (the gate is `a_real_422_key_frame_and_inter_sequence_decode_pixel_exact`); and a sibling-witness comment still pointed at `a_non_420_subsampled_sequence_header_is_refused_by_name`, the test this lift deleted. Both re-pointed.
272+
273+**No gate was added, and no decoder logic, assertion, fixture or gate body was touched.** Every line of the diff is a comment, verified mechanically:
274+
275+```text
276+$ git diff -U0 crates/ec-av1/src/{decode,stream,refusal_inventory}.rs \
277+ | grep -E '^[+-]' | grep -vE '^(\+\+\+|---)' | grep -vE '^[+-]\s*(///|//|\*)'
278+(no output — every changed line is a comment)
279+
280+$ cargo check -p ec-av1 --lib --tests --examples
281+CLEAN — 0 errors, 0 warnings
282+
283+$ EC_AV1_REQUIRE_FFMPEG=1 cargo test -p ec-av1 --lib -- --test-threads=4 \
284+ a_real_422 the_pinned_422 the_440_cell
285+running 10 tests ... test result: ok. 10 passed; 0 failed; 0 ignored; 801 filtered out; 7.84s
286+```
287+
288+10 passed / 0 failed — the same shape as before the correction, which is the point: a prose-only diff cannot move a gate.