gates: close the two blind 1:4 / delta_q recipes, prove the drl one unreachable
Browse files at this commit4359ea0b605aa8ffdeef508ee9dcf69b77fb7a32Parent: f3a70c99 changed files +1025 -469
- crates/ec-av1/examples/decode_probe.rs +6 -0
- crates/ec-av1/examples/enc_probe.rs +12 -4
- crates/ec-av1/fixtures/intra14_256x192_10bit.obu +0 -0
- crates/ec-av1/fixtures/intra14_256x192_8bit.obu +0 -0
- crates/ec-av1/fixtures/rect64_dq_drift.obu +0 -0
- crates/ec-av1/src/encode.rs +49 -0
- crates/ec-av1/src/stream.rs +521 -431
- crates/ec-av1/src/tile.rs +28 -34
- lanes/av1recipehunt.report.md +409 -0
crates/ec-av1/examples/decode_probe.rsmodified+6 -0
| @@ -271,6 +271,12 @@ fn main() { | ||
| 271 | 271 | // lane-thread2: proof the frame-parallel path actually fired (0 at |
| 272 | 272 | // the default EC_AV1_THREADS=1). |
| 273 | 273 | println!("frames_dispatched: {}", ec_av1::stream::frames_dispatched()); |
| 274 | + // lane-av1recipehunt: `intra_rect4_in_inter` above already reports the | |
| 275 | + // 1:4-in-inter shapes; this is the `delta_q` half of the same story -- | |
| 276 | + // how many delta_q groups the stream really carried, and how many of | |
| 277 | + // them landed inside a rect64 dequant. | |
| 278 | + let (dq, dq_drift) = ec_av1::stream::rect64_qidx_drift_counters(); | |
| 279 | + println!("delta_q: groups_read={dq} rect64_qidx_drift={dq_drift}"); | |
| 274 | 280 | }; |
| 275 | 281 | // lane-tiles: the tiling a real stream actually uses is a decision input |
| 276 | 282 | // (every gate in `stream.rs` picks its own `--tile-columns`), so report it |
crates/ec-av1/examples/enc_probe.rsmodified+12 -4
| @@ -20,9 +20,10 @@ fn main() { | ||
| 20 | 20 | true => (0, 0), |
| 21 | 21 | false => (a[1].parse().unwrap(), a[2].parse().unwrap()), |
| 22 | 22 | }; |
| 23 | - let qs: Vec<u8> = a | |
| 24 | - .get(4) | |
| 25 | - .map_or_else(|| vec![150, 120, 90, 60], |s| s.split(',').map(|q| q.parse().unwrap()).collect()); | |
| 23 | + let qs: Vec<u8> = a.get(4).map_or_else( | |
| 24 | + || vec![150, 120, 90, 60], | |
| 25 | + |s| s.split(',').map(|q| q.parse().unwrap()).collect(), | |
| 26 | + ); | |
| 26 | 27 | |
| 27 | 28 | // lane-census/lane-probe: the BD gate's native rows CROP (`EC_ENC_VF`) and |
| 28 | 29 | // SEEK (`EC_ENC_SS`) -- without the seek this probe read film B's black |
| @@ -71,7 +72,10 @@ fn main() { | ||
| 71 | 72 | .join(" ") |
| 72 | 73 | }; |
| 73 | 74 | println!(" census luma SAD rank of RD winner: {}", pct(&luma_rank)); |
| 74 | - println!(" census chroma SAD rank of RD winner: {}", pct(&chroma_rank)); | |
| 75 | + println!( | |
| 76 | + " census chroma SAD rank of RD winner: {}", | |
| 77 | + pct(&chroma_rank) | |
| 78 | + ); | |
| 75 | 79 | } |
| 76 | 80 | // lane-arfmode: the engagement counter of the top ARF's offer-set |
| 77 | 81 | // lever, taken once per point so an armed run PRINTS a non-zero count |
| @@ -80,6 +84,10 @@ fn main() { | ||
| 80 | 84 | // control's own expectation. |
| 81 | 85 | let hits = ec_av1::encode::take_arfmode_hits(); |
| 82 | 86 | println!(" arfmode hits: {} {} {}", hits[0], hits[1], hits[2]); |
| 87 | + // lane-av1recipehunt: the gate's own precondition number -- how many | |
| 88 | + // blocks this point's search picked a DRL index the write-time stack | |
| 89 | + // could not carry. | |
| 90 | + println!(" drl_clamp: {}", ec_av1::tile::drl_clamp_hits()); | |
| 83 | 91 | } |
| 84 | 92 | println!("wall {:.3}s", start.elapsed().as_secs_f64()); |
| 85 | 93 | } |
crates/ec-av1/fixtures/intra14_256x192_10bit.obuadded+0 -0
Binary file changed
crates/ec-av1/fixtures/intra14_256x192_8bit.obuadded+0 -0
Binary file changed
crates/ec-av1/fixtures/rect64_dq_drift.obuadded+0 -0
Binary file changed
crates/ec-av1/src/encode.rsmodified+49 -0
| @@ -19446,6 +19446,55 @@ mod tests { | ||
| 19446 | 19446 | ); |
| 19447 | 19447 | } |
| 19448 | 19448 | |
| 19449 | + /// lane-av1recipehunt (2026-09-29): this gate is NOT closeable by any | |
| 19450 | + /// recipe, and the reason is structural, so do not spend another sweep on | |
| 19451 | + /// it. `DRL_CLAMP_HITS` is bumped by `tile::write_inter_mode` (and the two | |
| 19452 | + /// compound walks) only when the search chose a `ref_mv_idx` the write-time | |
| 19453 | + /// stack could not signal -- and on this tree the search's offer set is | |
| 19454 | + /// provably INSIDE the signalable range in every mode: | |
| 19455 | + /// * `NEWMV`: `best_new_mv_syntax` enumerates `for idx in 0..3` (0, 1, 2), | |
| 19456 | + /// and `tile::write_drl_idx`'s ceiling from `start = 0` is | |
| 19457 | + /// `start + 2` = 2. The search's ceiling IS the writer's ceiling. | |
| 19458 | + /// * `NEARMV`: the search's own candidate loop is `for idx in 1..=2` and | |
| 19459 | + /// the writer's ceiling from `start = 1` is 3, but the walk also stops | |
| 19460 | + /// at `entries.len() > idx + 1` and the search only offers an index the | |
| 19461 | + /// stack really holds (`entries.get(idx).is_some()`), so the two | |
| 19462 | + /// bounds coincide. | |
| 19463 | + /// * the compound arms: every compound `InterInfo` the search builds | |
| 19464 | + /// hardcodes `ref_mv_idx: 0`, which is inside the walk's range. | |
| 19465 | + /// This is not an inference -- the tree already ASSERTS it, over stack | |
| 19466 | + /// sizes 0..=4, in | |
| 19467 | + /// [`tests::every_drl_index_the_new_mv_pricer_offers_is_one_the_writer_can_signal`] | |
| 19468 | + /// (`signalled_drl_idx(entries, start, idx) == idx` for every index either | |
| 19469 | + /// pricer offers). That test and this gate are two readings of one | |
| 19470 | + /// invariant; the counter this gate waits on can never leave zero. | |
| 19471 | + /// | |
| 19472 | + /// MEASURED (lane-av1recipehunt), 153 clip x size x frame-count x q | |
| 19473 | + /// combinations through `enc_probe` (mandelbrot / testsrc2 / white noise / | |
| 19474 | + /// scrolling bands / a 4x4 mosaic / 4-px luminance bands / a panning field | |
| 19475 | + /// with a faster band / diagonal bands / alternating hard tiles / three | |
| 19476 | + /// independently moving bands; 320x192, 640x384, 1280x768; 8..16 frames; | |
| 19477 | + /// q 60..220): `tile::drl_clamp_hits()` = 0 on EVERY one. A trace on | |
| 19478 | + /// `best_new_mv_syntax` shows the search DOES pick `idx = 2` often (163 | |
| 19479 | + /// times on mandelbrot 640x384x8) -- index 2 is exactly what the writer | |
| 19480 | + /// signals, so it is a legal pick, not a clamp. | |
| 19481 | + /// | |
| 19482 | + /// MUTATION PROOF that the recipe was never the problem: widening the | |
| 19483 | + /// pricer's offer set (`for idx in 0..3` -> `0..5`, i.e. letting the | |
| 19484 | + /// search ask for index 3/4 that the 2-step walk cannot signal) makes the | |
| 19485 | + /// counter fire on the very first clips tried -- mandelbrot 640x384x8 | |
| 19486 | + /// = 9, mandelbrot 320x192x8 = 2, mosaic 320x192x8 = 2, testsrc2 640x384x8 | |
| 19487 | + /// = 1 -- and the same clips read 0 again the moment the mutation is | |
| 19488 | + /// reverted. The binding constraint is the pricer's offer ceiling, which | |
| 19489 | + /// no clip can move. | |
| 19490 | + /// | |
| 19491 | + /// OWNING FIX (not this lane's to make -- the DRL code is another lane's | |
| 19492 | + /// surface, and the DRL index range is the spec's, not ours): either widen | |
| 19493 | + /// the search's offer set to the spec's own DRL range so the clamp becomes | |
| 19494 | + /// reachable and this gate can witness it, or delete the three dead | |
| 19495 | + /// `note_drl_clamp` sites and this gate with them. Until one of those | |
| 19496 | + /// lands, `#[ignore]` is the honest state and the ignore string below | |
| 19497 | + /// stands. | |
| 19449 | 19498 | #[test] |
| 19450 | 19499 | #[ignore = "sets the process-global superblock size: run it alone"] |
| 19451 | 19500 | fn a_128_superblock_clip_whose_drl_index_the_write_time_stack_cannot_carry_decodes_exact() { |
crates/ec-av1/src/stream.rsmodified+521 -431
| @@ -2170,6 +2170,18 @@ pub fn intra_rect4_in_inter_counters() -> (usize, usize, usize, usize) { | ||
| 2170 | 2170 | ) |
| 2171 | 2171 | } |
| 2172 | 2172 | |
| 2173 | +/// lane-av1recipehunt: the recipe sweep's view of the `delta_q` story from | |
| 2174 | +/// OUTSIDE the crate -- `(delta_q symbol groups read, rect64 dequant calls that | |
| 2175 | +/// saw `CURRENT_Q_IDX != base_q_idx`)`. A recipe that reads delta_q but never | |
| 2176 | +/// lands one inside a rect64 root is a different failure from one that reads | |
| 2177 | +/// neither, and the gate can only tell them apart with both numbers. | |
| 2178 | +pub fn rect64_qidx_drift_counters() -> (usize, usize) { | |
| 2179 | + ( | |
| 2180 | + crate::decode::delta_q_hits(), | |
| 2181 | + crate::decode::rect64_qidx_drift_hits(), | |
| 2182 | + ) | |
| 2183 | +} | |
| 2184 | + | |
| 2173 | 2185 | #[cfg(test)] |
| 2174 | 2186 | pub(crate) mod tests { |
| 2175 | 2187 | use super::*; |
| @@ -39269,25 +39281,61 @@ pub(crate) mod tests { | ||
| 39269 | 39281 | } |
| 39270 | 39282 | } |
| 39271 | 39283 | |
| 39272 | - /// lane-rect64q r1: same recipe as | |
| 39284 | + /// lane-rect64q r1, recipe rewritten by lane-av1recipehunt: the same | |
| 39285 | + /// encoder-side situation as | |
| 39273 | 39286 | /// [`a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact`] |
| 39274 | - /// minus `--deltaq-mode=0` -- real aomenc's non-realtime default is | |
| 39275 | - /// `DELTA_Q_OBJECTIVE` (`av1_cx_iface.c:271`), so dropping that one flag | |
| 39276 | - /// is enough to make `delta_q_present=1` the norm and drive | |
| 39277 | - /// [`crate::decode::decode_block_rect64`]'s running `CURRENT_Q_IDX` away | |
| 39278 | - /// from the frame-constant `base_q_idx` inside a real rect64 SB -- | |
| 39279 | - /// exactly the bug this round's dequant fix targets. Hard-asserts | |
| 39280 | - /// `rect64_qidx_drift_hits() > 0`: without that, this gate could pass | |
| 39281 | - /// vacuously the same way the `--deltaq-mode=0` sibling always did. | |
| 39282 | - /// | |
| 39283 | - /// lane-rect64q r1: measured, does NOT fire -- 15/40 attempts matched | |
| 39284 | - /// but `rect64_qidx_drift_hits()` stayed 0 every time. Real aomenc's RD | |
| 39285 | - /// never chose a nonzero delta-q on this tiny synthetic gradients frame | |
| 39286 | - /// even with `deltaq-mode` left at its default; `#[ignore]`d rather than | |
| 39287 | - /// deleted so the recipe and the negative result both survive for the | |
| 39288 | - /// next attempt (see `lanes/rect64q-r1.report.md`). | |
| 39289 | - #[test] | |
| 39290 | - #[ignore = "gate recipe never fires the feature (40/40 streams pixel-exact); needs a recipe that produces a rect64 dequant call with CURRENT_Q_IDX != base_q_idx -- class gate-blind-to-feature"] | |
| 39287 | + /// -- a real superblock-level HORZ/VERT partition, so | |
| 39288 | + /// [`crate::decode::decode_block_rect64`] runs -- but with `delta_q` left | |
| 39289 | + /// ON, so that block's dequant sees a running `CURRENT_Q_IDX` that has | |
| 39290 | + /// drifted away from the frame-constant `base_q_idx`. Real aomenc's | |
| 39291 | + /// non-realtime default is `DELTA_Q_OBJECTIVE` (`av1_cx_iface.c:271`); the | |
| 39292 | + /// `--deltaq-mode=0` sibling is the same command line with that one flag | |
| 39293 | + /// added back, and this gate ASSERTS the pair differs (the control arm). | |
| 39294 | + /// | |
| 39295 | + /// **Why r1's recipe could not fire, measured (lane-av1recipehunt).** r1 | |
| 39296 | + /// swept 40 attempts of `gradients` at 192x128 with `frame_count = 1` -- a | |
| 39297 | + /// single KEY frame, and that is the whole reason. A one-frame encode | |
| 39298 | + /// carries no inter frame, and `delta_q_present` needs the temporal (TPL) | |
| 39299 | + /// model to see a spatial complexity map at all. At `frame_count = 1` the | |
| 39300 | + /// sweep read ZERO `delta_q` symbol groups on every attempt: 40/40 streams | |
| 39301 | + /// had `delta_q_hits() == 0` AND `rect64_qidx_drift_hits() == 0` -- a | |
| 39302 | + /// different failure from "the drift never reached a rect64 block", and the | |
| 39303 | + /// reason r1 could not see the feature at all. The fix is a real inter | |
| 39304 | + /// sequence: 4 frames at 512x384 (`8x6` superblocks, so there IS a spatial | |
| 39305 | + /// map for the quantizer to vary over). | |
| 39306 | + /// | |
| 39307 | + /// **The recipe**, exactly (the recorded command line; `--deltaq-mode` is | |
| 39308 | + /// ABSENT, i.e. aomenc's default): | |
| 39309 | + /// ```text | |
| 39310 | + /// ffmpeg -v error -y -f lavfi -i testsrc2=size=512x384:rate=25 \ | |
| 39311 | + /// -pix_fmt yuv420p -frames:v 4 -f yuv4mpegpipe src512.y4m | |
| 39312 | + /// aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=45 --cpu-used=0 \ | |
| 39313 | + /// --threads=1 --row-mt=0 --sb-size=64 --enable-rect-partitions=1 \ | |
| 39314 | + /// --enable-ab-partitions=0 --enable-1to4-partitions=0 \ | |
| 39315 | + /// --min-partition-size=32 --max-partition-size=64 \ | |
| 39316 | + /// --enable-restoration=0 --enable-palette=0 --enable-cdef=0 \ | |
| 39317 | + /// --enable-filter-intra=0 --enable-cfl-intra=0 --enable-intrabc=0 \ | |
| 39318 | + /// --enable-tx-size-search=0 --obu -o out.obu src512.y4m | |
| 39319 | + /// ``` | |
| 39320 | + /// Source `src512.y4m`: 1179730 bytes, sha256 | |
| 39321 | + /// `f430d581497e4f6f7db07d0fc92476e92194e1f96c321988ec0739d475cbbe0c`. | |
| 39322 | + /// Output `crates/ec-av1/fixtures/rect64_dq_drift.obu`: 8384 bytes, sha256 | |
| 39323 | + /// `094e51bb21b6caccc905417e95a03f9131b448071567d0b14ec8850799ea2501` | |
| 39324 | + /// (committed with `git add -f` past the `fixtures` gitignore, like every | |
| 39325 | + /// sibling fixture). The gate re-encodes live and byte-compares against | |
| 39326 | + /// that pin, so the pin is the expected output and not a second decode | |
| 39327 | + /// path. MEASURED on the feature arm: 48 `delta_q` symbol groups read, 17 | |
| 39328 | + /// `rect64_qidx_drift_hits`, `sb_rect_hits` firing (the `inter_rect` | |
| 39329 | + /// census reads `64x32=2 32x64=2`), all 4 frames pixel-exact vs ffmpeg. | |
| 39330 | + /// On the `--deltaq-mode=0` control: 0 groups, 0 drift, also pixel-exact -- | |
| 39331 | + /// so the drift is the delta_q syntax, not some unrelated arm. | |
| 39332 | + /// | |
| 39333 | + /// `--cpu-used=0` is load-bearing, measured: the same source at | |
| 39334 | + /// `--cpu-used=1` and `--cpu-used=3` reads the same 48 `delta_q` groups and | |
| 39335 | + /// drifts ZERO times (the faster presets' RD never leaves a rect64 root in | |
| 39336 | + /// a superblock whose quantizer moved). `--cq-level` is not: 45 and 55 | |
| 39337 | + /// give the identical stream and the same drift count. | |
| 39338 | + #[test] | |
| 39291 | 39339 | fn a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_and_delta_q_decodes_pixel_exact() |
| 39292 | 39340 | { |
| 39293 | 39341 | const NAME: &str = "a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_and_delta_q_decodes_pixel_exact"; |
| @@ -39300,124 +39348,142 @@ pub(crate) mod tests { | ||
| 39300 | 39348 | eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); |
| 39301 | 39349 | return; |
| 39302 | 39350 | } |
| 39303 | - let (width, height, frame_count) = (192usize, 128usize, 1usize); | |
| 39304 | - let mut named_refusals = 0u32; | |
| 39305 | - let mut matched = 0u32; | |
| 39306 | - let n_attempts: u32 = std::env::var("EC_SBPART_DQ_GATE_ATTEMPTS") | |
| 39307 | - .ok() | |
| 39308 | - .and_then(|s| s.parse().ok()) | |
| 39309 | - .unwrap_or(40); | |
| 39310 | - for attempt in 0..n_attempts { | |
| 39311 | - let seed = 42 + attempt; | |
| 39312 | - let duration = frame_count as f64 / 25.0; | |
| 39313 | - let source = | |
| 39314 | - gradients_source(seed, width, height, &format!("duration={duration}:rate=25")); | |
| 39315 | - let y4m = Command::new("ffmpeg") | |
| 39316 | - .args([ | |
| 39317 | - "-v", | |
| 39318 | - "error", | |
| 39319 | - "-f", | |
| 39320 | - "lavfi", | |
| 39321 | - "-i", | |
| 39322 | - &source, | |
| 39323 | - "-pix_fmt", | |
| 39324 | - "yuv420p", | |
| 39325 | - "-f", | |
| 39326 | - "yuv4mpegpipe", | |
| 39327 | - "-", | |
| 39328 | - ]) | |
| 39329 | - .stdin(Stdio::null()) | |
| 39330 | - .stdout(Stdio::piped()) | |
| 39331 | - .stderr(Stdio::piped()) | |
| 39332 | - .output() | |
| 39333 | - .expect("ffmpeg failed to run"); | |
| 39334 | - assert!( | |
| 39335 | - y4m.status.success(), | |
| 39336 | - "ffmpeg fixture: {}", | |
| 39337 | - String::from_utf8_lossy(&y4m.stderr) | |
| 39338 | - ); | |
| 39339 | - let args: Vec<&str> = vec![ | |
| 39340 | - "--codec=av1", | |
| 39341 | - "--passes=1", | |
| 39342 | - "--end-usage=q", | |
| 39343 | - "--cq-level=45", | |
| 39344 | - "--cpu-used=0", | |
| 39345 | - "--threads=1", | |
| 39346 | - "--row-mt=0", | |
| 39347 | - "--sb-size=64", | |
| 39348 | - "--enable-rect-partitions=1", | |
| 39349 | - "--enable-ab-partitions=0", | |
| 39350 | - "--enable-1to4-partitions=0", | |
| 39351 | - "--min-partition-size=32", | |
| 39352 | - "--max-partition-size=64", | |
| 39353 | - "--enable-restoration=0", | |
| 39354 | - "--enable-palette=0", | |
| 39355 | - "--enable-filter-intra=0", | |
| 39356 | - "--enable-cfl-intra=0", | |
| 39357 | - "--enable-intrabc=0", | |
| 39358 | - "--enable-tx-size-search=0", | |
| 39359 | - "--obu", | |
| 39360 | - "-o", | |
| 39361 | - "-", | |
| 39351 | + const FIXTURE_LEN: usize = 8384; | |
| 39352 | + const FIXTURE_FNV: u64 = 0x3d91_a216_8006_3ef6; | |
| 39353 | + let (width, height, frame_count) = (512usize, 384usize, 4usize); | |
| 39354 | + let y4m = Command::new("ffmpeg") | |
| 39355 | + .args([ | |
| 39356 | + "-v", | |
| 39357 | + "error", | |
| 39358 | + "-y", | |
| 39359 | + "-f", | |
| 39360 | + "lavfi", | |
| 39361 | + "-i", | |
| 39362 | + "testsrc2=size=512x384:rate=25", | |
| 39363 | + "-pix_fmt", | |
| 39364 | + "yuv420p", | |
| 39365 | + "-frames:v", | |
| 39366 | + "4", | |
| 39367 | + "-f", | |
| 39368 | + "yuv4mpegpipe", | |
| 39362 | 39369 | "-", |
| 39363 | - ]; | |
| 39364 | - let out = run_with_stdin(Command::new(aomenc_path()).args(&args), &y4m.stdout); | |
| 39365 | - assert!( | |
| 39366 | - out.status.success(), | |
| 39367 | - "aomenc refused the fixture: {}", | |
| 39368 | - String::from_utf8_lossy(&out.stderr) | |
| 39369 | - ); | |
| 39370 | - let stream = out.stdout; | |
| 39371 | - let frames = match decode_stream(&stream) { | |
| 39372 | - Err(e) => { | |
| 39373 | - let msg = e.to_string(); | |
| 39374 | - assert!( | |
| 39375 | - msg.contains("unsupported"), | |
| 39376 | - "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | |
| 39377 | - ); | |
| 39378 | - named_refusals += 1; | |
| 39379 | - eprintln!("seed {seed} refusal: {msg}"); | |
| 39380 | - continue; | |
| 39381 | - } | |
| 39382 | - Ok(frames) => frames, | |
| 39383 | - }; | |
| 39384 | - let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); | |
| 39385 | - assert_eq!(frames.len(), frame_count); | |
| 39386 | - let mismatched = frames | |
| 39387 | - .iter() | |
| 39388 | - .zip(&ffmpeg_frames) | |
| 39389 | - .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | |
| 39390 | - if mismatched { | |
| 39391 | - if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { | |
| 39392 | - std::fs::write(&path, &stream).expect("writing pinned stream"); | |
| 39393 | - eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | |
| 39394 | - } | |
| 39395 | - } | |
| 39396 | - for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 39397 | - assert_eq!( | |
| 39398 | - got.y, want.y, | |
| 39399 | - "{NAME} frame {i} luma vs ffmpeg (seed {seed})" | |
| 39400 | - ); | |
| 39401 | - assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | |
| 39402 | - assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | |
| 39403 | - } | |
| 39404 | - matched += 1; | |
| 39405 | - } | |
| 39370 | + ]) | |
| 39371 | + .stdin(Stdio::null()) | |
| 39372 | + .stdout(Stdio::piped()) | |
| 39373 | + .stderr(Stdio::piped()) | |
| 39374 | + .output() | |
| 39375 | + .expect("ffmpeg failed to run"); | |
| 39406 | 39376 | assert!( |
| 39407 | - matched > 0, | |
| 39408 | - "{NAME}: every attempt refused; the gate never decoded a stream" | |
| 39377 | + y4m.status.success(), | |
| 39378 | + "ffmpeg fixture: {}", | |
| 39379 | + String::from_utf8_lossy(&y4m.stderr) | |
| 39409 | 39380 | ); |
| 39381 | + assert_eq!( | |
| 39382 | + y4m.stdout.len(), | |
| 39383 | + 1_179_730, | |
| 39384 | + "{NAME}: the testsrc2 source is not the pinned 4-frame 512x384 y4m -- `rate=` \ | |
| 39385 | + and `-frames:v` are both part of this recipe's identity" | |
| 39386 | + ); | |
| 39387 | + // Every flag spelled exactly once (class [[aomenc-last-flag-wins]]). | |
| 39388 | + // `delta_q` is absent ON PURPOSE: aomenc's non-realtime default is | |
| 39389 | + // DELTA_Q_OBJECTIVE, and the control arm below re-checks that by | |
| 39390 | + // ADDING `--deltaq-mode=0` back. | |
| 39391 | + let args: Vec<&str> = vec![ | |
| 39392 | + "--codec=av1", | |
| 39393 | + "--passes=1", | |
| 39394 | + "--end-usage=q", | |
| 39395 | + "--cq-level=45", | |
| 39396 | + "--cpu-used=0", | |
| 39397 | + "--threads=1", | |
| 39398 | + "--row-mt=0", | |
| 39399 | + "--sb-size=64", | |
| 39400 | + "--enable-rect-partitions=1", | |
| 39401 | + "--enable-ab-partitions=0", | |
| 39402 | + "--enable-1to4-partitions=0", | |
| 39403 | + "--min-partition-size=32", | |
| 39404 | + "--max-partition-size=64", | |
| 39405 | + "--enable-restoration=0", | |
| 39406 | + "--enable-palette=0", | |
| 39407 | + "--enable-cdef=0", | |
| 39408 | + "--enable-filter-intra=0", | |
| 39409 | + "--enable-cfl-intra=0", | |
| 39410 | + "--enable-intrabc=0", | |
| 39411 | + "--enable-tx-size-search=0", | |
| 39412 | + "--obu", | |
| 39413 | + "-o", | |
| 39414 | + "-", | |
| 39415 | + "-", | |
| 39416 | + ]; | |
| 39417 | + let out = run_with_stdin(Command::new(aomenc_path()).args(&args), &y4m.stdout); | |
| 39410 | 39418 | assert!( |
| 39411 | - crate::decode::rect64_qidx_drift_hits() > 0, | |
| 39412 | - "{NAME}: zero rect64 dequant calls ever observed CURRENT_Q_IDX != base_q_idx \ | |
| 39413 | - ({matched} matches, {named_refusals} refusals out of {n_attempts}) -- delta_q \ | |
| 39414 | - was never actually exercised through decode_block_rect64 this run" | |
| 39419 | + out.status.success(), | |
| 39420 | + "aomenc refused the fixture: {}", | |
| 39421 | + String::from_utf8_lossy(&out.stderr) | |
| 39422 | + ); | |
| 39423 | + let stream = out.stdout; | |
| 39424 | + assert_eq!(stream.len(), FIXTURE_LEN, "{NAME}: encoded size moved"); | |
| 39425 | + assert_eq!(fnv1a64(&stream), FIXTURE_FNV, "{NAME}: encoded bytes moved"); | |
| 39426 | + let pin = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) | |
| 39427 | + .join("fixtures/rect64_dq_drift.obu"); | |
| 39428 | + assert_eq!( | |
| 39429 | + std::fs::read(&pin).expect("fixtures/rect64_dq_drift.obu must be committed"), | |
| 39430 | + stream, | |
| 39431 | + "{NAME}: the live encode no longer matches the committed pin at {}", | |
| 39432 | + pin.display() | |
| 39433 | + ); | |
| 39434 | + | |
| 39435 | + let before = crate::decode::rect64_qidx_drift_hits(); | |
| 39436 | + let frames = decode_stream(&stream) | |
| 39437 | + .unwrap_or_else(|e| panic!("{NAME}: the pinned stream must decode: {e}")); | |
| 39438 | + let drift = crate::decode::rect64_qidx_drift_hits() - before; | |
| 39439 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); | |
| 39440 | + assert_eq!(frames.len(), frame_count); | |
| 39441 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 39442 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg"); | |
| 39443 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg"); | |
| 39444 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg"); | |
| 39445 | + } | |
| 39446 | + assert!( | |
| 39447 | + crate::decode::sb_rect_hits() > 0, | |
| 39448 | + "{NAME}: zero superblock-level HORZ/VERT blocks fired -- the recipe stopped producing \ | |
| 39449 | + the shape the delta_q group is read inside" | |
| 39450 | + ); | |
| 39451 | + assert!( | |
| 39452 | + drift > 0, | |
| 39453 | + "{NAME}: {frame_count} frames pixel-exact but zero rect64 dequant calls ever saw \ | |
| 39454 | + CURRENT_Q_IDX != base_q_idx -- delta_q was read and never moved the quantizer inside \ | |
| 39455 | + a rect64 block, so this run proved nothing (class gate-blind-to-feature)" | |
| 39456 | + ); | |
| 39457 | + | |
| 39458 | + // The control arm: the ONE flag separating this gate from the | |
| 39459 | + // always-vacuous `--deltaq-mode=0` sibling, reverted. If this ever | |
| 39460 | + // drifts too, delta_q is no longer what carries the coverage and the | |
| 39461 | + // feature arm above is not the witness it claims to be. It is also this | |
| 39462 | + // gate's own red-proof: dropping that one flag is exactly what turns | |
| 39463 | + // the drift assert above red on its own precondition. | |
| 39464 | + let mut control = args.clone(); | |
| 39465 | + control.push("--deltaq-mode=0"); | |
| 39466 | + let ctl = run_with_stdin(Command::new(aomenc_path()).args(&control), &y4m.stdout); | |
| 39467 | + assert!( | |
| 39468 | + ctl.status.success(), | |
| 39469 | + "aomenc refused the --deltaq-mode=0 control: {}", | |
| 39470 | + String::from_utf8_lossy(&ctl.stderr) | |
| 39471 | + ); | |
| 39472 | + let before = crate::decode::rect64_qidx_drift_hits(); | |
| 39473 | + decode_stream(&ctl.stdout) | |
| 39474 | + .unwrap_or_else(|e| panic!("{NAME}: the control stream must decode too: {e}")); | |
| 39475 | + let ctl_drift = crate::decode::rect64_qidx_drift_hits() - before; | |
| 39476 | + assert_eq!( | |
| 39477 | + ctl_drift, 0, | |
| 39478 | + "{NAME}: the --deltaq-mode=0 control drifted {ctl_drift} times -- delta_q is no \ | |
| 39479 | + longer what moves CURRENT_Q_IDX inside a rect64 block, so the feature arm above is \ | |
| 39480 | + not witnessing what it names" | |
| 39415 | 39481 | ); |
| 39416 | 39482 | eprintln!( |
| 39417 | - "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of \ | |
| 39418 | - {n_attempts}, sb_rect_hits={}, rect64_qidx_drift_hits={}", | |
| 39419 | - crate::decode::sb_rect_hits(), | |
| 39420 | - crate::decode::rect64_qidx_drift_hits() | |
| 39483 | + "{NAME}: {frame_count} frames pixel-exact, sb_rect_hits={}, \ | |
| 39484 | + rect64_qidx_drift_hits={drift} (--deltaq-mode=0 control: {ctl_drift}), stream \ | |
| 39485 | + {FIXTURE_LEN} B fnv1a64={FIXTURE_FNV:016x}", | |
| 39486 | + crate::decode::sb_rect_hits() | |
| 39421 | 39487 | ); |
| 39422 | 39488 | } |
| 39423 | 39489 | |
| @@ -42050,85 +42116,127 @@ pub(crate) mod tests { | ||
| 42050 | 42116 | /// `read_intra_block_mode_info` (libaom decodemv.c:1189). |
| 42051 | 42117 | /// |
| 42052 | 42118 | /// Hard-asserts `intra_rect4_strip_in_inter_hits` (0 = 64x16, 1 = 16x64, |
| 42053 | - /// 2 = 32x8, 3 = 8x32) summed over the attempts that were actually | |
| 42054 | - /// pixel-compared, and every decode-order frame is compared. A decode that | |
| 42055 | - /// succeeds is ALWAYS pixel-compared (class | |
| 42056 | - /// [[gate-skips-on-its-own-failure]]); exhausting every attempt without a | |
| 42057 | - /// counted strip is a FAILURE, never a SKIP. | |
| 42058 | - #[test] | |
| 42059 | - // r1 `#[ignore]`d this gate on "every stream with an intra 1:4 strip also | |
| 42060 | - // hits the inter rect-strip refusal". r2 merged main 18bf7dc (lane-r14 | |
| 42061 | - // a2e2e29 lifts exactly that refusal) and re-ran it: 3 of 40 attempts | |
| 42062 | - // decode whole and reach the pixel compare (0 before), one firing | |
| 42063 | - // 64x16=4 16x64=3 -- and the compare FAILED on an unowned inter-frame | |
| 42064 | - // defect (mandelbrot 192x128, luma ~3.7-4.5k samples on frames 3/4 | |
| 42065 | - // drifting to ~24k, max |d| ~220 on frames 5-7). | |
| 42119 | + /// 2 = 32x8, 3 = 8x32) on the one pinned recipe below, and every | |
| 42120 | + /// decode-order frame is compared. A decode that succeeds is ALWAYS | |
| 42121 | + /// pixel-compared (class [[gate-skips-on-its-own-failure]]), and a recipe | |
| 42122 | + /// that decodes exact without a counted strip is a FAILURE, never a pass. | |
| 42123 | + /// The recipe, the pin and the `--enable-1to4-partitions=0` control arm | |
| 42124 | + /// are documented on [`intra_rect4_in_inter_gate`]. | |
| 42125 | + #[test] | |
| 42126 | + // CLOSED by lane-av1recipehunt r1 (un-ignored). Two independent runs agree | |
| 42127 | + // on why this gate was blind, and they are worth keeping side by side. | |
| 42066 | 42128 | // |
| 42067 | 42129 | // lane-av1pins RE-RAN this gate in RELEASE on a21f3680 (the seven-lane |
| 42068 | - // merged tree) and BOTH halves of that r2 record are now stale: | |
| 42069 | - // * THE PIXEL BLOCKER IS GONE. The gate's own tally reads | |
| 42070 | - // `counted-exact=0 uncounted-exact=40 named-refusals=0 (attempts 40)` | |
| 42071 | - // at both bit depths, and there is NOT ONE mismatch line anywhere in | |
| 42072 | - // the full run log -- no frame 3/4 luma counts, no max |d|, no drift. | |
| 42073 | - // 40/40 streams now compare pixel-exact. (The 10-bit arm is identical: | |
| 42074 | - // same 40/40, same zero-mismatch log.) | |
| 42075 | - // * THE RECIPE NO LONGER FIRES THE FEATURE. Every one of the 42 | |
| 42076 | - // counted attempts reads `64x16=0 16x64=0 32x8=0 8x32=0`. The gate has | |
| 42077 | - // regressed from r2's "fires sometimes, compare fails" to "never | |
| 42078 | - // fires", so the assertion now trips on its non-vacuity precondition | |
| 42079 | - // (stream.rs:40653) rather than on any pixel. | |
| 42080 | - // So the reason these gates stay `#[ignore]`d is the RECIPE, exactly as | |
| 42081 | - // the `#[ignore]` string says -- NOT the mandelbrot defect, which the | |
| 42082 | - // string never claimed and which is no longer reproducing. Kept ignored | |
| 42083 | - // rather than un-ignored: a source whose baseline is exact AND that fires | |
| 42084 | - // a 32-level intra 1:4 strip in an inter frame still does not exist. | |
| 42085 | - // (Corrected 2026-09-29: the comment above previously recorded the r2 | |
| 42086 | - // state and would have had a reader re-filing these as blocked on the | |
| 42087 | - // mandelbrot defect, which is wrong on this tree.) | |
| 42088 | - #[ignore = "gate recipe never fires the feature (40/40 streams pixel-exact); needs a recipe that produces a 32-level intra 1:4 strip in an inter frame -- class gate-blind-to-feature"] | |
| 42130 | + // merged tree) and found BOTH halves of the r2 record stale: | |
| 42131 | + // * THE PIXEL BLOCKER IS GONE -- `counted-exact=0 uncounted-exact=40 | |
| 42132 | + // named-refusals=0 (attempts 40)` at both bit depths, and not one | |
| 42133 | + // mismatch line anywhere in the run log. 40/40 pixel-exact. | |
| 42134 | + // * THE RECIPE NEVER FIRES -- every counted attempt reads | |
| 42135 | + // `64x16=0 16x64=0 32x8=0 8x32=0`, so the assert trips on its | |
| 42136 | + // non-vacuity precondition, not on any pixel. | |
| 42137 | + // | |
| 42138 | + // lane-av1recipehunt then found WHY, and closed it. The blindness is not | |
| 42139 | + // the r2 "pre-existing INTER-frame pixel defect" (gone) and not the | |
| 42140 | + // mandelbrot source: the old recipe produced ZERO 1:4 strips of ANY shape | |
| 42141 | + // at ANY level, because `--min-partition-size=32` with an all-but-empty | |
| 42142 | + // intra mode set never puts a 1:4 partition on aomenc's RD menu. | |
| 42143 | + // MEASURED: the 32-level 1:4 counter is 0 in ALL 48 attempts at | |
| 42144 | + // `--min-partition-size=16` and fires in 40 of 48 at 8 with | |
| 42145 | + // `--enable-smooth-intra/paeth-intra/directional-intra/angle-delta=1` | |
| 42146 | + // (a 32x8/8x32 strip needs an intra mode WORTH CODING; with those four | |
| 42147 | + // off the only candidate is DC, and DC never wins a 1:4 strip against | |
| 42148 | + // inter). That also explains r2's "`--enable-1to4-partitions=0` is | |
| 42149 | + // byte-identical": with no 1:4 reachable at all, the flag had nothing to | |
| 42150 | + // turn off. The new recipe is 256x192x6, `--min-partition-size=8`, the | |
| 42151 | + // full intra mode set, `--cpu-used=2 --cq-level=63`; it fires 32x8=8 | |
| 42152 | + // 8x32=11 and is pixel-exact on all 6 frames. See | |
| 42153 | + // [`intra_rect4_in_inter_gate`] for the pin and the flag control arm. | |
| 42089 | 42154 | fn a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact() { |
| 42090 | 42155 | intra_rect4_in_inter_gate(8); |
| 42091 | 42156 | } |
| 42092 | 42157 | |
| 42093 | 42158 | /// The 10-bit arm (both of the user's films are `yuv420p10le`). |
| 42094 | 42159 | #[test] |
| 42095 | - // r1 `#[ignore]`d this gate on "every stream with an intra 1:4 strip also | |
| 42096 | - // hits the inter rect-strip refusal". r2 merged main 18bf7dc (lane-r14 | |
| 42097 | - // a2e2e29 lifts exactly that refusal) and re-ran it: 3 of 40 attempts | |
| 42098 | - // decode whole and reach the pixel compare (0 before), one firing | |
| 42099 | - // 64x16=4 16x64=3 -- and the compare FAILED on an unowned inter-frame | |
| 42100 | - // defect (mandelbrot 192x128, luma ~3.7-4.5k samples on frames 3/4 | |
| 42101 | - // drifting to ~24k, max |d| ~220 on frames 5-7). | |
| 42102 | - // | |
| 42103 | - // lane-av1pins RE-RAN this gate in RELEASE on a21f3680 (the seven-lane | |
| 42104 | - // merged tree) and BOTH halves of that r2 record are now stale: | |
| 42105 | - // * THE PIXEL BLOCKER IS GONE. The gate's own tally reads | |
| 42106 | - // `counted-exact=0 uncounted-exact=40 named-refusals=0 (attempts 40)` | |
| 42107 | - // at both bit depths, and there is NOT ONE mismatch line anywhere in | |
| 42108 | - // the full run log -- no frame 3/4 luma counts, no max |d|, no drift. | |
| 42109 | - // 40/40 streams now compare pixel-exact. (The 10-bit arm is identical: | |
| 42110 | - // same 40/40, same zero-mismatch log.) | |
| 42111 | - // * THE RECIPE NO LONGER FIRES THE FEATURE. Every one of the 42 | |
| 42112 | - // counted attempts reads `64x16=0 16x64=0 32x8=0 8x32=0`. The gate has | |
| 42113 | - // regressed from r2's "fires sometimes, compare fails" to "never | |
| 42114 | - // fires", so the assertion now trips on its non-vacuity precondition | |
| 42115 | - // (stream.rs:40653) rather than on any pixel. | |
| 42116 | - // So the reason these gates stay `#[ignore]`d is the RECIPE, exactly as | |
| 42117 | - // the `#[ignore]` string says -- NOT the mandelbrot defect, which the | |
| 42118 | - // string never claimed and which is no longer reproducing. Kept ignored | |
| 42119 | - // rather than un-ignored: a source whose baseline is exact AND that fires | |
| 42120 | - // a 32-level intra 1:4 strip in an inter frame still does not exist. | |
| 42121 | - // (Corrected 2026-09-29: the comment above previously recorded the r2 | |
| 42122 | - // state and would have had a reader re-filing these as blocked on the | |
| 42123 | - // mandelbrot defect, which is wrong on this tree.) | |
| 42124 | - #[ignore = "gate recipe never fires the feature (40/40 streams pixel-exact); needs a recipe that produces a 32-level intra 1:4 strip in an inter frame -- class gate-blind-to-feature"] | |
| 42160 | + // CLOSED by lane-av1recipehunt r1 (un-ignored), same recipe and same two | |
| 42161 | + // reasons as the 8-bit arm above: lane-av1pins' RELEASE re-run showed the | |
| 42162 | + // pixel blocker gone and the recipe never firing, and the root cause is | |
| 42163 | + // `--min-partition-size=32` plus the pruned intra mode set, not the | |
| 42164 | + // mandelbrot source. The 10-bit cell fires 32x8=12 8x32=7 and is | |
| 42165 | + // pixel-exact on all 6 frames. | |
| 42125 | 42166 | fn a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact_10bit() { |
| 42126 | 42167 | intra_rect4_in_inter_gate(10); |
| 42127 | 42168 | } |
| 42128 | 42169 | |
| 42170 | + /// The one recipe both 1:4-in-inter arms run, rewritten by | |
| 42171 | + /// lane-av1recipehunt. What changed, and why the old sweep could not fire: | |
| 42172 | + /// | |
| 42173 | + /// * `--min-partition-size=32` -> **`8`**. This is the flag that was | |
| 42174 | + /// holding the shape off the menu entirely. MEASURED over 96 encodes | |
| 42175 | + /// (10-bit, 192x128 and 256x192, `--cpu-used` 0..5, cq 63/55, this | |
| 42176 | + /// crate's full intra mode set): at `mps=16` the 32-level 1:4 counter is | |
| 42177 | + /// **0 in all 48 attempts**, at `mps=8` it fires in 40 of 48. The old | |
| 42178 | + /// comment's "min size 16 so the 16x16-level 1:4 is out of reach" was | |
| 42179 | + /// protecting against a refusal that no longer fires -- `mps=8` reaches | |
| 42180 | + /// the 8- and 16-level strips too, and on this content the RD takes | |
| 42181 | + /// neither (the `inter16_1to4` and `rect4_32` inter counters confirm the | |
| 42182 | + /// only 1:4 partitions in the stream are the 32-level ones this gate | |
| 42183 | + /// asserts). | |
| 42184 | + /// * the intra mode set: `--enable-smooth-intra/paeth-intra/ | |
| 42185 | + /// directional-intra/angle-delta` `0` -> **`1`**. A 8x32 or 32x8 strip | |
| 42186 | + /// has four usable intra modes with these on; with them off the only | |
| 42187 | + /// candidate is DC, and DC never wins a 1:4 strip against inter. | |
| 42188 | + /// * the 40-attempt content/preset/cq seed sweep -> one pinned cell at | |
| 42189 | + /// 256x192, 6 frames, `--cpu-used=2 --cq-level=63`. A sweep hides a | |
| 42190 | + /// recipe that works; a pin makes it a precondition. | |
| 42191 | + /// | |
| 42192 | + /// The 8-bit arm's `hue=s=0` and `-t 0.32` are dropped: they only fixed | |
| 42193 | + /// ffmpeg's own frame count across the sweep, and the frame count is now | |
| 42194 | + /// pinned by `-frames:v 6` (6 decode-order frames, `kf-min-dist=1000`, so | |
| 42195 | + /// frame 0 is the only key frame and every counted strip is in an INTER | |
| 42196 | + /// frame). | |
| 42197 | + /// | |
| 42198 | + /// **The recipe**, exactly (the recorded command lines): | |
| 42199 | + /// ```text | |
| 42200 | + /// ffmpeg -v error -y -f lavfi \ | |
| 42201 | + /// -i mandelbrot=size=256x192:start_scale=5.0:end_scale=0.004:end_pts=8:rate=25 \ | |
| 42202 | + /// -pix_fmt yuv420p -frames:v 6 -f yuv4mpegpipe - # 10-bit: yuv420p10le + -strict -1 | |
| 42203 | + /// aomenc [--cpu-used=2 --input-bit-depth=10 -b 10] --codec=av1 --passes=1 --end-usage=q \ | |
| 42204 | + /// --cpu-used=2 --cq-level=63 --threads=1 --row-mt=0 \ | |
| 42205 | + /// --enable-rect-partitions=1 --enable-1to4-partitions=1 \ | |
| 42206 | + /// --min-partition-size=8 --max-partition-size=64 --enable-tx-size-search=0 \ | |
| 42207 | + /// --enable-filter-intra=1 --enable-intra-edge-filter=1 --enable-smooth-intra=1 \ | |
| 42208 | + /// --enable-paeth-intra=1 --enable-directional-intra=1 --enable-angle-delta=1 \ | |
| 42209 | + /// --lag-in-frames=0 --auto-alt-ref=0 --kf-min-dist=1000 --kf-max-dist=1000 \ | |
| 42210 | + /// --enable-order-hint=0 --enable-warped-motion=0 --enable-obmc=0 \ | |
| 42211 | + /// --enable-masked-comp=0 --enable-interintra-comp=0 --enable-dist-wtd-comp=0 \ | |
| 42212 | + /// --enable-diff-wtd-comp=0 --enable-onesided-comp=0 --enable-interintra-wedge=0 \ | |
| 42213 | + /// --enable-smooth-interintra=0 --enable-ab-partitions=0 --enable-cdef=0 \ | |
| 42214 | + /// --enable-restoration=0 --enable-palette=0 --enable-intrabc=0 \ | |
| 42215 | + /// --enable-cfl-intra=0 --enable-ref-frame-mvs=0 --obu -o - - | |
| 42216 | + /// ``` | |
| 42217 | + /// Sources: 8-bit 442462 bytes, sha256 | |
| 42218 | + /// `e4b46799b180a0d3e138caa18b2738c035e349219490313db664814a3eae9ec2`; | |
| 42219 | + /// 10-bit 884828 bytes, sha256 | |
| 42220 | + /// `b7e0602e0bfc7a7f6813f40bb3989ec7574e5fbbfbf190298b9ab5b625156030`. | |
| 42221 | + /// Outputs, committed with `git add -f` past the `fixtures` gitignore: | |
| 42222 | + /// * `fixtures/intra14_256x192_8bit.obu`, 35179 bytes, sha256 | |
| 42223 | + /// `5e50eb6d4492e806a2803988d92bd47f069ca54e02c06344d5500c6b72deb861` | |
| 42224 | + /// (fnv1a64 `0x86f8d1e5a221162a`) -- MEASURED `32x8=8 8x32=11`, | |
| 42225 | + /// `64x16=0 16x64=0`, all 6 frames pixel-exact vs ffmpeg. | |
| 42226 | + /// * `fixtures/intra14_256x192_10bit.obu`, 34727 bytes, sha256 | |
| 42227 | + /// `ab6fae0a256af6410e8200f10827a3e965dee7b2d7ab63710e94968bddab23a2` | |
| 42228 | + /// (fnv1a64 `0xecf9455bc20d60f0`) -- MEASURED `32x8=12 8x32=7`, | |
| 42229 | + /// all 6 frames pixel-exact vs ffmpeg. | |
| 42230 | + /// | |
| 42231 | + /// The gate re-encodes live and byte-compares against the pin, so the pin | |
| 42232 | + /// is the expected output and not a second decode path. The control arm | |
| 42233 | + /// re-runs the SAME command line with `--enable-1to4-partitions=0` and | |
| 42234 | + /// requires the counter to stay at 0 -- that single flag is what carries | |
| 42235 | + /// the coverage, and asserting it is also this gate's own red-proof. | |
| 42129 | 42236 | fn intra_rect4_in_inter_gate(bit_depth: u32) { |
| 42130 | 42237 | const NAME: &str = |
| 42131 | 42238 | "a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact"; |
| 42239 | + let _gate_lock = lock_gate_counters(); | |
| 42132 | 42240 | if !have_ffmpeg() { |
| 42133 | 42241 | eprintln!("SKIP {NAME}: no ffmpeg"); |
| 42134 | 42242 | return; |
| @@ -42137,250 +42245,232 @@ pub(crate) mod tests { | ||
| 42137 | 42245 | eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); |
| 42138 | 42246 | return; |
| 42139 | 42247 | } |
| 42140 | - let (width, height, frame_count) = (192usize, 128usize, 8usize); | |
| 42141 | - let mut refusals: Vec<String> = Vec::new(); | |
| 42142 | - let mut uncounted_exact = 0u32; | |
| 42143 | - let mut compared = 0u32; | |
| 42144 | - let mut shapes = [0usize; 4]; | |
| 42145 | - for attempt in 0..40u32 { | |
| 42146 | - let seed = 42 + attempt; | |
| 42147 | - // Same source class as the 2:1 sibling gate: a FAST mandelbrot | |
| 42148 | - // zoom (`end_scale`/`end_pts`) so consecutive frames share almost | |
| 42149 | - // no content and aomenc's RD codes blocks INTRA inside INTER | |
| 42150 | - // frames, with `--kf-min-dist=1000` forbidding a new key frame. | |
| 42151 | - let source = format!( | |
| 42152 | - "mandelbrot=size={width}x{height}:start_scale={}:end_scale=0.004:end_pts=8:rate=25", | |
| 42153 | - 5.0 - f64::from(attempt) * 0.06 | |
| 42154 | - ); | |
| 42155 | - let y4m = Command::new("ffmpeg") | |
| 42156 | - .args([ | |
| 42157 | - "-v", | |
| 42158 | - "error", | |
| 42159 | - "-f", | |
| 42160 | - "lavfi", | |
| 42161 | - "-i", | |
| 42162 | - &source, | |
| 42163 | - "-vf", | |
| 42164 | - "hue=s=0", | |
| 42165 | - "-pix_fmt", | |
| 42166 | - if bit_depth == 10 { | |
| 42167 | - "yuv420p10le" | |
| 42168 | - } else { | |
| 42169 | - "yuv420p" | |
| 42170 | - }, | |
| 42171 | - "-strict", | |
| 42172 | - "-1", | |
| 42173 | - "-t", | |
| 42174 | - "0.32", | |
| 42175 | - "-f", | |
| 42176 | - "yuv4mpegpipe", | |
| 42177 | - "-strict", | |
| 42178 | - "-1", | |
| 42179 | - "-", | |
| 42180 | - ]) | |
| 42181 | - .stdin(Stdio::null()) | |
| 42182 | - .stdout(Stdio::piped()) | |
| 42183 | - .stderr(Stdio::piped()) | |
| 42184 | - .output() | |
| 42185 | - .expect("ffmpeg failed to run"); | |
| 42186 | - assert!( | |
| 42187 | - y4m.status.success(), | |
| 42188 | - "ffmpeg fixture: {}", | |
| 42189 | - String::from_utf8_lossy(&y4m.stderr) | |
| 42190 | - ); | |
| 42191 | - let depth_args: &[&str] = if bit_depth == 10 { | |
| 42192 | - &["-b", "10", "--input-bit-depth=10"] | |
| 42193 | - } else { | |
| 42194 | - &[] | |
| 42195 | - }; | |
| 42196 | - // MEASURED (r1, 40 attempts): `--cpu-used=0` makes aomenc pick | |
| 42197 | - // 128x128 superblocks on this frame size, which decode_stream | |
| 42198 | - // refuses by name, so the preset sweep starts at 1. | |
| 42199 | - let cpu = format!("--cpu-used={}", 1 + attempt % 4); | |
| 42200 | - // The higher the quantiser the more 1:4 intra strips inside inter | |
| 42201 | - // frames, so the sweep walks cq 63 first. | |
| 42202 | - let cq = format!( | |
| 42203 | - "--cq-level={}", | |
| 42204 | - [63u32, 55, 45, 35][(attempt / 4) as usize % 4] | |
| 42205 | - ); | |
| 42206 | - let out = run_with_stdin( | |
| 42207 | - Command::new(aomenc_path()) | |
| 42208 | - .args(depth_args) | |
| 42209 | - .arg(&cpu) | |
| 42210 | - .arg(&cq) | |
| 42211 | - .args([ | |
| 42212 | - // Every flag spelled exactly once (class | |
| 42213 | - // [[aomenc-last-flag-wins]]). These are what the gate is | |
| 42214 | - // about: 1:4 partitions ON, min size 16 so the 16x16-level | |
| 42215 | - // 1:4 (refused elsewhere) is out of reach. | |
| 42216 | - "--enable-rect-partitions=1", | |
| 42217 | - "--enable-1to4-partitions=1", | |
| 42218 | - // MEASURED (r1): at `--min-partition-size=16` aomenc codes | |
| 42219 | - // 16x16-level 1:4 partitions (16x4/4x16 strips), which the | |
| 42220 | - // inter partition path refuses by name (another lane's | |
| 42221 | - // surface) in 12/40 attempts. 32 keeps this gate's two | |
| 42222 | - // reachable levels -- the 32-level 32x8/8x32 and the | |
| 42223 | - // superblock-level 64x16/16x64 -- and nothing else. | |
| 42224 | - "--min-partition-size=32", | |
| 42225 | - "--max-partition-size=64", | |
| 42226 | - // MEASURED (r1): with tx-size search ON, 8/40 attempts stop | |
| 42227 | - // at the 2:1 strip's own split-tx refusal (merge-cross-product, | |
| 42228 | - // another lane's surface) before a 1:4 strip is reached. | |
| 42229 | - "--enable-tx-size-search=0", | |
| 42230 | - "--enable-filter-intra=1", | |
| 42231 | - "--enable-intra-edge-filter=1", | |
| 42232 | - "--codec=av1", | |
| 42233 | - "--passes=1", | |
| 42234 | - "--end-usage=q", | |
| 42235 | - "--lag-in-frames=0", | |
| 42236 | - "--auto-alt-ref=0", | |
| 42237 | - "--kf-min-dist=1000", | |
| 42238 | - "--kf-max-dist=1000", | |
| 42239 | - "--threads=1", | |
| 42240 | - "--row-mt=0", | |
| 42241 | - "--enable-order-hint=0", | |
| 42242 | - "--enable-warped-motion=0", | |
| 42243 | - "--enable-obmc=0", | |
| 42244 | - "--enable-masked-comp=0", | |
| 42245 | - "--enable-interintra-comp=0", | |
| 42246 | - "--enable-dist-wtd-comp=0", | |
| 42247 | - "--enable-diff-wtd-comp=0", | |
| 42248 | - "--enable-onesided-comp=0", | |
| 42249 | - "--enable-interintra-wedge=0", | |
| 42250 | - "--enable-smooth-interintra=0", | |
| 42251 | - "--enable-ab-partitions=0", | |
| 42252 | - "--enable-smooth-intra=0", | |
| 42253 | - "--enable-paeth-intra=0", | |
| 42254 | - "--enable-directional-intra=0", | |
| 42255 | - "--enable-angle-delta=0", | |
| 42256 | - "--enable-cdef=0", | |
| 42257 | - "--enable-restoration=0", | |
| 42258 | - // Ledger dead-end (lane-r14): a NEW gate spelling | |
| 42259 | - // `--enable-cfl-intra=1` retires that tool from | |
| 42260 | - // `NEVER_EXERCISED_8BIT` on the flag alone while no CfL | |
| 42261 | - // hit counter exists to assert -- so it stays 0 here. | |
| 42262 | - // Palette stays 0 for the same class of reason: this arm | |
| 42263 | - // refuses a screen-content frame whole, so a palette flag | |
| 42264 | - // would buy no coverage. | |
| 42265 | - "--enable-palette=0", | |
| 42266 | - "--enable-intrabc=0", | |
| 42267 | - "--enable-cfl-intra=0", | |
| 42268 | - "--enable-ref-frame-mvs=0", | |
| 42269 | - "--obu", | |
| 42270 | - "-o", | |
| 42271 | - "-", | |
| 42272 | - "-", | |
| 42273 | - ]), | |
| 42274 | - &y4m.stdout, | |
| 42275 | - ); | |
| 42276 | - assert!( | |
| 42277 | - out.status.success(), | |
| 42278 | - "aomenc refused the fixture: {}", | |
| 42279 | - String::from_utf8_lossy(&out.stderr) | |
| 42280 | - ); | |
| 42281 | - let stream = out.stdout; | |
| 42282 | - let before: Vec<usize> = (0..4) | |
| 42283 | - .map(decode::intra_rect4_strip_in_inter_hits) | |
| 42284 | - .collect(); | |
| 42285 | - let frames = match decode_stream(&stream) { | |
| 42286 | - Ok(frames) => frames, | |
| 42287 | - Err(e) => { | |
| 42288 | - let msg = e.to_string(); | |
| 42289 | - assert!( | |
| 42290 | - msg.contains("unsupported"), | |
| 42291 | - "intra-1:4-in-inter decode failed outright (seed {seed}): {msg}" | |
| 42248 | + let (width, height, frame_count) = (256usize, 192usize, 6usize); | |
| 42249 | + let (src_len, src_sha, pin_name, pin_len, pin_fnv) = if bit_depth == 10 { | |
| 42250 | + ( | |
| 42251 | + 884_828usize, | |
| 42252 | + "b7e0602e0bfc7a7f6813f40bb3989ec7574e5fbbfbf190298b9ab5b625156030", | |
| 42253 | + "fixtures/intra14_256x192_10bit.obu", | |
| 42254 | + 34_727usize, | |
| 42255 | + 0xecf9_455b_c20d_60f0u64, | |
| 42256 | + ) | |
| 42257 | + } else { | |
| 42258 | + ( | |
| 42259 | + 442_462usize, | |
| 42260 | + "e4b46799b180a0d3e138caa18b2738c035e349219490313db664814a3eae9ec2", | |
| 42261 | + "fixtures/intra14_256x192_8bit.obu", | |
| 42262 | + 35_179usize, | |
| 42263 | + 0x86f8_d1e5_a221_162au64, | |
| 42264 | + ) | |
| 42265 | + }; | |
| 42266 | + let mut source_args: Vec<&str> = vec![ | |
| 42267 | + "-v", | |
| 42268 | + "error", | |
| 42269 | + "-y", | |
| 42270 | + "-f", | |
| 42271 | + "lavfi", | |
| 42272 | + "-i", | |
| 42273 | + "mandelbrot=size=256x192:start_scale=5.0:end_scale=0.004:end_pts=8:rate=25", | |
| 42274 | + "-pix_fmt", | |
| 42275 | + ]; | |
| 42276 | + source_args.push(if bit_depth == 10 { | |
| 42277 | + "yuv420p10le" | |
| 42278 | + } else { | |
| 42279 | + "yuv420p" | |
| 42280 | + }); | |
| 42281 | + source_args.extend(["-frames:v", "6"]); | |
| 42282 | + if bit_depth == 10 { | |
| 42283 | + // yuv420p10le is not an official yuv4mpegpipe format on this ffmpeg | |
| 42284 | + source_args.extend(["-strict", "-1"]); | |
| 42285 | + } | |
| 42286 | + source_args.extend(["-f", "yuv4mpegpipe", "-"]); | |
| 42287 | + let y4m = Command::new("ffmpeg") | |
| 42288 | + .args(&source_args) | |
| 42289 | + .stdin(Stdio::null()) | |
| 42290 | + .stdout(Stdio::piped()) | |
| 42291 | + .stderr(Stdio::piped()) | |
| 42292 | + .output() | |
| 42293 | + .expect("ffmpeg failed to run"); | |
| 42294 | + assert!( | |
| 42295 | + y4m.status.success(), | |
| 42296 | + "ffmpeg fixture: {}", | |
| 42297 | + String::from_utf8_lossy(&y4m.stderr) | |
| 42298 | + ); | |
| 42299 | + assert_eq!( | |
| 42300 | + y4m.stdout.len(), | |
| 42301 | + src_len, | |
| 42302 | + "{NAME} ({bit_depth}-bit): the mandelbrot source is not the pinned 6-frame y4m -- \ | |
| 42303 | + `rate=`, `end_pts` and `-frames:v` are all part of this recipe's identity" | |
| 42304 | + ); | |
| 42305 | + eprintln!("{NAME} ({bit_depth}-bit): source y4m sha256 {src_sha}"); | |
| 42306 | + let mut args: Vec<&str> = Vec::new(); | |
| 42307 | + if bit_depth == 10 { | |
| 42308 | + args.extend(["-b", "10", "--input-bit-depth=10"]); | |
| 42309 | + } | |
| 42310 | + // Every flag spelled exactly once (class [[aomenc-last-flag-wins]]). | |
| 42311 | + args.extend([ | |
| 42312 | + "--codec=av1", | |
| 42313 | + "--passes=1", | |
| 42314 | + "--end-usage=q", | |
| 42315 | + "--cpu-used=2", | |
| 42316 | + "--cq-level=63", | |
| 42317 | + "--threads=1", | |
| 42318 | + "--row-mt=0", | |
| 42319 | + "--enable-rect-partitions=1", | |
| 42320 | + // The feature this gate is about, and the flag the control arm | |
| 42321 | + // below reverts. | |
| 42322 | + "--enable-1to4-partitions=1", | |
| 42323 | + // 8, not 16 or 32: MEASURED, the 32-level 1:4 counter is 0 in all | |
| 42324 | + // 48 attempts at 16 and fires in 40 of 48 at 8. | |
| 42325 | + "--min-partition-size=8", | |
| 42326 | + "--max-partition-size=64", | |
| 42327 | + "--enable-tx-size-search=0", | |
| 42328 | + // A 1:4 strip needs an intra mode worth coding: with these four | |
| 42329 | + // off the only candidate is DC and it never wins. | |
| 42330 | + "--enable-filter-intra=1", | |
| 42331 | + "--enable-intra-edge-filter=1", | |
| 42332 | + "--enable-smooth-intra=1", | |
| 42333 | + "--enable-paeth-intra=1", | |
| 42334 | + "--enable-directional-intra=1", | |
| 42335 | + "--enable-angle-delta=1", | |
| 42336 | + // Single reference and one key frame, so every counted strip is | |
| 42337 | + // inside an INTER frame. | |
| 42338 | + "--lag-in-frames=0", | |
| 42339 | + "--auto-alt-ref=0", | |
| 42340 | + "--kf-min-dist=1000", | |
| 42341 | + "--kf-max-dist=1000", | |
| 42342 | + "--enable-order-hint=0", | |
| 42343 | + "--enable-warped-motion=0", | |
| 42344 | + "--enable-obmc=0", | |
| 42345 | + "--enable-masked-comp=0", | |
| 42346 | + "--enable-interintra-comp=0", | |
| 42347 | + "--enable-dist-wtd-comp=0", | |
| 42348 | + "--enable-diff-wtd-comp=0", | |
| 42349 | + "--enable-onesided-comp=0", | |
| 42350 | + "--enable-interintra-wedge=0", | |
| 42351 | + "--enable-smooth-interintra=0", | |
| 42352 | + "--enable-ab-partitions=0", | |
| 42353 | + "--enable-cdef=0", | |
| 42354 | + "--enable-restoration=0", | |
| 42355 | + // Ledger dead-end (lane-r14): a NEW gate spelling | |
| 42356 | + // `--enable-cfl-intra=1` retires that tool from | |
| 42357 | + // `NEVER_EXERCISED_8BIT` on the flag alone while no CfL | |
| 42358 | + // hit counter exists to assert -- so it stays 0 here. | |
| 42359 | + // Palette stays 0 for the same class of reason: this arm | |
| 42360 | + // refuses a screen-content frame whole, so a palette flag | |
| 42361 | + // would buy no coverage. | |
| 42362 | + "--enable-palette=0", | |
| 42363 | + "--enable-intrabc=0", | |
| 42364 | + "--enable-cfl-intra=0", | |
| 42365 | + "--enable-ref-frame-mvs=0", | |
| 42366 | + "--obu", | |
| 42367 | + "-o", | |
| 42368 | + "-", | |
| 42369 | + "-", | |
| 42370 | + ]); | |
| 42371 | + let out = run_with_stdin(Command::new(aomenc_path()).args(&args), &y4m.stdout); | |
| 42372 | + assert!( | |
| 42373 | + out.status.success(), | |
| 42374 | + "aomenc refused the fixture: {}", | |
| 42375 | + String::from_utf8_lossy(&out.stderr) | |
| 42376 | + ); | |
| 42377 | + let stream = out.stdout; | |
| 42378 | + assert_eq!( | |
| 42379 | + stream.len(), | |
| 42380 | + pin_len, | |
| 42381 | + "{NAME} ({bit_depth}-bit): encoded size moved" | |
| 42382 | + ); | |
| 42383 | + assert_eq!( | |
| 42384 | + fnv1a64(&stream), | |
| 42385 | + pin_fnv, | |
| 42386 | + "{NAME} ({bit_depth}-bit): encoded bytes moved" | |
| 42387 | + ); | |
| 42388 | + let pin = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(pin_name); | |
| 42389 | + assert_eq!( | |
| 42390 | + std::fs::read(&pin).unwrap_or_else(|e| panic!("{pin_name} must be committed: {e}")), | |
| 42391 | + stream, | |
| 42392 | + "{NAME} ({bit_depth}-bit): the live encode no longer matches the committed pin" | |
| 42393 | + ); | |
| 42394 | + | |
| 42395 | + let before: Vec<usize> = (0..4) | |
| 42396 | + .map(decode::intra_rect4_strip_in_inter_hits) | |
| 42397 | + .collect(); | |
| 42398 | + let frames = decode_stream(&stream) | |
| 42399 | + .unwrap_or_else(|e| panic!("{NAME} ({bit_depth}-bit): the pin must decode: {e}")); | |
| 42400 | + let delta: Vec<usize> = (0..4) | |
| 42401 | + .map(|k| decode::intra_rect4_strip_in_inter_hits(k) - before[k]) | |
| 42402 | + .collect(); | |
| 42403 | + let ffmpeg_frames = if bit_depth == 10 { | |
| 42404 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | |
| 42405 | + } else { | |
| 42406 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | |
| 42407 | + }; | |
| 42408 | + assert_eq!(frames.len(), frame_count); | |
| 42409 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 42410 | + for (plane, (g, w)) in [ | |
| 42411 | + ("Y", (&got.y, &want.y)), | |
| 42412 | + ("U", (&got.u, &want.u)), | |
| 42413 | + ("V", (&got.v, &want.v)), | |
| 42414 | + ] { | |
| 42415 | + let stride = if plane == "Y" { width } else { width / 2 }; | |
| 42416 | + if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { | |
| 42417 | + eprintln!( | |
| 42418 | + "{NAME} ({bit_depth}-bit): frame {i} {plane} first diff at ({}, {})", | |
| 42419 | + at % stride, | |
| 42420 | + at / stride | |
| 42292 | 42421 | ); |
| 42293 | - refusals.push(format!("seed {seed} {cpu} {cq}: {msg}")); | |
| 42294 | - continue; | |
| 42295 | - } | |
| 42296 | - }; | |
| 42297 | - let delta: Vec<usize> = (0..4) | |
| 42298 | - .map(|k| decode::intra_rect4_strip_in_inter_hits(k) - before[k]) | |
| 42299 | - .collect(); | |
| 42300 | - let ffmpeg_frames = if bit_depth == 10 { | |
| 42301 | - ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | |
| 42302 | - } else { | |
| 42303 | - ffmpeg_decode_sequence(&stream, width, height, frame_count) | |
| 42304 | - }; | |
| 42305 | - assert_eq!(frames.len(), frame_count); | |
| 42306 | - eprintln!( | |
| 42307 | - "intra14 gate {bit_depth}-bit seed={seed} {cpu} {cq}: intra 1:4 strips in inter \ | |
| 42308 | - frames 64x16={} 16x64={} 32x8={} 8x32={}", | |
| 42309 | - delta[0], delta[1], delta[2], delta[3] | |
| 42310 | - ); | |
| 42311 | - for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 42312 | - for (plane, (g, w)) in [ | |
| 42313 | - ("Y", (&got.y, &want.y)), | |
| 42314 | - ("U", (&got.u, &want.u)), | |
| 42315 | - ("V", (&got.v, &want.v)), | |
| 42316 | - ] { | |
| 42317 | - let stride = if plane == "Y" { width } else { width / 2 }; | |
| 42318 | - if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { | |
| 42319 | - let maxd = g | |
| 42320 | - .iter() | |
| 42321 | - .zip(w.iter()) | |
| 42322 | - .map(|(a, b)| i32::from(*a).abs_diff(i32::from(*b))) | |
| 42323 | - .max() | |
| 42324 | - .unwrap_or(0); | |
| 42325 | - eprintln!( | |
| 42326 | - "intra14 gate {bit_depth}-bit seed={seed}: frame {i} {plane} first \ | |
| 42327 | - diff at ({}, {}) got {} want {} ({} samples differ, max |d|={maxd})", | |
| 42328 | - at % stride, | |
| 42329 | - at / stride, | |
| 42330 | - g[at], | |
| 42331 | - w[at], | |
| 42332 | - g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), | |
| 42333 | - ); | |
| 42334 | - } | |
| 42335 | - assert_eq!(g, w, "{plane} vs ffmpeg (seed {seed}, frame {i})"); | |
| 42336 | 42422 | } |
| 42337 | - } | |
| 42338 | - compared += 1; | |
| 42339 | - if delta.iter().all(|d| *d == 0) { | |
| 42340 | - uncounted_exact += 1; | |
| 42341 | - refusals.push(format!( | |
| 42342 | - "seed {seed} {cpu} {cq}: decoded and pixel-compared, but no intra 1:4 strip on \ | |
| 42343 | - the inter path" | |
| 42344 | - )); | |
| 42345 | - } | |
| 42346 | - for k in 0..4 { | |
| 42347 | - shapes[k] += delta[k]; | |
| 42348 | - } | |
| 42349 | - // Both LEVELS (32 and 64) is the bar; orientation is whichever the | |
| 42350 | - // encoder picks. | |
| 42351 | - if shapes[0] + shapes[1] > 0 && shapes[2] + shapes[3] > 0 { | |
| 42352 | - break; | |
| 42423 | + assert_eq!(g, w, "{plane} vs ffmpeg (frame {i})"); | |
| 42353 | 42424 | } |
| 42354 | 42425 | } |
| 42355 | - gate_buckets( | |
| 42356 | - NAME, | |
| 42357 | - compared - uncounted_exact, | |
| 42358 | - uncounted_exact, | |
| 42359 | - refusals.len() - uncounted_exact as usize, | |
| 42360 | - ); | |
| 42361 | - eprintln!( | |
| 42362 | - "{NAME} ({bit_depth}-bit): compared {compared} streams, intra 1:4 strips in inter \ | |
| 42363 | - frames: 64x16={} 16x64={} 32x8={} 8x32={}; refusals:\n{}", | |
| 42364 | - shapes[0], | |
| 42365 | - shapes[1], | |
| 42366 | - shapes[2], | |
| 42367 | - shapes[3], | |
| 42368 | - refusals.join("\n") | |
| 42369 | - ); | |
| 42370 | 42426 | assert!( |
| 42371 | - compared > 0, | |
| 42372 | - "{NAME} ({bit_depth}-bit): every attempt hit a named refusal -- nothing was \ | |
| 42373 | - pixel-compared:\n{}", | |
| 42374 | - refusals.join("\n") | |
| 42427 | + delta[2] + delta[3] > 0, | |
| 42428 | + "{NAME} ({bit_depth}-bit): {frame_count} frames pixel-exact but no 32-level intra 1:4 \ | |
| 42429 | + strip (32x8/8x32) fired (64x16={} 16x64={} 32x8={} 8x32={}) -- the recipe stopped \ | |
| 42430 | + producing the shape this gate names (class gate-blind-to-feature)", | |
| 42431 | + delta[0], | |
| 42432 | + delta[1], | |
| 42433 | + delta[2], | |
| 42434 | + delta[3] | |
| 42375 | 42435 | ); |
| 42436 | + | |
| 42437 | + // The control arm: the one flag that is this gate's feature, reverted. | |
| 42438 | + // If it ever fires too, 1:4 is no longer what puts these strips on the | |
| 42439 | + // RD menu and the feature arm above is not the witness it claims to be. | |
| 42440 | + // It is also this gate's own red-proof. | |
| 42441 | + let mut control = args.clone(); | |
| 42442 | + let at = control | |
| 42443 | + .iter() | |
| 42444 | + .position(|a| *a == "--enable-1to4-partitions=1") | |
| 42445 | + .expect("the feature flag is in the recipe"); | |
| 42446 | + control[at] = "--enable-1to4-partitions=0"; | |
| 42447 | + let ctl = run_with_stdin(Command::new(aomenc_path()).args(&control), &y4m.stdout); | |
| 42376 | 42448 | assert!( |
| 42377 | - shapes[2] + shapes[3] > 0, | |
| 42378 | - "{NAME} ({bit_depth}-bit): no 32-level intra 1:4 strip (32x8/8x32) fired over \ | |
| 42379 | - {compared} compared streams (64x16={} 16x64={} 32x8={} 8x32={})", | |
| 42380 | - shapes[0], | |
| 42381 | - shapes[1], | |
| 42382 | - shapes[2], | |
| 42383 | - shapes[3] | |
| 42449 | + ctl.status.success(), | |
| 42450 | + "aomenc refused the --enable-1to4-partitions=0 control: {}", | |
| 42451 | + String::from_utf8_lossy(&ctl.stderr) | |
| 42452 | + ); | |
| 42453 | + let ctl_before: Vec<usize> = (0..4) | |
| 42454 | + .map(decode::intra_rect4_strip_in_inter_hits) | |
| 42455 | + .collect(); | |
| 42456 | + decode_stream(&ctl.stdout) | |
| 42457 | + .unwrap_or_else(|e| panic!("{NAME}: the control stream must decode too: {e}")); | |
| 42458 | + let ctl_delta: Vec<usize> = (0..4) | |
| 42459 | + .map(|k| decode::intra_rect4_strip_in_inter_hits(k) - ctl_before[k]) | |
| 42460 | + .collect(); | |
| 42461 | + assert_eq!( | |
| 42462 | + ctl_delta, [0; 4], | |
| 42463 | + "{NAME} ({bit_depth}-bit): the --enable-1to4-partitions=0 control fired \ | |
| 42464 | + 64x16={} 16x64={} 32x8={} 8x32={} -- 1:4 partitions are no longer what produce these \ | |
| 42465 | + strips, so the feature arm above is not witnessing what it names", | |
| 42466 | + ctl_delta[0], ctl_delta[1], ctl_delta[2], ctl_delta[3] | |
| 42467 | + ); | |
| 42468 | + gate_buckets(NAME, 1, 0, 0); | |
| 42469 | + eprintln!( | |
| 42470 | + "{NAME} ({bit_depth}-bit): {frame_count} frames pixel-exact, intra 1:4 strips in inter \ | |
| 42471 | + frames 64x16={} 16x64={} 32x8={} 8x32={} (--enable-1to4-partitions=0 control: \ | |
| 42472 | + 0/0/0/0), stream {pin_len} B fnv1a64={pin_fnv:016x}", | |
| 42473 | + delta[0], delta[1], delta[2], delta[3] | |
| 42384 | 42474 | ); |
| 42385 | 42475 | } |
| 42386 | 42476 |
crates/ec-av1/src/tile.rsmodified+28 -34
| @@ -12,16 +12,16 @@ | ||
| 12 | 12 | use std::cell::RefCell; |
| 13 | 13 | #[cfg(test)] |
| 14 | 14 | use std::collections::BTreeMap; |
| 15 | -use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering}; | |
| 16 | 15 | use std::sync::LazyLock; |
| 16 | +use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering}; | |
| 17 | 17 | |
| 18 | 18 | use ec_core::{Error, Result}; |
| 19 | 19 | |
| 20 | 20 | use crate::cdf; |
| 21 | 21 | use crate::cdf_state::{Cdfs, MvComponentCdfs, TxbSet, TxbTables}; |
| 22 | -use crate::decode::{txfm_partition_ctx_rect, TXFM_CTX_INIT}; | |
| 22 | +use crate::decode::{TXFM_CTX_INIT, txfm_partition_ctx_rect}; | |
| 23 | 23 | use crate::msac::SymbolEncoder; |
| 24 | -use crate::mvstack::{find_mv_stack, mv16, MiGrid, MiInfo, NO_REF1}; | |
| 24 | +use crate::mvstack::{MiGrid, MiInfo, NO_REF1, find_mv_stack, mv16}; | |
| 25 | 25 | use crate::transform::TxType; |
| 26 | 26 | |
| 27 | 27 | // --------------------------------------------------------------------------- |
| @@ -1637,10 +1637,10 @@ fn write_compound_ref_frames( | ||
| 1637 | 1637 | (ref0, ref1): (i8, i8), |
| 1638 | 1638 | ) -> Result<()> { |
| 1639 | 1639 | use crate::mvstack::{ |
| 1640 | - comp_reference_type_ctx, single_ref_p1_ctx, single_ref_p2_ctx, single_ref_p3_ctx, | |
| 1641 | - single_ref_p4_ctx, single_ref_p5_ctx, single_ref_p6_ctx, uni_comp_ref_p1_ctx, | |
| 1642 | - ALTREF2_FRAME, ALTREF_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST2_FRAME, LAST3_FRAME, | |
| 1643 | - LAST_FRAME, | |
| 1640 | + ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME, | |
| 1641 | + LAST3_FRAME, comp_reference_type_ctx, single_ref_p1_ctx, single_ref_p2_ctx, | |
| 1642 | + single_ref_p3_ctx, single_ref_p4_ctx, single_ref_p5_ctx, single_ref_p6_ctx, | |
| 1643 | + uni_comp_ref_p1_ctx, | |
| 1644 | 1644 | }; |
| 1645 | 1645 | let a = (above_ref > 0).then_some(above_ref); |
| 1646 | 1646 | let l = (left_ref > 0).then_some(left_ref); |
| @@ -1819,7 +1819,10 @@ fn write_compound_block( | ||
| 1819 | 1819 | if crate::envflags::env_flag!("EC_TRACE_MODE") { |
| 1820 | 1820 | eprintln!( |
| 1821 | 1821 | "EC_WCOMP mi_row={mi_row} mi_col={mi_col} mode={mode} ref0={} ref1={ref1} ctx={ctx} new_mv_ctx={} ref_mv_ctx={} stack={}", |
| 1822 | - info.ref_frame, stack.new_mv_ctx, stack.ref_mv_ctx, stack.entries.len() | |
| 1822 | + info.ref_frame, | |
| 1823 | + stack.new_mv_ctx, | |
| 1824 | + stack.ref_mv_ctx, | |
| 1825 | + stack.entries.len() | |
| 1823 | 1826 | ); |
| 1824 | 1827 | } |
| 1825 | 1828 | enc.symbol(mode, &mut cdfs.inter_compound_mode[ctx]); |
| @@ -5889,7 +5892,7 @@ fn scan_of(side: usize) -> &'static Vec<u16> { | ||
| 5889 | 5892 | /// DECODER's own table so the two cannot drift, cached per size and class. |
| 5890 | 5893 | fn class_scan_of(side: usize, class: crate::decode::TxClass) -> &'static [u16] { |
| 5891 | 5894 | static SCANS: LazyLock<[[Vec<u16>; 2]; 4]> = LazyLock::new(|| { |
| 5892 | - use crate::decode::{class_scan_table, TxClass}; | |
| 5895 | + use crate::decode::{TxClass, class_scan_table}; | |
| 5893 | 5896 | [TX4, TX8, TX16, TX32].map(|side| { |
| 5894 | 5897 | [ |
| 5895 | 5898 | class_scan_table(side, TxClass::Horiz), |
| @@ -6966,11 +6969,7 @@ pub(crate) fn intra_inter_ctx( | ||
| 6966 | 6969 | /// `CLASS0_SIZE << (class + 2)` (spec 3), the magnitude an `MV_CLASS_n` |
| 6967 | 6970 | /// component's own bits start counting from; class zero starts at zero. |
| 6968 | 6971 | fn mv_class_base(class: usize) -> i32 { |
| 6969 | - if class == 0 { | |
| 6970 | - 0 | |
| 6971 | - } else { | |
| 6972 | - 2i32 << (class + 2) | |
| 6973 | - } | |
| 6972 | + if class == 0 { 0 } else { 2i32 << (class + 2) } | |
| 6974 | 6973 | } |
| 6975 | 6974 | |
| 6976 | 6975 | /// The class a pre-offset magnitude `z` (`|diff| - 1`) falls in — the inverse |
| @@ -7096,9 +7095,9 @@ fn write_single_ref( | ||
| 7096 | 7095 | REF_HITS[(ref_frame.max(1) - 1) as usize % 7] |
| 7097 | 7096 | .fetch_add(1, std::sync::atomic::Ordering::Relaxed); |
| 7098 | 7097 | use crate::mvstack::{ |
| 7098 | + ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST2_FRAME, LAST3_FRAME, | |
| 7099 | 7099 | single_ref_p1_ctx, single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, |
| 7100 | - single_ref_p5_ctx, single_ref_p6_ctx, ALTREF2_FRAME, ALTREF_FRAME, BWDREF_FRAME, | |
| 7101 | - GOLDEN_FRAME, LAST2_FRAME, LAST3_FRAME, | |
| 7100 | + single_ref_p5_ctx, single_ref_p6_ctx, | |
| 7102 | 7101 | }; |
| 7103 | 7102 | let above = (above_ref > 0).then_some(above_ref); |
| 7104 | 7103 | let left = (left_ref > 0).then_some(left_ref); |
| @@ -7202,6 +7201,13 @@ pub(crate) fn take_drl_clamp_hits() -> usize { | ||
| 7202 | 7201 | DRL_CLAMP_HITS.swap(0, std::sync::atomic::Ordering::Relaxed) |
| 7203 | 7202 | } |
| 7204 | 7203 | |
| 7204 | +/// Reads [`DRL_CLAMP_HITS`] WITHOUT clearing it -- the before/after delta is | |
| 7205 | +/// `take_drl_clamp_hits`, but a recipe sweep that arms one encode and reads the | |
| 7206 | +/// total (lane-av1recipehunt's `enc_probe` driver) wants a non-destructive read. | |
| 7207 | +pub fn drl_clamp_hits() -> usize { | |
| 7208 | + DRL_CLAMP_HITS.load(std::sync::atomic::Ordering::Relaxed) | |
| 7209 | +} | |
| 7210 | + | |
| 7205 | 7211 | fn note_inter_mode(mode: usize, drl: usize) { |
| 7206 | 7212 | INTER_MODE_HITS[mode].fetch_add(1, std::sync::atomic::Ordering::Relaxed); |
| 7207 | 7213 | DRL_HITS[drl.min(3)].fetch_add(1, std::sync::atomic::Ordering::Relaxed); |
| @@ -7335,7 +7341,7 @@ fn write_inter_mode( | ||
| 7335 | 7341 | enc.symbol(1, &mut cdfs.new_mv[stack.new_mv_ctx]); // not NEWMV |
| 7336 | 7342 | enc.symbol(1, &mut cdfs.zero_mv[stack.zero_mv_ctx]); // not GLOBALMV |
| 7337 | 7343 | enc.symbol(1, &mut cdfs.ref_mv[stack.ref_mv_ctx]); // NEARMV |
| 7338 | - // `RefMvIdx` starts at 1 for NEARMV (spec 5.11.24). | |
| 7344 | + // `RefMvIdx` starts at 1 for NEARMV (spec 5.11.24). | |
| 7339 | 7345 | let idx = idx.max(1); |
| 7340 | 7346 | let signalled = write_drl_idx(enc, cdfs, stack, 1, idx); |
| 7341 | 7347 | let mv = stack.entries.get(signalled).map_or(stack.near_mv, |e| e.mv); |
| @@ -8954,8 +8960,8 @@ mod tests { | ||
| 8954 | 8960 | use crate::sequence::sequence_header_obu; |
| 8955 | 8961 | use ec_av1_syntax::sequence::SequenceHeader; |
| 8956 | 8962 | use ec_av1_syntax::{ |
| 8957 | - FrameHeader, FrameType, LoopFilterParams, QuantizationParams, TileInfo, TxMode, | |
| 8958 | - PRIMARY_REF_NONE, | |
| 8963 | + FrameHeader, FrameType, LoopFilterParams, PRIMARY_REF_NONE, QuantizationParams, TileInfo, | |
| 8964 | + TxMode, | |
| 8959 | 8965 | }; |
| 8960 | 8966 | use std::process::{Command, Stdio}; |
| 8961 | 8967 | |
| @@ -10594,11 +10600,7 @@ mod tests { | ||
| 10594 | 10600 | .map(|&v| { |
| 10595 | 10601 | let m = f64::from(v).abs() + 0.5; |
| 10596 | 10602 | let l = if m < 1.0 { 0 } else { m.floor() as i32 }; |
| 10597 | - if v < 0.0 { | |
| 10598 | - -l | |
| 10599 | - } else { | |
| 10600 | - l | |
| 10601 | - } | |
| 10603 | + if v < 0.0 { -l } else { l } | |
| 10602 | 10604 | }) |
| 10603 | 10605 | .collect(); |
| 10604 | 10606 | let before = levels.clone(); |
| @@ -10657,11 +10659,7 @@ mod tests { | ||
| 10657 | 10659 | .map(|&v| { |
| 10658 | 10660 | let m = f64::from(v).abs() + 0.5; |
| 10659 | 10661 | let l = if m < 1.0 { 0 } else { m.floor() as i32 }; |
| 10660 | - if v < 0.0 { | |
| 10661 | - -l | |
| 10662 | - } else { | |
| 10663 | - l | |
| 10664 | - } | |
| 10662 | + if v < 0.0 { -l } else { l } | |
| 10665 | 10663 | }) |
| 10666 | 10664 | .collect(); |
| 10667 | 10665 | let bits = rdoq( |
| @@ -11158,11 +11156,7 @@ mod tests { | ||
| 11158 | 11156 | (d << 3) | (fr << 1) | 1 |
| 11159 | 11157 | }; |
| 11160 | 11158 | let mag = mv_class_base(class) + local as i32 + 1; |
| 11161 | - if sign == 1 { | |
| 11162 | - -mag | |
| 11163 | - } else { | |
| 11164 | - mag | |
| 11165 | - } | |
| 11159 | + if sign == 1 { -mag } else { mag } | |
| 11166 | 11160 | } |
| 11167 | 11161 | |
| 11168 | 11162 | /// Decodes one superblock a [`sb_coeff_inter_frame_tile`] payload wrote, |
lanes/av1recipehunt.report.mdadded+409 -0
| @@ -0,0 +1,409 @@ | ||
| 1 | +# lane-av1recipehunt report | |
| 2 | + | |
| 3 | +Three `#[ignore]`d ec-av1 gates whose RECIPE never provoked the feature. Two are | |
| 4 | +CLOSED with a pinned, red-proved fixture. One is UNPRODUCIBLE for a structural | |
| 5 | +reason that no recipe can move, proved by mutation. | |
| 6 | + | |
| 7 | +Branch `lane-av1recipehunt`, base `a21f3680`. Oracle | |
| 8 | +`~/.cache/aom-oracle/build/aomenc` (aom `v3.13.3-7-g9bb526a`), ffmpeg | |
| 9 | +`/usr/bin/ffmpeg`. Every number below was measured in RELEASE on this tree; the | |
| 10 | +row format is `recipe | parsed feature evidence | counter before | counter after | |
| 11 | +| pixel verdict`. | |
| 12 | + | |
| 13 | +Method: hunt deliberately from the code path out, not by random sweep. For each | |
| 14 | +gate, first read the DECODE-path counter that the gate's own precondition assert | |
| 15 | +consumes, then work out which encoder-side knob can move it, then sweep only | |
| 16 | +that knob. Reachability is asserted from the real read (`decode_probe` prints | |
| 17 | +each counter from the decode path; `enc_probe` prints the writer-side one), never | |
| 18 | +from a mirror call site, and every firing recipe is additionally pixel-compared. | |
| 19 | + | |
| 20 | +--- | |
| 21 | + | |
| 22 | +## Gate 1 -- `a_128_superblock_clip_whose_drl_index_the_write_time_stack_cannot_carry_decodes_exact` | |
| 23 | + | |
| 24 | +**Verdict: UNPRODUCIBLE. The gate stays `#[ignore]`d.** | |
| 25 | + | |
| 26 | +### Baseline (run unmodified, RELEASE) | |
| 27 | + | |
| 28 | +``` | |
| 29 | +thread 'encode::tests::a_128_superblock_clip_whose_drl_index_the_write_time_stack_cannot_carry_decodes_exact' | |
| 30 | +panicked at crates/ec-av1/src/encode.rs:19484:9: | |
| 31 | +this clip never asked for a drl index the write-time stack could not carry, so it cannot witness the defect | |
| 32 | +test result: FAILED. 0 passed; 1 failed; ... finished in 32.25s | |
| 33 | +``` | |
| 34 | + | |
| 35 | +`assert!(clamps > 0)` with `clamps = crate::tile::take_drl_clamp_hits()` after | |
| 36 | +63.93 s (32.25 s here) of real encoding of mandelbrot 1280x768x12 at q 150 with | |
| 37 | +`force_sb128(true)`. | |
| 38 | + | |
| 39 | +### Why no recipe exists | |
| 40 | + | |
| 41 | +`DRL_CLAMP_HITS` is bumped by `tile::write_inter_mode` (and the two compound | |
| 42 | +walks) only when the SEARCH chose a `ref_mv_idx` the write-time stack could not | |
| 43 | +signal. On this tree the search's offer set is inside the signalable range in | |
| 44 | +every mode: | |
| 45 | + | |
| 46 | +| mode | search's offer set | writer's signalable ceiling | gap | | |
| 47 | +|---|---|---|---| | |
| 48 | +| `NEWMV` | `best_new_mv_syntax`, `for idx in 0..3` -> {0,1,2} | `write_drl_idx(..., start=0, ...)`: `idx < start + 2` -> 2 | none | | |
| 49 | +| `NEARMV` | `for idx in 1..=2` (both search arms) | `start=1`, `idx < 3`, plus `entries.len() > idx + 1` | none: the search offers `idx` only when `entries.get(idx).is_some()`, i.e. `entries.len() > idx`, and the walk stops one entry later -- the bounds coincide at every stack size | | |
| 50 | +| `NEARESTMV` / `GLOBALMV` | no DRL | n/a | n/a | | |
| 51 | +| compound (`write_compound_block`) | every compound `InterInfo` the search builds hardcodes `ref_mv_idx: 0` | walks start at 0/1 | none | | |
| 52 | + | |
| 53 | +This is not inference. The tree already ASSERTS it, over stack sizes 0..=4, in | |
| 54 | +`encode::tests::every_drl_index_the_new_mv_pricer_offers_is_one_the_writer_can_signal`: | |
| 55 | +for every index either pricer offers, `tile::signalled_drl_idx(entries, start, idx) | |
| 56 | +== idx`. That test and this gate are two readings of one invariant, and it is | |
| 57 | +still green on this tree (verified). The counter this gate waits on can never | |
| 58 | +leave zero. | |
| 59 | + | |
| 60 | +### Attempt table -- 153 combinations, every one `drl_clamp = 0` | |
| 61 | + | |
| 62 | +Driven by `enc_probe` (`tile::drl_clamp_hits()` printed per encode point). | |
| 63 | + | |
| 64 | +| recipe | parsed feature evidence | clamps before | clamps after | pixel verdict | | |
| 65 | +|---|---|---|---|---| | |
| 66 | +| mandelbrot 320x192x8 q150 (the gate's own clip class, small) | search picks DRL idx 2 (35x, traced) | 0 | 0 | n/a (encode-side) | | |
| 67 | +| mandelbrot 640x384x8 q150 | search picks DRL idx 2 (163x, traced) | 0 | 0 | n/a | | |
| 68 | +| mandelbrot 640x384x12 q110 / q150 / q200 | idx 2 chosen | 0 | 0 | n/a | | |
| 69 | +| mandelbrot 1280x768x8 q110 / q150 / q200 (the gate's EXACT clip) | idx 2 chosen | 0 | 0 | n/a | | |
| 70 | +| mandelbrot 1280x768x12 q150 (the gate's exact point) | idx 2 chosen | 0 | 0 | n/a | | |
| 71 | +| testsrc2 320x192 / 640x384 / 1280x768 x 8/12, q 110/150/200 | idx 2 chosen (27x on 640x384) | 0 | 0 | n/a | | |
| 72 | +| white noise 320x192 / 640x384 x 8/12, q 60/110/150/200 | idx 0 only (drl_index histogram 108/0/0/0 -- the write-time stack never reaches 3 entries) | 0 | 0 | n/a | | |
| 73 | +| scrolling hard bands 320x192x8 | idx 0 only | 0 | 0 | n/a | | |
| 74 | +| 4x4 mandelbrot mosaic, per-tile independent drift, 320x192 / 640x384 x 8/12 | idx 2 chosen (35x) | 0 | 0 | n/a | | |
| 75 | +| 4-px luminance bands, both axes, 192x128, mps 8/16, cpu 0..6 | idx 2 chosen | 0 | 0 | n/a | | |
| 76 | +| panning field + a faster band inside it, 640x384x10/16, b=32/64, q 100/150/200 | idx 2 chosen | 0 | 0 | n/a | | |
| 77 | +| diagonal band on a pan, 640x384x10/16, b=32/64, q 100/150/200 | idx 2 chosen | 0 | 0 | n/a | | |
| 78 | +| three independently moving bands, 320x192x10/16, b=32/64, q 100/150/200 | idx 2 chosen | 0 | 0 | n/a | | |
| 79 | +| alternating hard 32x32 tiles (whole tiles re-predict from wherever the identical tile last was), 640x384x10, q 150 | idx 2 chosen | 0 | 0 | n/a | | |
| 80 | +| q ladder 60 / 150 / 220 on one clip (three encode points in a run) | idx 2 chosen | 0 | 0 / 0 / 0 | n/a | | |
| 81 | + | |
| 82 | +A trace on `best_new_mv_syntax` is the decisive negative: the search DOES choose | |
| 83 | +DRL index 2, often (163 times on mandelbrot 640x384x8). Index 2 is exactly what | |
| 84 | +the writer signals, so it is a legal pick, not a clamp. The instrument I built | |
| 85 | +for the hunt (`tile::drl_index_histogram`, reading `DRL_HITS`) was REMOVED before | |
| 86 | +commit: it records the SIGNALLED index, which is downstream of the clamp and | |
| 87 | +structurally cannot show 3+, so it cannot separate "the search never asked" from | |
| 88 | +"it asked and the stack could not carry it". Shipping it would have been a | |
| 89 | +misleading instrument. | |
| 90 | + | |
| 91 | +### Mutation proof -- the recipe was never the problem | |
| 92 | + | |
| 93 | +`best_new_mv_syntax`'s offer set widened `for idx in 0..3` -> `0..5`, i.e. | |
| 94 | +letting the search ask for index 3/4 that the 2-step walk cannot signal: | |
| 95 | + | |
| 96 | +| recipe (identical command line, only the offer set differs) | clamps | | |
| 97 | +|---|---| | |
| 98 | +| mandelbrot 640x384x8 q150 | **9** | | |
| 99 | +| mandelbrot 320x192x8 q150 | **2** | | |
| 100 | +| mandelbrot mosaic 320x192x8 q150 | **2** | | |
| 101 | +| testsrc2 640x384x8 q150 | **1** | | |
| 102 | +| white noise 320x192x8 q150 | 0 | | |
| 103 | +| alternating hard tiles 640x384x10 q150 | **1** | | |
| 104 | +| all of the above, mutation reverted | 0 | | |
| 105 | + | |
| 106 | +Same clips, same presets, only the pricer's offer ceiling moved. The binding | |
| 107 | +constraint is the ceiling, which no clip can move. Mutation reverted and | |
| 108 | +`git diff` on `encode.rs` is empty apart from this lane's doc comment. | |
| 109 | + | |
| 110 | +### Disposition | |
| 111 | + | |
| 112 | +`#[ignore]` kept -- un-ignoring it would ship a gate that can never pass. The | |
| 113 | +gate's doc comment now carries the whole finding (the per-mode table, the | |
| 114 | +existing invariant test that proves it, the 153-row measurement, the mutation | |
| 115 | +proof, and the owning fix) so the next lane does not repeat the sweep. | |
| 116 | + | |
| 117 | +**Owning fix, not this lane's to make** (the DRL code is another lane's surface, | |
| 118 | +and the DRL index range is the AV1 spec's, not ours): either widen the search's | |
| 119 | +offer set to the spec's own DRL range so the clamp becomes reachable and this | |
| 120 | +gate can witness it, or delete the three dead `note_drl_clamp` sites and this | |
| 121 | +gate with them. `deferred(unblock: DRL owner widens `best_new_mv_syntax`'s offer | |
| 122 | +set past the writer's `start + 2` ceiling, or retires the counter)`. | |
| 123 | + | |
| 124 | +--- | |
| 125 | + | |
| 126 | +## Gate 2 -- `a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_and_delta_q_decodes_pixel_exact` | |
| 127 | + | |
| 128 | +**Verdict: CLOSED. Un-ignored, pinned, red-proved.** | |
| 129 | + | |
| 130 | +### Baseline (run unmodified, RELEASE) | |
| 131 | + | |
| 132 | +``` | |
| 133 | +a_real_aomenc_stream_..._and_delta_q_decodes_pixel_exact: zero rect64 dequant calls | |
| 134 | +ever observed CURRENT_Q_IDX != base_q_idx (40 matches, 0 refusals out of 40) -- | |
| 135 | +delta_q was never actually exercised through decode_block_rect64 this run | |
| 136 | +``` | |
| 137 | + | |
| 138 | +### Root cause of the blindness | |
| 139 | + | |
| 140 | +r1 swept 40 attempts of `gradients` at 192x128 with `frame_count = 1`. That is a | |
| 141 | +single KEY frame, and it is the whole reason. `delta_q_present` needs the | |
| 142 | +temporal (TPL) model to see a spatial complexity map at all; a one-frame encode | |
| 143 | +has no inter frame to carry it. Measured over 120 sweep arms at 192x128 / | |
| 144 | +256x192 / 320x256 / 512x384, 4 and 10 frames, cpu 0/1/3, cq 45/55, five source | |
| 145 | +classes: at `frame_count = 1` EVERY arm read `delta_q_hits() == 0` AND | |
| 146 | +`rect64_qidx_drift_hits() == 0`. A different failure from "the drift never | |
| 147 | +reached a rect64 block", and the reason r1 could not see the feature at all. | |
| 148 | + | |
| 149 | +### The recipe that fires | |
| 150 | + | |
| 151 | +`testsrc2` 512x384, **4 frames**, `--cpu-used=0`, `delta_q` left at aomenc's | |
| 152 | +default. Exactly: | |
| 153 | + | |
| 154 | +``` | |
| 155 | +ffmpeg -v error -y -f lavfi -i testsrc2=size=512x384:rate=25 \ | |
| 156 | + -pix_fmt yuv420p -frames:v 4 -f yuv4mpegpipe src512.y4m | |
| 157 | +aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=45 --cpu-used=0 \ | |
| 158 | + --threads=1 --row-mt=0 --sb-size=64 --enable-rect-partitions=1 \ | |
| 159 | + --enable-ab-partitions=0 --enable-1to4-partitions=0 \ | |
| 160 | + --min-partition-size=32 --max-partition-size=64 \ | |
| 161 | + --enable-restoration=0 --enable-palette=0 --enable-cdef=0 \ | |
| 162 | + --enable-filter-intra=0 --enable-cfl-intra=0 --enable-intrabc=0 \ | |
| 163 | + --enable-tx-size-search=0 --obu -o out.obu src512.y4m | |
| 164 | +``` | |
| 165 | + | |
| 166 | +* source `src512.y4m`: 1179730 bytes, sha256 | |
| 167 | + `f430d581497e4f6f7db07d0fc92476e92194e1f96c321988ec0739d475cbbe0c` | |
| 168 | +* output `crates/ec-av1/fixtures/rect64_dq_drift.obu`: **8384 bytes**, sha256 | |
| 169 | + `094e51bb21b6caccc905417e95a03f9131b448071567d0b14ec8850799ea2501`, fnv1a64 | |
| 170 | + `0x3d91a21680063ef6` (committed with `git add -f` past the `fixtures` | |
| 171 | + gitignore, like every sibling fixture) | |
| 172 | + | |
| 173 | +### Attempt table (representative; the sweep was 120 arms) | |
| 174 | + | |
| 175 | +| recipe | parsed feature evidence | drift before | drift after | pixel verdict | | |
| 176 | +|---|---|---|---|---| | |
| 177 | +| testsrc2 512x384 **1 frame** cpu0 q45 (r1's shape) | `delta_q_present` absent, 0 groups | 0 | 0 | n/a (no feature) | | |
| 178 | +| testsrc2 512x384 4 frames cpu0 q45 | 48 `delta_q` groups; `inter_rect: 64x32=2 32x64=2` | 0 | **17** | **EXACT** all 4 frames | | |
| 179 | +| testsrc2 512x384 10 frames cpu0 q45 | 134 groups | 0 | 16 | EXACT | | |
| 180 | +| testsrc2 256x192 4 frames cpu0 q45 | 12 groups | 0 | 6 | EXACT | | |
| 181 | +| testsrc2 256x192 10 frames cpu0 q45 | 55 groups | 0 | 6 | EXACT | | |
| 182 | +| testsrc2 192x128 4 frames cpu0 q45 | 6 groups | 0 | 2 | EXACT | | |
| 183 | +| testsrc2 192x128 10 frames cpu0 q45 | 30 groups | 0 | 2 | EXACT | | |
| 184 | +| grad42 512x384 4 / 10 frames cpu0 q45 | 48 / 68 groups | 0 | 8 / 15 | EXACT | | |
| 185 | +| grad43 512x384 4 / 10 frames cpu0 q45 | 48 / 76 groups | 0 | 4 / 17 | EXACT | | |
| 186 | +| smptebars 512x384 4 / 10 frames cpu0 q45 | 48 groups | 0 | 6 / 5 | EXACT | | |
| 187 | +| **same source, `--cpu-used=1`** | 48-134 groups | 0 | **0** | EXACT | | |
| 188 | +| **same source, `--cpu-used=3`** | 48-138 groups | 0 | **0** | EXACT | | |
| 189 | +| **same source, `--deltaq-mode=0` (control)** | **0 groups** | 0 | **0** | EXACT | | |
| 190 | +| same source, `--cq-level=55` | 48 groups | 0 | 17 | EXACT (byte-identical to cq 45) | | |
| 191 | +| a "zone"/checkerboard source, every size and preset | 0 groups | 0 | 0 | EXACT (no delta_q at all) | | |
| 192 | +| smptebars / zone at `--cq-level=30` and `55` | 0 groups | 0 | 0 | EXACT | | |
| 193 | + | |
| 194 | +`--cpu-used=0` is load-bearing and measured: at `--cpu-used=1` and `3` the same | |
| 195 | +source reads the same 48 `delta_q` groups and drifts ZERO times -- the faster | |
| 196 | +presets' RD never leaves a rect64 root in a superblock whose quantizer moved. | |
| 197 | +`--cq-level` is not load-bearing. | |
| 198 | + | |
| 199 | +Note for whoever reads the census: a 192x128 SINGLE-frame testsrc2 at cpu 0 is | |
| 200 | +NOT pixel-exact on this tree (2177 differing bytes), and so is the 25-frame | |
| 201 | +512x384 one (2190). That is a pre-existing intra-frame defect, unrelated to | |
| 202 | +`delta_q` (the `--deltaq-mode=0` arm at the same size shows the same count), and | |
| 203 | +it is why the recipe uses a 4-frame 512x384 cell rather than either of those. | |
| 204 | + | |
| 205 | +### Red-proof | |
| 206 | + | |
| 207 | +The gate's own control arm re-runs the same command line with `--deltaq-mode=0` | |
| 208 | +and requires the drift to stay at 0. Run explicitly, by reverting the | |
| 209 | +feature-bearing flag INTO the feature arm (and relaxing the byte pin so the | |
| 210 | +precondition is what fires, not the byte identity): | |
| 211 | + | |
| 212 | +``` | |
| 213 | +thread 'stream::tests::a_real_aomenc_stream_..._and_delta_q_decodes_pixel_exact' | |
| 214 | +panicked at crates/ec-av1/src/stream.rs:37752:9: | |
| 215 | +...: 4 frames pixel-exact but zero rect64 dequant calls ever saw CURRENT_Q_IDX != | |
| 216 | +base_q_idx -- delta_q was read and never moved the quantizer inside a rect64 block, | |
| 217 | +so this run proved nothing (class gate-blind-to-feature) | |
| 218 | +test result: FAILED. 0 passed; 1 failed | |
| 219 | +``` | |
| 220 | + | |
| 221 | +The pixel compare passed in that run; only the precondition went red. Both | |
| 222 | +temporary edits reverted; green again immediately after. | |
| 223 | + | |
| 224 | +### Green | |
| 225 | + | |
| 226 | +``` | |
| 227 | +...: 4 frames pixel-exact, sb_rect_hits=40, rect64_qidx_drift_hits=17 | |
| 228 | +(--deltaq-mode=0 control: 0), stream 8384 B fnv1a64=3d91a21680063ef6 | |
| 229 | +test result: ok. 1 passed | |
| 230 | +``` | |
| 231 | + | |
| 232 | +Runtime 1.7 s (r1's 40-arm sweep was the 60 s+ version). | |
| 233 | + | |
| 234 | +--- | |
| 235 | + | |
| 236 | +## Gate 3 -- `a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact` (+ `_10bit`) | |
| 237 | + | |
| 238 | +**Verdict: CLOSED, both arms. Un-ignored, pinned, red-proved.** | |
| 239 | + | |
| 240 | +### Baseline (run unmodified, RELEASE, both arms) | |
| 241 | + | |
| 242 | +``` | |
| 243 | +a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact: no 32-level | |
| 244 | +intra 1:4 strip (32x8/8x32) fired over 40 compared streams (64x16=0 16x64=0 32x8=0 8x32=0) | |
| 245 | +``` | |
| 246 | +Same text for the `_10bit` arm. 40/40 streams pixel-compared, zero mismatches. | |
| 247 | + | |
| 248 | +### Root cause of the blindness, and the stale comment | |
| 249 | + | |
| 250 | +The 22-line comment above the `#[ignore]` blamed a pre-existing inter-frame | |
| 251 | +pixel defect (frames 3-7 drifting to ~24k samples, max |d| ~220). **That is | |
| 252 | +stale: the pixel blocker cleared.** What actually kept the gate blind is a | |
| 253 | +second, purely mechanical fact the comment never mentions -- and its own | |
| 254 | +conclusion ("the 1:4 shape is not the discriminator either") was measuring the | |
| 255 | +wrong arm: | |
| 256 | + | |
| 257 | +* `--min-partition-size=32` with an all-but-empty intra mode set | |
| 258 | + (`--enable-smooth-intra/paeth-intra/directional-intra/angle-delta` all `0`) | |
| 259 | + never puts a 1:4 partition on aomenc's RD menu at all. Measured: at | |
| 260 | + `--min-partition-size=16` the 32-level 1:4 counter is **0 in all 48** attempts | |
| 261 | + (10-bit, 192x128 and 256x192, `--cpu-used` 0..5, cq 63/55); at | |
| 262 | + `--min-partition-size=8` with the intra mode tools on it fires in **40 of 48**. | |
| 263 | +* A 32x8/8x32 strip needs an intra mode worth coding. With the four tools off | |
| 264 | + the only candidate is DC, and DC never wins a 1:4 strip against inter. | |
| 265 | + | |
| 266 | +So both the old `--min-partition-size=32` (protecting against a 16x4/4x16 | |
| 267 | +refusal that no longer fires -- at `mps=8` the RD takes neither the 8- nor the | |
| 268 | +16-level 1:4 on this content, confirmed by the `inter16_1to4` and `rect4_32` | |
| 269 | +inter counters staying at 0) and the four intra-mode flags were holding the | |
| 270 | +shape off the menu. r2's `--enable-1to4-partitions=0` "byte-identical stream" | |
| 271 | +observation is explained by the same thing: with no 1:4 partitions reachable at | |
| 272 | +all, the flag had nothing to turn off. | |
| 273 | + | |
| 274 | +### The recipe that fires | |
| 275 | + | |
| 276 | +mandelbrot zoom, **256x192, 6 frames**, `--cpu-used=2 --cq-level=63`, | |
| 277 | +`--min-partition-size=8`, the full intra mode set. Exactly: | |
| 278 | + | |
| 279 | +``` | |
| 280 | +ffmpeg -v error -y -f lavfi \ | |
| 281 | + -i mandelbrot=size=256x192:start_scale=5.0:end_scale=0.004:end_pts=8:rate=25 \ | |
| 282 | + -pix_fmt yuv420p -frames:v 6 -f yuv4mpegpipe - # 10-bit: yuv420p10le + -strict -1 | |
| 283 | +aomenc [--cpu-used=2 --input-bit-depth=10 -b 10] --codec=av1 --passes=1 --end-usage=q \ | |
| 284 | + --cpu-used=2 --cq-level=63 --threads=1 --row-mt=0 \ | |
| 285 | + --enable-rect-partitions=1 --enable-1to4-partitions=1 \ | |
| 286 | + --min-partition-size=8 --max-partition-size=64 --enable-tx-size-search=0 \ | |
| 287 | + --enable-filter-intra=1 --enable-intra-edge-filter=1 --enable-smooth-intra=1 \ | |
| 288 | + --enable-paeth-intra=1 --enable-directional-intra=1 --enable-angle-delta=1 \ | |
| 289 | + --lag-in-frames=0 --auto-alt-ref=0 --kf-min-dist=1000 --kf-max-dist=1000 \ | |
| 290 | + --enable-order-hint=0 --enable-warped-motion=0 --enable-obmc=0 \ | |
| 291 | + --enable-masked-comp=0 --enable-interintra-comp=0 --enable-dist-wtd-comp=0 \ | |
| 292 | + --enable-diff-wtd-comp=0 --enable-onesided-comp=0 --enable-interintra-wedge=0 \ | |
| 293 | + --enable-smooth-interintra=0 --enable-ab-partitions=0 --enable-cdef=0 \ | |
| 294 | + --enable-restoration=0 --enable-palette=0 --enable-intrabc=0 \ | |
| 295 | + --enable-cfl-intra=0 --enable-ref-frame-mvs=0 --obu -o - - | |
| 296 | +``` | |
| 297 | + | |
| 298 | +* 8-bit source: 442462 bytes, sha256 `e4b46799b180a0d3e138caa18b2738c035e349219490313db664814a3eae9ec2` | |
| 299 | +* 10-bit source: 884828 bytes, sha256 `b7e0602e0bfc7a7f6813f40bb3989ec7574e5fbbfbf190298b9ab5b625156030` | |
| 300 | +* `crates/ec-av1/fixtures/intra14_256x192_8bit.obu`: **35179 bytes**, sha256 | |
| 301 | + `5e50eb6d4492e806a2803988d92bd47f069ca54e02c06344d5500c6b72deb861`, fnv1a64 | |
| 302 | + `0x86f8d1e5a221162a` | |
| 303 | +* `crates/ec-av1/fixtures/intra14_256x192_10bit.obu`: **34727 bytes**, sha256 | |
| 304 | + `ab6fae0a256af6410e8200f10827a3e965dee7b2d7ab63710e94968bddab23a2`, fnv1a64 | |
| 305 | + `0xecf9455bc20d60f0` | |
| 306 | + | |
| 307 | +### Attempt table (grid v2: 576 arms, 0 hits; grid v3: 2520 streams carrying SOME 1:4, 54 hits) | |
| 308 | + | |
| 309 | +| recipe | parsed feature evidence | 64x16 / 16x64 / 32x8 / 8x32 | pixel verdict | | |
| 310 | +|---|---|---|---| | |
| 311 | +| **grid v2, the gate's own recipe** (mandelbrot 192x128x8, zoom `start_scale` 3.0/4.4/5.0, cq 63/55/45, cpu 1-4, flagsets `bare`/`intratools`/`screen`/`screen16`, 6 sources x 2 sizes) | NO 1:4 partition of any level in any stream -- `rect4_32`, `inter16_1to4` and `intra_rect4_in_inter` all 0 | 0/0/0/0 | EXACT on all 64 arms | | |
| 312 | +| banded 4-px content, STATIC in T, mps 8, cpu 0..6 | 241 B stream -- every inter frame SKIPs, no partitions at all | 0/0/0/0 | EXACT | | |
| 313 | +| 4-px bands that MOVE, mps 8, cpu 0 | `rect32x8_inter_tu: 32x8=1` -- a 32-level 1:4 strip, but INTER | 0/0/0/0 | EXACT | | |
| 314 | +| 4-px bands that move, mps 8, cpu 4 | `rect4_32: horz=4` / `vert=8` -- 1:4 again, INTER | 0/0/0/0 | EXACT | | |
| 315 | +| 4-px bands jumping 37/97/173 px per frame, mps 8/32, cq 63, cpu 0/2/4 | 1:4 present, INTER | 0/0/0/0 | EXACT | | |
| 316 | +| grid v2 with `--min-partition-size=8` and the intra tools ON, plain mandelbrot 192x128x6, cpu 2, cq 63 | **`intra_rect4_in_inter: 32x8=4 8x32=8`** | 0/0/**4**/**8** | **EXACT** | | |
| 317 | +| same, cpu 3, cq 63 | 32x8=4 8x32=8 | 0/0/4/8 | EXACT | | |
| 318 | +| same, cpu 2, cq 45 | 8x32=7 | 0/0/0/7 | EXACT | | |
| 319 | +| same, cpu 3, cq 45 | 8x32=10 | 0/0/0/10 | EXACT | | |
| 320 | +| 10-bit, 192x128, `--min-partition-size=8`, cpu 0, cq 63 | 32x8=4 8x32=11 | 0/0/4/11 | EXACT | | |
| 321 | +| **10-bit, 192x128, `--min-partition-size=16`, cpu 0..5, cq 63/55** (24 arms) | **ZERO 1:4 at any level** | 0/0/0/0 | EXACT | | |
| 322 | +| **10-bit, 256x192, `--min-partition-size=8`, cpu 0..5, cq 63/55** (24 arms) | fires at every preset 0-4, never at 5 | varies | EXACT | | |
| 323 | +| **`--enable-1to4-partitions=0` control, 8-bit** | `intra_rect4_in_inter` all 0, 20205 B vs 35179 B | 0/0/0/0 | EXACT | | |
| 324 | +| **CHOSEN: 8-bit 256x192x6 cpu2 q63 mps8** | 32x8=8 8x32=11 | 0/0/**8**/**11** | **EXACT** all 6 frames | | |
| 325 | +| **CHOSEN: 10-bit 256x192x6 cpu2 q63 mps8** | 32x8=12 8x32=7 | 0/0/**12**/**7** | **EXACT** all 6 frames | | |
| 326 | + | |
| 327 | +`--min-partition-size=8` vs `16` is the single load-bearing flag: 0/48 vs 40/48. | |
| 328 | + | |
| 329 | +One methodology note, recorded because it nearly cost the hunt: grid v3's | |
| 330 | +`scene-cut` source builder reused `[0:v]` for BOTH concat halves, so the | |
| 331 | +"second scene" argument had no effect and six nominally different rows produced | |
| 332 | +byte-identical results. The real driver was `mps=8` + the intra mode set, not the | |
| 333 | +scene cut. The chosen recipe is the plain source with no concat at all. | |
| 334 | + | |
| 335 | +### Red-proof | |
| 336 | + | |
| 337 | +The gate's own control arm re-runs the same command line with | |
| 338 | +`--enable-1to4-partitions=0` and requires all four counters to stay at 0. Run | |
| 339 | +explicitly, by reverting that flag INTO the feature arm (and relaxing the byte | |
| 340 | +pin so the precondition is what fires, not the byte identity): | |
| 341 | + | |
| 342 | +``` | |
| 343 | +thread 'stream::tests::a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact' | |
| 344 | +panicked at crates/ec-av1/src/stream.rs:40677:9: | |
| 345 | +... (8-bit): 6 frames pixel-exact but no 32-level intra 1:4 strip (32x8/8x32) fired | |
| 346 | +(64x16=0 16x64=0 32x8=0 8x32=0) -- the recipe stopped producing the shape this gate names | |
| 347 | +(class gate-blind-to-feature) | |
| 348 | +test result: FAILED. 0 passed; 1 failed | |
| 349 | +``` | |
| 350 | + | |
| 351 | +All 6 frames still compared pixel-exact in that run; only the precondition went | |
| 352 | +red. Both temporary edits reverted. | |
| 353 | + | |
| 354 | +### Green | |
| 355 | + | |
| 356 | +``` | |
| 357 | +...(8-bit): 6 frames pixel-exact, intra 1:4 strips in inter frames 64x16=0 16x64=0 32x8=8 8x32=11 (--enable-1to4-partitions=0 control: 0/0/0/0), stream 35179 B fnv1a64=86f8d1e5a221162a | |
| 358 | +...(10-bit): 6 frames pixel-exact, intra 1:4 strips in inter frames 64x16=0 16x64=0 32x8=12 8x32=7 (--enable-1to4-partitions=0 control: 0/0/0/0), stream 34727 B fnv1a64=ecf9455bc20d60f0 | |
| 359 | +test result: ok. 3 passed; 0 failed | |
| 360 | +``` | |
| 361 | + | |
| 362 | +2.3 s and 2.1 s per arm (r1's 40-arm sweep was 60 s+ each). | |
| 363 | + | |
| 364 | +--- | |
| 365 | + | |
| 366 | +## What changed in the tree | |
| 367 | + | |
| 368 | +* `stream.rs`: gate 2 and the two gate-3 arms rewritten around a pinned recipe | |
| 369 | + with a byte pin (len + fnv1a64 + equality against the committed fixture), a | |
| 370 | + hard precondition assert on the decode-path counter, a full pixel compare, and | |
| 371 | + a feature-flag control arm. All three un-ignored. The stale 22-line comment on | |
| 372 | + the 1:4 pair is replaced by the measurement that actually explains them. | |
| 373 | +* `encode.rs`: gate 1's doc comment now carries the structural finding, the | |
| 374 | + existing invariant test that proves it, the 153-row measurement, the mutation | |
| 375 | + proof and the owning fix. The gate and its `#[ignore]` are unchanged. | |
| 376 | +* `tile.rs`: `pub fn drl_clamp_hits()` -- a non-destructive read of | |
| 377 | + `DRL_CLAMP_HITS` (the `#[cfg(test)]` `take_drl_clamp_hits` clears), so a | |
| 378 | + recipe sweep can read the gate's own precondition from outside the test | |
| 379 | + binary. | |
| 380 | +* `stream.rs`: `pub fn rect64_qidx_drift_counters() -> (usize, usize)` -- | |
| 381 | + `(delta_q groups read, rect64 dequant calls that saw CURRENT_Q_IDX != | |
| 382 | + base_q_idx)`. The pair is the point: a recipe that reads no `delta_q` at all | |
| 383 | + and a recipe that reads it but never moves the quantizer inside a rect64 block | |
| 384 | + are different failures, and gate 2 was the first of those. | |
| 385 | +* `examples/decode_probe.rs`: prints that pair. | |
| 386 | +* `examples/enc_probe.rs`: prints `tile::drl_clamp_hits()`. | |
| 387 | +* Three fixtures committed under `crates/ec-av1/fixtures/` with `git add -f`. | |
| 388 | + | |
| 389 | +## Hazards hit, worth the next lane's time | |
| 390 | + | |
| 391 | +* **A shared `CARGO_TARGET_DIR` is not safe for a probe-driven hunt.** | |
| 392 | + `~/.cache/cargo-target` was overwritten mid-sweep by a sibling lane's build | |
| 393 | + and the probe binary silently lost its new counter lines -- a sweep that reads | |
| 394 | + counters can be measuring an instrument that no longer exists. Give each lane | |
| 395 | + its own target dir (`~/.cache/cargo-target-<lane>`). | |
| 396 | +* **A counter placed downstream of the event it names is not an instrument.** | |
| 397 | + The first thing built for gate 1 was a histogram of the DRL index each block | |
| 398 | + *coded*, read off `DRL_HITS`. It records the SIGNALLED index, so it is | |
| 399 | + structurally incapable of showing the 3+ bucket and cannot distinguish "the | |
| 400 | + search never asked" from "it asked and could not be carried". It was removed | |
| 401 | + rather than shipped. The trace that did work was on the SEARCH's choice | |
| 402 | + (`best_new_mv_syntax`), upstream of the writer. | |
| 403 | +* **`cargo test` under `scripts/memguard-runner.sh` collides on transient | |
| 404 | + systemd scopes** ("Unit run-pNNNN.scope was already loaded or has a fragment | |
| 405 | + file") when runs overlap. It is a runner failure, not a test failure; retry. | |
| 406 | +* **A 10-bit pixel compare needs `EC_PROBE_OUT16`, not `EC_PROBE_OUT`.** | |
| 407 | + `EC_PROBE_OUT` writes u8 and every sample then differs from ffmpeg's | |
| 408 | + `yuv420p10le` raw -- a 220438-byte "defect" that is purely a dump-format | |
| 409 | + mismatch. |