Lane report — deblock-aware intra trial, +0.03 dB film BD
Browse files at this commit9fc5978d961517b5f944c5d5fbe43f0b29eabc5cParent: bb59e0b- docs
- lane report — deblock-aware intra trial, +0.03 dB film BD
1 changed file +95 -0
- lanes/h264rd-r2.report.md +95 -0
lanes/h264rd-r2.report.mdadded+95 -0
| @@ -0,0 +1,95 @@ | |||
| 1 | +# h264rd r2 — deblock-aware intra trial distortion | ||
| 2 | + | ||
| 3 | +Lane `h264rd2`, worktree `ec-wt-h264rd2`. Goal inherited from r1: the opt-in | ||
| 4 | +`transform_8x8` flag lost ~0.1 dB BD-PSNR on natural content (won on synthetic). | ||
| 5 | +r1 (`3165e8c`) re-priced the 8x8 RD by exact syntax bit delta; r2 makes the | ||
| 6 | +intra trial distortion itself deblock-aware. | ||
| 7 | + | ||
| 8 | +## Harness | ||
| 9 | + | ||
| 10 | +`real_clip_t8x8_bd_psnr` in `crates/ec-h264/tests/encode.rs` (`#[ignore]`d, | ||
| 11 | +existing test binary). `EC_H264_CLIP` names a file; ec-mp4 + this crate's | ||
| 12 | +decoder yield the first 30 pictures 1 s apart; a q22/26/30/34 sweep | ||
| 13 | +(gop 10, CABAC, full size, framerate 1.0) prints per-qp points, BD-PSNR | ||
| 14 | +flag-on vs flag-off, and the 8x8 MB share. Asserts nothing — the number | ||
| 15 | +gates the lane, not the suite. | ||
| 16 | + | ||
| 17 | + EC_H264_CLIP=<file> cargo test --release -p ec-h264 --test encode \ | ||
| 18 | + real_clip_t8x8_bd_psnr -- --ignored --nocapture | ||
| 19 | + | ||
| 20 | +## Baselines (harness commit `d5b0525`, before the r2 change) | ||
| 21 | + | ||
| 22 | +**natural 720p film** (1280x720, 30 pictures, 8x8 share 13.5 % avg): | ||
| 23 | + | ||
| 24 | +| qp | off bits | off dB | on bits | on dB | 8x8 share | | ||
| 25 | +|----|----------|--------|---------|-------|-----------| | ||
| 26 | +| 22 | 9538320 | 50.06 | 9345832 | 50.87 | 14.6 % | | ||
| 27 | +| 26 | 6220816 | 47.73 | 6105104 | 48.17 | 13.5 % | | ||
| 28 | +| 30 | 3975904 | 44.14 | 3911680 | 45.21 | 14.7 % | | ||
| 29 | +| 34 | 2474616 | 42.36 | 2442024 | 42.45 | 11.3 % | | ||
| 30 | + | ||
| 31 | +**BD-PSNR +0.796 dB.** The r1 loss on this class is already closed by the | ||
| 32 | +exact-bits pricing — the r1-era -0.102 dB was measured under the old rough-bit | ||
| 33 | +cost model. r2's job became: don't regress it, push it. | ||
| 34 | + | ||
| 35 | +**obs 1440p capture** (2560x1440, 19 pictures, 8x8 share 1.9 % avg): | ||
| 36 | +q22 52.41/52.44, q26 49.01/49.00, q30 45.32/45.19, q34 41.28/41.43 dB — | ||
| 37 | +**BD-PSNR -0.007 dB.** | ||
| 38 | + | ||
| 39 | +## Change (`da6a6bb`) | ||
| 40 | + | ||
| 41 | +`ssd_mb_deblocked` in `crates/ec-h264/src/enc/mb.rs`, swapped into the three | ||
| 42 | +`t8x8_intra` trial costs (cost4/cost8/cost16) of `encode_intra_mb`: | ||
| 43 | + | ||
| 44 | +- Copy the candidate's 16x16 luma recon plus 4-px left/top aprons (gated on | ||
| 45 | + `nbr.a`/`nbr.b`, the same availability intra prediction uses) into a 24x24 | ||
| 46 | + scratch; the apron feeds the bS-4 p3 read / p2 rewrite. | ||
| 47 | +- Filter exactly as `deblock_picture` will: bS 4 on the MB edges, bS 3 on | ||
| 48 | + internal edges, verticals left-to-right then horizontals, `edge_params(qp, 0, 0, bs)`; | ||
| 49 | + the 8x8 candidate skips luma edges 4/12 — the decoder's `internal()` gate — | ||
| 50 | + so each candidate meets its own true edge set. | ||
| 51 | +- Luma SSD on the filtered scratch vs source, composited with `ssd_mb - | ||
| 52 | + ssd_luma` for the untouched chroma half (chroma never takes the 8x8 | ||
| 53 | + transform; it cannot separate the candidates). | ||
| 54 | +- Flag-off path untouched: default output stays byte-identical (structural; | ||
| 55 | + only the three `e.t8x8_intra(mb_y)` branches changed). | ||
| 56 | + | ||
| 57 | +## After (feature commit `da6a6bb`) | ||
| 58 | + | ||
| 59 | +**natural 720p film** (8x8 share 13.5 % avg): | ||
| 60 | + | ||
| 61 | +| qp | off bits | off dB | on bits | on dB | 8x8 share | | ||
| 62 | +|----|----------|--------|---------|-------|-----------| | ||
| 63 | +| 22 | 9538320 | 50.06 | 9349104 | 50.87 | 14.7 % | | ||
| 64 | +| 26 | 6220816 | 47.73 | 6098024 | 48.18 | 13.3 % | | ||
| 65 | +| 30 | 3975904 | 44.14 | 3888736 | 45.25 | 14.7 % | | ||
| 66 | +| 34 | 2474616 | 42.36 | 2426344 | 42.35 | 11.4 % | | ||
| 67 | + | ||
| 68 | +**BD-PSNR +0.827 dB** (was +0.796; +0.031). | ||
| 69 | + | ||
| 70 | +**obs 1440p capture** (8x8 share 1.8 % avg): | ||
| 71 | +q22 52.41/52.44, q26 49.01/49.02, q30 45.32/45.20, q34 41.28/41.46 dB — | ||
| 72 | +**BD-PSNR -0.000 dB** (was -0.007; +0.007). | ||
| 73 | + | ||
| 74 | +Mechanism visible in the points: same or better PSNR at fewer bits where 8x8 | ||
| 75 | +competes (720p q30: 45.21 dB @ 3912 kb → 45.25 dB @ 3889 kb); the share is | ||
| 76 | +stable, so the gain is truer candidate pricing, not mode flipping. | ||
| 77 | + | ||
| 78 | +## Variants measured / rejected | ||
| 79 | + | ||
| 80 | +- None needed: the primary design passed both clip gates on the first | ||
| 81 | + measurement. Deliberate scope cuts (chroma half pre-filter; aprons | ||
| 82 | + pre-filter; no right/bottom edges — those belong to MBs coded later; | ||
| 83 | + neighbours at slice qp rather than tracked per-MB) stayed as designed. | ||
| 84 | + | ||
| 85 | +## Gates | ||
| 86 | + | ||
| 87 | +1. `cargo test --release -p ec-h264` — **75+23+9+1 passed, 0 failed** | ||
| 88 | + (includes the synthetic gate `eight_by_eight_gains_on_flat_and_text` | ||
| 89 | + pinning BD ≥ 0.255347 - 0.02 dB and the byte-identity determinism tests). | ||
| 90 | +2. Harness both clips: 720p +0.827 ≥ -0.02; obs -0.000, not below its | ||
| 91 | + -0.007 baseline — **pass**. | ||
| 92 | +3. `cargo test --release -p ec-h264 --test conformance` — **23 passed, | ||
| 93 | + 0 failed**. | ||
| 94 | + | ||
| 95 | +Out of scope by charter: the inter trial (`encode_inter_mb` cost4/cost8). | ||