From 4e24be37e5849bbea28f47cf76dac63588f1f6e1 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:22:12 +0300 Subject: [PATCH] feat(av1): RDOQ on to preset 6; re-pin the encoder's own streams Preset-6 gate says it dominates the ladder (preset 6 with RDOQ beats preset 0 without it on every row and both columns, at less wall), so the lever is on to 6 and withheld from the unmeasured real-time rungs. Pins 9853 -> 8618 at q=150 and 35866 -> 33339 at q=60; EC_AV1_RDOQ=0 restores both. --- crates/ec-av1/src/encode.rs | 7 +++++- crates/ec-av1/src/speed.rs | 20 +++++++++++++--- lanes/rdoq-lgop.log | 7 ++++++ lanes/rdoq-s6off.log | 46 +++++++++++++++++++++++++++++++++++++ lanes/rdoq-s6on.log | 40 ++++++++++++++++++++++++++++++++ 5 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 lanes/rdoq-s6off.log diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index 57cd1880..0a6d2d38 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -13747,8 +13747,13 @@ mod tests { // (`crate::encoder::arf_altref`) instead of the key frame it already // reads as `GOLDEN` -- 9859 -> 9853 at q=150 and 35904 -> 35866 at // q=60. `EC_AV1_ARF_ALTREF=0` restores these. + // Re-taken on lane-rdoq: the coefficient quantiser runs the + // rate-distortion pass ([`crate::tile::rdoq`]) now, so every block of + // these four pictures codes the levels that pass settled on -- 9853 + // -> 8618 at q=150 and 35866 -> 33339 at q=60. `EC_AV1_RDOQ=0` + // restores 9853 / 35866. let pins: [(u8, usize, u64); 2] = - [(150, 9853, 0x0f6d_bbc8_b72c_ceb3), (60, 35866, 0xbd00_f4ed_e283_3ce4)]; + [(150, 8618, 0xc238_83cc_3cfc_bb3e), (60, 33339, 0xfff4_a39f_0cd8_285f)]; for (q, bytes, hash) in pins { let encoded = encode_sequence(&source, q, 0.5).unwrap(); assert_eq!( diff --git a/crates/ec-av1/src/speed.rs b/crates/ec-av1/src/speed.rs index b3f81ef7..21f5b9f2 100644 --- a/crates/ec-av1/src/speed.rs +++ b/crates/ec-av1/src/speed.rs @@ -170,10 +170,24 @@ pub(crate) fn at(table: &[T; 11]) -> T { pub(crate) const B64_ROOT: [bool; 11] = [crate::encode::B64_ROOT; 11]; /// `encode::rdoq_on`: rate-distortion optimised quantisation -/// ([`crate::tile::rdoq`], lane-rdoq). Provisional table -- the wall/BD -/// measurement per preset is in `lanes/rdoq.report.md`. +/// ([`crate::tile::rdoq`], lane-rdoq). MEASURED at both ends of the range on +/// the 12-frame native gate (BD vs libaom `cpu-used 6` / rav1e `speed 6`, +/// our wall): +/// +/// | row | preset 0 off | preset 0 on | preset 6 off | preset 6 on | +/// |---|---|---|---|---| +/// | film A | +37.1 / +7.3 (77s) | +24.4 / -1.8 (138s) | +46.0 / +14.5 (32s) | +30.4 / +2.9 (60s) | +/// | film B | +52.5 / +22.3 (78s) | +35.5 / +7.6 (130s) | +67.8 / +35.0 (30s) | +43.5 / +14.2 (51s) | +/// | screen | +33.4 / -23.8 (45s) | +28.1 / -25.7 (79s) | +40.3 / -20.0 (15s) | +34.9 / -22.0 (34s) | +/// +/// It costs about 2x wall and pays at BOTH ends, and it DOMINATES the ladder: +/// preset 6 with it on is better than preset 0 with it off on every row and +/// on both columns, at less wall. So it is on up to preset 6. The top rungs +/// (7..=10) are the real-time ones and are UNMEASURED here, so they keep the +/// cheaper choice rather than an assumed one; `EC_AV1_RDOQ=1` turns it on +/// there. pub(crate) const RDOQ: [bool; 11] = [ - true, true, true, false, false, false, false, false, false, false, false, + true, true, true, true, true, true, true, false, false, false, false, ]; /// `encode::SPLIT_RD_THRESHOLD`: how cheap a block has to be before its split diff --git a/lanes/rdoq-lgop.log b/lanes/rdoq-lgop.log index 21019891..7525837c 100644 --- a/lanes/rdoq-lgop.log +++ b/lanes/rdoq-lgop.log @@ -4,3 +4,10 @@ test encode::tests::bd_rate_film_long_gop ... native crop, 48 frames, gop=48; 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) | |---|---|---|---|---| +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=895 +film A (1080p source): motion_mode 32x32 SIMPLE=192900 OBMC=0 WARP=7450 | 16x16 SIMPLE=57575 OBMC=0 WARP=6884 | 8x8 SIMPLE=24687 OBMC=0 WARP=3239 (0.0% OBMC / 6.0% WARP of 292735 eligible) +film A (1080p source): inter var-tx depths of 259566 blocks -- leaf single 0=42208 1=6041 (12.5% split) | leaf compound 0=105604 1=17598 (14.3% split) | 32x32 single 0=23152 1=14905 (39.2% split) | 32x32 compound 0=30637 1=19421 (38.8% 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 92991 (modes DC=21700 V=14106 H=18102 D157=25835 PAETH=13248) +| film A (1080p source) 1920x768 | 43.99 dB/188841 B, 45.66 dB/321714 B, 46.92 dB/542939 B, 48.11 dB/1196594 B | +29.4% | -3.9% | 575.7s:41.6s:60.6s | diff --git a/lanes/rdoq-s6off.log b/lanes/rdoq-s6off.log new file mode 100644 index 00000000..41633fc1 --- /dev/null +++ b/lanes/rdoq-s6off.log @@ -0,0 +1,46 @@ + +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=14 real=155 +bars 1080p: motion_mode 32x32 SIMPLE=0 OBMC=0 WARP=0 | 16x16 SIMPLE=0 OBMC=0 WARP=0 | 8x8 SIMPLE=0 OBMC=0 WARP=0 (0.0% OBMC / 0.0% WARP of 0 eligible) +bars 1080p: inter var-tx depths of 0 blocks -- leaf single 0=0 1=0 (0.0% split) | leaf compound 0=0 1=0 (0.0% split) | 32x32 single 0=0 1=0 (0.0% split) | 32x32 compound 0=0 1=0 (0.0% 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=false blocks 0 (modes DC=0 V=0 H=0 D157=0 PAETH=0) +| bars 1080p 1920x1024 | 41.95 dB/270702 B, 45.99 dB/457826 B, 49.74 dB/646368 B, 53.19 dB/853166 B | +73.4% | +45.9% | 26.7s:10.8s:27.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=155 +bars 2160p: motion_mode 32x32 SIMPLE=0 OBMC=0 WARP=0 | 16x16 SIMPLE=0 OBMC=0 WARP=0 | 8x8 SIMPLE=0 OBMC=0 WARP=0 (0.0% OBMC / 0.0% WARP of 0 eligible) +bars 2160p: inter var-tx depths of 0 blocks -- leaf single 0=0 1=0 (0.0% split) | leaf compound 0=0 1=0 (0.0% split) | 32x32 single 0=0 1=0 (0.0% split) | 32x32 compound 0=0 1=0 (0.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=false blocks 0 (modes DC=0 V=0 H=0 D157=0 PAETH=0) +| bars 2160p 1920x1024 | 42.18 dB/277456 B, 46.12 dB/442877 B, 49.96 dB/619605 B, 53.64 dB/805687 B | +69.0% | +34.4% | 24.2s:7.0s:19.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=16 real=175 +film A (1080p source): motion_mode 32x32 SIMPLE=0 OBMC=0 WARP=0 | 16x16 SIMPLE=0 OBMC=0 WARP=0 | 8x8 SIMPLE=0 OBMC=0 WARP=0 (0.0% OBMC / 0.0% WARP of 0 eligible) +film A (1080p source): inter var-tx depths of 0 blocks -- leaf single 0=0 1=0 (0.0% split) | leaf compound 0=0 1=0 (0.0% split) | 32x32 single 0=0 1=0 (0.0% split) | 32x32 compound 0=0 1=0 (0.0% 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=false blocks 0 (modes DC=0 V=0 H=0 D157=0 PAETH=0) +| film A (1080p source) 1920x768 | 43.99 dB/74036 B, 45.60 dB/124285 B, 46.93 dB/216333 B, 48.20 dB/511129 B | +46.0% | +14.5% | 31.9s:10.3s:16.3s | +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=16 real=159 +film B (2160p HDR source): motion_mode 32x32 SIMPLE=0 OBMC=0 WARP=0 | 16x16 SIMPLE=0 OBMC=0 WARP=0 | 8x8 SIMPLE=0 OBMC=0 WARP=0 (0.0% OBMC / 0.0% WARP of 0 eligible) +film B (2160p HDR source): inter var-tx depths of 0 blocks -- leaf single 0=0 1=0 (0.0% split) | leaf compound 0=0 1=0 (0.0% split) | 32x32 single 0=0 1=0 (0.0% split) | 32x32 compound 0=0 1=0 (0.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=false blocks 0 (modes DC=0 V=0 H=0 D157=0 PAETH=0) +| film B (2160p HDR source) 1920x1024 | 46.52 dB/34162 B, 47.86 dB/69448 B, 49.05 dB/148408 B, 50.21 dB/392984 B | +67.8% | +35.0% | 29.9s:21.5s:16.8s | +screen capture (2026-07-25 02-09-04.mkv): 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 None +screen capture (2026-07-25 02-09-04.mkv): pricer armings default=150 real=0 +screen capture (2026-07-25 02-09-04.mkv): motion_mode 32x32 SIMPLE=0 OBMC=0 WARP=0 | 16x16 SIMPLE=0 OBMC=0 WARP=0 | 8x8 SIMPLE=0 OBMC=0 WARP=0 (0.0% OBMC / 0.0% WARP of 0 eligible) +screen capture (2026-07-25 02-09-04.mkv): inter var-tx depths of 0 blocks -- leaf single 0=0 1=0 (0.0% split) | leaf compound 0=0 1=0 (0.0% split) | 32x32 single 0=0 1=0 (0.0% split) | 32x32 compound 0=0 1=0 (0.0% split) +screen capture (2026-07-25 02-09-04.mkv): screen frames on=48 off=0 (100.0% on); palette blocks luma 6931 chroma 1319; intrabc blocks 0 (searched 0 / valid 0 / won 0) +screen capture (2026-07-25 02-09-04.mkv): filter intra on=false blocks 0 (modes DC=0 V=0 H=0 D157=0 PAETH=0) +| screen capture (2026-07-25 02-09-04.mkv) 1920x1024 | 45.67 dB/41570 B, 48.41 dB/52646 B, 50.68 dB/66384 B, 52.82 dB/82870 B | +40.3% | -20.0% | 14.5s:10.6s:13.1s | +ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 603 filtered out; finished in 309.81s + +RC=0 diff --git a/lanes/rdoq-s6on.log b/lanes/rdoq-s6on.log index 5d647e9f..b06938d9 100644 --- a/lanes/rdoq-s6on.log +++ b/lanes/rdoq-s6on.log @@ -4,3 +4,43 @@ 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=14 real=155 +bars 1080p: motion_mode 32x32 SIMPLE=0 OBMC=0 WARP=0 | 16x16 SIMPLE=0 OBMC=0 WARP=0 | 8x8 SIMPLE=0 OBMC=0 WARP=0 (0.0% OBMC / 0.0% WARP of 0 eligible) +bars 1080p: inter var-tx depths of 0 blocks -- leaf single 0=0 1=0 (0.0% split) | leaf compound 0=0 1=0 (0.0% split) | 32x32 single 0=0 1=0 (0.0% split) | 32x32 compound 0=0 1=0 (0.0% 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=false blocks 0 (modes DC=0 V=0 H=0 D157=0 PAETH=0) +| bars 1080p 1920x1024 | 41.49 dB/223627 B, 45.59 dB/427038 B, 49.51 dB/627517 B, 53.03 dB/822694 B | +68.7% | +40.5% | 90.2s:7.1s:17.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=155 +bars 2160p: motion_mode 32x32 SIMPLE=0 OBMC=0 WARP=0 | 16x16 SIMPLE=0 OBMC=0 WARP=0 | 8x8 SIMPLE=0 OBMC=0 WARP=0 (0.0% OBMC / 0.0% WARP of 0 eligible) +bars 2160p: inter var-tx depths of 0 blocks -- leaf single 0=0 1=0 (0.0% split) | leaf compound 0=0 1=0 (0.0% split) | 32x32 single 0=0 1=0 (0.0% split) | 32x32 compound 0=0 1=0 (0.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=false blocks 0 (modes DC=0 V=0 H=0 D157=0 PAETH=0) +| bars 2160p 1920x1024 | 41.77 dB/235891 B, 45.76 dB/414770 B, 49.65 dB/592370 B, 53.45 dB/787194 B | +63.9% | +29.3% | 81.0s:6.4s:17.2s | +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=16 real=170 +film A (1080p source): motion_mode 32x32 SIMPLE=0 OBMC=0 WARP=0 | 16x16 SIMPLE=0 OBMC=0 WARP=0 | 8x8 SIMPLE=0 OBMC=0 WARP=0 (0.0% OBMC / 0.0% WARP of 0 eligible) +film A (1080p source): inter var-tx depths of 0 blocks -- leaf single 0=0 1=0 (0.0% split) | leaf compound 0=0 1=0 (0.0% split) | 32x32 single 0=0 1=0 (0.0% split) | 32x32 compound 0=0 1=0 (0.0% 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=false blocks 0 (modes DC=0 V=0 H=0 D157=0 PAETH=0) +| film A (1080p source) 1920x768 | 43.66 dB/63290 B, 45.31 dB/101375 B, 46.70 dB/167805 B, 48.02 dB/400919 B | +30.4% | +2.9% | 60.1s:10.5s:14.9s | +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=15 real=157 +film B (2160p HDR source): motion_mode 32x32 SIMPLE=0 OBMC=0 WARP=0 | 16x16 SIMPLE=0 OBMC=0 WARP=0 | 8x8 SIMPLE=0 OBMC=0 WARP=0 (0.0% OBMC / 0.0% WARP of 0 eligible) +film B (2160p HDR source): inter var-tx depths of 0 blocks -- leaf single 0=0 1=0 (0.0% split) | leaf compound 0=0 1=0 (0.0% split) | 32x32 single 0=0 1=0 (0.0% split) | 32x32 compound 0=0 1=0 (0.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=false blocks 0 (modes DC=0 V=0 H=0 D157=0 PAETH=0) +| film B (2160p HDR source) 1920x1024 | 46.33 dB/27609 B, 47.64 dB/50415 B, 48.84 dB/106427 B, 50.00 dB/285711 B | +43.5% | +14.2% | 51.1s:22.7s:19.5s | +screen capture (2026-07-25 02-09-04.mkv): 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 None +screen capture (2026-07-25 02-09-04.mkv): pricer armings default=150 real=0 +screen capture (2026-07-25 02-09-04.mkv): motion_mode 32x32 SIMPLE=0 OBMC=0 WARP=0 | 16x16 SIMPLE=0 OBMC=0 WARP=0 | 8x8 SIMPLE=0 OBMC=0 WARP=0 (0.0% OBMC / 0.0% WARP of 0 eligible) +screen capture (2026-07-25 02-09-04.mkv): inter var-tx depths of 0 blocks -- leaf single 0=0 1=0 (0.0% split) | leaf compound 0=0 1=0 (0.0% split) | 32x32 single 0=0 1=0 (0.0% split) | 32x32 compound 0=0 1=0 (0.0% split) +screen capture (2026-07-25 02-09-04.mkv): screen frames on=48 off=0 (100.0% on); palette blocks luma 6956 chroma 1305; intrabc blocks 0 (searched 0 / valid 0 / won 0) +screen capture (2026-07-25 02-09-04.mkv): filter intra on=false blocks 0 (modes DC=0 V=0 H=0 D157=0 PAETH=0) +| screen capture (2026-07-25 02-09-04.mkv) 1920x1024 | 45.08 dB/39630 B, 47.98 dB/49482 B, 50.13 dB/60751 B, 52.35 dB/75439 B | +34.9% | -22.0% | 33.9s:10.4s:13.5s | +ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 603 filtered out; finished in 478.83s + +RC=0