Merge lane-av1422census422: a 4:2:2 unit census exists, and the strip enumeration stops pretending 4:2:2 is unreachable
Browse files at this commit5 changed files +532 -57
- crates/ec-av1/examples/decode_probe.rs +21 -0
- crates/ec-av1/src/decode.rs +49 -31
- crates/ec-av1/src/refusal_inventory.rs +37 -8
- crates/ec-av1/src/stream.rs +22 -18
- lanes/av1422census422.report.md +403 -0
crates/ec-av1/examples/decode_probe.rsmodified+21 -0
| @@ -292,6 +292,27 @@ fn main() { | |||
| 292 | // them landed inside a rect64 dequant. | 292 | // them landed inside a rect64 dequant. |
| 293 | let (dq, dq_drift) = ec_av1::stream::rect64_qidx_drift_counters(); | 293 | let (dq, dq_drift) = ec_av1::stream::rect64_qidx_drift_counters(); |
| 294 | println!("delta_q: groups_read={dq} rect64_qidx_drift={dq_drift}"); | 294 | println!("delta_q: groups_read={dq} rect64_qidx_drift={dq_drift}"); |
| 295 | + // lane-av1422census422: the per-plane coefficient-unit census, armed | ||
| 296 | + // for 4:4:4 and 4:2:2 (4:2:0 arms nothing, so a 4:2:0 recipe sweep | ||
| 297 | + // reads `luma=0 u=0 v=0` BY DESIGN and must not read that as "the | ||
| 298 | + // walk was empty" -- `units_total` is the UNCONDITIONAL per-frame | ||
| 299 | + // total, so the two together say whether the census was armed at | ||
| 300 | + // all). This is what makes a 4:2:2 non-vacuity requirement | ||
| 301 | + // writable: before the widening every per-plane field read zero on a | ||
| 302 | + // 4:2:2 cell BY CONSTRUCTION, so a byte-exact 4:2:2 gate could | ||
| 303 | + // assert it and prove nothing about the stream it had decoded. | ||
| 304 | + let cu = ec_av1::decode::census_nonsub_units(); | ||
| 305 | + let cc = ec_av1::decode::census_nonsub_coded(); | ||
| 306 | + println!( | ||
| 307 | + "census_units: luma={} u={} v={} | coded: luma={} u={} v={} | units_total={}", | ||
| 308 | + cu[0], | ||
| 309 | + cu[1], | ||
| 310 | + cu[2], | ||
| 311 | + cc[0], | ||
| 312 | + cc[1], | ||
| 313 | + cc[2], | ||
| 314 | + ec_av1::decode::census_unit_n(), | ||
| 315 | + ); | ||
| 295 | }; | 316 | }; |
| 296 | // lane-tiles: the tiling a real stream actually uses is a decision input | 317 | // lane-tiles: the tiling a real stream actually uses is a decision input |
| 297 | // (every gate in `stream.rs` picks its own `--tile-columns`), so report it | 318 | // (every gate in `stream.rs` picks its own `--tile-columns`), so report it |
crates/ec-av1/src/decode.rsmodified+49 -31
| @@ -2293,17 +2293,28 @@ pub(crate) fn rect_class1_hits() -> usize { | |||
| 2293 | // lane-av1readcensus: the PER-UNIT coefficient census -- one unit counted | 2293 | // lane-av1readcensus: the PER-UNIT coefficient census -- one unit counted |
| 2294 | // per `read_coeffs`/`read_coeffs_rect` call, i.e. per object this decoder | 2294 | // per `read_coeffs`/`read_coeffs_rect` call, i.e. per object this decoder |
| 2295 | // actually walks, which is the unit the round-4 `av1444rect` count measured | 2295 | // actually walks, which is the unit the round-4 `av1444rect` count measured |
| 2296 | -// (636 square chroma reads against the oracle's 1086). The counters are | 2296 | +// (636 square chroma reads against the oracle's 1086). |
| 2297 | -// 4:4:4-ONLY (`CENSUS_444`, set per frame beside `set_subsampling`), so a | 2297 | +// |
| 2298 | -// 4:2:0 control reads `(0, 0, 0)` -- a walk-shape change at 4:2:0 is another | 2298 | +// lane-av1422census422 widened the arming. The counters used to be |
| 2299 | -// lane's business, and this census must not fire there. | 2299 | +// 4:4:4-ONLY (`CENSUS_444`), so at 4:2:2 -- a chroma format an AV1 |
| 2300 | +// `color_config` can carry and libaom's writer emits -- every | ||
| 2301 | +// `census_444_units()` / `census_444_coded()` read zero BY CONSTRUCTION: a | ||
| 2302 | +// byte-exact 4:2:2 gate asserting those counters would be asserting a | ||
| 2303 | +// literal, and would be green while proving nothing about that stream. The | ||
| 2304 | +// census is now armed for every chroma format that leaves at least one luma | ||
| 2305 | +// axis unsubsampled -- (0,0) 4:4:4 and (1,0) 4:2:2 -- and 4:2:0 (1,1) stays | ||
| 2306 | +// off, so the existing 4:4:4 exact counts and the 4:2:0 zero control are | ||
| 2307 | +// unmoved by the widening. The counters are per-PLANE, not per-format, so a | ||
| 2308 | +// 4:2:2 cell's `[luma, u, v]` split is directly comparable with a 4:4:4 | ||
| 2309 | +// cell's on the same walk shape. | ||
| 2300 | thread_local! { | 2310 | thread_local! { |
| 2301 | - /// Per-plane unit counts, `[luma, u, v]`, at 4:4:4 only. | 2311 | + /// Per-plane unit counts, `[luma, u, v]`, at 4:4:4 and 4:2:2. |
| 2302 | - static CENSUS_444_UNITS: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) }; | 2312 | + static CENSUS_NONSUB_UNITS: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) }; |
| 2303 | - /// Of [`CENSUS_444_UNITS`], the units that coded at least one coefficient | 2313 | + /// Of [`CENSUS_NONSUB_UNITS`], the units that coded at least one |
| 2304 | - /// (`txb_skip == 0`) -- the per-plane split is only comparable against | 2314 | + /// coefficient (`txb_skip == 0`) -- the per-plane split is only |
| 2305 | - /// the oracle's when both sides count all-zero units the same way. | 2315 | + /// comparable against the oracle's when both sides count all-zero units |
| 2306 | - static CENSUS_444_CODED: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) }; | 2316 | + /// the same way. |
| 2317 | + static CENSUS_NONSUB_CODED: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) }; | ||
| 2307 | /// Sequential unit index, so a trace line names its own position in the | 2318 | /// Sequential unit index, so a trace line names its own position in the |
| 2308 | /// frame's walk rather than relying on line order alone. | 2319 | /// frame's walk rather than relying on line order alone. |
| 2309 | static CENSUS_UNIT_N: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2320 | static CENSUS_UNIT_N: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| @@ -2313,29 +2324,36 @@ thread_local! { | |||
| 2313 | /// are not this lane's to edit and would each grow an argument; the | 2324 | /// are not this lane's to edit and would each grow an argument; the |
| 2314 | /// plane-owning readers stamp it once on entry instead. | 2325 | /// plane-owning readers stamp it once on entry instead. |
| 2315 | static CENSUS_PLANE: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2326 | static CENSUS_PLANE: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2316 | - /// 4:4:4 (`subsampling_x == 0 && subsampling_y == 0`) for the frame being | 2327 | + /// At least one luma axis unsubsampled -- (0,0) 4:4:4 or (1,0) 4:2:2 -- |
| 2317 | - /// decoded, set per frame from [`crate::stream`]. | 2328 | + /// for the frame being decoded, set per frame from [`crate::stream`]. |
| 2318 | - static CENSUS_444: std::cell::Cell<bool> = const { std::cell::Cell::new(false) }; | 2329 | + /// 4:2:0 (1,1) arms nothing. |
| 2330 | + static CENSUS_NONSUB: std::cell::Cell<bool> = const { std::cell::Cell::new(false) }; | ||
| 2319 | } | 2331 | } |
| 2320 | 2332 | ||
| 2321 | -/// Current `[luma, u, v]` 4:4:4 coefficient-unit counts. | 2333 | +/// Current `[luma, u, v]` coefficient-unit counts, per plane. Zero at 4:2:0 |
| 2322 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 2334 | +/// by design ([`set_census_nonsub`] arms nothing there). |
| 2323 | -pub(crate) fn census_444_units() -> [usize; 3] { | 2335 | +pub fn census_nonsub_units() -> [usize; 3] { |
| 2324 | - CENSUS_444_UNITS.with(|c| c.get()) | 2336 | + CENSUS_NONSUB_UNITS.with(|c| c.get()) |
| 2325 | } | 2337 | } |
| 2326 | 2338 | ||
| 2327 | -/// Current `[luma, u, v]` 4:4:4 counts of units that coded coefficients. | 2339 | +/// Current `[luma, u, v]` counts of units that coded coefficients. |
| 2328 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 2340 | +pub fn census_nonsub_coded() -> [usize; 3] { |
| 2329 | -pub(crate) fn census_444_coded() -> [usize; 3] { | 2341 | + CENSUS_NONSUB_CODED.with(|c| c.get()) |
| 2330 | - CENSUS_444_CODED.with(|c| c.get()) | ||
| 2331 | } | 2342 | } |
| 2332 | 2343 | ||
| 2333 | -/// lane-av1readcensus: arms the 4:4:4 census for the frame about to decode, | 2344 | +/// lane-av1readcensus: arms the coefficient-unit census for the frame about |
| 2334 | -/// called once per frame from [`crate::stream`]'s decode loop beside | 2345 | +/// to decode, called once per frame from [`crate::stream`]'s decode loop |
| 2335 | -/// [`set_subsampling`]. At 4:2:0 (or 4:2:2) every census counter stays zero -- | 2346 | +/// beside [`set_subsampling`]. Armed for every chroma format with an |
| 2336 | -/// the walk-shape question this census answers is a 4:4:4 one. | 2347 | +/// unsubsampled luma axis -- 4:4:4 (0,0) and 4:2:2 (1,0) -- and NOT for |
| 2337 | -pub(crate) fn set_census_444(ss_x: u8, ss_y: u8) { | 2348 | +/// 4:2:0 (1,1), where the walk-shape question this census answers does not |
| 2338 | - CENSUS_444.with(|c| c.set(ss_x == 0 && ss_y == 0)); | 2349 | +/// arise, so a 4:2:0 control can still assert exactly zero. |
| 2350 | +/// | ||
| 2351 | +/// lane-av1422census422 widened this from `(ss_x == 0 && ss_y == 0)`. The | ||
| 2352 | +/// old condition made 4:2:2 silently UNCUNTABLE rather than uncounted. The | ||
| 2353 | +/// two format pairs keep disjoint conditions, so neither the 4:4:4 exact | ||
| 2354 | +/// counts nor the 4:2:0 zero control can move because of this. | ||
| 2355 | +pub(crate) fn set_census_nonsub(ss_x: u8, ss_y: u8) { | ||
| 2356 | + CENSUS_NONSUB.with(|c| c.set(ss_x == 0 || ss_y == 0)); | ||
| 2339 | } | 2357 | } |
| 2340 | 2358 | ||
| 2341 | /// lane-av1readcensus: the plane the units read from here on belong to, | 2359 | /// lane-av1readcensus: the plane the units read from here on belong to, |
| @@ -2377,15 +2395,15 @@ fn census_unit( | |||
| 2377 | let coded = usize::from(!all_zero); | 2395 | let coded = usize::from(!all_zero); |
| 2378 | CENSUS_UNIT_N.with(|c| c.set(c.get() + 1)); | 2396 | CENSUS_UNIT_N.with(|c| c.set(c.get() + 1)); |
| 2379 | hit_do! { | 2397 | hit_do! { |
| 2380 | - CENSUS_444_UNITS.with(|c| { | 2398 | + CENSUS_NONSUB_UNITS.with(|c| { |
| 2381 | - if CENSUS_444.with(|on| on.get()) { | 2399 | + if CENSUS_NONSUB.with(|on| on.get()) { |
| 2382 | let mut v = c.get(); | 2400 | let mut v = c.get(); |
| 2383 | v[plane] += 1; | 2401 | v[plane] += 1; |
| 2384 | c.set(v); | 2402 | c.set(v); |
| 2385 | } | 2403 | } |
| 2386 | }); | 2404 | }); |
| 2387 | - CENSUS_444_CODED.with(|c| { | 2405 | + CENSUS_NONSUB_CODED.with(|c| { |
| 2388 | - if CENSUS_444.with(|on| on.get()) { | 2406 | + if CENSUS_NONSUB.with(|on| on.get()) { |
| 2389 | let mut v = c.get(); | 2407 | let mut v = c.get(); |
| 2390 | v[plane] += coded; | 2408 | v[plane] += coded; |
| 2391 | c.set(v); | 2409 | c.set(v); |
crates/ec-av1/src/refusal_inventory.rsmodified+37 -8
| @@ -2005,11 +2005,35 @@ mod tests { | |||
| 2005 | /// (`(chroma_w.min(32), chroma_h.min(32))`), so the enumeration walks the | 2005 | /// (`(chroma_w.min(32), chroma_h.min(32))`), so the enumeration walks the |
| 2006 | /// strip domain -- the 64-axis 2:1 and 1:4 footprints, the only shapes the | 2006 | /// strip domain -- the 64-axis 2:1 and 1:4 footprints, the only shapes the |
| 2007 | /// two callers (`read_sb128_root`, `decode_intra_rect_in_inter`) hand the | 2007 | /// two callers (`read_sb128_root`, `decode_intra_rect_in_inter`) hand the |
| 2008 | - /// function -- through both supported chroma formats (4:4:4 and 4:2:0; | 2008 | + /// function -- through every chroma format an AV1 `color_config` can |
| 2009 | - /// every mixed format is refused at the sequence header) against the | 2009 | + /// carry, against the `match` arms read out of decode.rs itself (class |
| 2010 | - /// `match` arms read out of decode.rs itself (class | ||
| 2011 | /// `table-and-reader-move-together`). | 2010 | /// `table-and-reader-move-together`). |
| 2012 | /// | 2011 | /// |
| 2012 | + /// lane-av1422census422 widened the format domain from `{(0,0), (1,1)}` | ||
| 2013 | + /// to `{(0,0), (1,0), (1,1)}`. The old walk justified stopping at two | ||
| 2014 | + /// formats with "every mixed format is refused at the sequence header" -- | ||
| 2015 | + /// a proof that DEPENDS on that guard, so the moment the guard is lifted | ||
| 2016 | + /// the enumeration keeps passing while covering nothing about 4:2:2, with | ||
| 2017 | + /// no failure and no output change. The sibling enumeration | ||
| 2018 | + /// `every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table` | ||
| 2019 | + /// (same file, the 32-level strips) already walked `(1,0)` and said why: | ||
| 2020 | + /// `ec-av1-syntax`'s `color_config` only ever READS `subsampling_y` when | ||
| 2021 | + /// `subsampling_x == 1` (`sequence.rs:481`), so `(0,1)` is uncodable and | ||
| 2022 | + /// the reachable set is exactly these three. That sibling was RIGHT and | ||
| 2023 | + /// this half was wrong: "the header refuses it" is a statement about | ||
| 2024 | + /// today's tree, not about the strip domain, and a domain that shrinks | ||
| 2025 | + /// 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. | ||
| 2027 | + /// | ||
| 2028 | + /// The 32-per-axis cap is what keeps 4:2:2 covered without new table | ||
| 2029 | + /// arms: a 4:2:0 32x64 strip is a 16x32 chroma unit and its 4:2:2 | ||
| 2030 | + /// counterpart is a 16x64 one, but the cap resolves BOTH to `(16, 32)` | ||
| 2031 | + /// (likewise 16x64 -> `(8, 32)`). So 4:2:2 lands entirely inside the | ||
| 2032 | + /// existing five arms and the `hit == handled` non-vacuity assert below is | ||
| 2033 | + /// unchanged. That is a measured result, not an assumption: this | ||
| 2034 | + /// paragraph describes the widened walk in this test's own body, which | ||
| 2035 | + /// asserts both the per-unit table membership and the 12-unit count. | ||
| 2036 | + /// | ||
| 2013 | /// lane-av1-witness2 hunted the shape with 8 real aomenc key-frame encodes | 2037 | /// lane-av1-witness2 hunted the shape with 8 real aomenc key-frame encodes |
| 2014 | /// (screen+intrabc, rect+1:4, sb 64 and 128, cq 10..63, cpu-used 0..2): | 2038 | /// (screen+intrabc, rect+1:4, sb 64 and 128, cq 10..63, cpu-used 0..2): |
| 2015 | /// no recipe reached the arm, and the three streams that decode to | 2039 | /// no recipe reached the arm, and the three streams that decode to |
| @@ -2126,9 +2150,13 @@ mod tests { | |||
| 2126 | if ratio != 2 && ratio != 4 { | 2150 | if ratio != 2 && ratio != 4 { |
| 2127 | continue; | 2151 | continue; |
| 2128 | } | 2152 | } |
| 2129 | - // (ss_x, ss_y): (0, 0) is 4:4:4, (1, 1) is 4:2:0. The mixed | 2153 | + // (ss_x, ss_y): (0, 0) is 4:4:4, (1, 0) is 4:2:2, (1, 1) is |
| 2130 | - // formats are refused by name at the sequence header. | 2154 | + // 4:2:0. `(0, 1)` is uncodable -- `color_config` reads |
| 2131 | - for (ss_x, ss_y) in [(0usize, 0usize), (1, 1)] { | 2155 | + // `subsampling_y` only when `subsampling_x == 1` |
| 2156 | + // (sequence.rs:481) -- so these three are the whole | ||
| 2157 | + // reachable set, and each is walked whether or not the | ||
| 2158 | + // sequence header still refuses it. | ||
| 2159 | + for (ss_x, ss_y) in [(0usize, 0usize), (1, 0), (1, 1)] { | ||
| 2132 | let (chroma_w, chroma_h) = (bw >> ss_x, bh >> ss_y); | 2160 | let (chroma_w, chroma_h) = (bw >> ss_x, bh >> ss_y); |
| 2133 | let unit = (chroma_w.min(32), chroma_h.min(32)); | 2161 | let unit = (chroma_w.min(32), chroma_h.min(32)); |
| 2134 | assert!( | 2162 | assert!( |
| @@ -2143,8 +2171,9 @@ mod tests { | |||
| 2143 | } | 2171 | } |
| 2144 | } | 2172 | } |
| 2145 | assert_eq!( | 2173 | assert_eq!( |
| 2146 | - checked, 8, | 2174 | + checked, 12, |
| 2147 | - "the strip domain is not the four 64-axis strips x two supported formats" | 2175 | + "the strip domain is not the four 64-axis strips x three codable \ |
| 2176 | + chroma formats (4:4:4, 4:2:2, 4:2:0)" | ||
| 2148 | ); | 2177 | ); |
| 2149 | assert_eq!( | 2178 | assert_eq!( |
| 2150 | hit, handled, | 2179 | hit, handled, |
crates/ec-av1/src/stream.rsmodified+22 -18
| @@ -1910,10 +1910,14 @@ fn decode_frame( | |||
| 1910 | // 4:2:0 one never inherits the wrong plane count. | 1910 | // 4:2:0 one never inherits the wrong plane count. |
| 1911 | crate::decode::set_mono(seq.mono_chrome, fctx); | 1911 | crate::decode::set_mono(seq.mono_chrome, fctx); |
| 1912 | crate::decode::set_subsampling(seq.subsampling_x, seq.subsampling_y, fctx); | 1912 | crate::decode::set_subsampling(seq.subsampling_x, seq.subsampling_y, fctx); |
| 1913 | - // lane-av1readcensus: the 4:4:4 coefficient-unit census is armed here, | 1913 | + // lane-av1readcensus: the coefficient-unit census is armed here, off the |
| 1914 | - // off the same sequence-header subsampling -- at 4:2:0/4:2:2 every census | 1914 | + // same sequence-header subsampling. lane-av1422census422 widened it from |
| 1915 | - // counter reads zero, so a 4:2:0 control can assert exactly that. | 1915 | + // 4:4:4-only to "any format with an unsubsampled luma axis", so a 4:2:2 |
| 1916 | - crate::decode::set_census_444(seq.subsampling_x, seq.subsampling_y); | 1916 | + // cell's per-plane unit counts are readable and a 4:2:2 gate can assert |
| 1917 | + // a non-vacuous walk; 4:2:0 still reads zero, so the 4:2:0 control in | ||
| 1918 | + // `a_pixel_exact_444_stream_walks_the_same_coefficient_units_the_oracle_does` | ||
| 1919 | + // keeps asserting exactly that. | ||
| 1920 | + crate::decode::set_census_nonsub(seq.subsampling_x, seq.subsampling_y); | ||
| 1917 | // lane-av1txr: spec 5.9.2 `disable_cdf_update` -- a frame that sets it | 1921 | // lane-av1txr: spec 5.9.2 `disable_cdf_update` -- a frame that sets it |
| 1918 | // codes every tile symbol against the CDFs it started with, so the tile | 1922 | // codes every tile symbol against the CDFs it started with, so the tile |
| 1919 | // readers must not adapt (libaom `decodeframe.c:2909`: | 1923 | // readers must not adapt (libaom `decodeframe.c:2909`: |
| @@ -24395,16 +24399,16 @@ exit 0 | |||
| 24395 | [now[0] - before[0], now[1] - before[1], now[2] - before[2]] | 24399 | [now[0] - before[0], now[1] - before[1], now[2] - before[2]] |
| 24396 | }; | 24400 | }; |
| 24397 | 24401 | ||
| 24398 | - let u0 = crate::decode::census_444_units(); | 24402 | + let u0 = crate::decode::census_nonsub_units(); |
| 24399 | - let c0 = crate::decode::census_444_coded(); | 24403 | + let c0 = crate::decode::census_nonsub_coded(); |
| 24400 | let (frames, hidden) = decode_all_frames_vs_oracle(&stream, NAME); | 24404 | let (frames, hidden) = decode_all_frames_vs_oracle(&stream, NAME); |
| 24401 | assert_eq!( | 24405 | assert_eq!( |
| 24402 | frames + hidden, | 24406 | frames + hidden, |
| 24403 | 8, | 24407 | 8, |
| 24404 | "{NAME}: expected 8 decode-order frames (6 shown + 2 hidden)" | 24408 | "{NAME}: expected 8 decode-order frames (6 shown + 2 hidden)" |
| 24405 | ); | 24409 | ); |
| 24406 | - let walked = delta(crate::decode::census_444_units(), u0); | 24410 | + let walked = delta(crate::decode::census_nonsub_units(), u0); |
| 24407 | - let coded = delta(crate::decode::census_444_coded(), c0); | 24411 | + let coded = delta(crate::decode::census_nonsub_coded(), c0); |
| 24408 | 24412 | ||
| 24409 | // The oracle's own census on the same stream, paired by post_rng: | 24413 | // The oracle's own census on the same stream, paired by post_rng: |
| 24410 | // 3764 units per plane, 975 / 1793 / 1859 of them coded. | 24414 | // 3764 units per plane, 975 / 1793 / 1859 of them coded. |
| @@ -24436,15 +24440,15 @@ exit 0 | |||
| 24436 | .join("fixtures/444_lossy_rect4_inter_witness.obu"); | 24440 | .join("fixtures/444_lossy_rect4_inter_witness.obu"); |
| 24437 | let stream2 = std::fs::read(&path2) | 24441 | let stream2 = std::fs::read(&path2) |
| 24438 | .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path2.display())); | 24442 | .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path2.display())); |
| 24439 | - let m0 = crate::decode::census_444_units(); | 24443 | + let m0 = crate::decode::census_nonsub_units(); |
| 24440 | - let mc0 = crate::decode::census_444_coded(); | 24444 | + let mc0 = crate::decode::census_nonsub_coded(); |
| 24441 | let (frames2, hidden2) = decode_all_frames_vs_oracle(&stream2, NAME); | 24445 | let (frames2, hidden2) = decode_all_frames_vs_oracle(&stream2, NAME); |
| 24442 | assert!( | 24446 | assert!( |
| 24443 | frames2 + hidden2 > 0, | 24447 | frames2 + hidden2 > 0, |
| 24444 | "{NAME}: the mixed-shape 4:4:4 arm decoded no frames" | 24448 | "{NAME}: the mixed-shape 4:4:4 arm decoded no frames" |
| 24445 | ); | 24449 | ); |
| 24446 | - let walked2 = delta(crate::decode::census_444_units(), m0); | 24450 | + let walked2 = delta(crate::decode::census_nonsub_units(), m0); |
| 24447 | - let coded2 = delta(crate::decode::census_444_coded(), mc0); | 24451 | + let coded2 = delta(crate::decode::census_nonsub_coded(), mc0); |
| 24448 | assert_eq!( | 24452 | assert_eq!( |
| 24449 | walked2, | 24453 | walked2, |
| 24450 | [629, 372, 372], | 24454 | [629, 372, 372], |
| @@ -24464,21 +24468,21 @@ exit 0 | |||
| 24464 | .join("fixtures/av1_192x128_8bit_intra64_in_inter.obu"), | 24468 | .join("fixtures/av1_192x128_8bit_intra64_in_inter.obu"), |
| 24465 | ) | 24469 | ) |
| 24466 | .unwrap_or_else(|e| panic!("{NAME}: reading the 4:2:0 control: {e}")); | 24470 | .unwrap_or_else(|e| panic!("{NAME}: reading the 4:2:0 control: {e}")); |
| 24467 | - let k0 = crate::decode::census_444_units(); | 24471 | + let k0 = crate::decode::census_nonsub_units(); |
| 24468 | - let kc0 = crate::decode::census_444_coded(); | 24472 | + let kc0 = crate::decode::census_nonsub_coded(); |
| 24469 | let k_frames = decode_stream(&control) | 24473 | let k_frames = decode_stream(&control) |
| 24470 | .unwrap_or_else(|e| panic!("{NAME}: the 4:2:0 control no longer decodes: {e}")) | 24474 | .unwrap_or_else(|e| panic!("{NAME}: the 4:2:0 control no longer decodes: {e}")) |
| 24471 | .len(); | 24475 | .len(); |
| 24472 | assert!(k_frames > 0, "{NAME}: the 4:2:0 control decoded no frames"); | 24476 | assert!(k_frames > 0, "{NAME}: the 4:2:0 control decoded no frames"); |
| 24473 | assert_eq!( | 24477 | assert_eq!( |
| 24474 | - delta(crate::decode::census_444_units(), k0), | 24478 | + delta(crate::decode::census_nonsub_units(), k0), |
| 24475 | [0, 0, 0], | 24479 | [0, 0, 0], |
| 24476 | - "{NAME}: the 4:4:4 census fired on the 4:2:0 control" | 24480 | + "{NAME}: the coefficient-unit census fired on the 4:2:0 control" |
| 24477 | ); | 24481 | ); |
| 24478 | assert_eq!( | 24482 | assert_eq!( |
| 24479 | - delta(crate::decode::census_444_coded(), kc0), | 24483 | + delta(crate::decode::census_nonsub_coded(), kc0), |
| 24480 | [0, 0, 0], | 24484 | [0, 0, 0], |
| 24481 | - "{NAME}: the 4:4:4 coded-unit census fired on the 4:2:0 control" | 24485 | + "{NAME}: the coded-unit census fired on the 4:2:0 control" |
| 24482 | ); | 24486 | ); |
| 24483 | } | 24487 | } |
| 24484 | 24488 | ||
lanes/av1422census422.report.mdadded+403 -0
| @@ -0,0 +1,403 @@ | |||
| 1 | +# lane-av1422census422 — the two non-vacuity prerequisites for the 4:2:2 lift | ||
| 2 | + | ||
| 3 | +**Branch:** `lane/av1422census422`. **Base:** `main` = `19b16ffd`. | ||
| 4 | +**Worktree:** `/home/user/.cache/wt/av1422census422`. | ||
| 5 | +**Changed:** `crates/ec-av1/src/decode.rs`, `crates/ec-av1/src/stream.rs`, | ||
| 6 | +`crates/ec-av1/src/refusal_inventory.rs`, `crates/ec-av1/examples/decode_probe.rs`. | ||
| 7 | +**Not touched, by instruction:** the sequence-header refusal, `film_grain.rs`, | ||
| 8 | +`decode_rect4_16_intrabc`, the reserved group-tail chroma SKIP arm. | ||
| 9 | + | ||
| 10 | +Both prerequisites named in `lanes/av1422liftrisk.report.md` §5 **R7** and **R8** are | ||
| 11 | +closed, and each is measured rather than argued. No 4:2:2 unit was found missing from | ||
| 12 | +any coefficient table, so there is no defect to report on that front (§2). | ||
| 13 | + | ||
| 14 | +--- | ||
| 15 | + | ||
| 16 | +## 1. The two findings, in one line each | ||
| 17 | + | ||
| 18 | +* **R7 — the strip enumeration silently dropped 4:2:2.** Fixed: the walk is now | ||
| 19 | + `{(0,0), (1,0), (1,1)}`, the count moved `8 -> 12`, and **the 4:2:2 half resolves | ||
| 20 | + entirely inside the five existing table arms, so no new arm was needed** (§2). | ||
| 21 | +* **R8 — no 4:2:2 unit census.** Fixed: the per-plane coefficient-unit census is armed | ||
| 22 | + for 4:2:2 as well as 4:4:4, and its counters **move on every 4:2:2 cell measured** | ||
| 23 | + while the 4:2:0 and 4:4:4 numbers are **bit-identical before and after** (§3). | ||
| 24 | + | ||
| 25 | +--- | ||
| 26 | + | ||
| 27 | +## 2. The strip enumeration (`refusal_inventory.rs`) | ||
| 28 | + | ||
| 29 | +### 2.1 The change | ||
| 30 | + | ||
| 31 | +`every_chroma_unit_a_64_axis_strip_can_present_has_a_coefficient_table` walked | ||
| 32 | +`[(0,0), (1,1)]` and asserted `checked == 8`, justifying the missing format with | ||
| 33 | +"every mixed format is refused at the sequence header". It now walks | ||
| 34 | +`[(0,0), (1,0), (1,1)]` and asserts `checked == 12`. | ||
| 35 | + | ||
| 36 | +### 2.2 The new count and the derivation — no unit was missing | ||
| 37 | + | ||
| 38 | +The four 64-axis strips in the domain (ratio 2 or 4, both sides 16..64) crossed with | ||
| 39 | +the three codable formats, chroma shape `bw >> ss_x, bh >> ss_y`, unit | ||
| 40 | +`(chroma_w.min(32), chroma_h.min(32))`: | ||
| 41 | + | ||
| 42 | +| strip | 4:4:4 (0,0) | **4:2:2 (1,0)** | 4:2:0 (1,1) | | ||
| 43 | +|---|---|---|---| | ||
| 44 | +| 64x16 | 32x16 | **32x16** | 32x8 | | ||
| 45 | +| 64x32 | 32x32 | **32x32** | 32x16 | | ||
| 46 | +| 32x64 | 16x32 | **16x32** | 16x32 | | ||
| 47 | +| 16x64 | 8x32 | **8x32** | 8x32 | | ||
| 48 | + | ||
| 49 | +`4 strips x 3 formats = 12` checks. The 32-per-axis cap (`decode.rs`, `let (uw, uh) = | ||
| 50 | +(chroma_w.min(32), chroma_h.min(32));`) is why 4:2:2 needs nothing new: a 4:2:0 32x64 | ||
| 51 | +strip is a 16x32 chroma unit and its 4:2:2 counterpart is a **16x64** one, but the cap | ||
| 52 | +resolves both to `(16, 32)`. Same for 16x64 -> `(8, 32)`. | ||
| 53 | + | ||
| 54 | +**Every 4:2:2 unit is already in the table**: `{(32,32), (32,16), (16,32), (32,8), | ||
| 55 | +(8,32)}`, asserted exactly by the pre-existing `arms == handled` pin. The | ||
| 56 | +`hit == handled` non-vacuity assert is unchanged, which is the point — the widening | ||
| 57 | +added formats, not arms. **No unit with no coefficient table was found; the | ||
| 58 | +`decode_block_rect64` `_` arm stays dead for 4:2:2.** | ||
| 59 | + | ||
| 60 | +### 2.3 Which half of the file was right, and why | ||
| 61 | + | ||
| 62 | +The sibling `every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table` | ||
| 63 | +(the 32-level strips, same file) already walked `[(0,0), (1,0), (1,1)]` and said why: | ||
| 64 | +`ec-av1-syntax`'s `color_config` only ever READS `subsampling_y` when | ||
| 65 | +`subsampling_x == 1` (`sequence.rs:481`), so `(0,1)` is uncodable and the reachable set | ||
| 66 | +is exactly those three — and it walked `(1,0)` "so the proof does not depend on that | ||
| 67 | +guard staying in place". | ||
| 68 | + | ||
| 69 | +**The sibling was right; this half was wrong.** "The header refuses it" is a statement | ||
| 70 | +about today's tree, not about the strip domain. A domain that shrinks silently when a | ||
| 71 | +guard moves is not an enumeration — it is a snapshot of one guard's current value, and | ||
| 72 | +the failure mode is the quiet one: no red, no output change, no counter, just a proof | ||
| 73 | +that quietly stops being a proof. The sibling's phrasing is the generalizable rule and | ||
| 74 | +is now mirrored here: walk what `color_config` can produce, and let the header guard be | ||
| 75 | +irrelevant to the proof. | ||
| 76 | + | ||
| 77 | +### 2.4 Non-vacuity: the widening is load-bearing, proved by mutation | ||
| 78 | + | ||
| 79 | +The obvious mutation (delete a table arm) trips the pre-existing exact-table pin at | ||
| 80 | +`refusal_inventory.rs:2132` before the walk, so it does not test the new code. The | ||
| 81 | +mutation that does is re-narrowing the format list: | ||
| 82 | + | ||
| 83 | +``` | ||
| 84 | +$ cargo test -p ec-av1 --lib every_chroma_unit_a_64_axis_strip | ||
| 85 | +# with (1, 0) removed from the loop: | ||
| 86 | +assertion `left == right` failed: the strip domain is not the four 64-axis strips | ||
| 87 | + x three codable chroma formats (4:4:4, 4:2:2, 4:2:0) | ||
| 88 | + left: 8 | ||
| 89 | + right: 12 | ||
| 90 | +``` | ||
| 91 | + | ||
| 92 | +So a future re-narrowing **fails** instead of passing quietly — which is the exact | ||
| 93 | +property the old test lacked. Both mutations were reverted and byte-verified | ||
| 94 | +(`diff -q` against a pre-mutation copy: `RESTORED IDENTICAL`). | ||
| 95 | + | ||
| 96 | +Restored, the test passes: | ||
| 97 | + | ||
| 98 | +``` | ||
| 99 | +test refusal_inventory::tests::every_chroma_unit_a_64_axis_strip_can_present_has_a_coefficient_table ... ok | ||
| 100 | +test refusal_inventory::tests::every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table ... ok | ||
| 101 | +``` | ||
| 102 | + | ||
| 103 | +--- | ||
| 104 | + | ||
| 105 | +## 3. The 4:2:2 unit census (`decode.rs`) | ||
| 106 | + | ||
| 107 | +### 3.1 The mechanism | ||
| 108 | + | ||
| 109 | +The census counted one unit per `read_coeffs` / `read_coeffs_rect` call — i.e. per | ||
| 110 | +transform unit that reads a `txb_skip` symbol — split per plane, and | ||
| 111 | +`set_census_444` armed it **only** at `ss (0,0)`: | ||
| 112 | + | ||
| 113 | +```rust | ||
| 114 | +// before | ||
| 115 | +CENSUS_444.with(|c| c.set(ss_x == 0 && ss_y == 0)); | ||
| 116 | +``` | ||
| 117 | + | ||
| 118 | +So at 4:2:2 every `census_444_units()` / `census_444_coded()` read zero **by | ||
| 119 | +construction**, and a byte-exact 4:2:2 gate could assert those counters, be green, and | ||
| 120 | +have proven nothing. | ||
| 121 | + | ||
| 122 | +The arming is now the disjoint complement — every format with at least one unsubsampled | ||
| 123 | +luma axis, 4:2:0 still off: | ||
| 124 | + | ||
| 125 | +```rust | ||
| 126 | +// after (set_census_nonsub) | ||
| 127 | +CENSUS_NONSUB.with(|c| c.set(ss_x == 0 || ss_y == 0)); | ||
| 128 | +``` | ||
| 129 | + | ||
| 130 | +Three deliberate choices: | ||
| 131 | + | ||
| 132 | +1. **Renamed** `CENSUS_444` / `census_444_units` / `census_444_coded` / | ||
| 133 | + `set_census_444` -> `CENSUS_NONSUB` / `census_nonsub_units` / `census_nonsub_coded` | ||
| 134 | + / `set_census_nonsub`. A census called `444` that fires on 4:2:2 is the same | ||
| 135 | + lying-name defect this lane exists to remove, and the file's own convention is | ||
| 136 | + already to name a counter for its domain. | ||
| 137 | +2. **The two format pairs keep disjoint conditions**, so the 4:4:4 exact counts and the | ||
| 138 | + 4:2:0 zero control cannot move because of the widening. Measured in §3.3. | ||
| 139 | +3. **The accessors are now `pub`**, not `pub(crate)`, and `decode_probe` prints them | ||
| 140 | + (`census_units: luma=.. u=.. v=.. | coded: luma=.. u=.. v=.. | units_total=..`). | ||
| 141 | + Without this the counters are unreachable from the probe, which is the only | ||
| 142 | + instrument that can read a 4:2:2 stream at all while the header refusal stands. | ||
| 143 | + `census_unit_n()` (already `pub`) is printed alongside as the **unconditional** | ||
| 144 | + per-frame total, so one line says both how many units were counted per plane and | ||
| 145 | + whether the census was armed at all — a 4:2:0 cell's `luma=0 u=0 v=0` is then | ||
| 146 | + distinguishable from an empty walk without a second run. | ||
| 147 | + | ||
| 148 | +Nothing else changed: the counting sites, the plane stamping, and the trace are | ||
| 149 | +untouched. The counters are per-PLANE, not per-format, so a 4:2:2 cell's `[luma, u, v]` | ||
| 150 | +split is directly comparable with a 4:4:4 cell's on the same walk shape. | ||
| 151 | + | ||
| 152 | +### 3.2 Before / after, same cells, same probe, same bypass | ||
| 153 | + | ||
| 154 | +Two builds, both from `main` + the probe print, differing in **one expression**: | ||
| 155 | + | ||
| 156 | +* **BEFORE** — a throwaway detached worktree at `main`, print-only patch, arming | ||
| 157 | + reverted to `(ss_x == 0 && ss_y == 0)`. | ||
| 158 | +* **AFTER** — this lane, arming `(ss_x == 0 || ss_y == 0)`. | ||
| 159 | + | ||
| 160 | +Both carry the probe bypass, so both can decode 4:2:2 at all. | ||
| 161 | + | ||
| 162 | +| cell | format | BEFORE units `[L,U,V]` | AFTER units `[L,U,V]` | AFTER coded `[L,U,V]` | `units_total` (both) | | ||
| 163 | +|---|---|---|---|---|---| | ||
| 164 | +| `s422_320x240` | 4:2:2 8b | `[0, 0, 0]` | **`[2338, 1328, 1328]`** | `[1020, 843, 949]` | 4994 | | ||
| 165 | +| `s422_320x242_10b` | 4:2:2 10b | `[0, 0, 0]` | **`[2046, 1149, 1149]`** | `[860, 799, 825]` | 4344 | | ||
| 166 | +| `s422_326x240` | 4:2:2 8b | `[0, 0, 0]` | **`[2798, 1433, 1433]`** | `[1200, 876, 1029]` | 5664 | | ||
| 167 | +| `s422_416x250_10b` | 4:2:2 10b | `[0, 0, 0]` | **`[2927, 1426, 1426]`** | `[1068, 837, 996]` | 5779 | | ||
| 168 | +| `g422_t5` (film grain) | 4:2:2 8b | `[0, 0, 0]` | **`[1443, 529, 529]`** | `[238, 268, 269]` | 2501 | | ||
| 169 | + | ||
| 170 | +The BEFORE column is the vacuity proof in its strongest form: on a 4:2:2 cell the old | ||
| 171 | +census read `[0, 0, 0]` while the same decode walked **4994 units**. It was not that | ||
| 172 | +the walk was empty; it was that the census was not looking. | ||
| 173 | + | ||
| 174 | +### 3.3 Controls — unchanged, with the numbers | ||
| 175 | + | ||
| 176 | +| control | format | BEFORE | AFTER | verdict | | ||
| 177 | +|---|---|---|---|---| | ||
| 178 | +| `fixtures/av1_192x128_8bit_intra64_in_inter.obu` | 4:2:0 | `[0,0,0]` / coded `[0,0,0]`, total 405 | `[0,0,0]` / coded `[0,0,0]`, total 405 | identical | | ||
| 179 | +| `sweep/s420_320x240.obu` | 4:2:0 | — | `[0,0,0]`, total 3514 | census stays off at 4:2:0 by construction, as the table row above shows for the before/after pair | | ||
| 180 | +| `fixtures/ll444_minp8_inter.obu` | 4:4:4 | `[3764, 3764, 3764]`, coded `[975, 1793, 1859]`, total 11292 | **same** | identical | | ||
| 181 | +| `fixtures/444_lossy_rect4_inter_witness.obu` | 4:4:4 | `[629, 372, 372]`, coded `[130, 253, 278]`, total 1373 | **same** | identical | | ||
| 182 | + | ||
| 183 | +The two 4:4:4 rows are the numbers the existing gate | ||
| 184 | +`a_pixel_exact_444_stream_walks_the_same_coefficient_units_the_oracle_does` pins against | ||
| 185 | +libaom's own `EC_ECDUMP_IN` census (paired by `post_rng`). It passes unchanged on this | ||
| 186 | +branch, together with its 4:2:0 zero control: | ||
| 187 | + | ||
| 188 | +``` | ||
| 189 | +$ EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib \ | ||
| 190 | + a_pixel_exact_444_stream_walks_the_same_coefficient_units | ||
| 191 | +test stream::tests::a_pixel_exact_444_stream_walks_the_same_coefficient_units_the_oracle_does ... ok | ||
| 192 | +``` | ||
| 193 | + | ||
| 194 | +Whole-sweep confirmation over all 54 cells (18 per format, | ||
| 195 | +`/home/user/.cache/census422b/sweep`, run through the ffmpeg comparator with the | ||
| 196 | +widened census): **18/18 4:2:0 cells BYTE-EXACT with `[0,0,0]`; 18/18 4:4:4 cells | ||
| 197 | +BYTE-EXACT with non-zero per-plane counts; 17/18 4:2:2 cells BYTE-EXACT with non-zero | ||
| 198 | +per-plane counts, 1 DIVERGES** (`s422_384x240`, `U=1780 V=1871 Y=0` — a chroma-only | ||
| 199 | +divergence, and the one cell the risk study's R4 already flags as owned elsewhere). | ||
| 200 | + | ||
| 201 | +Incidental good news for the lift: the 7 divergences the ffmpegbase census recorded | ||
| 202 | +(`s422_320x246`, `s422_322x240`, `s422_322x246`, `s422_352x242_10b`, `s422_384x240`, | ||
| 203 | +`s422_416x242_10b`, `s422_416x250_10b`) have collapsed to **one** on today's tree. | ||
| 204 | + | ||
| 205 | +### 3.4 Comparator liveness — 324/324 arms | ||
| 206 | + | ||
| 207 | +`scripts/flipctl-422.py`, 9 cells x 36 arms (3 sample positions x 3 planes x 2 shown | ||
| 208 | +frames x both directions), mapping re-derived from luma identity: | ||
| 209 | + | ||
| 210 | +``` | ||
| 211 | +$ python3 flipctl-422.py cells_flip9.json | ||
| 212 | +s422_320x240: baseline [0, 0, 0] 17 decode / 16 shown, hidden [1], 1 mapping solution(s), 36 arms | ||
| 213 | +s422_320x242_10b: baseline [0, 0, 0] ... 36 arms | ||
| 214 | +s422_326x240: baseline [0, 0, 0] ... 36 arms | ||
| 215 | +s422_416x250_10b: baseline [0, 0, 0] ... 36 arms | ||
| 216 | +s422_384x240: baseline [0, 1780, 1871] ... 36 arms | ||
| 217 | +s420_320x240: baseline [0, 0, 0] ... 36 arms | ||
| 218 | +s420_320x242_10b: baseline [0, 0, 0] ... 36 arms | ||
| 219 | +s444_320x240: baseline [0, 0, 0] ... 36 arms | ||
| 220 | +s444_320x242_10b: baseline [0, 0, 0] ... 36 arms | ||
| 221 | + | ||
| 222 | +324 PASS, 0 FAIL of 324 flip arms | ||
| 223 | +``` | ||
| 224 | + | ||
| 225 | +Every flipped sample moved exactly the owning plane by exactly 1 and no other plane at | ||
| 226 | +all, on both the oracle arm and the ours arm. So the `BYTE-EXACT` verdicts in §3.3 are | ||
| 227 | +produced by a comparator that reads both sides, and the 4:2:2 cells' census numbers come | ||
| 228 | +from streams that are genuinely byte-exact. | ||
| 229 | + | ||
| 230 | +### 3.5 The exact commands | ||
| 231 | + | ||
| 232 | +```sh | ||
| 233 | +# worktrees | ||
| 234 | +git worktree add -b lane/av1422census422 /home/user/.cache/wt/av1422census422 main | ||
| 235 | +git worktree add --detach /home/user/.cache/wt/census422-base main # BEFORE build | ||
| 236 | +# BEFORE build = main + probe print, arming reverted to (ss_x == 0 && ss_y == 0) | ||
| 237 | +# AFTER build = this lane | ||
| 238 | + | ||
| 239 | +# probe bypass, patch-run-restore, in BOTH scratch trees, never committed: | ||
| 240 | +# stream.rs:1803 if seq.subsampling_x != seq.subsampling_y { | ||
| 241 | +# -> // TEMP-PROBE-BYPASS lane-av1422census422: patch-run-restore, never committed. | ||
| 242 | +# if false && seq.subsampling_x != seq.subsampling_y { | ||
| 243 | + | ||
| 244 | +CARGO_TARGET_DIR=/home/user/.cache/tgt/census422-base cargo build -p ec-av1 --example decode_probe | ||
| 245 | +CARGO_TARGET_DIR=/home/user/.cache/tgt/census422 cargo build -p ec-av1 --example decode_probe | ||
| 246 | + | ||
| 247 | +# census before/after, same cells, both binaries | ||
| 248 | +BASE=/home/user/.cache/tgt/census422-base/debug/examples/decode_probe | ||
| 249 | +AFTER=/home/user/.cache/tgt/census422/debug/examples/decode_probe | ||
| 250 | +$BASE /home/user/.cache/census422b/sweep/s422_320x240.obu | grep census_units | ||
| 251 | +$AFTER /home/user/.cache/census422b/sweep/s422_320x240.obu | grep census_units | ||
| 252 | + | ||
| 253 | +# ffmpeg comparison (copy of scripts/run422-ffmpeg.py with PROBE pointed at the | ||
| 254 | +# AFTER binary; cmpff.py imported unchanged) | ||
| 255 | +/home/user/.cache/tgt/census422/debug/examples/decode_probe # via EC_AV1_FINAL_DUMP | ||
| 256 | +python3 run422.py cells_all.json out_all.json | ||
| 257 | + | ||
| 258 | +# comparator liveness | ||
| 259 | +python3 flipctl-422.py cells_flip9.json # 324 PASS, 0 FAIL | ||
| 260 | + | ||
| 261 | +# scoped gates on the restored, clean tree | ||
| 262 | +cargo check -p ec-av1 --lib --tests --examples # clean, no warnings | ||
| 263 | +EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -- \ | ||
| 264 | + every_chroma_unit_a_64_axis_strip \ | ||
| 265 | + a_pixel_exact_444_stream_walks_the_same_coefficient_units # 2 passed | ||
| 266 | +cargo test -p ec-av1 --lib every_chroma_unit # 2 passed | ||
| 267 | +cargo test -p ec-av1 --lib census # 12 passed, 3 ignored | ||
| 268 | +``` | ||
| 269 | + | ||
| 270 | +--- | ||
| 271 | + | ||
| 272 | +## 4. Which arms the new census reaches, and which it cannot see | ||
| 273 | + | ||
| 274 | +This is the part a future gate must not over-read. | ||
| 275 | + | ||
| 276 | +**The census's structural reach is exactly: every transform unit that reads a `txb_skip` | ||
| 277 | +symbol.** There are only two such sites in the decoder — `read_coeffs` and | ||
| 278 | +`read_coeffs_rect` — and both call `census_unit` on every exit path (the `all_zero` | ||
| 279 | +early return included). So the census counts every residual transform unit of every | ||
| 280 | +plane, at every block shape, and its per-plane split is stamped by | ||
| 281 | +`read_plane` / `read_inter_plane` / `read_inter_plane_rect` / `read_coeffs_rect`. | ||
| 282 | + | ||
| 283 | +**Reached and counted on the four 4:2:2 cells measured** (arm counters from the same | ||
| 284 | +runs; these are the arms a 4:2:2 gate can honestly claim the census witnesses): | ||
| 285 | + | ||
| 286 | +| arm | `s422_320x240` | `s422_320x242_10b` | `s422_326x240` | `s422_416x250_10b` | | ||
| 287 | +|---|---|---|---|---| | ||
| 288 | +| `chroma422_square` | 64 | 57 | 58 | 68 | | ||
| 289 | +| `chroma422_rect` | 304 | 282 | 300 | 326 | | ||
| 290 | +| `chroma422_sub8` | 236 | 188 | 189 | 198 | | ||
| 291 | +| `cfl_ac` 4:2:2 arm | 152 | 132 | 134 | 164 | | ||
| 292 | +| `reelc_chroma` dir-1:4 pairs | 9 | 16 | 7 | 18 | | ||
| 293 | +| `inter_rect` 64x32 / 64x16 | 2 / 0 | 4 / 0 | 6 / 4 | 4 / 0 | | ||
| 294 | +| `rect4_16_pair` intrabc | 0 | 0 | 0 | 1 | | ||
| 295 | + | ||
| 296 | +Square, rect and sub-8 chroma 4:2:2 units, the 4:2:2 CfL AC arm, the 1:4 chroma | ||
| 297 | +direction pairs, the 64-axis inter strips and the rect4_16 intrabc pair are all walked | ||
| 298 | +by these cells, and all of them route their coefficients through the two readers the | ||
| 299 | +census instruments — so their units are inside the measured counts. `chroma422_square + | ||
| 300 | +chroma422_rect + chroma422_sub8 = 604` on `s422_320x240` against 2656 chroma units | ||
| 301 | +(1328 U + 1328 V): the arm counters count *blocks* and the census counts *units*, so | ||
| 302 | +they are not expected to agree, and the census is the finer of the two. | ||
| 303 | + | ||
| 304 | +**Cannot be seen by this census, and therefore NOT witnessed by these cells:** | ||
| 305 | + | ||
| 306 | +1. **`chroma422_chunk` — the 128-root CHUNKS chroma walk: `0` on all four cells.** Its | ||
| 307 | + coefficients do go through `read_inter_plane_rect` -> `read_coeffs_rect`, so the | ||
| 308 | + census *would* count them; no cell here reaches the arm. A 4:2:2 gate cannot claim | ||
| 309 | + 128-root chunked chroma on this evidence. | ||
| 310 | +2. **`chroma422_pair_wide`: `0` on all four cells.** Same reasoning, same conclusion. | ||
| 311 | +3. **IntraBC / DC-only blocks.** They read no `txb_skip`, so they contribute **zero | ||
| 312 | + units** — by design (the census counts units, and an IntraBC block's DC values are | ||
| 313 | + not a transform unit). `ibc128: mu_chroma=0 intra128=0` on all four cells anyway, | ||
| 314 | + so no 4:2:2 IntraBC arm is witnessed here. | ||
| 315 | +4. **Skipped blocks** (no residual) and palette blocks with no coded residual — | ||
| 316 | + invisible for the same reason. A cell whose walk is mostly skip would show a small | ||
| 317 | + non-zero count and still have exercised few coefficient paths; the count is a | ||
| 318 | + lower bound on *units*, never a statement that every arm ran. | ||
| 319 | +5. **Anything the sequence header refuses.** With the guard standing, no committed test | ||
| 320 | + can produce these numbers; they are probe measurements. A committed 4:2:2 gate has | ||
| 321 | + to wait for the lift (see §6). | ||
| 322 | + | ||
| 323 | +--- | ||
| 324 | + | ||
| 325 | +## 5. What a 4:2:2 gate can now assert that it could not before | ||
| 326 | + | ||
| 327 | +**One line:** a byte-exact 4:2:2 gate can now assert that the per-plane coefficient-unit | ||
| 328 | +census is non-zero on every plane (`census_nonsub_units() > 0` and | ||
| 329 | +`census_nonsub_coded() > 0` for LUMA/U/V), which is a real non-vacuity requirement on | ||
| 330 | +the stream it decoded — before this lane that assertion read `[0, 0, 0]` on every | ||
| 331 | +4:2:2 cell by construction and was therefore satisfied by a decoder that had walked | ||
| 332 | +nothing at all. | ||
| 333 | + | ||
| 334 | +Concretely, R8's requirement — "the reachability counter for the arm each cell witnesses | ||
| 335 | +must be `> 0`" — is now writable for 4:2:2, and once paired with a per-cell expected | ||
| 336 | +count it also becomes a **walk-shape** assertion comparable against libaom's | ||
| 337 | +`EC_ECDUMP_IN` census on a 4:2:2 stream, which is what the 4:4:4 gate already does with | ||
| 338 | +its pinned `[3764, 3764, 3764]` / `[975, 1793, 1859]`. | ||
| 339 | + | ||
| 340 | +--- | ||
| 341 | + | ||
| 342 | +## 6. Status, and what is deliberately not done | ||
| 343 | + | ||
| 344 | +**Delivered:** the R7 enumeration widened to three formats with the count at 12 and the | ||
| 345 | +4:2:2 membership proven (and a mutation proof that the widening bites); the R8 census | ||
| 346 | +widened to 4:2:2 with measured deltas, unchanged 4:2:0/4:4:4 controls, a 324/324 | ||
| 347 | +comparator liveness control, and an honest arm-reach census of its own. | ||
| 348 | + | ||
| 349 | +**Not done, with the unblock:** | ||
| 350 | + | ||
| 351 | +* **No committed 4:2:2 gate.** The end-to-end gate needs the refusal lifted; a | ||
| 352 | + committed one is red today for a reason that has nothing to do with this lane. Hand | ||
| 353 | + the measured expectations in §3.2 over with the lift — they are the numbers a | ||
| 354 | + committed gate should pin, and §3.5 is the exact command set to re-derive them. | ||
| 355 | +* **The 128-root CHUNKS and pair-wide 4:2:2 arms are still unwitnessed** (§4 items 1-2). | ||
| 356 | + They need a recipe that reaches them; the census is now able to measure whichever | ||
| 357 | + cell that is. | ||
| 358 | + | ||
| 359 | +--- | ||
| 360 | + | ||
| 361 | +## 7. Incidents and observations, reported rather than buried | ||
| 362 | + | ||
| 363 | +1. **A relative-path edit leaked into the PRIMARY checkout, and was caught and reverted.** | ||
| 364 | + My first two `edit` calls used the relative path `crates/ec-av1/src/...` while the | ||
| 365 | + shell CWD was the primary checkout, so they landed in | ||
| 366 | + `/home/user/Documents/Code/Rust/edith_codecs` instead of the lane worktree — the | ||
| 367 | + tool reported success and the worktree looked untouched. Caught by | ||
| 368 | + `git status --porcelain` in the primary (2 modified files), the diff was confirmed to | ||
| 369 | + be entirely mine (57 insertions, all of them census text), saved to a patch file, | ||
| 370 | + and the primary was restored with `git checkout --`; `git status --porcelain` in the | ||
| 371 | + primary is **empty**. The work was then re-applied with **absolute paths**. Final | ||
| 372 | + state: primary clean, `grep -c 'TEMP-PROBE-BYPASS\|if false &&'` = 0 in every tree I | ||
| 373 | + touched. This is the same near-miss the liftrisk study reported from the other | ||
| 374 | + direction (§0.1) — the check that found it is `git status` in the primary, and it | ||
| 375 | + should be the first thing after the first edit, not the last. | ||
| 376 | +2. **`EC_AV1_FINAL_DUMP` is written PRE-grain, so a film-grain stream can never compare | ||
| 377 | + byte-exact through it.** Measured on `g422_t5.obu` (4:2:2 + `--film-grain-test=5`): | ||
| 378 | + our dump differs from ffmpeg 8.1.3 in **100396 of 153600 bytes** (Y 76.7%, U 55.5%, | ||
| 379 | + V 52.6%, max delta 16) with the default decoder, with `-c:v libaom-av1`, and with | ||
| 380 | + `-c:v libdav1d` — and our own output is **byte-identical with and without | ||
| 381 | + `EC_AV1_NO_GRAIN=1`**. The cause is the dump's placement, not the decode: the dump | ||
| 382 | + writes `picture` at `stream.rs:2215` ("the frame exactly as it is about to be stored | ||
| 383 | + into the reference slots"), while `apply_grain` runs later at `stream.rs:1326` on | ||
| 384 | + the emitted output. ffmpeg's rawvideo is post-grain. **This is not a defect of my | ||
| 385 | + lane and I did not touch it** — but the grain lane's report §6 lists `g422_t5.obu` as | ||
| 386 | + byte-exact, and that is only reproducible through the in-memory `decode_stream` | ||
| 387 | + comparator it used, not through the dump path. Worth knowing before a lift writes a | ||
| 388 | + grain-cell gate on the dump path. My census numbers for `g422_t5` are therefore | ||
| 389 | + reported as walk-shape only, with no exactness claim attached. | ||
| 390 | +3. **Probe bypass hygiene, verified.** Both scratch trees carried | ||
| 391 | + `// TEMP-PROBE-BYPASS lane-av1422census422` + `if false &&` at `stream.rs:1803` for | ||
| 392 | + the measurements only. Restored with `git checkout --`, then verified: the guard | ||
| 393 | + reads plain at line 1803, `grep -c 'TEMP-PROBE-BYPASS\|if false &&'` = 0, the | ||
| 394 | + restored probe **refuses** `s422_320x240` by name again, and the | ||
| 395 | + `census422-base` worktree is removed (`git worktree list` no longer lists it). The | ||
| 396 | + probe binary that the committed scripts hardcode | ||
| 397 | + (`/home/user/.cache/tgt/av1422seed/...`) was never written by this lane; my own | ||
| 398 | + `tgt/census422` binary was rebuilt from the clean tree and re-verified to refuse. | ||
| 399 | +4. **FYI, not mine:** `git worktree list` shows two *other* lanes' trees carrying a | ||
| 400 | + `TEMP-PROBE-BYPASS` in `crates/ec-av1/src/stream.rs` right now | ||
| 401 | + (`~/.cache/wt/av1422luma-probe`, `~/.cache/wt/av1422tailskip`). Each lane restores | ||
| 402 | + its own; flagging it only because a bypass left in a tree is one `git add -A` from | ||
| 403 | + admitting 4:2:2 silently. | ||