forge
Explore
Log in

Don't you dare go Hollow

Per-superblock delta_q on at presets 5 and 6, gated off screen content

Browse files at this commit

e6bd6d8212debc9d64ca9ed836e93e3c99b8a7c6Ahmet Kaan GümüşParent: 2b123fb
  • feat
    • per-superblock delta_q on at presets 5 and 6, gated off screen content
Show full message
feat(av1): per-superblock delta_q on at presets 5 and 6, gated off screen content

lane-deltaq measured the whole mapping sweep flat because the tpl lookahead
was one picture; with the window back the map is real. 12-frame
bd_rate_screen_native, BD vs libaom / vs rav1e, off -> on:

  preset 6: film A +27.2/-0.2 -> +26.6/-0.4, film B +35.2/+6.6 -> +34.7/+6.4
  preset 5: film A +26.6/-0.7 -> +25.8/-1.1, film B +33.3/+4.9 -> +32.8/+4.6
  preset 4: film B +29.9/+2.0 -> +30.2/+2.6 -- rejected

The desktop capture was the only row delta_q cost, so the map is gated on
!allow_screen_content_tools, the content gate b64_residual/b64_compound take:
its four q points code the identical byte counts on and off.
crates/ec-av1/src/encode.rsmodified+6 -0
@@ -10070,8 +10070,14 @@ pub(crate) fn encode_inter_frame(
10070 // tpl map the lambda factor comes from ([`deltaq_for_factor`]). Present10070 // tpl map the lambda factor comes from ([`deltaq_for_factor`]). Present
10071 // only when the map is, and `delta_q_res` follows straight into the frame10071 // only when the map is, and `delta_q_res` follows straight into the frame
10072 // header (`write_delta_q_params`) and into the tile writer's own plan.10072 // header (`write_delta_q_params`) and into the tile writer's own plan.
10073+ // Not on a screen frame ([`b64_residual`]'s content gate): lane-dq3
10074+ // measured the per-superblock quantizer as a win on both films and a
10075+ // 0.5 loss vs libaom on the desktop capture, so a frame that set
10076+ // `allow_screen_content_tools` codes no delta syntax at all and stays
10077+ // byte-identical to the pre-lane encoder.
10073 let deltaq_res: Option<i32> = tpl_factors10078 let deltaq_res: Option<i32> = tpl_factors
10074 .as_ref()10079 .as_ref()
10080+ .filter(|_| !screen)
10075 .and(deltaq_res_log2().map(|r| 1i32 << r));10081 .and(deltaq_res_log2().map(|r| 1i32 << r));
10076 let sb_q: Option<Vec<u8>> = match (&tpl_factors, deltaq_res) {10082 let sb_q: Option<Vec<u8>> = match (&tpl_factors, deltaq_res) {
10077 (Some(f), Some(res)) => {10083 (Some(f), Some(res)) => {
crates/ec-av1/src/speed.rsmodified+24 -15
@@ -200,25 +200,34 @@ pub(crate) const I64_ROOT: [bool; 11] = [crate::encode::I64_ROOT; 11];
200 /// `encode::deltaq_res_log2`: the per-superblock quantizer's `delta_q_res`200 /// `encode::deltaq_res_log2`: the per-superblock quantizer's `delta_q_res`
201 /// LOG2 (2 = a step of 4 qindex), or `4` for "no delta_q syntax at all".201 /// LOG2 (2 = a step of 4 qindex), or `4` for "no delta_q syntax at all".
202 ///202 ///
203-/// SHIPPED OFF at every preset. lane-deltaq measured the whole mapping sweep203+/// ON (res 4) AT PRESETS 5 AND 6, off everywhere else, and never on a screen
204-/// on the 12-frame native gate against its own control (film A +34.8/+5.0,204+/// frame -- `encode_inter_frame` gates the whole map on
205-/// film B +47.0/+16.5, screen +33.4/-23.8):205+/// `!allow_screen_content_tools`, the same content gate `b64_residual` and
206+/// `b64_compound` take, so a desktop capture codes no delta syntax and stays
207+/// byte-identical to the pre-lane encoder.
206 ///208 ///
207-/// | arm | film A | film B | screen |209+/// lane-deltaq measured the mapping sweep with the tpl lookahead still cut to
210+/// one picture, so the map it read was inert and every arm was flat. With the
211+/// window back (lane-tplwin) lane-dq2 re-measured and lane-dq3 shipped it,
212+/// 12-frame `bd_rate_screen_native`, BD vs libaom / vs rav1e, off -> on:
213+///
214+/// | preset | film A | film B | screen capture |
208 /// |---|---|---|---|215 /// |---|---|---|---|
209-/// | res 4, K 1.0 | +34.7 / +5.2 | +46.7 / +16.6 | +34.1 / -23.6 |216+/// | 6 | +27.2/-0.2 -> +26.6/-0.4 | +35.2/+6.6 -> +34.7/+6.4 | +26.0/-27.2, byte-identical |
210-/// | res 4, K 1.3 | +34.7 / +5.1 | +46.8 / +16.6 | +34.3 / -23.5 |217+/// | 5 | +26.6/-0.7 -> +25.8/-1.1 | +33.3/+4.9 -> +32.8/+4.6 | gated off |
211-/// | res 8, K 1.0 | +35.2 / +5.3 | +47.8 / +17.1 | +35.0 / -23.4 |218+/// | 4 | +23.7/-2.9 -> +23.1/-3.1 | +29.9/+2.0 -> +30.2/+2.6 | gated off |
212 ///219 ///
213-/// The best arm moves neither film row by as much as the keep rule's 0.5 on220+/// Both films gain on both columns at 5 and 6 (the four q points of the
214-/// either column (film A -0.1/+0.2, film B -0.3/+0.1) and costs screen 0.7221+/// capture row code the identical byte counts on and off). PRESET 4 REJECTS
215-/// against libaom. Coarser steps (res 8) are worse everywhere. The syntax is222+/// -- film B goes the wrong way on both columns there. Preset 3 rejects
216-/// all there and proven three ways223+/// (lane-dq2: film B worse on both columns) and preset 0 is neutral, so they
224+/// stay off. Coarser steps (res 8) were worse everywhere in lane-deltaq's
225+/// sweep. The syntax is proven three ways
217 /// (`a_moving_detail_clip_codes_two_delta_q_levels_both_decoders_read_exactly`);226 /// (`a_moving_detail_clip_codes_two_delta_q_levels_both_decoders_read_exactly`);
218-/// `EC_AV1_DELTAQ=2` switches it on. Above preset 6 it is inert anyway --227+/// `EC_AV1_DELTAQ=2` forces it on at any preset, `EC_AV1_DELTAQ=0` off.
219-/// [`TPL_DEPTH`] cuts the lookahead to one picture there, so there is no map228+/// Above preset 6 it is inert anyway -- [`TPL_DEPTH`] cuts the lookahead to
220-/// to vary the quantizer by (lane-tplwin gave presets 1..6 a window back).229+/// one picture there, so there is no map to vary the quantizer by.
221-pub(crate) const DELTAQ_RES: [u8; 11] = [4; 11];230+pub(crate) const DELTAQ_RES: [u8; 11] = [4, 4, 4, 4, 4, 2, 2, 4, 4, 4, 4];
222 231
223 /// `encode::SPLIT_RD_THRESHOLD`: how cheap a block has to be before its split232 /// `encode::SPLIT_RD_THRESHOLD`: how cheap a block has to be before its split
224 /// trial is withheld. The single biggest wall lever in the tile search.233 /// trial is withheld. The single biggest wall lever in the tile search.
lanes/dq3.report.mdadded+52 -0
@@ -0,0 +1,52 @@
1+# lane-dq3 -- per-superblock delta_q shipped at presets 5 and 6, gated off screen
2+
3+## Change
4+
5+* `crates/ec-av1/src/encode.rs` (`encode_inter_frame`, the `deltaq_res` binding):
6+ `.filter(|_| !screen)` -- a frame that set `allow_screen_content_tools` codes
7+ no delta syntax at all, the same content gate `b64_residual` / `b64_compound`
8+ take. This is what makes the capture row byte-identical, at any preset and
9+ even under `EC_AV1_DELTAQ=2`.
10+* `crates/ec-av1/src/speed.rs`: `DELTAQ_RES = [4,4,4,4,4,2,2,4,4,4,4]` --
11+ res 4 (`delta_q_res` log2 = 2) at presets 5 and 6, off everywhere else.
12+
13+## Measurement -- 12-frame `bd_rate_screen_native`, BD vs libaom / vs rav1e
14+
15+Control = same binary with `EC_AV1_DELTAQ=0`; arm = delta_q on.
16+
17+| preset | film A off -> on | film B off -> on | verdict |
18+|---|---|---|---|
19+| 6 | +27.2/-0.2 -> +26.6/-0.4 | +35.2/+6.6 -> +34.7/+6.4 | SHIP (both films, both columns) |
20+| 5 | +26.6/-0.7 -> +25.8/-1.1 | +33.3/+4.9 -> +32.8/+4.6 | SHIP (both films, both columns) |
21+| 4 | +23.7/-2.9 -> +23.1/-3.1 | +29.9/+2.0 -> +30.2/+2.6 | REJECT (film B worse on both) |
22+| 3 | (lane-dq2) | film B worse on both | REJECT |
23+| 0 | (lane-deltaq) neutral | | stays off |
24+
25+Preset 6 reproduces lane-dq2's numbers to the digit on both films.
26+
27+### Screen capture, preset 6 -- BYTE-IDENTICAL
28+
29+| arm | ours PSNR/bytes per point | vs libaom | vs rav1e |
30+|---|---|---|---|
31+| control | 45.40/37996, 48.11/46966, 50.55/58908, 52.93/74047 | +26.0% | -27.2% |
32+| shipped | 45.40/37996, 48.11/46966, 50.55/58908, 52.93/74047 | +26.0% | -27.2% |
33+
34+All four q points code the identical byte count; the row prints
35+`screen frames on=48 off=0`, so the gate is what is doing it.
36+
37+The two `testsrc2` bars rows are fixtures, not decisions (they move: 1080p
38++68.4 -> +67.0, 2160p +62.7 -> +64.1).
39+
40+## Invariants (release binary)
41+
42+* `EC_COMP_MISMATCH=1 --include-ignored identically_with_one_and_four`: 3 passed
43+ (decode / recon / filter thread determinism).
44+* `EC_COMP_MISMATCH=1 the_facade_codes_the_same_bytes_as_encode_sequence`: 1 passed.
45+* `--ignored every_speed_preset_decodes_sample_exact_through_both_decoders`: 1 passed.
46+* Bitrate pins unchanged (8562 / 33357), preset 0 untouched -- green inside the suite.
47+* `cargo test -p ec-av1 --release`: **568 passed, 0 failed, 45 ignored**.
48+* `cargo check --workspace --all-targets -j4`: 0 errors, 0 ec-av1 warnings.
49+
50+## Logs
51+
52+`$HOME/.cache/dq3/{p6-ship,p6-ctl,p5-on,p5-ctl,p4-on,p4-ctl,inv,suite}.log`.