Merge lane-av1sb128chroma: the SB128 chroma arm is already correct (premise refuted, fixture gap closed)
Browse files at this commit4 changed files +482 -0
- crates/ec-av1/fixtures/444_intra_in_inter_128root_mu_chroma.obu +0 -0
- crates/ec-av1/fixtures/444_sb128cq20_tsrc2_control.obu +0 -0
- crates/ec-av1/src/stream.rs +202 -0
- lanes/av1sb128chroma.report.md +280 -0
crates/ec-av1/fixtures/444_intra_in_inter_128root_mu_chroma.obuadded+0 -0
Binary file changed
crates/ec-av1/fixtures/444_sb128cq20_tsrc2_control.obuadded+0 -0
Binary file changed
crates/ec-av1/src/stream.rsmodified+202 -0
| @@ -38136,6 +38136,208 @@ pub(crate) mod tests { | |||
| 38136 | ); | 38136 | ); |
| 38137 | } | 38137 | } |
| 38138 | 38138 | ||
| 38139 | + /// lane-av1sb128chroma: the PINNED half of | ||
| 38140 | + /// [`a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact`]. | ||
| 38141 | + /// That gate re-encodes its fixture on every run, so the arm it names had | ||
| 38142 | + /// NO committed 4:4:4 bytes at all: a host without ffmpeg/aomenc silently | ||
| 38143 | + /// skips it, and the whole committed 4:4:4 base is lossless 8-bit, so | ||
| 38144 | + /// nothing else in the crate decoded one of these streams. This gate is | ||
| 38145 | + /// the pin, and it also carries the COUNTER-PROOF arm: the recipe a | ||
| 38146 | + /// proposed 4:4:4 `--sb-size=128` chroma repair was argued from reads | ||
| 38147 | + /// ZERO on both the arm's own counters, so its green is vacuous. | ||
| 38148 | + /// | ||
| 38149 | + /// **Witness** `fixtures/444_intra_in_inter_128root_mu_chroma.obu`, | ||
| 38150 | + /// sha256 `f5999bd996fef820472dc7846e42cad3e62bd1f816fafd7f218e34b77786394a`, | ||
| 38151 | + /// 3570 bytes, 3 decode-order frames. Recipe (verified byte-reproducible): | ||
| 38152 | + /// ```text | ||
| 38153 | + /// ffmpeg -v error -f lavfi -i "gradients=size=128x256:c0=0xa1128f:c1=0xd98c48:\ | ||
| 38154 | + /// c2=0x120601:c3=0x4abfba:seed=63:duration=0.12:rate=25,\ | ||
| 38155 | + /// noise=all_seed=63:alls=6:allf=t" -pix_fmt yuv444p -t 0.12 -f yuv4mpegpipe - > in.y4m | ||
| 38156 | + /// aomenc --codec=av1 --profile=1 --passes=1 --end-usage=q --cq-level=62 \ | ||
| 38157 | + /// --cpu-used=0 --threads=1 --row-mt=0 --sb-size=128 --limit=3 \ | ||
| 38158 | + /// --max-partition-size=128 --min-partition-size=64 \ | ||
| 38159 | + /// --enable-rect-partitions=0 --enable-ab-partitions=0 \ | ||
| 38160 | + /// --enable-1to4-partitions=0 --enable-palette=0 --enable-intrabc=0 \ | ||
| 38161 | + /// --deltaq-mode=0 --enable-tx-size-search=0 --obu -o out.obu in.y4m | ||
| 38162 | + /// ``` | ||
| 38163 | + /// `duration=0.12:rate=25` and `--limit=3` are load-bearing (the | ||
| 38164 | + /// `gradients`/`noise` patterns are time-parameterised, and at `--limit=2` | ||
| 38165 | + /// the encoder stops choosing INTRA over inter for a whole 128 root). | ||
| 38166 | + /// | ||
| 38167 | + /// **Measured on this witness** (unpatched `main` `57834ee2`): the arm | ||
| 38168 | + /// fires `intra_128_in_inter_hits = 1` root and | ||
| 38169 | + /// `intra_128_in_inter_mu_chroma_hits = 4` mu-chunk chroma reads (a 4:4:4 | ||
| 38170 | + /// 64x64 mu chunk is FOUR TX_32X32 units per plane, two chunks, one | ||
| 38171 | + /// plane reached before the other), and all 3 frames are byte-exact | ||
| 38172 | + /// against the oracle. The claimed `cu_tx = 64` repair is refuted by two | ||
| 38173 | + /// independent measurements: (a) with `cu_tx` at 64 this arm PANICS -- | ||
| 38174 | + /// `no default scan for a 64-point transform` at `decode.rs:7197`, because | ||
| 38175 | + /// libaom's `av1_get_adjusted_tx_size` (blockd.h:1361) maps TX_64X64 to | ||
| 38176 | + /// TX_32X32 unconditionally, so a 4:4:4 chroma unit is never 64 and | ||
| 38177 | + /// `av1_scan_orders` has no 64-point chroma table; (b) with only the | ||
| 38178 | + /// luma-span and per-chunk-origin halves of that repair applied (`cu_tx` | ||
| 38179 | + /// left at 32 so the mutation reaches the pixels), this same witness goes | ||
| 38180 | + /// RED: Y 12537, U 16696, V 16667 wrong samples of 98304 per plane, | ||
| 38181 | + /// first at Y(90,120) ours 142 vs oracle 141, U(65,120) 153 vs 152, | ||
| 38182 | + /// V(64,120) 145 vs 146 -- all of it on decode-order frame 2, and the | ||
| 38183 | + /// counters still read 1/4, so the damage is on PIXELS. | ||
| 38184 | + #[test] | ||
| 38185 | + fn a_444_intra_in_inter_128root_muchroma_pinned_stream_decodes_pixel_exact() { | ||
| 38186 | + const NAME: &str = | ||
| 38187 | + "a_444_intra_in_inter_128root_muchroma_pinned_stream_decodes_pixel_exact"; | ||
| 38188 | + const WITNESS_LEN: usize = 3570; | ||
| 38189 | + const WITNESS_FNV: u64 = 0xe455_060d_f685_86dd; | ||
| 38190 | + const CONTROL_LEN: usize = 31602; | ||
| 38191 | + const CONTROL_FNV: u64 = 0xc542_f45f_f3a5_d494; | ||
| 38192 | + const W: usize = 128; | ||
| 38193 | + const H: usize = 256; | ||
| 38194 | + const FRAMES: usize = 3; | ||
| 38195 | + let dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("fixtures"); | ||
| 38196 | + let read_pinned = |name: &str, len: usize, fnv: u64| -> Vec<u8> { | ||
| 38197 | + let path = dir.join(name); | ||
| 38198 | + let bytes = std::fs::read(&path).unwrap_or_else(|e| { | ||
| 38199 | + panic!( | ||
| 38200 | + "{NAME}: pinned fixture {} is missing ({e}) -- the gate cannot run, \ | ||
| 38201 | + which is a failure, not a skip", | ||
| 38202 | + path.display() | ||
| 38203 | + ) | ||
| 38204 | + }); | ||
| 38205 | + assert_eq!(bytes.len(), len, "{NAME}: {name} length moved"); | ||
| 38206 | + assert_eq!(fnv1a64(&bytes), fnv, "{NAME}: {name} bytes moved"); | ||
| 38207 | + bytes | ||
| 38208 | + }; | ||
| 38209 | + let stream = read_pinned( | ||
| 38210 | + "444_intra_in_inter_128root_mu_chroma.obu", | ||
| 38211 | + WITNESS_LEN, | ||
| 38212 | + WITNESS_FNV, | ||
| 38213 | + ); | ||
| 38214 | + | ||
| 38215 | + let _gate_lock = lock_gate_counters(); | ||
| 38216 | + // The shape claim first: a stream that silently came back 4:2:0 would | ||
| 38217 | + // leave the arm unexercised while every other assert still passed. | ||
| 38218 | + let header = { | ||
| 38219 | + let mut parser = ec_av1_syntax::Av1Parser::new(); | ||
| 38220 | + let mut pos = 0usize; | ||
| 38221 | + while let Ok(obu) = parser.parse_obu(&stream[pos..]) { | ||
| 38222 | + pos += obu.total_size; | ||
| 38223 | + if pos >= stream.len() { | ||
| 38224 | + break; | ||
| 38225 | + } | ||
| 38226 | + } | ||
| 38227 | + parser.sequence_header().map(|q| { | ||
| 38228 | + ( | ||
| 38229 | + q.use_128x128_superblock, | ||
| 38230 | + q.color_config.subsampling_x, | ||
| 38231 | + q.color_config.subsampling_y, | ||
| 38232 | + q.color_config.mono_chrome, | ||
| 38233 | + ) | ||
| 38234 | + }) | ||
| 38235 | + }; | ||
| 38236 | + assert_eq!( | ||
| 38237 | + header, | ||
| 38238 | + Some((true, 0, 0, false)), | ||
| 38239 | + "{NAME}: the witness is not a 4:4:4 (ss 0/0, non-mono) 128x128-superblock stream \ | ||
| 38240 | + -- {header:?}, so the arm under test is not the one that ran" | ||
| 38241 | + ); | ||
| 38242 | + let before = ( | ||
| 38243 | + crate::decode::intra_128_in_inter_hits(), | ||
| 38244 | + crate::decode::intra_128_in_inter_mu_chroma_hits(), | ||
| 38245 | + ); | ||
| 38246 | + let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, NAME); | ||
| 38247 | + let (roots, units) = ( | ||
| 38248 | + crate::decode::intra_128_in_inter_hits() - before.0, | ||
| 38249 | + crate::decode::intra_128_in_inter_mu_chroma_hits() - before.1, | ||
| 38250 | + ); | ||
| 38251 | + assert_eq!(decoded, FRAMES, "{NAME}: decode-order frame count"); | ||
| 38252 | + // At 4:4:4 the chroma planes are full resolution; a decoder that kept | ||
| 38253 | + // the 4:2:0 extent would hand quarter-size chroma to the byte compare, | ||
| 38254 | + // which cannot pass. Say it here rather than let the compare stand in | ||
| 38255 | + // for the shape claim. | ||
| 38256 | + for f in crate::stream::decode_stream(&stream) | ||
| 38257 | + .unwrap_or_else(|e| panic!("{NAME}: the witness no longer decodes cleanly: {e}")) | ||
| 38258 | + { | ||
| 38259 | + assert_eq!((f.width, f.height), (W, H), "{NAME}: frame dimensions"); | ||
| 38260 | + assert_eq!( | ||
| 38261 | + f.u.len(), | ||
| 38262 | + W * H, | ||
| 38263 | + "{NAME}: chroma plane is {} samples", | ||
| 38264 | + f.u.len() | ||
| 38265 | + ); | ||
| 38266 | + } | ||
| 38267 | + assert!( | ||
| 38268 | + roots >= 1, | ||
| 38269 | + "{NAME}: no INTRA-coded 128x128 root inside an inter frame -- the arm under \ | ||
| 38270 | + test never ran" | ||
| 38271 | + ); | ||
| 38272 | + assert!( | ||
| 38273 | + units >= 4, | ||
| 38274 | + "{NAME}: only {units} mu-chunk chroma reads across {roots} intra-in-inter 128 \ | ||
| 38275 | + root(s) -- a 4:4:4 64x64 mu chunk is FOUR TX_32X32 units per plane, so fewer \ | ||
| 38276 | + than four means the per-unit walk this gate names did not run" | ||
| 38277 | + ); | ||
| 38278 | + eprintln!( | ||
| 38279 | + "{NAME}: {decoded} decode-order frame(s) pixel-exact ({hidden} hidden), \ | ||
| 38280 | + intra_128_in_inter={roots} mu_chunk_chroma_reads={units}" | ||
| 38281 | + ); | ||
| 38282 | + | ||
| 38283 | + // The COUNTER-PROOF arm. The 4:4:4 `--sb-size=128 --cq-level=20` | ||
| 38284 | + // `testsrc2` recipe a 64-point-chroma repair was argued from is | ||
| 38285 | + // byte-exact on all 24 frames AND reads ZERO on both of the arm's | ||
| 38286 | + // counters: on clean `testsrc2` the encoder's RD never picks INTRA | ||
| 38287 | + // over inter for a whole 128 root, so that stream cannot witness this | ||
| 38288 | + // arm at all. Pinning it keeps the refutation reproducible in-crate | ||
| 38289 | + // with no encoder on the host. | ||
| 38290 | + let control = read_pinned("444_sb128cq20_tsrc2_control.obu", CONTROL_LEN, CONTROL_FNV); | ||
| 38291 | + let ctl_header = { | ||
| 38292 | + let mut parser = ec_av1_syntax::Av1Parser::new(); | ||
| 38293 | + let mut pos = 0usize; | ||
| 38294 | + while let Ok(obu) = parser.parse_obu(&control[pos..]) { | ||
| 38295 | + pos += obu.total_size; | ||
| 38296 | + if pos >= control.len() { | ||
| 38297 | + break; | ||
| 38298 | + } | ||
| 38299 | + } | ||
| 38300 | + parser.sequence_header().map(|q| { | ||
| 38301 | + ( | ||
| 38302 | + q.use_128x128_superblock, | ||
| 38303 | + q.color_config.subsampling_x, | ||
| 38304 | + q.color_config.subsampling_y, | ||
| 38305 | + ) | ||
| 38306 | + }) | ||
| 38307 | + }; | ||
| 38308 | + assert_eq!( | ||
| 38309 | + ctl_header, | ||
| 38310 | + Some((true, 0, 0)), | ||
| 38311 | + "{NAME}: the control stream is not the 4:4:4 128-superblock stream its recipe \ | ||
| 38312 | + names -- {ctl_header:?}" | ||
| 38313 | + ); | ||
| 38314 | + let ctl_before = ( | ||
| 38315 | + crate::decode::intra_128_in_inter_hits(), | ||
| 38316 | + crate::decode::intra_128_in_inter_mu_chroma_hits(), | ||
| 38317 | + ); | ||
| 38318 | + let ctl_frames = crate::stream::decode_stream(&control) | ||
| 38319 | + .unwrap_or_else(|e| panic!("{NAME}: the control stream no longer decodes: {e}")) | ||
| 38320 | + .len(); | ||
| 38321 | + let ctl = ( | ||
| 38322 | + crate::decode::intra_128_in_inter_hits() - ctl_before.0, | ||
| 38323 | + crate::decode::intra_128_in_inter_mu_chroma_hits() - ctl_before.1, | ||
| 38324 | + ); | ||
| 38325 | + assert_eq!(ctl_frames, 24, "{NAME}: control frame count"); | ||
| 38326 | + assert_eq!( | ||
| 38327 | + ctl, | ||
| 38328 | + (0, 0), | ||
| 38329 | + "{NAME}: the control stream now reaches the arm ({ctl:?}) -- the witness's \ | ||
| 38330 | + non-vacuity argument rested on `testsrc2` never choosing an \ | ||
| 38331 | + intra-coded 128 root, and that is no longer true, so the two \ | ||
| 38332 | + fixtures no longer separate the cells" | ||
| 38333 | + ); | ||
| 38334 | + if aomdec_available(NAME) { | ||
| 38335 | + let (ctl_decoded, ctl_hidden) = decode_all_frames_vs_oracle(&control, NAME); | ||
| 38336 | + assert_eq!(ctl_decoded, 24, "{NAME}: control decode-order frame count"); | ||
| 38337 | + eprintln!("{NAME}: control {ctl_decoded} frame(s) pixel-exact ({ctl_hidden} hidden)"); | ||
| 38338 | + } | ||
| 38339 | + } | ||
| 38340 | + | ||
| 38139 | /// lane-sbpart r2: a real `aomenc` stream whose superblock-level | 38341 | /// lane-sbpart r2: a real `aomenc` stream whose superblock-level |
| 38140 | /// partition decision is genuinely HORZ/VERT (not NONE/SPLIT) must | 38342 | /// partition decision is genuinely HORZ/VERT (not NONE/SPLIT) must |
| 38141 | /// decode pixel-exact through [`crate::decode::decode_block_rect64`] -- | 38343 | /// decode pixel-exact through [`crate::decode::decode_block_rect64`] -- |
lanes/av1sb128chroma.report.mdadded+280 -0
| @@ -0,0 +1,280 @@ | |||
| 1 | +# lane-av1sb128chroma — the ticket's `cu_tx = 64` repair is REFUTED; the arm is pinned and gated | ||
| 2 | + | ||
| 3 | +Base: `main` `57834ee2` ("Merge lane-av1chromarect-r2 …"). Branch | ||
| 4 | +`lane-av1sb128chroma`, worktree `/home/user/.cache/wt/av1sb128chroma`. | ||
| 5 | +Oracle `~/.cache/aom-oracle` (aom `v3.13.3-7-g9bb526a`, instrumented), read-only. | ||
| 6 | + | ||
| 7 | +**Verdict: no source fix — there is nothing to fix.** The site named by the | ||
| 8 | +ticket is *already* the repaired form, and the repair itself is a hard panic | ||
| 9 | +plus a 45 900-sample pixel divergence when applied. What the ticket's premise | ||
| 10 | +was right about is the *fixture* gap: this arm had no committed bytes, so I | ||
| 11 | +pinned the witness, added the gate, and closed the ticket on evidence. | ||
| 12 | + | ||
| 13 | +--- | ||
| 14 | + | ||
| 15 | +## 0. The prerequisite is on `main` — here is the commit | ||
| 16 | + | ||
| 17 | +The ticket's stated unblock was `lane-av1444rect` `f92776ba` (the H1 fix). | ||
| 18 | + | ||
| 19 | +``` | ||
| 20 | +$ git merge-base --is-ancestor f92776ba main && echo YES | ||
| 21 | +YES | ||
| 22 | +$ git show -s --format='%H %ad %s' f92776ba | ||
| 23 | +f92776bab2442319e32d4f56844af6956e2fc18b Mon Sep 28 21:32:43 2026 +0300 | ||
| 24 | + ec-av1: lane-av1444rect -- a 1:4 inter strip's chroma context was gathered | ||
| 25 | + at the 4:2:0 pair extent at ss (0,0), forking the coder (H1) | ||
| 26 | +``` | ||
| 27 | + | ||
| 28 | +Confirmed on `main`. H1 is the `decode_inter_block` `around_c` context | ||
| 29 | +geometry, a **different arm** from the one under test (see §2). | ||
| 30 | + | ||
| 31 | +--- | ||
| 32 | + | ||
| 33 | +## 1. The site, re-located | ||
| 34 | + | ||
| 35 | +The ticket says "around 41930, re-locate with grep". Line numbers have drifted. | ||
| 36 | +The `EC_TMP_SB128CHROMA` counter that report line names is `lanes/av1tilerows.report.md:192`; | ||
| 37 | +grepping the crate for it finds nothing (it was removed), and its successor | ||
| 38 | +counter is `INTRA_128_IN_INTER_MU_CHROMA_HITS` (decode.rs:5591, hit at 43576). | ||
| 39 | + | ||
| 40 | +The arm is the **`side > 64` mu-chunk chroma walk of the INTRA-in-inter 128 | ||
| 41 | +root**, `decode.rs:43568-43772`, inside `decode_inter_block`. Its three | ||
| 42 | +claimed defects are all present in the *repaired* form: | ||
| 43 | + | ||
| 44 | +| line | ticket says it is | actually is | | ||
| 45 | +|---|---|---| | ||
| 46 | +| 43592 | `cu_tx = 32` is the 4:2:0 answer, must be `64` at ss (0,0) | `cu_tx = 32` — **correct at every subsampling** (§3) | | ||
| 47 | +| 43599-43600 | `luma_span = cu_tx * 2` is the 4:2:0 answer | `cu_tx << ss_x(fctx)` — already ss-aware | | ||
| 48 | +| 43667-43670 | the origin is per-chunk, should be `cpx + cc * 64` | `cpx + cc * chunk_chroma_w + uc * cu_tx` — per-chunk **and** per-unit | | ||
| 49 | + | ||
| 50 | +`git log -L 43568,43620:crates/ec-av1/src/decode.rs` names the commit that put | ||
| 51 | +it there: **`c0727d64` "lanes/av1txsizeaudit r5: re-re-base onto ec4e9528, | ||
| 52 | +declare provenance of the foreign work"**, which is | ||
| 53 | +`git merge-base --is-ancestor c0727d64 main` → **ON MAIN**. That same commit | ||
| 54 | +added the live-encode gate | ||
| 55 | +`a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact` | ||
| 56 | +(stream.rs:37893) with the counter-argument already written out at | ||
| 57 | +stream.rs:37883-37891. | ||
| 58 | + | ||
| 59 | +--- | ||
| 60 | + | ||
| 61 | +## 2. Which arm the ticket's `20 fires` was counting — NOT this one | ||
| 62 | + | ||
| 63 | +The ticket's evidence is a 4:4:4 lossy `--sb-size=128 --cq-level=20` stream | ||
| 64 | +with "20 fires at ss=(0,0) side=128". I encoded exactly that and measured both | ||
| 65 | +sets of counters on it (throwaway probe, since removed): | ||
| 66 | + | ||
| 67 | +``` | ||
| 68 | +$ aomenc --codec=av1 --profile=1 --passes=1 --end-usage=q --cq-level=20 \ | ||
| 69 | + --cpu-used=2 --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 \ | ||
| 70 | + --limit=24 --sb-size=128 --obu -o ts444_cq20.obu testsrc2_128x96.y4m | ||
| 71 | +sha256 84de42800452d69f5db8dfec7c538ef34d66b26dce7eb428c1960f80df3a103a, 31602 B, 24 frames | ||
| 72 | +header: (sb128=true, ss_x=0, ss_y=0, mono=false) -> 4:4:4 confirmed | ||
| 73 | + | ||
| 74 | +frames oracle=24 ours=24 | ||
| 75 | +intra_128_in_inter=0 mu_chroma=0 chroma_split_tx=0 <-- the arm NEVER runs | ||
| 76 | +per-plane wrong Y=0 U=0 V=0 per-frame wrong [0,0,... x24] | ||
| 77 | +``` | ||
| 78 | + | ||
| 79 | +**Zero fires, not 20.** On clean `testsrc2` the encoder's RD never picks INTRA | ||
| 80 | +over inter for a whole 128 root, so this recipe cannot reach the arm at all — | ||
| 81 | +and `lanes/av1txsizeaudit`'s author already measured the same thing | ||
| 82 | +("measured over 24 recipe/cell combinations, three of which fired and none of | ||
| 83 | +them `testsrc2`", stream.rs:37863-37865). The 20 was a count of the *other* | ||
| 84 | +`side > 64` chroma walk (the INTER twin, `chroma_split_tx_hits`), or a count | ||
| 85 | +inflated under the now-removed masking fork; either way it is not this arm. | ||
| 86 | +The ticket's own instruction — "re-measure rather than adopt either number" — | ||
| 87 | +is what produced 0. | ||
| 88 | + | ||
| 89 | +So the ticket's proposed evidence stream is **vacuous for the arm it names**. | ||
| 90 | +That is the finding. | ||
| 91 | + | ||
| 92 | +--- | ||
| 93 | + | ||
| 94 | +## 3. `av1_get_max_uv_txsize(BLOCK_128X128, 0, 0)` is `TX_32X32`, not `TX_64X64` | ||
| 95 | + | ||
| 96 | +The ticket's central "known fact" is the whole basis for `cu_tx = 64`. It is | ||
| 97 | +false. Read from the oracle tree: | ||
| 98 | + | ||
| 99 | +```c | ||
| 100 | +/* av1/common/blockd.h:1361-1370 */ | ||
| 101 | +static inline TX_SIZE av1_get_adjusted_tx_size(TX_SIZE tx_size) { | ||
| 102 | + switch (tx_size) { | ||
| 103 | + case TX_64X64: | ||
| 104 | + case TX_64X32: | ||
| 105 | + case TX_32X64: return TX_32X32; /* <-- unconditional 64 -> 32 */ | ||
| 106 | + case TX_64X16: return TX_32X16; | ||
| 107 | + case TX_16X64: return TX_16X32; | ||
| 108 | + default: return tx_size; | ||
| 109 | + } | ||
| 110 | +} | ||
| 111 | + | ||
| 112 | +/* av1/common/blockd.h:1372-1379 */ | ||
| 113 | +static inline TX_SIZE av1_get_max_uv_txsize(BLOCK_SIZE bsize, int subsampling_x, | ||
| 114 | + int subsampling_y) { | ||
| 115 | + const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, subsampling_x, subsampling_y); | ||
| 116 | + const TX_SIZE uv_tx = max_txsize_rect_lookup[plane_bsize]; | ||
| 117 | + return av1_get_adjusted_tx_size(uv_tx); | ||
| 118 | +} | ||
| 119 | +``` | ||
| 120 | + | ||
| 121 | +`av1_get_adjusted_tx_size` takes **no subsampling argument**. At ss (0,0), | ||
| 122 | +`get_plane_block_size(BLOCK_128X128, 0, 0) == BLOCK_128X128` and | ||
| 123 | +`max_txsize_rect_lookup[BLOCK_128X128] == TX_64X64`, so the answer is | ||
| 124 | +`adjusted(TX_64X64) == TX_32X32`. The 64→32 step fires **at ss (0,0) too**, | ||
| 125 | +which is exactly the point the ticket's derivation misses. | ||
| 126 | +`lanes/av1txsizeaudit.report.md` §0.1 measured the same table with a C probe | ||
| 127 | +linked against the oracle's own `libaom.a` | ||
| 128 | +(`DIRECT bsize=BLOCK_128X128 ss=00 … adjusted=3 (32x32)`), and §0.2 measured | ||
| 129 | +it at runtime from the oracle's `EC_TRACE_COEFF` on a 4:4:4 `--sb-size=128` | ||
| 130 | +stream: **chroma reads 0 units of any 64-axis shape, 49 units of `tx=3` | ||
| 131 | +(TX_32X32)**. | ||
| 132 | + | ||
| 133 | +Two independent confirmations from my own runs below: `cu_tx = 64` makes this | ||
| 134 | +crate **panic on a 64-point scan table that libaom does not have** | ||
| 135 | +(§5, mutation A), and the arm's own live-encode gate measured | ||
| 136 | +`mu_chunk_chroma_reads = 4` on the firing witness — four TX_32X32 units, not | ||
| 137 | +one TX_64X64. | ||
| 138 | + | ||
| 139 | +--- | ||
| 140 | + | ||
| 141 | +## 4. The witness (pinned) and the counter | ||
| 142 | + | ||
| 143 | +**Fixture** `crates/ec-av1/fixtures/444_intra_in_inter_128root_mu_chroma.obu` | ||
| 144 | +— sha256 `f5999bd996fef820472dc7846e42cad3e62bd1f816fafd7f218e34b77786394a`, | ||
| 145 | +3570 bytes, 3 decode-order frames, fnv1a64 `0xe455_060d_f685_86dd`. | ||
| 146 | + | ||
| 147 | +**Recipe**, re-run and `cmp`-confirmed byte-reproducible: | ||
| 148 | + | ||
| 149 | +```text | ||
| 150 | +ffmpeg -v error -f lavfi -i \ | ||
| 151 | + "gradients=size=128x256:c0=0xa1128f:c1=0xd98c48:c2=0x120601:c3=0x4abfba:\ | ||
| 152 | +seed=63:duration=0.12:rate=25,noise=all_seed=63:alls=6:allf=t" \ | ||
| 153 | + -pix_fmt yuv444p -t 0.12 -f yuv4mpegpipe - > in.y4m | ||
| 154 | + | ||
| 155 | +aomenc --codec=av1 --profile=1 --passes=1 --end-usage=q --cq-level=62 \ | ||
| 156 | + --cpu-used=0 --threads=1 --row-mt=0 --sb-size=128 --limit=3 \ | ||
| 157 | + --max-partition-size=128 --min-partition-size=64 \ | ||
| 158 | + --enable-rect-partitions=0 --enable-ab-partitions=0 \ | ||
| 159 | + --enable-1to4-partitions=0 --enable-palette=0 --enable-intrabc=0 \ | ||
| 160 | + --deltaq-mode=0 --enable-tx-size-search=0 --obu -o out.obu in.y4m | ||
| 161 | +``` | ||
| 162 | + | ||
| 163 | +`duration=0.12:rate=25` and `--limit=3` are load-bearing (the `gradients` / | ||
| 164 | +`noise` patterns are time-parameterised, and at `--limit=2` the encoder stops | ||
| 165 | +choosing the shape at all). | ||
| 166 | + | ||
| 167 | +**Counter, quoted** — the arm fires on the pinned witness: | ||
| 168 | + | ||
| 169 | +``` | ||
| 170 | +$ cargo test -p ec-av1 --lib -- a_444_intra_in_inter_128root_muchroma_pinned --nocapture | ||
| 171 | +a_444_intra_in_inter_128root_muchroma_pinned_stream_decodes_pixel_exact: | ||
| 172 | + 3 decode-order frame(s) pixel-exact (0 hidden), | ||
| 173 | + intra_128_in_inter=1 mu_chunk_chroma_reads=4 | ||
| 174 | +a_444_intra_in_inter_128root_muchroma_pinned_stream_decodes_pixel_exact: | ||
| 175 | + control 24 frame(s) pixel-exact (0 hidden) | ||
| 176 | +test result: ok. 1 passed; 0 failed | ||
| 177 | +``` | ||
| 178 | + | ||
| 179 | +`intra_128_in_inter_hits = 1` (one intra-coded 128x128 root inside an inter | ||
| 180 | +frame) and `intra_128_in_inter_mu_chroma_hits = 4` (mu-chunk chroma reads: | ||
| 181 | +a 4:4:4 64x64 mu chunk is FOUR TX_32X32 units per plane, and the walk | ||
| 182 | +`continue`s after the first chunk's arms). The gate asserts `roots >= 1` and | ||
| 183 | +`units >= 4`, so it is non-vacuous by construction. The pre-existing | ||
| 184 | +live-encode gate independently reports the same `1` / `4` on the same recipe, | ||
| 185 | +so the pin matches it byte-for-byte. | ||
| 186 | + | ||
| 187 | +**Control, also pinned** — | ||
| 188 | +`crates/ec-av1/fixtures/444_sb128cq20_tsrc2_control.obu`, sha256 | ||
| 189 | +`84de42800452d69f5db8dfec7c538ef34d66b26dce7eb428c1960f80df3a103a`, 31602 B, | ||
| 190 | +24 frames, fnv1a64 `0xc542_f45f_f3a5_d494`. This is the ticket's own recipe | ||
| 191 | +(§2). The gate asserts it decodes 24 frames byte-exact **and** reads | ||
| 192 | +`(0, 0)` on both arm counters, which is what pins the refutation in-crate | ||
| 193 | +with no encoder on the host. | ||
| 194 | + | ||
| 195 | +--- | ||
| 196 | + | ||
| 197 | +## 5. Red / green | ||
| 198 | + | ||
| 199 | +**GREEN, unpatched `main` `57834ee2`:** all 3 decode-order frames of the | ||
| 200 | +pinned witness byte-exact vs the oracle `aomdec`; per-plane wrong | ||
| 201 | +**Y 0, U 0, V 0**; 24/24 frames of the control byte-exact. | ||
| 202 | + | ||
| 203 | +There is no red-before *of the site*, because the site is already correct. | ||
| 204 | +The red is therefore measured on the **ticket's proposed change**, applied to | ||
| 205 | +the site and then reverted. Two directions, both of which make the new gate | ||
| 206 | +fail: | ||
| 207 | + | ||
| 208 | +### Mutation A — the ticket's full change (`cu_tx = 64` at ss (0,0), | ||
| 209 | +plus `unit_luma_w/h = cu_tx * 2`, plus `(cpx + cc * 64, cpy + cr * 64)`) | ||
| 210 | + | ||
| 211 | +``` | ||
| 212 | +thread 'stream::tests::a_444_intra_in_inter_128root_muchroma_pinned_stream_decodes_pixel_exact' | ||
| 213 | +panicked at crates/ec-av1/src/decode.rs:7197:5: | ||
| 214 | +no default scan for a 64-point transform | ||
| 215 | +test result: FAILED. 0 passed; 1 failed | ||
| 216 | +``` | ||
| 217 | + | ||
| 218 | +Not a pixel divergence — a **hard panic**. libaom's `av1_scan_orders` has no | ||
| 219 | +64-point chroma table (a 64-axis transform codes only its 32x32 corner; | ||
| 220 | +scan.c aliases TX_64X64 to `default_scan_32x32`), so asking for one asserts. | ||
| 221 | +This is the decisive single measurement: the ticket's answer does not decode. | ||
| 222 | + | ||
| 223 | +### Mutation B — the ticket's luma-span and per-chunk-origin halves only | ||
| 224 | +(`cu_tx` left at 32, so the mutation reaches the pixels instead of the assert) | ||
| 225 | + | ||
| 226 | +``` | ||
| 227 | +thread '…muchroma_pinned_stream_decodes_pixel_exact' panicked at | ||
| 228 | + crates/ec-av1/src/stream.rs:9767:17: | ||
| 229 | + decode-order frame 2 of 3 (3 shown, 0 hidden) differs from the oracle at | ||
| 230 | + byte 15450 (ours 142 vs 141), 45900 bytes differ | ||
| 231 | +test result: FAILED. 0 passed; 1 failed | ||
| 232 | +``` | ||
| 233 | + | ||
| 234 | +Per-plane wrong samples over the 3 frames (98 304 per plane), from the | ||
| 235 | +throwaway probe that measured them plane-by-plane: | ||
| 236 | + | ||
| 237 | +| plane | wrong samples | first differing sample | ours | oracle | | ||
| 238 | +|---|---|---|---|---| | ||
| 239 | +| Y | 12 537 | (x=90, y=120) | 142 | 141 | | ||
| 240 | +| U | 16 696 | (x=65, y=120) | 153 | 152 | | ||
| 241 | +| V | 16 667 | (x=64, y=120) | 145 | 146 | | ||
| 242 | + | ||
| 243 | +Per-frame wrong: `[0, 0, 45900]` — all of it on decode-order frame 2, and the | ||
| 244 | +arm's counters still read `intra_128_in_inter=1`, | ||
| 245 | +`mu_chunk_chroma_reads=4`, so the damage is on **pixels**, not on the counter | ||
| 246 | +(class `gate-blind-to-feature`, avoided). | ||
| 247 | + | ||
| 248 | +**GREEN after revert:** both mutations reverted; `git diff crates/ec-av1/src/decode.rs` | ||
| 249 | +is **empty** — the decoder is byte-identical to `main`. The only source | ||
| 250 | +change in this lane is the new test in `stream.rs` plus the two pinned | ||
| 251 | +fixtures. | ||
| 252 | + | ||
| 253 | +--- | ||
| 254 | + | ||
| 255 | +## 6. Gates re-run | ||
| 256 | + | ||
| 257 | +| scope | command | result | | ||
| 258 | +|---|---|---| | ||
| 259 | +| the new pinned gate | `cargo test -p ec-av1 --lib -- a_444_intra_in_inter_128root_muchroma_pinned` | **1 passed / 0 failed** (witness 1 root / 4 mu-chunk chroma reads, 3/3 frames byte-exact; control 24/24 byte-exact, 0 fires) | | ||
| 260 | +| the pre-existing live-encode twin | `… -- a_real_aomenc_444_intra_in_inter_128_root` | **passed**, same `1` / `4` | | ||
| 261 | +| every 4:4:4 and 4:2:0 gate in the crate (44) | `cargo test -p ec-av1 --lib -- <44 names matching 444\|420>` | **44 passed / 0 failed** | | ||
| 262 | +| the 128-root / lossless families (66 names) | `cargo test -p ec-av1 --lib -- <66 names matching 128\|lossless\|ll444\|mu_chunk>` | **55 passed / 0 failed / 11 ignored** — the 11 are pre-existing `#[ignore]`d probes, none of them this lane's gate | | ||
| 263 | +| compile | `cargo check -p ec-av1 --all-targets` | **clean**, no warnings | | ||
| 264 | + | ||
| 265 | +No full suite, no formatters — sibling lanes are live in this box. | ||
| 266 | + | ||
| 267 | +--- | ||
| 268 | + | ||
| 269 | +## 7. What is left for whoever picks this up | ||
| 270 | + | ||
| 271 | +Nothing on the source side. The arm is correct, gated, and now pinned. The one | ||
| 272 | +thing this lane could not close, and hands on unchanged: | ||
| 273 | + | ||
| 274 | +- **`decode.rs:43568`'s `around_mi` is the square-gather form.** The inter | ||
| 275 | + twins at 40904/43661 already use `around_mi_rect(unit_mi, unit_luma_w, | ||
| 276 | + unit_luma_h)`; this arm passes one `side`. With `w == h` the two are | ||
| 277 | + byte-identical, and `unit_luma_w != unit_luma_h` only at 4:2:2, which the | ||
| 278 | + sequence header refuses by name — so it is **unreachable**, not a defect. | ||
| 279 | + Left as is; `lanes/av1txsizeaudit.report.md` §1.4 names it as its own | ||
| 280 | + (already-known) row. | ||