Lane-deltaq report -- what the feature commit holds and the mapping derivation
Browse files at this commiteb6e4d0272dc39c763c9d5352456885ace901a91Parent: 1c072fa- docs
- lane-deltaq report -- what the feature commit holds and the mapping derivation
4 changed files +148 -0
- lanes/deltaq.report.md +66 -0
- lanes/dq-arm.sh +7 -0
- lanes/dq-ctrl.log +38 -0
- lanes/dq-r2k1.log +37 -0
lanes/deltaq.report.mdadded+66 -0
| @@ -0,0 +1,66 @@ | |||
| 1 | +# lane-deltaq — per-superblock `delta_qindex` from the tpl map | ||
| 2 | + | ||
| 3 | +Base `36b573b9` (no RDOQ on this head). Feature commit `c121e991`. | ||
| 4 | + | ||
| 5 | +## What the commit holds | ||
| 6 | + | ||
| 7 | +* **Frame header** — `frame.rs::write_delta_q_params` already wrote the spec's | ||
| 8 | + syntax; `encode_inter_frame` now SETS `header.delta.q_present` / | ||
| 9 | + `delta.q_res` whenever the frame has a tpl map and the lever is on. | ||
| 10 | +* **Tile syntax** — `tile.rs::write_delta_q`, the write side of decode.rs | ||
| 11 | + `maybe_read_delta_q`, called right after `write_cdef_idx` at each of the | ||
| 12 | + four inter block writers (`Whole64`, the 32x32 quadrant, the 16x16 leaf, | ||
| 13 | + the 8x8 leaf), i.e. the spec's `skip -> cdef -> delta_q` order. Fires only | ||
| 14 | + at the superblock's top-left mode-info position, and (as the reader does) | ||
| 15 | + never when that block IS the superblock and is skipped. `arm_delta_q` | ||
| 16 | + carries the per-SB plan the way `arm_cdef_idx` carries the CDEF one and is | ||
| 17 | + cleared by the same `CdefIdxGuard`, so `CurrentQIndex` resets at each tile | ||
| 18 | + exactly as the spec's `decode_tile` does. The `delta_q` CDF was already in | ||
| 19 | + `cdf_state` and already in the per-frame counter reset. | ||
| 20 | +* **Per-superblock quantizer in the search** — every trial reaches the | ||
| 21 | + quantiser through `Search::base_q_idx` (luma and chroma alike), so the | ||
| 22 | + search sets that field per superblock and both the quantisation and the | ||
| 23 | + dequantisation that reconstructs the block move with it. `qmatrix` is off. | ||
| 24 | +* **Mapping** — `encode::deltaq_for_factor`, derived, not fitted (below). | ||
| 25 | +* **Levers** — `EC_AV1_DELTAQ` (the `delta_q_res` LOG2; `0` = off, stream | ||
| 26 | + byte-identical to the pre-lane one), `EC_AV1_DELTAQ_K`, | ||
| 27 | + `EC_AV1_DELTAQ_CLAMP`, and `speed::DELTAQ_RES` (preset 0..10). | ||
| 28 | +* **Fire counter** — `encode::take_deltaq_levels`, the number of DISTINCT | ||
| 29 | + qindex levels the last frame's grid carried; a flat grid makes every | ||
| 30 | + exactness assert below vacuous (class `gate-blind-to-feature`). | ||
| 31 | +* **One decoder-side fix** (deviation from "do not touch the decoder", and the | ||
| 32 | + reason the feature could not work without it): `decode_inter_frame_tiles_lr` | ||
| 33 | + hard-coded `DeltaParams::default()`, the exact stale-header class the three | ||
| 34 | + parameters above it in that signature document. The encoder's own trial | ||
| 35 | + decode therefore never read the syntax the writer wrote and desynced at the | ||
| 36 | + first superblock, surfacing as a reference-slot refusal ("refusal from own | ||
| 37 | + desync"). It now takes the frame's own `delta` and forwards it; the two | ||
| 38 | + in-crate gates that decode a raw tile take `frame.delta` from the new | ||
| 39 | + `Encoded::delta` field. | ||
| 40 | + | ||
| 41 | +## The mapping derivation | ||
| 42 | + | ||
| 43 | +The tpl map hands out a factor `f` on LAMBDA. RD lambda goes as the square of | ||
| 44 | +the quantiser step (`encode_inter_frame`: `lambda = .. * step * step`, `step = | ||
| 45 | +ac_q(base)/8`), so a superblock the map prices at `f` wants a step of | ||
| 46 | +`sqrt(f)` times the frame's. `ac_q` is not linear in the index, so the step | ||
| 47 | +ratio is inverted THROUGH THE TABLE — the index whose `ac_q` is closest to | ||
| 48 | +`ac_q(base) * sqrt(f)` — rather than through a fitted `K`: | ||
| 49 | + | ||
| 50 | + delta = argmin_q | ac_q(8, q) - ac_q(8, base) * sqrt(f) | - base | ||
| 51 | + | ||
| 52 | +`EC_AV1_DELTAQ_K` then scales that step (1.0 = the whole derivation, the | ||
| 53 | +sweep's `x0.7` / `x1.3`), the result is snapped onto the `delta_q_res` grid | ||
| 54 | +BEFORE the +-clamp (a clamp applied after would hand back a qindex that is not | ||
| 55 | +congruent to `base`, and the coded symbol would not be a whole number of | ||
| 56 | +steps), and the clamp defaults to +-16 (libaom clamps its objective deltaq | ||
| 57 | +around a quarter of the base qindex). | ||
| 58 | + | ||
| 59 | +Self-consistency: the superblock's RD lambda is then recomputed FROM the | ||
| 60 | +qindex it is coded at (`sb_q_search`: `lambda * (ac_q(q)/ac_q(base))^2`) and | ||
| 61 | +replaces the raw tpl lambda factor, so nothing is counted twice. At `K = 1` | ||
| 62 | +unclamped the two are the same number. | ||
| 63 | + | ||
| 64 | +## Results | ||
| 65 | + | ||
| 66 | +(filled in below as each gate lands) | ||
lanes/dq-arm.shadded+7 -0
| @@ -0,0 +1,7 @@ | |||
| 1 | +#!/bin/bash | ||
| 2 | +# lane-deltaq: one native-gate arm under a named env set. | ||
| 3 | +# usage: dq-arm.sh <name> <test> <ENV=VAL ...> | ||
| 4 | +name=$1; test=$2; shift 2 | ||
| 5 | +B=$HOME/.cache/cargo-target-deltaq/release/deps/ec_av1-8fef0196ab10338d | ||
| 6 | +systemd-run --user --unit dq-$name -p MemoryMax=8G --collect --working-directory=$PWD \ | ||
| 7 | + bash -c "env $* $B --ignored --nocapture --test-threads 1 $test > lanes/dq-$name.log 2>&1; echo RC=\$? >> lanes/dq-$name.log" | ||
lanes/dq-ctrl.logadded+38 -0
| @@ -0,0 +1,38 @@ | |||
| 1 | + | ||
| 2 | +running 1 test | ||
| 3 | +test encode::tests::bd_rate_screen_native ... | ||
| 4 | +native crop, 12 frames, gop=12; tiles (0, 0), tile threads 1, intrabc false, palette maxcolors 128 | ||
| 5 | +| clip | ours PSNR/bytes per point | BD-rate vs libaom | BD-rate vs rav1e | wall ours:libaom:rav1e (noisy) | | ||
| 6 | +|---|---|---|---|---| | ||
| 7 | +bars 1080p: sequence, pyramid requested Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) effective Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) | ||
| 8 | +bars 1080p: pricer armings default=17 real=184 | ||
| 9 | +bars 1080p: 64x64 roots 17517 (with a residual 12680, split luma 3147, compound 7657) | ||
| 10 | +bars 1080p: motion_mode 32x32 SIMPLE=32530 OBMC=0 WARP=224 | 16x16 SIMPLE=4477 OBMC=0 WARP=576 | 8x8 SIMPLE=16655 OBMC=0 WARP=1069 (0.0% OBMC / 3.4% WARP of 55531 eligible) | ||
| 11 | +bars 1080p: inter var-tx depths of 11179 blocks -- leaf single 0=1646 1=1191 (42.0% split) | leaf compound 0=840 1=601 (41.7% split) | 32x32 single 0=785 1=1824 (69.9% split) | 32x32 compound 0=2121 1=2171 (50.6% split) | ||
| 12 | +bars 1080p: screen frames on=0 off=4 (0.0% on); palette blocks luma 0 chroma 0; intrabc blocks 0 (searched 0 / valid 0 / won 0) | ||
| 13 | +bars 1080p: filter intra on=true blocks 29255 (modes DC=6958 V=3291 H=5589 D157=8762 PAETH=4655) | ||
| 14 | +| bars 1080p 1920x1024 | 44.17 dB/217969 B, 47.71 dB/320944 B, 51.09 dB/442499 B, 54.30 dB/592258 B | +1.8% | -14.4% | 50.0s:11.2s:20.9s | | ||
| 15 | +bars 2160p: sequence, pyramid requested Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) effective Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) | ||
| 16 | +bars 2160p: pricer armings default=14 real=171 | ||
| 17 | +bars 2160p: 64x64 roots 18483 (with a residual 12366, split luma 2442, compound 6718) | ||
| 18 | +bars 2160p: motion_mode 32x32 SIMPLE=27815 OBMC=0 WARP=280 | 16x16 SIMPLE=2569 OBMC=0 WARP=629 | 8x8 SIMPLE=6855 OBMC=0 WARP=215 (0.0% OBMC / 2.9% WARP of 38363 eligible) | ||
| 19 | +bars 2160p: inter var-tx depths of 9151 blocks -- leaf single 0=1260 1=523 (29.3% split) | leaf compound 0=1086 1=268 (19.8% split) | 32x32 single 0=391 1=1233 (75.9% split) | 32x32 compound 0=175 1=4215 (96.0% split) | ||
| 20 | +bars 2160p: screen frames on=0 off=4 (0.0% on); palette blocks luma 0 chroma 0; intrabc blocks 0 (searched 0 / valid 0 / won 0) | ||
| 21 | +bars 2160p: filter intra on=true blocks 12531 (modes DC=3289 V=748 H=2666 D157=4107 PAETH=1721) | ||
| 22 | +| bars 2160p 1920x1024 | 43.69 dB/231175 B, 47.61 dB/341600 B, 51.20 dB/455550 B, 54.54 dB/584210 B | +12.6% | -9.9% | 34.8s:6.1s:16.8s | | ||
| 23 | +film A (1080p source): sequence, pyramid requested Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) effective Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) | ||
| 24 | +film A (1080p source): pricer armings default=20 real=213 | ||
| 25 | +film A (1080p source): 64x64 roots 9184 (with a residual 6132, split luma 2902, compound 3587) | ||
| 26 | +film A (1080p source): motion_mode 32x32 SIMPLE=32120 OBMC=0 WARP=1129 | 16x16 SIMPLE=19154 OBMC=0 WARP=1686 | 8x8 SIMPLE=4971 OBMC=0 WARP=959 (0.0% OBMC / 6.3% WARP of 60019 eligible) | ||
| 27 | +film A (1080p source): inter var-tx depths of 85205 blocks -- leaf single 0=13756 1=2673 (16.3% split) | leaf compound 0=32829 1=6881 (17.3% split) | 32x32 single 0=7393 1=5732 (43.7% split) | 32x32 compound 0=9874 1=6067 (38.1% split) | ||
| 28 | +film A (1080p source): screen frames on=0 off=4 (0.0% on); palette blocks luma 0 chroma 0; intrabc blocks 0 (searched 0 / valid 0 / won 0) | ||
| 29 | +film A (1080p source): filter intra on=true blocks 23573 (modes DC=6103 V=3470 H=4339 D157=6770 PAETH=2891) | ||
| 30 | +| film A (1080p source) 1920x768 | 44.33 dB/74306 B, 45.84 dB/124416 B, 47.04 dB/213610 B, 48.29 dB/508783 B | +34.8% | +5.0% | 70.9s:10.0s:14.2s | | ||
| 31 | +film B (2160p HDR source): sequence, pyramid requested Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) effective Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) | ||
| 32 | +film B (2160p HDR source): pricer armings default=20 real=189 | ||
| 33 | +film B (2160p HDR source): 64x64 roots 15265 (with a residual 6697, split luma 2052, compound 7180) | ||
| 34 | +film B (2160p HDR source): motion_mode 32x32 SIMPLE=34383 OBMC=0 WARP=1084 | 16x16 SIMPLE=12348 OBMC=0 WARP=964 | 8x8 SIMPLE=2108 OBMC=0 WARP=359 (0.0% OBMC / 4.7% WARP of 51246 eligible) | ||
| 35 | +film B (2160p HDR source): inter var-tx depths of 75867 blocks -- leaf single 0=12990 1=2179 (14.4% split) | leaf compound 0=28745 1=5183 (15.3% split) | 32x32 single 0=7860 1=5938 (43.0% split) | 32x32 compound 0=8021 1=4951 (38.2% split) | ||
| 36 | +film B (2160p HDR source): screen frames on=0 off=4 (0.0% on); palette blocks luma 0 chroma 0; intrabc blocks 0 (searched 0 / valid 0 / won 0) | ||
| 37 | +film B (2160p HDR source): filter intra on=true blocks 16917 (modes DC=4552 V=2320 H=2430 D157=5857 PAETH=1758) | ||
| 38 | +| film B (2160p HDR source) 1920x1024 | 46.95 dB/33881 B, 48.06 dB/68679 B, 49.13 dB/144407 B, 50.24 dB/387536 B | +47.0% | +16.5% | 68.9s:22.0s:16.0s | | ||
lanes/dq-r2k1.logadded+37 -0
| @@ -0,0 +1,37 @@ | |||
| 1 | + | ||
| 2 | +running 1 test | ||
| 3 | +test encode::tests::bd_rate_screen_native ... | ||
| 4 | +native crop, 12 frames, gop=12; tiles (0, 0), tile threads 1, intrabc false, palette maxcolors 128 | ||
| 5 | +| clip | ours PSNR/bytes per point | BD-rate vs libaom | BD-rate vs rav1e | wall ours:libaom:rav1e (noisy) | | ||
| 6 | +|---|---|---|---|---| | ||
| 7 | +bars 1080p: sequence, pyramid requested Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) effective Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) | ||
| 8 | +bars 1080p: pricer armings default=17 real=182 | ||
| 9 | +bars 1080p: 64x64 roots 17505 (with a residual 13043, split luma 3182, compound 7471) | ||
| 10 | +bars 1080p: motion_mode 32x32 SIMPLE=32442 OBMC=0 WARP=187 | 16x16 SIMPLE=4779 OBMC=0 WARP=548 | 8x8 SIMPLE=17075 OBMC=0 WARP=862 (0.0% OBMC / 2.9% WARP of 55893 eligible) | ||
| 11 | +bars 1080p: inter var-tx depths of 11880 blocks -- leaf single 0=1770 1=1345 (43.2% split) | leaf compound 0=932 1=625 (40.1% split) | 32x32 single 0=787 1=1879 (70.5% split) | 32x32 compound 0=2309 1=2233 (49.2% split) | ||
| 12 | +bars 1080p: screen frames on=0 off=4 (0.0% on); palette blocks luma 0 chroma 0; intrabc blocks 0 (searched 0 / valid 0 / won 0) | ||
| 13 | +bars 1080p: filter intra on=true blocks 28117 (modes DC=6831 V=2959 H=5210 D157=9006 PAETH=4111) | ||
| 14 | +| bars 1080p 1920x1024 | 44.57 dB/228802 B, 48.13 dB/334388 B, 51.54 dB/459000 B, 54.74 dB/612525 B | +1.5% | -14.9% | 51.5s:11.5s:20.6s | | ||
| 15 | +bars 2160p: sequence, pyramid requested Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) effective Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) | ||
| 16 | +bars 2160p: pricer armings default=14 real=175 | ||
| 17 | +bars 2160p: 64x64 roots 18448 (with a residual 13053, split luma 2449, compound 6339) | ||
| 18 | +bars 2160p: motion_mode 32x32 SIMPLE=29802 OBMC=0 WARP=206 | 16x16 SIMPLE=2750 OBMC=0 WARP=445 | 8x8 SIMPLE=7520 OBMC=0 WARP=190 (0.0% OBMC / 2.1% WARP of 40913 eligible) | ||
| 19 | +bars 2160p: inter var-tx depths of 9250 blocks -- leaf single 0=1237 1=548 (30.7% split) | leaf compound 0=1043 1=228 (17.9% split) | 32x32 single 0=408 1=1293 (76.0% split) | 32x32 compound 0=149 1=4344 (96.7% split) | ||
| 20 | +bars 2160p: screen frames on=0 off=4 (0.0% on); palette blocks luma 0 chroma 0; intrabc blocks 0 (searched 0 / valid 0 / won 0) | ||
| 21 | +bars 2160p: filter intra on=true blocks 12509 (modes DC=3443 V=708 H=2716 D157=3875 PAETH=1767) | ||
| 22 | +| bars 2160p 1920x1024 | 43.74 dB/232825 B, 47.78 dB/347045 B, 51.29 dB/458448 B, 54.74 dB/590364 B | +12.5% | -9.8% | 34.9s:6.1s:16.9s | | ||
| 23 | +film A (1080p source): sequence, pyramid requested Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) effective Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) | ||
| 24 | +film A (1080p source): pricer armings default=20 real=212 | ||
| 25 | +film A (1080p source): 64x64 roots 9130 (with a residual 6191, split luma 2911, compound 3504) | ||
| 26 | +film A (1080p source): motion_mode 32x32 SIMPLE=31602 OBMC=0 WARP=1222 | 16x16 SIMPLE=19477 OBMC=0 WARP=1345 | 8x8 SIMPLE=4984 OBMC=0 WARP=851 (0.0% OBMC / 5.7% WARP of 59481 eligible) | ||
| 27 | +film A (1080p source): inter var-tx depths of 89007 blocks -- leaf single 0=14637 1=2884 (16.5% split) | leaf compound 0=34236 1=7531 (18.0% split) | 32x32 single 0=7421 1=5834 (44.0% split) | 32x32 compound 0=10179 1=6285 (38.2% split) | ||
| 28 | +film A (1080p source): screen frames on=0 off=4 (0.0% on); palette blocks luma 0 chroma 0; intrabc blocks 0 (searched 0 / valid 0 / won 0) | ||
| 29 | +film A (1080p source): filter intra on=true blocks 23886 (modes DC=6059 V=3487 H=4504 D157=6813 PAETH=3023) | ||
| 30 | +| film A (1080p source) 1920x768 | 44.37 dB/75837 B, 45.89 dB/126770 B, 47.11 dB/219938 B, 48.31 dB/514160 B | +34.7% | +5.2% | 72.0s:10.0s:14.6s | | ||
| 31 | +film B (2160p HDR source): sequence, pyramid requested Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) effective Some(Pyramid { mini_gop: 8, arf_q_offset: -32, leaf_q_offset: 12, mid_q_offset: Some(-8), quarter_q_offset: None, key_q_offset: -48 }) | ||
| 32 | +film B (2160p HDR source): pricer armings default=20 real=190 | ||
| 33 | +film B (2160p HDR source): 64x64 roots 15239 (with a residual 6732, split luma 2056, compound 7256) | ||
| 34 | +film B (2160p HDR source): motion_mode 32x32 SIMPLE=33757 OBMC=0 WARP=1046 | 16x16 SIMPLE=12048 OBMC=0 WARP=970 | 8x8 SIMPLE=1857 OBMC=0 WARP=342 (0.0% OBMC / 4.7% WARP of 50020 eligible) | ||
| 35 | +film B (2160p HDR source): inter var-tx depths of 77362 blocks -- leaf single 0=13093 1=2331 (15.1% split) | leaf compound 0=29653 1=5369 (15.3% split) | 32x32 single 0=7921 1=5758 (42.1% split) | 32x32 compound 0=8206 1=5031 (38.0% split) | ||
| 36 | +film B (2160p HDR source): screen frames on=0 off=4 (0.0% on); palette blocks luma 0 chroma 0; intrabc blocks 0 (searched 0 / valid 0 / won 0) | ||
| 37 | +film B (2160p HDR source): filter intra on=true blocks 16945 (modes DC=4638 V=2305 H=2417 D157=5827 PAETH=1758) | ||