forge
Explore
Log in

Don't you dare go Hollow

lane-av1422lrless: add the gate FOR REAL, and re-pin from a truly controlled recipe

Browse files at this commit

78b7b48994a7edf5cc8efde26cdde833d0f7805aAhmet Kaan GümüşParent: 959ed1d
Reviewer P0 and P2, both accepted. The P0 was a false claim on my part
and the mechanism is worth naming: I ran the gate and both mutation checks
in the WORKING TREE, then ran `git checkout -- crates/ec-av1/src/stream.rs`
to revert the probe bypass -- which reverted the gate too, because they
were in the same file -- and then committed. `git show --stat 4a18a77b`
is one binary fixture and zero lines of stream.rs. The gate never shipped
while the commit message and the report both said it had.

P0, THE GATE NOW EXISTS. the_pinned_422_lr_off_witness_is_present_and_
refuses_by_name, next to its LR-on sibling, with FILE/BYTES/FP verified
against the committed fixture bytes in this tree rather than taken on
trust. `cargo test -p ec-av1 --lib -- 422_lr_off` runs 1 test, not 0.
Both mutations are red, with output quoted in the report: a flipped
fixture byte panics "bytes drifted" (exit 101); a wrong refusal string
panics "must refuse by name" (exit 101); restored, green (exit 0).

P2, THE PAIR IS NOW PROVABLY CONTROLLED, and fixing it required fixing
the PARENT's recipe first. The committed LR-on recipe could not reproduce
its own pinned bytes: re-encoding from the recorded source gave 38774
bytes, not 38845. Sweeping the flag space, `--pass=1` reproduces the
committed 38845 bytes EXACTLY -- aomenc DEFAULTS to two-pass, so the
single-pass flag has to be stated. So the sibling's doc described a
two-pass encode that never happened, and its ffmpeg filter string was
also not the one that ran. Both are corrected in place, with the
measurement that pins them.

The LR-off arm is then re-encoded from that same reproduced recipe with
EXACTLY ONE flag added, `--enable-restoration=0`:

    aomenc ... --enable-global-motion=1 --pass=1 --enable-restoration=0 ...

38538 bytes, sha256
8bed368f7ec4bca772137c6a9c2af89e1b2767ed5f937b91bd9e72ec60aeb42f, fnv1a64
0x4b8ff761701e2bef. (The previously pinned arm was 38701 bytes /
0xf331fb2ed6b79efa, from an uncontrolled 2-pass encode; it is replaced.)

Results on the honest pair, and the engagement advantage survives it:
- 16/16 pixel-exact vs aomdec --rawvideo, sha256
  1cf47bc9e06a6e286452dfe4ffe457a85b6badd25657dfd36af48262e8eb2464
- entropy 244756-for-244756 paired, no divergence, against the sibling's
  246735 -- the corners skip visible in the symbol stream
- LR proved off: all five LR counters 0 (sibling 22/10/0/26/28)
- top-half compound 11 vs the sibling's 3; top-half warp 5 vs 3
  (the earlier 14/10 was measured on the uncontrolled 2-pass arm and is
  withdrawn)

The engagement comparison is now honest, which is what the regeneration
was for.
crates/ec-av1/fixtures/422_residual_compound_warp_nolr_16f.obumodified+0 -0

Binary file changed

crates/ec-av1/src/stream.rsmodified+96 -4
@@ -2293,17 +2293,29 @@ pub(crate) mod tests {
2293 /// `d78e2afb43ce311d3d82335a945c6f80f62db4537966d881c1349a68b3aecb95`:2293 /// `d78e2afb43ce311d3d82335a945c6f80f62db4537966d881c1349a68b3aecb95`:
2294 ///2294 ///
2295 /// ```text2295 /// ```text
2296- /// ffmpeg -f lavfi -i "mandelbrot=size=256x288:rate=24:maxiter=220:2296+ /// ffmpeg -f lavfi -i "mandelbrot=size=256x288:rate=24:maxiter=220:start_scale=3:end_scale=0.35:end_pts=300,rotate=a=0.10*t:c=none:ow=256:oh=288" \
2297- /// start_scale=3:end_scale=0.35:end_pts=300:rotate=a=0.10"
2298 /// -frames:v 24 -pix_fmt yuv422p -f yuv4mpegpipe src422.y4m2297 /// -frames:v 24 -pix_fmt yuv422p -f yuv4mpegpipe src422.y4m
2299 /// aomenc --codec=av1 --profile=2 --input-bit-depth=8 --limit=162298 /// aomenc --codec=av1 --profile=2 --input-bit-depth=8 --limit=16
2300 /// --width=256 --height=288 --lag-in-frames=25 --auto-alt-ref=12299 /// --width=256 --height=288 --lag-in-frames=25 --auto-alt-ref=1
2301- /// --enable-global-motion=1 --cq-level=24 --cpu-used=02300+ /// --enable-global-motion=1 --pass=1
2301+ /// --cq-level=24 --cpu-used=0
2302 /// --threads=4 --kf-min-dist=0 --kf-max-dist=999999 \2302 /// --threads=4 --kf-min-dist=0 --kf-max-dist=999999 \
2303- /// -n ffp --pass=2 --fpf=src422.y4m -o a1.webm2303+ /// src422.y4m -o a1.webm
2304 /// ffmpeg -i a1.webm -c copy -f obu -y a1.obu2304 /// ffmpeg -i a1.webm -c copy -f obu -y a1.obu
2305 /// ```2305 /// ```
2306 ///2306 ///
2307+ /// CORRECTED by lane-av1422lrless (reviewer P2). This doc previously
2308+ /// carried a different ffmpeg filter (`rotate=a=0.10`, no `*t`, no
2309+ /// `:c=none:ow/oh`) and a `-n ffp --pass=2 --fpf=...` two-pass line.
2310+ /// **Neither produced these bytes.** Re-encoding from the recorded
2311+ /// source `src422.y4m` (sha256
2312+ /// `4d35eaf65d1a5541b3177e1183644c163b3868d8f141bed0ce9fdf833280ba9f`)
2313+ /// was measured three ways: the two-pass form gives 38774 bytes
2314+ /// (`e93c4ed7...`), and only adding `--pass=1` reproduces these 38845
2315+ /// bytes byte for byte (`d78e2afb...`). `aomenc` DEFAULTS to two-pass,
2316+ /// so the flag has to be stated to get back the pinned stream. The
2317+ /// recipe above is the one that was actually run.
2318+ ///
2307 /// Measured on a patch-run-restore build (the `EC_AV1_ALLOW_422_PROBE`2319 /// Measured on a patch-run-restore build (the `EC_AV1_ALLOW_422_PROBE`
2308 /// bypass applied for the run, reverted after -- it is deliberately NOT2320 /// bypass applied for the run, reverted after -- it is deliberately NOT
2309 /// committed, and the refusal below is what the committed tree asserts):2321 /// committed, and the refusal below is what the committed tree asserts):
@@ -2359,6 +2371,86 @@ pub(crate) mod tests {
2359 "{NAME}: {FILE} must refuse by name, got: {err}"2371 "{NAME}: {FILE} must refuse by name, got: {err}"
2360 );2372 );
2361 }2373 }
2374+ /// lane-av1422lrless: the LR-OFF half of the 4:2:2 coverage pair.
2375+ ///
2376+ /// This is `422_residual_compound_warp_16f.obu`'s recipe with EXACTLY
2377+ /// ONE flag changed, `--enable-restoration=0`, and that is a measured
2378+ /// claim rather than an assertion: both arms were re-encoded from the
2379+ /// same source `src422.y4m` (sha256
2380+ /// `4d35eaf65d1a5541b3177e1183644c163b3868d8f141bed0ce9fdf833280ba9f`)
2381+ /// with the same aomenc invocation, and the LR-on arm reproduces the
2382+ /// committed 38845 bytes byte for byte. So the pair is controlled, and
2383+ /// the corners code is the only thing that can differ between their
2384+ /// decodes: with restoration off, every plane's `frame_restoration_type`
2385+ /// is `RESTORE_NONE`, so `read_lr` skips each plane and never computes a
2386+ /// range. The LR-on stream exercises the range; this one proves the skip
2387+ /// is the skip.
2388+ ///
2389+ /// ```text
2390+ /// aomenc --codec=av1 --profile=2 --input-bit-depth=8 --limit=16
2391+ /// --width=256 --height=288 --lag-in-frames=25 --auto-alt-ref=1
2392+ /// --enable-global-motion=1 --pass=1 --enable-restoration=0
2393+ /// --cq-level=24 --cpu-used=0
2394+ /// --threads=4 --kf-min-dist=0 --kf-max-dist=999999 \
2395+ /// src422.y4m -o a3.webm
2396+ /// ffmpeg -i a3.webm -c copy -f obu -y a3.obu
2397+ /// ```
2398+ ///
2399+ /// 38538 bytes, sha256
2400+ /// `8bed368f7ec4bca772137c6a9c2af89e1b2767ed5f937b91bd9e72ec60aeb42f`.
2401+ ///
2402+ /// Measured on a patch-run-restore build (the `EC_AV1_ALLOW_422_PROBE`
2403+ /// bypass applied for the run, reverted after -- deliberately not
2404+ /// committed, and the refusal asserted below is what this tree ships):
2405+ ///
2406+ /// - all 16 frames pixel-exact against `aomdec --rawvideo`, 2359296
2407+ /// bytes each, sha256 `1cf47bc9e06a6e286452dfe4ffe457a85b6badd25
2408+ /// 657dfd36af48262e8eb2464` on both sides;
2409+ /// - the entropy stream pairs **244756-for-244756** against the
2410+ /// instrumented oracle with no divergence anywhere -- a different
2411+ /// read count from the LR-on sibling's 246735, which is the corners
2412+ /// skip showing up in the symbol stream, so the two arms really are
2413+ /// on different paths;
2414+ /// - **loop restoration is proved off, not inferred from the flag**:
2415+ /// all five LR counters read zero where the LR-on sibling reads
2416+ /// `lr_wiener` 22, `lr_sgrproj` 10, `lr_stripe0` 26, `lr_last_stripe`
2417+ /// 28;
2418+ /// - and it carries MORE of the coverage than its sibling, which is
2419+ /// what rescues the thin leg of the lift argument: **top-half
2420+ /// compound 11** against the sibling's 3, and top-half warp 5 against
2421+ /// 3. Frame-globally compound_warp 25, compound_warp_8 15, rotzoom
2422+ /// global-warp 77, cdef_idx 39, part128_split 95. The stronger arm is
2423+ /// the one where `read_lr` does nothing at all, so the engagement is
2424+ /// not an artefact of the code under test.
2425+ ///
2426+ /// Same scope as its siblings, for the same reason: with the header
2427+ /// refusal standing no committed test can decode a 4:2:2 stream,
2428+ /// because the bypass that would allow it must never be committed.
2429+ #[test]
2430+ fn the_pinned_422_lr_off_witness_is_present_and_refuses_by_name() {
2431+ const NAME: &str = "the_pinned_422_lr_off_witness_is_present_and_refuses_by_name";
2432+ const REFUSAL: &str = "a chroma format of 4:2:2";
2433+ const FILE: &str = "422_residual_compound_warp_nolr_16f.obu";
2434+ const BYTES: usize = 38538;
2435+ const FP: u64 = 0x4b8ff761701e2bef;
2436+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
2437+ .join("fixtures")
2438+ .join(FILE);
2439+ let data = std::fs::read(&path).unwrap_or_else(|e| {
2440+ panic!(
2441+ "{NAME}: pinned witness {} is missing ({e}) -- the gate cannot run",
2442+ path.display()
2443+ )
2444+ });
2445+ assert_eq!(data.len(), BYTES, "{NAME}: {FILE} size drifted");
2446+ assert_eq!(fnv1a64(&data), FP, "{NAME}: {FILE} bytes drifted");
2447+ let err = decode_stream(&data).unwrap_err().to_string();
2448+ assert!(
2449+ err.contains(REFUSAL),
2450+ "{NAME}: {FILE} must refuse by name, got: {err}"
2451+ );
2452+ }
2453+
2362 2454
2363 2455
2364 /// lane-av1-qmatrix: WITNESS for the lifted `using_qmatrix` refusal (the2456 /// lane-av1-qmatrix: WITNESS for the lifted `using_qmatrix` refusal (the