edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching·0 forks·Rust·370.3 MiB·9b67700·Tahinli·3 days ago·4021 commits
| 1 | # lane-intertx — the inter tx-type search on film (chroma inheritance made honest) |
| 2 | |
| 3 | Base: `810d8972` (charter). Fix commit: `9af60b4d`. Regression fix + report |
| 4 | commit: this one. Disposition: **stays-off** |
| 5 | (`crate::speed::TX_TYPE_SEARCH_INTER` keeps `Screen` at presets 0-6; the keep |
| 6 | rule's deciding column fails at best -0.1 against the required -0.5), but the |
| 7 | lane's correctness work is real and committed: the chroma inheritance desync |
| 8 | was LIVE and is fixed, the wider inter search is reachable and honest on |
| 9 | `reduced_tx_set = 0` frames, and on screen content the fix itself measures |
| 10 | -0.7/-0.4 BD against the pre-lane standing table. Pins untouched at |
| 11 | 8291 / 33227 (default non-screen streams byte-identical; pin test re-run |
| 12 | green). Never merged, never pushed. |
| 13 | |
| 14 | ## 1. The chroma inheritance desync: LIVE, fixed |
| 15 | |
| 16 | The wider inter search (`inter_tx_type_candidates`' seven-type `INTER_WIDE` |
| 17 | list) was unreachable: `inter_luma_set` named only the plain `Luma*Inter` |
| 18 | sets, so the `Set1` arms were dead code. The refusal reason lane-txi recorded |
| 19 | (the refs lane's DPB bookkeeping) was already known wrong; the real blocker |
| 20 | was `refusal-from-own-desync` in the CHROMA inheritance: |
| 21 | |
| 22 | - (a) the encoder never set `FrameCtx::reduced_tx_set_inter` on the shared |
| 23 | frame context, so `recode_inter_chroma`'s |
| 24 | `reduce_inherited_chroma_tx_type` reduced against a STALE allowance — |
| 25 | whatever the previous frame's own trial decode had last left in the cell — |
| 26 | while a `reduced_tx_set = 0` frame's decoder allows the full set; |
| 27 | - (b) `tile::write_block_planes` coded every chroma plane as `DCT_DCT`. |
| 28 | Chroma codes no `tx_type` symbol, but the type names the transform class, |
| 29 | and the class picks the scan, the `eob_pt` row and the neighbour contexts |
| 30 | (`write_coeffs`' lane-txw note) — so an inherited 1-D type desynced the |
| 31 | chroma exactly as luma once did. |
| 32 | |
| 33 | Fix (commit `9af60b4d`): (a) `encode_inter_frame` sets |
| 34 | `fctx.reduced_tx_set_inter` from the frame's own header bit the moment it is |
| 35 | decided (`header.reduced_tx_set = !wide_tx_set(screen)`); (b) the writer |
| 36 | derives each inter block's chroma type from the first luma unit's coded type |
| 37 | via the new `decode::reduce_inherited_chroma_tx_type_flagged` against |
| 38 | `Cdfs::reduced_tx_set` — the frame's own honest bit — and codes chroma with |
| 39 | it; the search names the Set1 sets through `luma_set_for` (the intra search's |
| 40 | own shape) at both the flat and the split-unit trial, so every candidate is |
| 41 | priced in the alphabet its symbol is coded into. All six |
| 42 | `write_block_planes` callers now pass the block's inter flag; intra chroma |
| 43 | rides `DCT_DCT`'s 2D class exactly as before. |
| 44 | |
| 45 | Witness `encoder::tests::a_non_screen_inter_clip_codes_a_one_d_type_both_decoders_read_every_plane_exactly` |
| 46 | (process-global `set_inter_tx_search(Some(true))` + `set_wide_tx_set(Some(true))` |
| 47 | + `force_screen(Some(false))` under `knob_write`, 320x192 moving |
| 48 | steps/ramps/plateaus, gop 4, q 90): the inter search WON and CODED |
| 49 | non-`DCT_DCT` types on the non-screen clip, and ALL THREE planes read |
| 50 | sample-exact through `decode_stream` AND ffmpeg at every frame. |
| 51 | |
| 52 | EVIDENCE: ~/.cache/intertx/witness-green.log | --ignored --exact --nocapture |
| 53 | run of the witness on `9af60b4d` | "inter wide-set witness: inter hits |
| 54 | [200, 979, 3, 97, 111, 40, 521, 0, ...], 8143 bytes" — coded>0 guards pass |
| 55 | for `IDTX` (200) and for the 1-D types (`V_DCT`=40 + `H_DCT`=521); all three |
| 56 | planes identical to ffmpeg on all four frames. ok. |
| 57 | |
| 58 | RED run (desync live): with the widening applied and fix (b) neutralized — |
| 59 | chroma coded `DCT_DCT` unconditionally, the pre-lane writer — the same encode |
| 60 | FAILS inside its own trial decode: the reader inherits the 1-D chroma type |
| 61 | the writer refused to code with, the tile desyncs, and the derail surfaces as |
| 62 | "a reference frame selected with no picture at this frame's own |
| 63 | ref_frame_idx slot" (class `refusal-from-own-desync`, not a real ref defect). |
| 64 | |
| 65 | EVIDENCE: ~/.cache/intertx/witness-red.log | same witness, fix (b) probe |
| 66 | removed | FAILED: trial-decode refusal aborts the encode at flush. |
| 67 | |
| 68 | Standing witnesses re-run green on the fixed HEAD: the wide witness now codes |
| 69 | 1-D inter units on its screen card too (`V_DCT`=41, `H_DCT`=405, `IDTX`=702 |
| 70 | of 1305) and reads every frame exact; the two-type inter witness passes. |
| 71 | |
| 72 | EVIDENCE: ~/.cache/intertx/standing-witnesses.log | --ignored --exact and |
| 73 | default runs | "a_wide_tx_set_clip... ok", "an_inter_clip... ok". |
| 74 | |
| 75 | ## 2. Long-GOP BD (deciding; 48 pictures, gop=48, both films, server-1) |
| 76 | |
| 77 | Control = default (lever `Screen`), arm = `EC_AV1_TXSET_INTER=all`, same HEAD |
| 78 | `9af60b4d`, same ladder (`encode::tests::bd_rate_film_long_gop`, |
| 79 | `--ignored --exact`). BD-rate, lower better: |
| 80 | |
| 81 | | row | ctrl vs libaom | ctrl vs rav1e | arm vs libaom | arm vs rav1e | |
| 82 | |---|---|---|---|---| |
| 83 | | film A (1080p) 1920x768 | +20.9% | -9.0% | +20.8% | -9.1% | |
| 84 | | film B (2160p HDR) 1920x1024 | +70.4% | -2.2% | +70.3% | -2.1% | |
| 85 | |
| 86 | Arm-minus-control: film A -0.1/-0.1, film B -0.1/+0.1. The control |
| 87 | reproduces the standing table (b128res-era film A +20.9/-9.0, film B |
| 88 | +70.4/-2.2) to the digit on a different HEAD. |
| 89 | |
| 90 | Wall ours: film A 1314.7s -> 1395.1s (+6.1%), film B 1031.5s -> 1074.0s |
| 91 | (+4.1%). LOADAVG 0.28/0.35/0.20 before, 1.30/1.20/1.11 after (control); |
| 92 | 0.93/1.12/1.09 before, 1.12/1.10/1.09 after (arm). |
| 93 | |
| 94 | EVIDENCE: ~/.cache/intertx/longgop-control.log | gate 2 control, server-1, |
| 95 | MemoryMax=5G, `systemd-run --user` | film A +20.9%/-9.0%, film B |
| 96 | +70.4%/-2.2%; census 100.0% `DCT_DCT` on both films. ok. |
| 97 | EVIDENCE: ~/.cache/intertx/longgop-arm.log | gate 2 arm, EC_AV1_TXSET_INTER=all | |
| 98 | film A +20.8%/-9.1%, film B +70.3%/-2.1%. ok. |
| 99 | |
| 100 | ## 3. 12-frame native guard (all five rows, server-1) |
| 101 | |
| 102 | `encode::tests::bd_rate_screen_native`, control and arm: |
| 103 | |
| 104 | | row | ctrl vs libaom | ctrl vs rav1e | arm vs libaom | arm vs rav1e | |
| 105 | |---|---|---|---|---| |
| 106 | | bars 1080p | -3.3% | -19.0% | -3.5% | -19.0% | |
| 107 | | bars 2160p | +8.4% | -13.9% | +8.5% | -13.8% | |
| 108 | | film A | +17.9% | -6.3% | +17.8% | -6.4% | |
| 109 | | film B | +22.6% | -3.8% | +22.7% | -3.7% | |
| 110 | | screen capture | +13.7% | -33.6% | +13.7% | -33.6% | |
| 111 | |
| 112 | The screen row is byte-identical between control and arm (same PSNR/bytes at |
| 113 | every point, same census) — exactly the charter's prediction: the search is |
| 114 | already on for screen frames, so `All` can add nothing there. |
| 115 | |
| 116 | Wall ours: bars 1080p 396.2s -> 411.1s (+3.8%), bars 2160p 336.3s -> 358.1s |
| 117 | (+6.5%), film A 350.9s -> 371.0s (+5.7%), film B 301.4s -> 309.8s (+2.8%), |
| 118 | screen capture 226.1s -> 225.1s (-0.4%). LOADAVG 0.88/1.05/1.07 before, |
| 119 | 1.07/1.14/1.11 after (control); 0.91/1.10/1.10 before, 1.12/1.13/1.09 after |
| 120 | (arm). |
| 121 | |
| 122 | Screen-content attribution note: the control screen row against the |
| 123 | b128res-era standing table moved +14.4% -> +13.7% (libaom) and -33.2% -> |
| 124 | -33.6% (rav1e). That delta is THIS lane's fix reaching the screen default: |
| 125 | the widened inter candidates are now offered to screen frames at preset 0, |
| 126 | where the lever already said `Screen`, and the census shows the new types |
| 127 | coding (below). Cross-HEAD comparison, so attribution is indicative only. |
| 128 | |
| 129 | EVIDENCE: ~/.cache/intertx/native-control.log | gate 3 control, five rows | |
| 130 | table above, control columns; three-way exactness held at every clip x q x |
| 131 | frame. ok. |
| 132 | EVIDENCE: ~/.cache/intertx/native-arm.log | gate 3 arm, EC_AV1_TXSET_INTER=all | |
| 133 | table above, arm columns. ok. |
| 134 | |
| 135 | ## 4. Inter tx-type census (search won / coded, per clip) |
| 136 | |
| 137 | Non-`DCT_DCT` share of COMMITTED inter luma units (the census names types |
| 138 | that were really coded), arm runs: |
| 139 | |
| 140 | | clip | inter units | coded non-DCT_DCT | share | |
| 141 | |---|---|---|---| |
| 142 | | film A long-GOP | 1468708 | 35618 `IDTX` | 2.4% | |
| 143 | | film B long-GOP | 1250132 | 41586 `IDTX` | 3.3% | |
| 144 | | bars 1080p 12f | 115907 | 21033 `IDTX` | 18.1% | |
| 145 | | bars 2160p 12f | 83614 | 20634 `IDTX` | 24.7% | |
| 146 | | film A 12f | 330189 | 7311 `IDTX` | 2.2% | |
| 147 | | film B 12f | 310009 | 7002 `IDTX` | 2.3% | |
| 148 | | screen capture 12f | 59731 | 1080 `IDTX` + 266 `ADST_ADST` + 346 `ADST_DCT` + 187 `DCT_ADST` + 455 `V_DCT` + 1572 `H_DCT` | 6.5% | |
| 149 | |
| 150 | Controls: 100.0% `DCT_DCT` on every non-screen clip (lever off there); |
| 151 | screen capture control already carries the wider alphabet (the fix's doing). |
| 152 | With `all`, film takes only the two-type set's `IDTX` (2.2-3.3%) — the |
| 153 | arm is INERT ON FILM, the same 0-to-small band the b128res arm showed. |
| 154 | Every one of these units decoded three-way exact (encoder == ffmpeg == |
| 155 | decode_stream) at every q point of every run — the gates' standing |
| 156 | exactness assertion covers the whole census, native resolution, both films |
| 157 | and all five native rows. |
| 158 | |
| 159 | ## 5. Keep rule — NOT met |
| 160 | |
| 161 | One film row >=0.5 BD down on a column: best delta anywhere is -0.1 (film A |
| 162 | long-GOP and 12-frame; native bars rows are not film). Other film row flat |
| 163 | within +/-0.3: yes (max 0.1). Screen not worse by 0.3: yes (byte-identical). |
| 164 | Wall <= +15%: yes (max +6.5%). The deciding column fails at -0.1 against the |
| 165 | required -0.5: `IDTX` at 2-3% of film units buys a tenth of a point. The |
| 166 | lever stays `Screen` at every preset; `speed.rs` is untouched. |
| 167 | |
| 168 | ## 6. Pins, witnesses, scope |
| 169 | |
| 170 | - Pins `encode::tests::the_encoders_own_streams_are_byte_identical_to_their_pins`: |
| 171 | re-run green on `9af60b4d` — `(150, 8291, 0x1f00bb0eb099a27f)` and |
| 172 | `(60, 33227, 0x57ee6b1f8eacd881)` stand. The pin fixture is the non-screen |
| 173 | h264 clip, where the fix changes nothing by construction (the widened |
| 174 | candidates need `reduced_tx_set = 0`, which only screen frames code at the |
| 175 | default preset). No pin re-take. |
| 176 | |
| 177 | EVIDENCE: ~/.cache/intertx/pins.log | default-preset pin run on 9af60b4d | |
| 178 | ok, both pins byte-identical. |
| 179 | |
| 180 | - server-1 provisioning verified before the first gate: filmA-gate.mkv 8833494 |
| 181 | bytes, filmB-gate.mkv 195927872 bytes, no partial files. |
| 182 | - Gate recipe deviations from charter §3 (all recorded): `systemd-run` |
| 183 | needs `-p WorkingDirectory=` (the unit does not inherit the shell's cwd), |
| 184 | `PATH`/`CARGO_TARGET_DIR` must be set INSIDE the unit (a |
| 185 | `bash -lc` wrapper), and the synced repo's `.git` was a stale worktree |
| 186 | pointer file that broke the memguard runner's `git rev-parse` — replaced |
| 187 | with a fresh `git init` on the server. One gate at a time throughout. |
| 188 | - Not verified: nothing in the charter's scope is unverified. The |
| 189 | three-lane lib suite and `cargo check --workspace --all-targets` were NOT |
| 190 | run — charter §2 requires them only on the keep-rule-met (ships-on) |
| 191 | branch; the stays-off branch carries the scoped local checks (ec-av1 lib |
| 192 | + tests compile warning-free; the three tx witnesses; the pin test) and |
| 193 | project-wide validation stays with the main agent. `FLIPADST` family and |
| 194 | the 1-D ADSTs remain unoffered (the standing lane-txi deferral). |
| 195 | |
| 196 | ## 7. Regression caught by the merge tier: the raw-tile decode wrapper's |
| 197 | ## stale `reduced_tx_set` |
| 198 | |
| 199 | Main's regression tier caught three `decode::tests` failures on the lane |
| 200 | HEAD (`a_gop_round_trips_bit_exact_against_the_encoder_reconstruction`, |
| 201 | `an_odd_size_gop_round_trips_bit_exact_against_the_encoder_reconstruction`, |
| 202 | `ffmpeg_and_this_decoder_agree_on_a_gop`), all refusing with "a reference |
| 203 | frame selected with no picture at this frame's own ref_frame_idx slot". |
| 204 | |
| 205 | Root cause (class: **test asserts against a stale header** -- the wrapper's |
| 206 | own parameter docs document five prior instances of exactly this class): |
| 207 | `decode::decode_inter_frame_tile_lr`, the raw-tile decode helper the GOP |
| 208 | round-trip tests use, hard-coded `reduced_tx_set: true` |
| 209 | (`decode.rs:34552` at the fix commit's parent) with the comment "this |
| 210 | wrapper's callers are the decoder's own tests, which all code the reduced |
| 211 | sets". True until this lane: no inter block ever inherited a non-`DCT_DCT` |
| 212 | chroma type. With the widened inter search live, a screen-detected GOP at |
| 213 | the default preset codes `reduced_tx_set = 0` frames whose inter luma takes |
| 214 | `V_DCT` (the traces show the first inter block at (0,0) 16x16 winning |
| 215 | exactly that), and the chroma inheritance reduces the inherited type |
| 216 | against the very bit the wrapper guessed: the test's decode derived |
| 217 | `DCT_DCT` from `inh=Some(V_DCT)` at chroma 8x8 where the writer coded |
| 218 | `V_DCT`, desynced, and the garbage symbols eventually read a ref_frame_idx |
| 219 | that names an empty slot -- the named refusal is downstream noise, the |
| 220 | first divergence is the chroma type. |
| 221 | |
| 222 | Fix (this commit): the wrapper takes the frame's own |
| 223 | `reduced_tx_set: bool` (placed before `tx_select`, mirroring the plural |
| 224 | fn), `Encoded` carries the bit (`encode.rs`, the `screen`/`tx_select` |
| 225 | pattern), the GOP tests and the key-frame tile test (`stream.rs`, whose |
| 226 | "our own encoder always writes `reduced_tx_set: true`" comment had the |
| 227 | same latent stale-header bug) pass the honest value. |
| 228 | |
| 229 | Why the gates and witnesses did not see it: every production decode path |
| 230 | (`stream.rs`'s parser, `decode_stream`, ffmpeg) reads the bit off the wire |
| 231 | honestly -- the gates' three-way exactness and all witnesses ride those. |
| 232 | Only the raw-tile test helper guessed. |
| 233 | |
| 234 | Encoder output is UNCHANGED by the fix: the diff touches the `Encoded` |
| 235 | metadata struct, the test-facing decode wrappers and one test call -- no |
| 236 | writer or search code (tile.rs is not in the fix diff at all), and the |
| 237 | three witnesses code byte-identical streams after it (8143 / 8211 bytes, |
| 238 | same census). The server-1 BD tables in sections 2-4 remain valid; no gate |
| 239 | re-run needed. |
| 240 | |
| 241 | EVIDENCE: ~/.cache/intertx/regression-repro.log | the three tests on the |
| 242 | unfixed lane HEAD | 3 failed, all with the named refusal. |
| 243 | EVIDENCE: ~/.cache/intertx/regression-fix.log | the three tests + the pin |
| 244 | test after the fix | 4 passed. |
| 245 | EVIDENCE: ~/.cache/intertx/witness-rerun.log | all three tx witnesses |
| 246 | re-run after the fix | byte-identical streams (8143 / 8211 bytes), ok. |
| 247 | |
| 248 | ## 8. Full suite and workspace check (post-fix) |
| 249 | |
| 250 | Three-lane lib suite LOCALLY on the fix commit, `--release --lib`: |
| 251 | `--skip stream::` 348 passed / 0 failed; `stream:: --skip 10bit` 202 |
| 252 | passed / 0 failed; `10bit` 42 passed / 0 failed -- **592 passed, 0 |
| 253 | failed**. `timeout 900 cargo check --workspace --all-targets -j4`: 0 |
| 254 | ec-av1 warnings (the 25 workspace warnings are ec-opus's, pre-existing). |
| 255 | |
| 256 | EVIDENCE: ~/.cache/intertx/suite-lane1.log | --skip stream:: | 348 passed. |
| 257 | EVIDENCE: ~/.cache/intertx/suite-lane2.log | stream:: --skip 10bit | 202 passed. |
| 258 | EVIDENCE: ~/.cache/intertx/suite-lane3.log | 10bit | 42 passed. |