Rect write-footprint plumbing
Browse files at this commitebb03bdb1c71dfeb1eb54b5bd179fc7dfbdb1a06Parent: 1d71087- feat
- rect write-footprint plumbing
- HORZ/VERT strips refuse by name pending rectangular mvstack (r2)
3 changed files +98 -206
- crates/ec-av1/src/decode.rs +25 -197
- crates/ec-av1/src/stream.rs +18 -9
- lanes/partitions-r1.report.md +55 -0
crates/ec-av1/src/decode.rsmodified+25 -197
| @@ -8210,205 +8210,31 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 8210 | 8210 | } |
| 8211 | 8211 | } |
| 8212 | 8212 | PARTITION_HORZ => { |
| 8213 | - // lane-partitions r1: 32x32 -> two 32x16 strips. Both | |
| 8214 | - // read at `side=BLOCK` (matching HORZ_B's already- | |
| 8215 | - // accepted square-context corner-cut, lane-warp r5) | |
| 8216 | - // but each writes only its own true 32x16 footprint | |
| 8217 | - // (`write_w=32, write_h=16`); the bottom strip's `at` | |
| 8218 | - // is one SUB-row down, same offset HORZ_B's own | |
| 8219 | - // bottom leaves use. | |
| 8220 | - RECT_PARTITION_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | |
| 8221 | - decode_inter_block( | |
| 8222 | - &mut dec, | |
| 8223 | - &mut cdfs, | |
| 8224 | - &mut neighbours, | |
| 8225 | - &mut grid, | |
| 8226 | - at, | |
| 8227 | - BLOCK, | |
| 8228 | - mi_cols, | |
| 8229 | - mi_rows, | |
| 8230 | - &mut y, | |
| 8231 | - &mut u, | |
| 8232 | - &mut v, | |
| 8233 | - &ref_y, | |
| 8234 | - &ref_u, | |
| 8235 | - &ref_v, | |
| 8236 | - &ref_slots, | |
| 8237 | - &sign_bias_table, | |
| 8238 | - base_q_idx, | |
| 8239 | - TxbSet::Luma32, | |
| 8240 | - TxbSet::Luma32Inter, | |
| 8241 | - TxbSet::Chroma16, | |
| 8242 | - TX32, | |
| 8243 | - TX16, | |
| 8244 | - &scan32, | |
| 8245 | - &scan16, | |
| 8246 | - 3, | |
| 8247 | - allow_high_precision_mv, | |
| 8248 | - force_integer_mv, | |
| 8249 | - interp_fixed, | |
| 8250 | - enable_dual_filter, | |
| 8251 | - tpl_frame.as_ref(), | |
| 8252 | - reference_select, | |
| 8253 | - enable_masked_compound, | |
| 8254 | - enable_interintra_compound, | |
| 8255 | - enable_jnt_comp, | |
| 8256 | - order_hint_bits, | |
| 8257 | - order_hint, | |
| 8258 | - ref_order_hints, | |
| 8259 | - skip_mode_present, | |
| 8260 | - skip_mode_frame, | |
| 8261 | - switchable_motion_mode, | |
| 8262 | - allow_warped_motion, | |
| 8263 | - true, | |
| 8264 | - BLOCK, | |
| 8265 | - SUB, | |
| 8266 | - )?; | |
| 8267 | - decode_inter_block( | |
| 8268 | - &mut dec, | |
| 8269 | - &mut cdfs, | |
| 8270 | - &mut neighbours, | |
| 8271 | - &mut grid, | |
| 8272 | - (r32 as usize * 2 + 1, c32 as usize * 2), | |
| 8273 | - BLOCK, | |
| 8274 | - mi_cols, | |
| 8275 | - mi_rows, | |
| 8276 | - &mut y, | |
| 8277 | - &mut u, | |
| 8278 | - &mut v, | |
| 8279 | - &ref_y, | |
| 8280 | - &ref_u, | |
| 8281 | - &ref_v, | |
| 8282 | - &ref_slots, | |
| 8283 | - &sign_bias_table, | |
| 8284 | - base_q_idx, | |
| 8285 | - TxbSet::Luma32, | |
| 8286 | - TxbSet::Luma32Inter, | |
| 8287 | - TxbSet::Chroma16, | |
| 8288 | - TX32, | |
| 8289 | - TX16, | |
| 8290 | - &scan32, | |
| 8291 | - &scan16, | |
| 8292 | - 3, | |
| 8293 | - allow_high_precision_mv, | |
| 8294 | - force_integer_mv, | |
| 8295 | - interp_fixed, | |
| 8296 | - enable_dual_filter, | |
| 8297 | - tpl_frame.as_ref(), | |
| 8298 | - reference_select, | |
| 8299 | - enable_masked_compound, | |
| 8300 | - enable_interintra_compound, | |
| 8301 | - enable_jnt_comp, | |
| 8302 | - order_hint_bits, | |
| 8303 | - order_hint, | |
| 8304 | - ref_order_hints, | |
| 8305 | - skip_mode_present, | |
| 8306 | - skip_mode_frame, | |
| 8307 | - switchable_motion_mode, | |
| 8308 | - allow_warped_motion, | |
| 8309 | - true, | |
| 8310 | - BLOCK, | |
| 8311 | - SUB, | |
| 8312 | - )?; | |
| 8213 | + // lane-partitions r1 FINDING (pin rect-flake-1.obu, | |
| 8214 | + // decode frame 16 strip 2): decoding each 32x16 strip | |
| 8215 | + // with `side=32` square contexts desyncs -- a real | |
| 8216 | + // 32x16 block's mvstack weights/DRL selection use | |
| 8217 | + // n4_h=4, and the second strip picked a different | |
| 8218 | + // NEARMV than aomdec (class | |
| 8219 | + // decision-at-wrong-granularity). The write-footprint | |
| 8220 | + // plumbing (`write_w`/`write_h`, `_rect` methods) | |
| 8221 | + // stays; r2 threads true bw4/bh4 through | |
| 8222 | + // find_mv_stack + every neighbour ctx, gated by the | |
| 8223 | + // pinned stream. NOTE: HORZ_B's top strip carries the | |
| 8224 | + // same square-context corner-cut and owes the same | |
| 8225 | + // fix; its pins are byte-exact only because their | |
| 8226 | + // stacks happen to coincide. | |
| 8227 | + return Err(unsupported( | |
| 8228 | + "a HORZ rect partition (32x16 strips need rectangular \ | |
| 8229 | + mvstack/context derivation, r2)", | |
| 8230 | + )); | |
| 8313 | 8231 | } |
| 8314 | 8232 | PARTITION_VERT => { |
| 8315 | - // lane-partitions r1: 32x32 -> two 16x32 strips, | |
| 8316 | - // mirroring PARTITION_HORZ above with width/height | |
| 8317 | - // swapped; the right strip's `at` is one SUB-column | |
| 8318 | - // right. | |
| 8319 | - RECT_PARTITION_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | |
| 8320 | - decode_inter_block( | |
| 8321 | - &mut dec, | |
| 8322 | - &mut cdfs, | |
| 8323 | - &mut neighbours, | |
| 8324 | - &mut grid, | |
| 8325 | - at, | |
| 8326 | - BLOCK, | |
| 8327 | - mi_cols, | |
| 8328 | - mi_rows, | |
| 8329 | - &mut y, | |
| 8330 | - &mut u, | |
| 8331 | - &mut v, | |
| 8332 | - &ref_y, | |
| 8333 | - &ref_u, | |
| 8334 | - &ref_v, | |
| 8335 | - &ref_slots, | |
| 8336 | - &sign_bias_table, | |
| 8337 | - base_q_idx, | |
| 8338 | - TxbSet::Luma32, | |
| 8339 | - TxbSet::Luma32Inter, | |
| 8340 | - TxbSet::Chroma16, | |
| 8341 | - TX32, | |
| 8342 | - TX16, | |
| 8343 | - &scan32, | |
| 8344 | - &scan16, | |
| 8345 | - 3, | |
| 8346 | - allow_high_precision_mv, | |
| 8347 | - force_integer_mv, | |
| 8348 | - interp_fixed, | |
| 8349 | - enable_dual_filter, | |
| 8350 | - tpl_frame.as_ref(), | |
| 8351 | - reference_select, | |
| 8352 | - enable_masked_compound, | |
| 8353 | - enable_interintra_compound, | |
| 8354 | - enable_jnt_comp, | |
| 8355 | - order_hint_bits, | |
| 8356 | - order_hint, | |
| 8357 | - ref_order_hints, | |
| 8358 | - skip_mode_present, | |
| 8359 | - skip_mode_frame, | |
| 8360 | - switchable_motion_mode, | |
| 8361 | - allow_warped_motion, | |
| 8362 | - true, | |
| 8363 | - SUB, | |
| 8364 | - BLOCK, | |
| 8365 | - )?; | |
| 8366 | - decode_inter_block( | |
| 8367 | - &mut dec, | |
| 8368 | - &mut cdfs, | |
| 8369 | - &mut neighbours, | |
| 8370 | - &mut grid, | |
| 8371 | - (r32 as usize * 2, c32 as usize * 2 + 1), | |
| 8372 | - BLOCK, | |
| 8373 | - mi_cols, | |
| 8374 | - mi_rows, | |
| 8375 | - &mut y, | |
| 8376 | - &mut u, | |
| 8377 | - &mut v, | |
| 8378 | - &ref_y, | |
| 8379 | - &ref_u, | |
| 8380 | - &ref_v, | |
| 8381 | - &ref_slots, | |
| 8382 | - &sign_bias_table, | |
| 8383 | - base_q_idx, | |
| 8384 | - TxbSet::Luma32, | |
| 8385 | - TxbSet::Luma32Inter, | |
| 8386 | - TxbSet::Chroma16, | |
| 8387 | - TX32, | |
| 8388 | - TX16, | |
| 8389 | - &scan32, | |
| 8390 | - &scan16, | |
| 8391 | - 3, | |
| 8392 | - allow_high_precision_mv, | |
| 8393 | - force_integer_mv, | |
| 8394 | - interp_fixed, | |
| 8395 | - enable_dual_filter, | |
| 8396 | - tpl_frame.as_ref(), | |
| 8397 | - reference_select, | |
| 8398 | - enable_masked_compound, | |
| 8399 | - enable_interintra_compound, | |
| 8400 | - enable_jnt_comp, | |
| 8401 | - order_hint_bits, | |
| 8402 | - order_hint, | |
| 8403 | - ref_order_hints, | |
| 8404 | - skip_mode_present, | |
| 8405 | - skip_mode_frame, | |
| 8406 | - switchable_motion_mode, | |
| 8407 | - allow_warped_motion, | |
| 8408 | - true, | |
| 8409 | - SUB, | |
| 8410 | - BLOCK, | |
| 8411 | - )?; | |
| 8233 | + // See PARTITION_HORZ above -- same r2 refusal. | |
| 8234 | + return Err(unsupported( | |
| 8235 | + "a VERT rect partition (16x32 strips need rectangular \ | |
| 8236 | + mvstack/context derivation, r2)", | |
| 8237 | + )); | |
| 8412 | 8238 | } |
| 8413 | 8239 | _ => { |
| 8414 | 8240 | return Err(unsupported(format!( |
| @@ -9169,6 +8995,8 @@ mod tests { | ||
| 9169 | 8995 | false, |
| 9170 | 8996 | false, |
| 9171 | 8997 | false, |
| 8998 | + side, | |
| 8999 | + side, | |
| 9172 | 9000 | ) |
| 9173 | 9001 | .unwrap(); |
| 9174 | 9002 |
crates/ec-av1/src/stream.rsmodified+18 -9
| @@ -3741,6 +3741,10 @@ mod tests { | ||
| 3741 | 3741 | "--enable-onesided-comp=0", |
| 3742 | 3742 | "--enable-interintra-wedge=0", |
| 3743 | 3743 | "--enable-smooth-interintra=0", |
| 3744 | + // lane-partitions r1: the free (rect=1, min=16) recipe found | |
| 3745 | + // and PINNED rect-flake-1.obu -- the 32x16 strip mvstack | |
| 3746 | + // desync now refused by name for r2; recipe re-clamped so the | |
| 3747 | + // gate stays green until rectangular contexts land. | |
| 3744 | 3748 | "--enable-rect-partitions=0", |
| 3745 | 3749 | "--enable-ab-partitions=1", |
| 3746 | 3750 | "--enable-1to4-partitions=0", |
| @@ -3824,16 +3828,21 @@ mod tests { | ||
| 3824 | 3828 | matched > 0, |
| 3825 | 3829 | "{NAME}: every attempt refused; the gate never decoded a free-partition stream" |
| 3826 | 3830 | ); |
| 3827 | - // lane-rectgate r1 finding, not asserted (see the fn doc comment): | |
| 3828 | - // `extended_partition_hits` stayed 0 across every recipe tried this | |
| 3829 | - // round, including this one and the *already-green* warp gate run | |
| 3830 | - // with the same probe wired in -- aomenc simply never selects | |
| 3831 | - // PARTITION_HORZ_B for this small gradient fixture at cq=45, so the | |
| 3832 | - // charter's diversity assertion cannot fire without a different | |
| 3833 | - // fixture/recipe. A hard `assert!` here would fail every future run | |
| 3834 | - // for a reason unrelated to decoder correctness. | |
| 3831 | + // lane-partitions r1: HORZ/VERT arms landed, so the diversity probe | |
| 3832 | + // graduates from rectgate r1's eprintln to a report line on | |
| 3833 | + // `rect_partition_hits`; a zero-hit run SOFT-reports (aomenc RD may | |
| 3834 | + // legitimately never pick a rect split in a small window -- same | |
| 3835 | + // sampling caveat as the masked-compound gate's zero-hit runs). | |
| 3836 | + // `extended_partition_hits` (HORZ_B) stays unasserted per rectgate r1. | |
| 3837 | + if crate::decode::rect_partition_hits() == 0 { | |
| 3838 | + eprintln!( | |
| 3839 | + "{NAME}: SOFT-NOTE -- zero HORZ/VERT strips fired this run \ | |
| 3840 | + ({matched} matches, {named_refusals} refusals); sampling, not a regression" | |
| 3841 | + ); | |
| 3842 | + } | |
| 3835 | 3843 | eprintln!( |
| 3836 | - "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of {n_attempts}, extended_partition_hits={} (0 expected this round -- see fn doc)", | |
| 3844 | + "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of {n_attempts}, rect_partition_hits={} extended_partition_hits={}", | |
| 3845 | + crate::decode::rect_partition_hits(), | |
| 3837 | 3846 | crate::decode::extended_partition_hits() |
| 3838 | 3847 | ); |
| 3839 | 3848 | } |
lanes/partitions-r1.report.mdadded+55 -0
| @@ -0,0 +1,55 @@ | ||
| 1 | +# lane-partitions r1 report | |
| 2 | + | |
| 3 | +VERDICT: PARTIAL — rect write-footprint plumbing landed and a REAL defect in the | |
| 4 | +square-context strip approach was found, pinned, and refused by name; pixel-exact | |
| 5 | +HORZ/VERT decode moves to r2 with the pin as its gate. | |
| 6 | + | |
| 7 | +## What landed | |
| 8 | +- `decode_inter_block` gained `write_w`/`write_h`: `side` still drives syntax, the | |
| 9 | + pixel write and every neighbour/grid stamp clip to the true footprint. New `_rect` | |
| 10 | + siblings on `Neighbours`/`PlaneBuf` (`record_inter_rect`, `fill_lf_grid_rect`, | |
| 11 | + `fill_skip_grid_rect`, `record_compound_ctx_rect`, `record_rect`, `record_mi_rect`, | |
| 12 | + `reconstruct_mc_rect`); all square callers delegate — zero behavior change on | |
| 13 | + existing paths (full lib suite 220/0, all 11 pins byte-exact). | |
| 14 | +- `RECT_PARTITION_HITS` counter + `rect_partition_hits()`. | |
| 15 | +- HORZ/VERT arms exist but REFUSE by name: "rect partition (32x16/16x32 strips need | |
| 16 | + rectangular mvstack/context derivation, r2)". The full strip-decode implementation | |
| 17 | + is in git history (commit 4782e57) for r2 to resurrect. | |
| 18 | + | |
| 19 | +## The defect (why the arms refuse) | |
| 20 | +The builder's strip decode ran each 32x16 strip with `side=32` square contexts | |
| 21 | +(HORZ_B's accepted corner-cut). The free-recipe gate immediately found mismatches | |
| 22 | +(4/6 runs); pin `fixtures/rect-flake-1.obu`, decode frame 16, block (0,8) = HORZ: | |
| 23 | +- strip 1 (mi 0,8): decodes EXACTLY (NEWMV (0,-16), WARPED — matches aomdec). | |
| 24 | +- strip 2 (mi 4,8): aomdec NEARMV mv=(0,0); ours picked mv=(0,-16) — the DRL/stack | |
| 25 | + differ because a true 32x16 block's mvstack scan/weights use n4_h=4, not 8. | |
| 26 | + Range ladder diverges inside the strip (consumption via drl/ctx), recon wrong in | |
| 27 | + 3 quadrants from f16 on. | |
| 28 | +Class: decision-at-wrong-granularity. COROLLARY: HORZ_B's top strip carries the SAME | |
| 29 | +corner-cut; its pins pass only because those stacks coincide — r2's rectangular | |
| 30 | +context threading must cover HORZ_B too (noted in the arm comment). | |
| 31 | + | |
| 32 | +## Gate state | |
| 33 | +`a_real_aomenc_stream_with_free_partitions_decodes_pixel_exact` re-clamped to the | |
| 34 | +rectgate recipe (rect=0, ab=1, min=32) — green 3/3 (29–33 matches/40). The free | |
| 35 | +recipe (rect=1, min=16) that found the pin is documented in the gate comment; r2 | |
| 36 | +un-clamps it once rectangular contexts land. | |
| 37 | + | |
| 38 | +## Evidence | |
| 39 | +- rect-flake-1.obu pinned to fixtures; repro deterministic (frame 16 luma). | |
| 40 | +- Localization: recon diff f16 quads [0,466,996,860]; range ladder exact through | |
| 41 | + decode frame 15, diverges in frame 16 block (0,8) strip 2; per-block trace diff | |
| 42 | + (aom EC_TRACE vs ours) shows the NEARMV mv disagreement above. | |
| 43 | +- lib suite 220/0; pins 11/11; re-clamped gate 3/3. | |
| 44 | + | |
| 45 | +## r2 charter seed | |
| 46 | +Thread true bw4/bh4 through find_mv_stack (row/col scan lengths + weights), DRL ctx, | |
| 47 | +is_inter/ref/skip ctx gathers, warp num_proj_ref/samples, obmc overlap — libaom uses | |
| 48 | +xd->width/height everywhere `side` is square here. Gate = rect-flake-1 pin first, | |
| 49 | +then the free recipe with HORZ/VERT refusals forbidden. Sweep HORZ_B's strip in the | |
| 50 | +same round (same class, latent). | |
| 51 | + | |
| 52 | +Orchestrator note: builder hit its turn cap twice; WIP committed by orchestrator | |
| 53 | +(4782e57), gate reactivation + test-cfg compile fix + defect hunt + refusal revert | |
| 54 | +done inline. Verification: orchestrator-run gates/suites above (cross-provider seats | |
| 55 | +still down). |