From eb6e4d0272dc39c763c9d5352456885ace901a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Mon, 7 Sep 2026 20:57:05 +0300 Subject: [PATCH] docs(av1): lane-deltaq report -- what the feature commit holds and the mapping derivation --- lanes/deltaq.report.md | 66 ++++++++++++++++++++++++++++++++++++++++++ lanes/dq-arm.sh | 7 +++++ lanes/dq-ctrl.log | 38 ++++++++++++++++++++++++ lanes/dq-r2k1.log | 37 +++++++++++++++++++++++ 4 files changed, 148 insertions(+) create mode 100644 lanes/deltaq.report.md create mode 100755 lanes/dq-arm.sh create mode 100644 lanes/dq-ctrl.log create mode 100644 lanes/dq-r2k1.log diff --git a/lanes/deltaq.report.md b/lanes/deltaq.report.md new file mode 100644 index 00000000..e7dae468 --- /dev/null +++ b/lanes/deltaq.report.md @@ -0,0 +1,66 @@ +# lane-deltaq — per-superblock `delta_qindex` from the tpl map + +Base `36b573b9` (no RDOQ on this head). Feature commit `c121e991`. + +## What the commit holds + +* **Frame header** — `frame.rs::write_delta_q_params` already wrote the spec's + syntax; `encode_inter_frame` now SETS `header.delta.q_present` / + `delta.q_res` whenever the frame has a tpl map and the lever is on. +* **Tile syntax** — `tile.rs::write_delta_q`, the write side of decode.rs + `maybe_read_delta_q`, called right after `write_cdef_idx` at each of the + four inter block writers (`Whole64`, the 32x32 quadrant, the 16x16 leaf, + the 8x8 leaf), i.e. the spec's `skip -> cdef -> delta_q` order. Fires only + at the superblock's top-left mode-info position, and (as the reader does) + never when that block IS the superblock and is skipped. `arm_delta_q` + carries the per-SB plan the way `arm_cdef_idx` carries the CDEF one and is + cleared by the same `CdefIdxGuard`, so `CurrentQIndex` resets at each tile + exactly as the spec's `decode_tile` does. The `delta_q` CDF was already in + `cdf_state` and already in the per-frame counter reset. +* **Per-superblock quantizer in the search** — every trial reaches the + quantiser through `Search::base_q_idx` (luma and chroma alike), so the + search sets that field per superblock and both the quantisation and the + dequantisation that reconstructs the block move with it. `qmatrix` is off. +* **Mapping** — `encode::deltaq_for_factor`, derived, not fitted (below). +* **Levers** — `EC_AV1_DELTAQ` (the `delta_q_res` LOG2; `0` = off, stream + byte-identical to the pre-lane one), `EC_AV1_DELTAQ_K`, + `EC_AV1_DELTAQ_CLAMP`, and `speed::DELTAQ_RES` (preset 0..10). +* **Fire counter** — `encode::take_deltaq_levels`, the number of DISTINCT + qindex levels the last frame's grid carried; a flat grid makes every + exactness assert below vacuous (class `gate-blind-to-feature`). +* **One decoder-side fix** (deviation from "do not touch the decoder", and the + reason the feature could not work without it): `decode_inter_frame_tiles_lr` + hard-coded `DeltaParams::default()`, the exact stale-header class the three + parameters above it in that signature document. The encoder's own trial + decode therefore never read the syntax the writer wrote and desynced at the + first superblock, surfacing as a reference-slot refusal ("refusal from own + desync"). It now takes the frame's own `delta` and forwards it; the two + in-crate gates that decode a raw tile take `frame.delta` from the new + `Encoded::delta` field. + +## The mapping derivation + +The tpl map hands out a factor `f` on LAMBDA. RD lambda goes as the square of +the quantiser step (`encode_inter_frame`: `lambda = .. * step * step`, `step = +ac_q(base)/8`), so a superblock the map prices at `f` wants a step of +`sqrt(f)` times the frame's. `ac_q` is not linear in the index, so the step +ratio is inverted THROUGH THE TABLE — the index whose `ac_q` is closest to +`ac_q(base) * sqrt(f)` — rather than through a fitted `K`: + + delta = argmin_q | ac_q(8, q) - ac_q(8, base) * sqrt(f) | - base + +`EC_AV1_DELTAQ_K` then scales that step (1.0 = the whole derivation, the +sweep's `x0.7` / `x1.3`), the result is snapped onto the `delta_q_res` grid +BEFORE the +-clamp (a clamp applied after would hand back a qindex that is not +congruent to `base`, and the coded symbol would not be a whole number of +steps), and the clamp defaults to +-16 (libaom clamps its objective deltaq +around a quarter of the base qindex). + +Self-consistency: the superblock's RD lambda is then recomputed FROM the +qindex it is coded at (`sb_q_search`: `lambda * (ac_q(q)/ac_q(base))^2`) and +replaces the raw tpl lambda factor, so nothing is counted twice. At `K = 1` +unclamped the two are the same number. + +## Results + +(filled in below as each gate lands) diff --git a/lanes/dq-arm.sh b/lanes/dq-arm.sh new file mode 100755 index 00000000..2e4ba952 --- /dev/null +++ b/lanes/dq-arm.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# lane-deltaq: one native-gate arm under a named env set. +# usage: dq-arm.sh +name=$1; test=$2; shift 2 +B=$HOME/.cache/cargo-target-deltaq/release/deps/ec_av1-8fef0196ab10338d +systemd-run --user --unit dq-$name -p MemoryMax=8G --collect --working-directory=$PWD \ + bash -c "env $* $B --ignored --nocapture --test-threads 1 $test > lanes/dq-$name.log 2>&1; echo RC=\$? >> lanes/dq-$name.log" diff --git a/lanes/dq-ctrl.log b/lanes/dq-ctrl.log new file mode 100644 index 00000000..cf1e65f6 --- /dev/null +++ b/lanes/dq-ctrl.log @@ -0,0 +1,38 @@ + +running 1 test +test encode::tests::bd_rate_screen_native ... +native crop, 12 frames, gop=12; tiles (0, 0), tile threads 1, intrabc false, palette maxcolors 128 +| clip | ours PSNR/bytes per point | BD-rate vs libaom | BD-rate vs rav1e | wall ours:libaom:rav1e (noisy) | +|---|---|---|---|---| +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 }) +bars 1080p: pricer armings default=17 real=184 +bars 1080p: 64x64 roots 17517 (with a residual 12680, split luma 3147, compound 7657) +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) +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) +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) +bars 1080p: filter intra on=true blocks 29255 (modes DC=6958 V=3291 H=5589 D157=8762 PAETH=4655) +| 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 | +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 }) +bars 2160p: pricer armings default=14 real=171 +bars 2160p: 64x64 roots 18483 (with a residual 12366, split luma 2442, compound 6718) +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) +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) +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) +bars 2160p: filter intra on=true blocks 12531 (modes DC=3289 V=748 H=2666 D157=4107 PAETH=1721) +| 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 | +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 }) +film A (1080p source): pricer armings default=20 real=213 +film A (1080p source): 64x64 roots 9184 (with a residual 6132, split luma 2902, compound 3587) +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) +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) +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) +film A (1080p source): filter intra on=true blocks 23573 (modes DC=6103 V=3470 H=4339 D157=6770 PAETH=2891) +| 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 | +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 }) +film B (2160p HDR source): pricer armings default=20 real=189 +film B (2160p HDR source): 64x64 roots 15265 (with a residual 6697, split luma 2052, compound 7180) +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) +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) +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) +film B (2160p HDR source): filter intra on=true blocks 16917 (modes DC=4552 V=2320 H=2430 D157=5857 PAETH=1758) +| 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 | diff --git a/lanes/dq-r2k1.log b/lanes/dq-r2k1.log new file mode 100644 index 00000000..1da1e579 --- /dev/null +++ b/lanes/dq-r2k1.log @@ -0,0 +1,37 @@ + +running 1 test +test encode::tests::bd_rate_screen_native ... +native crop, 12 frames, gop=12; tiles (0, 0), tile threads 1, intrabc false, palette maxcolors 128 +| clip | ours PSNR/bytes per point | BD-rate vs libaom | BD-rate vs rav1e | wall ours:libaom:rav1e (noisy) | +|---|---|---|---|---| +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 }) +bars 1080p: pricer armings default=17 real=182 +bars 1080p: 64x64 roots 17505 (with a residual 13043, split luma 3182, compound 7471) +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) +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) +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) +bars 1080p: filter intra on=true blocks 28117 (modes DC=6831 V=2959 H=5210 D157=9006 PAETH=4111) +| 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 | +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 }) +bars 2160p: pricer armings default=14 real=175 +bars 2160p: 64x64 roots 18448 (with a residual 13053, split luma 2449, compound 6339) +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) +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) +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) +bars 2160p: filter intra on=true blocks 12509 (modes DC=3443 V=708 H=2716 D157=3875 PAETH=1767) +| 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 | +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 }) +film A (1080p source): pricer armings default=20 real=212 +film A (1080p source): 64x64 roots 9130 (with a residual 6191, split luma 2911, compound 3504) +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) +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) +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) +film A (1080p source): filter intra on=true blocks 23886 (modes DC=6059 V=3487 H=4504 D157=6813 PAETH=3023) +| 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 | +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 }) +film B (2160p HDR source): pricer armings default=20 real=190 +film B (2160p HDR source): 64x64 roots 15239 (with a residual 6732, split luma 2056, compound 7256) +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) +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) +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) +film B (2160p HDR source): filter intra on=true blocks 16945 (modes DC=4638 V=2305 H=2417 D157=5827 PAETH=1758)