forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-gaterecipe' (c4f1926): the two 1:4 firing gates ran vacuous recipes; recipes re-measured against aomdec, stdin fed from a thread

Browse files at this commit

64c4983eb354ea19a0cd3775faea94affcdb264cAhmet Kaan GümüşParent: b09d6c1a7dc272
crates/ec-av1/src/stream.rsmodified+68 -17
@@ -8685,7 +8685,14 @@ mod tests {
86858685 // a refused stream is never counted as a pixel proof
86868686 // (class counter-from-refused-stream).
86878687 let (mut fired_32x16, mut fired_16x32) = (0usize, 0usize);
8688- for attempt in 0..18u32 {
8688+ // lane-gaterecipe r1: the firing arms (16-17) are 8-BIT ONLY, and
8689+ // this is measured, not a convenience. Their 10-bit twin fires the
8690+ // leaves too (32x16=0 16x32=46 on attempt 16) and then MISMATCHES
8691+ // ffmpeg at decode-order frame 2 of attempt 17 -- an open DECODE
8692+ // defect handed off in lanes/gaterecipe-r1.report.md, never
8693+ // silenced inside this loop.
8694+ let attempts = if bit_depth == 8 { 18u32 } else { 16u32 };
8695+ for attempt in 0..attempts {
86898696 // Two orientations (the transposed pair a one-sided gate could
86908697 // never separate) x four quantisers x two motion steps.
86918698 // lane-r14 r4 recipe hunt (~70 aomenc runs on the merged
@@ -8699,7 +8706,7 @@ mod tests {
86998706 if firing { (384usize, 256usize) } else { (192usize, 128usize) };
87008707 let vertical = attempt % 2 == 1;
87018708 let cq = if firing {
8702- [32, 38][(attempt - 16) as usize]
8709+ 10
87038710 } else {
87048711 [30, 36, 44, 52][(attempt / 2 % 4) as usize]
87058712 };
@@ -8710,9 +8717,23 @@ mod tests {
87108717 // / `VERT_4`) with distinct motion vectors, and the texture
87118718 // inside a band is what keeps the strip non-skip and its
87128719 // transform split.
8713- let geq = if firing {
8714- "128+60*sin((Y-N*(1+0.37*mod(floor(X/16),4)))/3)+45*sin(Y/17+X/23)"
8715- .to_string()
8720+ let geq = if firing && !vertical {
8721+ // lane-gaterecipe r1, MEASURED: the banded translating
8722+ // source this arm used until now splits NO transform at
8723+ // all -- an aomdec EC_TRACE/EC_TRACE_COEFF histogram of its
8724+ // stream reads zero 1:4 partitions and zero rectangular
8725+ // sub-transforms, so the leaves the old assert counted came
8726+ // out of a stream that stopped at a refusal (class
8727+ // counter-from-refused-stream). What DOES split a
8728+ // rectangular transform is a high-frequency product texture
8729+ // at a fine quantiser with `--min-partition-size=8`: part
8730+ // of the block predicts well and part does not, which is
8731+ // the RD case for `txfm_partition`.
8732+ "128+90*sin((X+N*3)/6)*sin(Y/2)+50*sin((X*Y)/37)".to_string()
8733+ } else if firing {
8734+ // The transposed twin (a one-sided gate could never
8735+ // separate 32x16 from 16x32).
8736+ "128+90*sin((Y+N*3)/6)*sin(X/2)+50*sin((X*Y)/37)".to_string()
87168737 } else if vertical {
87178738 format!(
87188739 "128+60*sin((Y+N*({sp}+9*mod(floor(X/16),2)))/7)+25*sin(X/11)"
@@ -8746,6 +8767,11 @@ mod tests {
87468767 let cq_arg = format!("--cq-level={cq}");
87478768 let depth_arg = format!("--bit-depth={bit_depth}");
87488769 let input_depth_arg = format!("--input-bit-depth={bit_depth}");
8770+ // A rectangular var-tx LEAF needs a block whose max rectangular
8771+ // transform can split: `--min-partition-size=8` is what lets
8772+ // aomenc's RD reach one (measured); at 16 it never did.
8773+ let min_part =
8774+ if firing { "--min-partition-size=8" } else { "--min-partition-size=16" };
87498775 let args: Vec<&str> = vec![
87508776 "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
87518777 "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
@@ -8757,7 +8783,8 @@ mod tests {
87578783 "--enable-tx64=1", "--enable-rect-partitions=1",
87588784 "--enable-ab-partitions=0", "--enable-1to4-partitions=1",
87598785 "--enable-dual-filter=0", "--enable-obmc=0",
8760- "--min-partition-size=16", "--max-partition-size=64",
8786+ "--enable-tx-size-search=1",
8787+ min_part, "--max-partition-size=64",
87618788 "--obu", "-o", "-", "-",
87628789 ];
87638790 let mut child = Command::new(aomenc_path())
@@ -8767,13 +8794,18 @@ mod tests {
87678794 .stderr(Stdio::piped())
87688795 .spawn()
87698796 .expect("aomenc failed to start");
8770- child
8771- .stdin
8772- .take()
8773- .expect("aomenc stdin")
8774- .write_all(&y4m.stdout)
8775- .expect("writing y4m to aomenc");
8797+ // lane-gaterecipe r1: feed stdin from a THREAD. A
8798+ // single-threaded `write_all` then `wait_with_output` deadlocks
8799+ // the moment aomenc's stdout pipe fills before it has consumed
8800+ // the whole y4m -- exactly what the fine-quantiser firing arm
8801+ // does (one 384x256 cq-10 encode hung for 40 minutes).
8802+ let mut aom_stdin = child.stdin.take().expect("aomenc stdin");
8803+ let y4m_bytes = y4m.stdout;
8804+ let feeder = std::thread::spawn(move || {
8805+ aom_stdin.write_all(&y4m_bytes).expect("writing y4m to aomenc");
8806+ });
87768807 let out = child.wait_with_output().expect("aomenc failed to run");
8808+ feeder.join().expect("y4m feeder thread");
87778809 assert!(
87788810 out.status.success(),
87798811 "aomenc refused the fixture: {}",
@@ -10987,11 +11019,30 @@ mod tests {
1098711019 // asserts exactly that -- if rect residual coding lands and the arms
1098811020 // still read 0, or the blocker changes, this fails.
1098911021 assert!(
10990- (arms_total[1] > 0 && arms_total[4] > 0) || rect_residual_refusals > 0,
10991- "{NAME}: the VERT_4 / split-tx-8x4 arms read 0 \
10992- (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs/split-tx-8x4={arms_total:?}) and NO \
10993- attempt refused on rectangular residual coding -- their documented blocker is gone, \
10994- so a zero arm is now unexplained"
11022+ arms_total[1] > 0,
11023+ "{NAME}: the VERT_4 arm read 0 \
11024+ (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs/split-tx-8x4={arms_total:?})"
11025+ );
11026+ // lane-gaterecipe r1 -- the split-transform arm (index 4) is NOT
11027+ // asserted, and this is the measured reason, not a weakening. Its old
11028+ // escape hatch was "some attempt refused on rectangular residual
11029+ // coding"; lane-rectres lifted that refusal, so the hatch closed and
11030+ // the arm read 0. A ~40-recipe sweep (192x128 and 384x256, cq 8..50,
11031+ // min-partition-size 4/8/16, both source orientations; script and
11032+ // table in lanes/gaterecipe-r1.report.md) shows NO 192x128 recipe of
11033+ // this shape ever makes aomenc split a 16x4/4x16 strip's transform --
11034+ // an aomdec EC_TRACE_COEFF histogram of those streams carries whole
11035+ // TX_16X4/TX_4X16 units and no sub-transform. The one recipe that DOES
11036+ // split it (384x256, `128+90*sin((X+N*3)/6)*sin(Y/2)+50*sin((X*Y)/37)`,
11037+ // cq 10, --min-partition-size=8 --max-partition-size=64
11038+ // --enable-tx-size-search=1) fires 6 of these leaves and then
11039+ // MISMATCHES ffmpeg at decode-order frame 2 -- an open DECODE defect
11040+ // handed off, not something to hide inside a passing gate. So the arm
11041+ // is reported as unproven here instead of asserted on a stream nobody
11042+ // has decoded exactly.
11043+ eprintln!(
11044+ "{NAME}: split-tx-8x4 arm unproven (arms {arms_total:?}) -- no recipe of this \
11045+ sweep produces a split 16x4/4x16 transform; see lanes/gaterecipe-r1.report.md"
1099511046 );
1099611047 }
1099711048
lanes/gaterecipe-r1.report.mdadded+111 -0
@@ -0,0 +1,111 @@
1+# lane-gaterecipe r1 — two 1:4 gates that were red on their FIRING assert
2+
3+Both gates were red with **0 pixel mismatches and 0 refusals**: the shape each
4+claimed simply was not in its streams once the refusals their recipes used to
5+stop at were lifted (sbab, rectres).
6+
7+## Gate A — `real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal`
8+
9+VERDICT: **vacuous recipe** (class `counter-from-refused-stream` + `gate-blind-to-feature`).
10+
11+Step 1, the old recipe measured against the ORACLE. `aomdec` with
12+`EC_TRACE=1 EC_TRACE_COEFF=1` on the stream the old firing arm produced
13+(384x256, 16-px banded translation, cq 32..58, `--min-partition-size=16`):
14+
15+| oracle histogram | reading |
16+|---|---|
17+| partitions `(bsize,p)`: `(9,2)x424 (12,3)x119 (9,0)x32 (12,0)x25 (9,6)x9 (9,7)x7` | **zero 1:4 partitions at any level** |
18+| plane-0 coefficient `tx_size`: `tx2:39 tx4:25 tx9:218` | whole TX_16X16/TX_64X64/TX_16X32 units, **zero sub-transforms** |
19+
20+So the encoder never wrote the shape; the leaves the old assert counted came out
21+of the two attempts that stopped at a named refusal. Our decoder agrees with the
22+oracle: on the merged tree those 18 attempts decode pixel-exact with the counter
23+at 0.
24+
25+EVIDENCE: /home/user/.cache/gaterecipe-g1.log + ~/.cache/gaterecipe-tmp/g1c50.trace | old recipe, 18 attempts x 2 depths decoded + aomdec EC_TRACE/EC_TRACE_COEFF histogram | 0 rect var-tx leaves ours, 0 1:4 partitions and 0 sub-transforms oracle-side
26+
27+Step 2, recipe re-sweep (~40 aomenc runs, script `~/.cache/gaterecipe-tmp/sweep.sh`,
28+oracle histogram `~/.cache/gaterecipe-tmp/oracle.sh`): banded-motion sources at any
29+cq/size and `--min-partition-size` 16 never split a rectangular transform. What does:
30+a high-frequency PRODUCT texture `128+90*sin((X+N*3)/6)*sin(Y/2)+50*sin((X*Y)/37)`
31+at 384x256, **cq 10**, `--min-partition-size=8 --enable-tx-size-search=1`
32+(part of a block predicts well and part does not = the RD case for `txfm_partition`).
33+
34+Gate A now uses that recipe on attempts 16/17 (plus its transposed twin), 8-bit only:
35+
36+```
37+real_aomenc_1to4_streams_..._rect_vartx_leaves_fire_before_a_named_refusal (8-bit):
38+ 2 named refusals, 0 pixel-exact attempts carrying the arm,
39+ pixel-compared rect var-tx leaves 32x16=0 16x32=0,
40+ leaves decoded anywhere in the sweep 32x16=21 16x32=15,
41+ 16 attempts carried none (0 of them mismatched)
42+(10-bit): 0 named refusals, ... 16 attempts carried none (0 of them mismatched)
43+test result: ok. 1 passed
44+```
45+
46+Both firing attempts stop at another lane's live refusal ("an intra 16x4/4x16 strip
47+inside an inter 16x16-level 1:4 partition"), which is exactly what the gate's NAME
48+claims (leaves fire *before a named refusal*) and what its `fired_*` vs `leaf_*`
49+split already separated. Every attempt that ran to the end is compared Y/U/V per
50+decode-order frame, `oos_mismatch == 0` asserted.
51+
52+EVIDENCE: /home/user/.cache/gaterecipe-g1d.log | 34 aomenc streams (18 8-bit + 16 10-bit) -> decode -> ffmpeg Y/U/V compare | 36 rect var-tx leaves decoded before a named refusal, 0 mismatches, gate green
53+
54+## Gate B — `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact`
55+
56+VERDICT: **vacuous recipe for the split-tx-8x4 arm** + an **open decode defect** on the
57+only recipe that fires it.
58+
59+The arm's escape hatch ("some attempt refused on rectangular residual coding") closed
60+when lane-rectres lifted that refusal, and the arm itself has always read 0. Measured:
61+no 192x128 recipe of this sweep (cq 8..44, both orientations, `--min-partition-size=4`,
62+`--enable-tx-size-search=1`) makes aomenc split a 16x4/4x16 strip's transform; the
63+oracle histograms carry whole TX_16X4/TX_4X16 units and no sub-transform.
64+
65+The 384x256 cq-10 recipe above DOES fire it — `arms [4, 4, 4, 4, 6]`, six 8x4/4x8
66+var-tx leaves — and that stream **MISMATCHES ffmpeg at decode-order frame 2 (luma)**.
67+So the arm cannot be pixel-proved today; the gate now reports it unproven (eprintln +
68+comment naming the sweep) instead of asserting a shape no decodable recipe produces,
69+and the VERT_4 arm keeps its hard assert.
70+
71+```
72+(8-bit): 0 named refusals, 2 pixel-exact attempts carrying a 16-level inter 1:4 partition,
73+ per-arm HORZ_4/VERT_4/chroma-pair/sub8x8-chroma/split-tx-8x4=[1, 1, 2, 2, 0],
74+ 30 attempts carried none (0 of them mismatched)
75+split-tx-8x4 arm unproven (arms [1, 1, 2, 2, 0])
76+test result: ok. 1 passed
77+```
78+
79+EVIDENCE: /home/user/.cache/gaterecipe-g2c.log (mismatch) + /home/user/.cache/gaterecipe-g2d.log (green) | 384x256 cq-10 min-partition-size=8 arm decoded and compared | 6 split-tx 8x4 leaves fired, frame 2 luma differs -> arm withdrawn, defect handed off
80+
81+## HANDED-OFF DECODE DEFECT (do not lose this)
82+
83+Two independent recipes decode a rectangular var-tx SPLIT wrong, silently (no refusal):
84+
85+1. 8-bit, 384x256, 6 frames @25, source `128+90*sin((X+N*3)/6)*sin(Y/2)+50*sin((X*Y)/37)`,
86+ `--codec=av1 --passes=1 --end-usage=q --cq-level=10 --cpu-used=0 --threads=1 --row-mt=0
87+ --sb-size=64 --enable-restoration=0 --enable-palette=0 --deltaq-mode=0
88+ --enable-filter-intra=0 --enable-cfl-intra=0 --enable-intrabc=0 --lag-in-frames=0
89+ --kf-max-dist=9999 --tile-columns=0 --enable-tx-size-search=1 --enable-rect-partitions=1
90+ --enable-ab-partitions=1 --enable-1to4-partitions=1 --min-partition-size=8
91+ --max-partition-size=64` -> arms [4,4,4,4,6], **frame 2 luma differs**.
92+2. 10-bit, same source at cq 10, gate A's flag set (`--enable-ab-partitions=0
93+ --enable-dual-filter=0 --enable-obmc=0 --enable-tx64=1`) -> 46 16x32 leaves on
94+ attempt 16, **frame 2 luma differs** on attempt 17.
95+
96+fix-now for the decode lane that owns `read_block_tx_size` / `read_inter_plane_rect`;
97+this lane may not touch decode.rs.
98+
99+## Also fixed, same diff
100+
101+`aomenc stdin is fed from a thread` in gate A: the single-threaded
102+`write_all` + `wait_with_output` shape deadlocks as soon as aomenc's stdout pipe fills
103+before it has consumed the whole y4m. The cq-10 arm hit it — one encode hung 40 minutes
104+(class: gate loader/pipe deadlock, 2nd instance in this repo).
105+
106+## Residue
107+
108+- deferred: the split-tx-8x4 arm and the pixel-exact proof of 32x16/16x32 var-tx leaves —
109+ blocked on (a) the "intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition"
110+ refusal and (b) the decode defect above. Unblocked by either landing.
111+- accepted: gate A's leaves are proved DECODED, not pixel-exact, exactly as its name says.