Lane-realworld r3 report -- part64 desync fixed, delta_q/lf fully scoped for r4
Browse files at this commit9167027d8e11b884c453f1e50956260746801bcaParent: 6e8fc0b- docs
- lane-realworld r3 report -- part64 desync fixed, delta_q/lf fully scoped for r4
1 changed file +158 -0
- lanes/realworld-r3.report.md +158 -0
lanes/realworld-r3.report.mdadded+158 -0
| @@ -0,0 +1,158 @@ | ||
| 1 | +# lane-realworld r3 report | |
| 2 | + | |
| 3 | +VERDICT: Job 1 (part64 silent desync) FIXED, tested, committed (879999d). | |
| 4 | +Job 2 (delta_q/delta_lf) UNSTARTED but fully scoped below — turn budget ran | |
| 5 | +out during the design phase, before any code was written, so there is | |
| 6 | +nothing half-done to unwind for the next agent. | |
| 7 | + | |
| 8 | +## Job 1 -- part64 silent desync (committed 879999d) | |
| 9 | +`decode_inter_frame_tile_with_cdfs` (decode.rs, the `(true, true)` arm around | |
| 10 | +what was line 9397) read `part64` then `let _ = part64;`, always recursing | |
| 11 | +the quadrant loop as if SPLIT. Fixed: the value is now kept (still inferred | |
| 12 | +as `PARTITION_SPLIT` for the three straddle/forced-half cases, matching the | |
| 13 | +intra tile's own three-way write), and if a real read comes back anything | |
| 14 | +other than `PARTITION_SPLIT` the function returns | |
| 15 | +`Err(unsupported("an inter SB-level partition type other than SPLIT (this | |
| 16 | +decoder's inter tile path only recurses a superblock as SPLIT)"))` before | |
| 17 | +the quadrant recursion runs. | |
| 18 | + | |
| 19 | +**New refusal string** (verbatim, for the merge's `refusal_inventory.rs`): | |
| 20 | +`"an inter SB-level partition type other than SPLIT (this decoder's inter | |
| 21 | +tile path only recurses a superblock as SPLIT)"` | |
| 22 | + | |
| 23 | +Test: `decode::tests::a_non_split_inter_sb_partition_refuses_by_name_instead_of_desyncing` | |
| 24 | +hand-writes a single `PARTITION_HORZ` `part64` symbol with `SymbolEncoder` | |
| 25 | +and asserts `decode_inter_frame_tile` returns that named error rather than | |
| 26 | +decoding garbage. `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j4`: | |
| 27 | +**234 passed, 0 failed, 17 ignored** (was 232/0/17 before this lane; +1 this | |
| 28 | +test, +1 from r2's CDEF work already on the branch). | |
| 29 | + | |
| 30 | +No gate needed for this one (charter: "make it refuse by name... and prove | |
| 31 | +the refusal with a test" -- minimum rung taken deliberately, not the | |
| 32 | +"handle it" rung, since real non-SPLIT part64 content requires the same | |
| 33 | +multi-SB, non-`--cpu-used=0` recipe r2 already flagged as its own separate | |
| 34 | +lane, not this desync fix). | |
| 35 | + | |
| 36 | +## Job 2 -- delta_q/delta_lf: scoped, not started | |
| 37 | + | |
| 38 | +Ran the libaom source at `~/.cache/aom-oracle/src/av1/decoder/decodemv.c` | |
| 39 | +and `av1/common/entropymode.c` directly (real oracle, not memory) before | |
| 40 | +running out of budget. Concrete plan for the next agent: | |
| 41 | + | |
| 42 | +### Default CDFs (verified against entropymode.c:840-852) | |
| 43 | +Both are 4-symbol alphabets (`DELTA_Q_PROBS`/`DELTA_LF_PROBS` = 3), and this | |
| 44 | +crate's CDF convention already matches libaom's `AOM_CDF4` arguments | |
| 45 | +directly (confirmed against `cdf.rs`'s existing `SKIP` table, which is | |
| 46 | +`AOM_CDF2(31671)` verbatim) -- no inversion needed: | |
| 47 | +```rust | |
| 48 | +pub const DELTA_Q: [u16; 5] = [28160, 32120, 32677, 32768, 0]; | |
| 49 | +pub const DELTA_LF: [u16; 5] = [28160, 32120, 32677, 32768, 0]; | |
| 50 | +pub const DELTA_LF_MULTI: [[u16; 5]; 4] = [DELTA_Q; 4]; // same value x FRAME_LF_COUNT | |
| 51 | +``` | |
| 52 | +(`FRAME_LF_COUNT = 4`, `MAX_LOOP_FILTER = 63`, `DELTA_Q_SMALL = DELTA_LF_SMALL = 3`.) | |
| 53 | + | |
| 54 | +### Read logic (decodemv.c:85-146, `read_delta_qindex`/`read_delta_lflevel`, | |
| 55 | +called from `read_delta_q_params` at :732) | |
| 56 | +Both follow the same shape: a 4-symbol CDF read; if the result is 3 | |
| 57 | +(`DELTA_*_SMALL`), extend with `L(3)`-then-`1+that`-many literal bits | |
| 58 | +(`rem_bits = literal(3)+1; thr = (1<<rem_bits)+1; abs = literal(rem_bits) + | |
| 59 | +thr`); if `abs != 0` read one sign literal bit (sign=1/no-read implied | |
| 60 | +"positive" when abs==0, matching spec/libaom exactly -- `sign = abs ? | |
| 61 | +read_bit() : 1`); `reduced = sign ? -abs : abs`. For q: `CurrentQIndex = | |
| 62 | +clamp(CurrentQIndex + reduced*delta_q_res, 1, 255)`. For lf: same shape, | |
| 63 | +`clamp(DeltaLF[i] + reduced*delta_lf_res, -63, 63)`, looped over 4 planes | |
| 64 | +if `delta_lf_multi` else just index 0 against the single `delta_lf_cdf`. | |
| 65 | + | |
| 66 | +### The gating condition (decodemv.c:94-95, :121-122) -- **not** a spec | |
| 67 | +`ReadDeltas` global, libaom computes it locally per call: | |
| 68 | +```c | |
| 69 | +read_delta_q_flag = (mi_col & (mib_size-1) == 0 && mi_row & (mib_size-1) == 0); | |
| 70 | +if ((bsize != sb_size || !skip) && read_delta_q_flag) { ...read... } | |
| 71 | +``` | |
| 72 | +Both conditions collapse to: **the very first block decoded inside a | |
| 73 | +superblock always has this MI position** (partition trees decode top-left | |
| 74 | +leaf first, always), so a per-SB `Cell<bool>` reset exactly like | |
| 75 | +`CDEF_TRANSMITTED` (decode.rs ~82, reset alongside it at the top of both | |
| 76 | +tile loops' `sb_c` loop bodies) replaces the position check with no | |
| 77 | +behavioural difference. The remaining condition, "skip the read entirely | |
| 78 | +(state carries over unchanged)", fires only when this first block **is | |
| 79 | +itself the whole superblock** (`bsize == sb_size`) **and** `skip == true`. | |
| 80 | + | |
| 81 | +### Call sites -- only 4, not the dozen it looks like | |
| 82 | +`maybe_read_cdef_idx` (decode.rs:115) is called from exactly 4 places, | |
| 83 | +right after each one's own `skip` read, and delta_q/delta_lf's spec order | |
| 84 | +is `skip -> cdef -> delta_q -> delta_lf` (already commented at decode.rs | |
| 85 | +~2474: "spec order... `cdef` lands right here" -- delta lands right after | |
| 86 | +that same line, one function per call site): | |
| 87 | +- `read_intra_mode_rect` (decode.rs:1987, feeds `decode_block_rect`) -- | |
| 88 | + `bw`/`bh` never both 64 here (SB-level partition never recurses to a rect | |
| 89 | + strip directly), so `is_whole_sb` is always `false`. | |
| 90 | +- `read_intra_mode` (decode.rs:2447, feeds `decode_block`/`decode_leaf8`) -- | |
| 91 | + has a `side: usize` param; `is_whole_sb = side == 64`. | |
| 92 | +- `decode_inter_block` (decode.rs:6344) -- has `side: usize`; same rule. | |
| 93 | +- `decode_inter_block8` (decode.rs:8215) -- always sub-8x8, `is_whole_sb` | |
| 94 | + always `false`. | |
| 95 | + | |
| 96 | +### Threading `CurrentQIndex` into dequant -- narrower than it looks | |
| 97 | +`base_q_idx: u8` is already threaded as a plain pass-through parameter | |
| 98 | +through every one of these functions down to exactly 2 real use sites | |
| 99 | +(confirmed by grep -- `base_q_idx` appears 92x in decode.rs but is *read*, | |
| 100 | +not just passed, only at decode.rs:2986 and :5397, both | |
| 101 | +`dequant_and_inverse_typed(..., i32::from(base_q_idx), ...)`). This means | |
| 102 | +the running quantizer state does **not** need a new parameter threaded | |
| 103 | +through every block/leaf/rect function signature: a `thread_local! | |
| 104 | +static CURRENT_Q_IDX: Cell<i32>`, reset to `base_q_idx as i32` at the top | |
| 105 | +of both `decode_key_frame_tile_with_cdfs`/`decode_inter_frame_tile_with_cdfs` | |
| 106 | +(same place `CDEF_BITS`/`CDEF_SB_COLS` already get set per tile), mutated | |
| 107 | +only inside the new `maybe_read_delta_q_lf` helper, and read back at the 2 | |
| 108 | +dequant call sites instead of `i32::from(base_q_idx)`, reproduces the exact | |
| 109 | +running-state semantics with no signature changes to the block readers. | |
| 110 | +`DeltaLF` needs the same `Cell<[i32; 4]>` treatment, but **does** need a | |
| 111 | +consumer: `lf_level`/`edge_params` (decode.rs:3991/4020) currently read | |
| 112 | +only the frame-level `LoopFilterParams.level` array -- applying `DeltaLF` | |
| 113 | +there needs `MiGrid`/`fill_lf_grid` (decode.rs:1444) to carry a per-block | |
| 114 | +delta value forward to the deblocker, which is genuinely new state, not a | |
| 115 | +narrow substitution like q_idx. This is the part of Job 2 that needs a | |
| 116 | +real design pass, not just wiring -- flag it to whoever picks this up next. | |
| 117 | + | |
| 118 | +### Header threading + refusal removal | |
| 119 | +`header.delta.{q_present,q_res,lf_present,lf_res,lf_multi}` | |
| 120 | +(`ec_av1_syntax::frame::DeltaParams`, already parsed) need to become new | |
| 121 | +parameters on `decode_key_frame_tile_with_cdfs`/`_inter_..._with_cdfs` (and | |
| 122 | +their public non-`_with_cdfs` wrappers, and `stream.rs`'s 2 call sites), | |
| 123 | +mirroring how `CdefParams`/`LoopFilterParams` are already threaded. Then | |
| 124 | +delete the `stream.rs:170-174` refusal | |
| 125 | +(`"a frame with delta_q_present or delta_lf_present set..."`). | |
| 126 | + | |
| 127 | +### Gate | |
| 128 | +Reproducible refusal fixture already on file (r2's note): `--aq-mode=1` or | |
| 129 | +default `cpu-used>=1` at 128x64+. Same shape as the CDEF gate (128x64, | |
| 130 | +2 SBs, `--threads=1 --row-mt=0`), with a hard-asserted firing counter | |
| 131 | +(`DELTA_Q_HITS`/`DELTA_LF_HITS`, same `Cell<usize>` pattern as | |
| 132 | +`CDEF_IDX_HITS`). | |
| 133 | + | |
| 134 | +## Remaining refusal strings verbatim (all pre-existing, untouched by this | |
| 135 | +lane except the one new one above) | |
| 136 | +- `"a partition type this encoder never writes"` (decode.rs, intra SB | |
| 137 | + level, key frame catchall) -- pre-existing, real, out of scope. | |
| 138 | +- `"a partition type this encoder never writes (value={part32})"` -- pre-existing. | |
| 139 | +- `"an INTER 32x32 partition type this encoder never writes (value={part32})"` -- pre-existing. | |
| 140 | +- `"a frame with delta_q_present or delta_lf_present set (this decoder | |
| 141 | + never reads the per-superblock delta symbols)"` -- Job 2's target, | |
| 142 | + **still present, still refuses correctly** (not touched this round). | |
| 143 | +- `"an inter SB-level partition type other than SPLIT (this decoder's | |
| 144 | + inter tile path only recurses a superblock as SPLIT)"` -- **new this | |
| 145 | + lane**, Job 1. | |
| 146 | + | |
| 147 | +## Merge note | |
| 148 | +`gate_coverage.rs`/`refusal_inventory.rs` (main-only guards this worktree | |
| 149 | +doesn't have) need the one new refusal string above added at merge; nothing | |
| 150 | +to delete from `gate_coverage.rs` this round since no gate closed a tool | |
| 151 | +entry (Job 1 has no gate by design, see above). | |
| 152 | + | |
| 153 | +## Next lever | |
| 154 | +Job 2 exactly as scoped above. The `DeltaLF`-into-deblocker sub-problem | |
| 155 | +(new `MiGrid` state, not a narrow substitution) is the one piece that needs | |
| 156 | +design before code -- everything else (CDFs, read logic, call sites, | |
| 157 | +`CURRENT_Q_IDX` substitution, header threading, refusal removal, gate | |
| 158 | +recipe) is now a direct port, not an investigation. |