edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
| 1 | //! The encoder's SPEED PRESET axis (lane-av1fast): one number, 0..=10 like |
| 2 | //! rav1e's `--speed`, that picks a default for every search lever this crate |
| 3 | //! already has a knob for. |
| 4 | //! |
| 5 | //! Speed 0 is today's search, byte for byte -- every table below reads its |
| 6 | //! shipped default at index 0, so `encoder::tests`' byte pins are the pin on |
| 7 | //! that. Higher speeds trade BD-rate for wall by switching off the levers in |
| 8 | //! [`levers`], each of which was already measured on its own (the doc comment |
| 9 | //! on each knob in [`crate::encode`] carries its sweep). |
| 10 | //! |
| 11 | //! The value is PROCESS-GLOBAL, the same shape [`crate::par`]'s thread counts |
| 12 | //! use, because the levers are read from the tile-search worker threads -- |
| 13 | //! a thread-local would not reach them. One speed per process at a time: |
| 14 | //! [`crate::encoder::Av1Encoder::with_speed`] sets it at construction, so two |
| 15 | //! encoders at different speeds must not run concurrently in one process. |
| 16 | //! `EC_AV1_SPEED=<n>` is the environment form the gates and `ec-bench` use. |
| 17 | //! Every individual `EC_AV1_*` lever override still wins over the preset. |
| 18 | |
| 19 | //! # The lever table (film A, native crop 1920x768, 12 frames) |
| 20 | //! |
| 21 | //! One ablation per lever on top of speed 0, `bd_rate_screen_native`'s film A |
| 22 | //! row (BD-rate vs libaom `cpu-used 6` / rav1e `speed 6`), against the arm's |
| 23 | //! own wall divided by the rav1e anchor's wall in the SAME arm -- the box ran |
| 24 | //! three arms at a time, so only that ratio is comparable (class: wall tables |
| 25 | //! are only comparable inside one interleaved batch). Baseline 75.7s/14.2s = |
| 26 | //! 5.33 = 1.00x. Logs: `lanes/ab-*.log`. |
| 27 | //! |
| 28 | //! | lever switched off | BD vs libaom / rav1e | rel. wall | |
| 29 | //! |---|---|---| |
| 30 | //! | -- (speed 0) | +53.2 / +23.4 | 1.00 | |
| 31 | //! | loop restoration | +53.0 / +23.3 | 0.83 | |
| 32 | //! | warp | +53.0 / +23.3 | 0.88 | |
| 33 | //! | tpl lambda map | +53.2 / +23.4 | 0.85 | |
| 34 | //! | chroma top-2 | +53.3 / +23.4 | 0.79 | |
| 35 | //! | split-RD breakout 0.5 | +53.6 / +23.7 | 0.82 | |
| 36 | //! | extra-reference NEWMV | +53.7 / +23.9 | 0.90 | |
| 37 | //! | **8x8 split** | **+53.8 / +23.6** | **0.41** | |
| 38 | //! | intra top-2 | +54.0 / +24.2 | 0.96 | |
| 39 | //! | CfL + angle delta | +54.1 / +24.2 | 0.71 | |
| 40 | //! | coefficient breakout 1 | +54.3 / +24.3 | 0.73 | |
| 41 | //! | 32x32 tx depth | +54.7 / +24.8 | 0.75 | |
| 42 | //! | inter var-tx | +55.5 / +25.2 | 0.95 | |
| 43 | //! | leaf second-reference search | +58.9 / +27.5 | 0.86 | |
| 44 | //! | leaf compound | +62.8 / +29.7 | 0.74 | |
| 45 | //! | compound | +83.7 / +45.8 | 0.62 | |
| 46 | //! |
| 47 | //! The ladder is that column read greedily by BD per wall: the 8x8 split is |
| 48 | //! more than half the film wall for +0.6 points, three levers (LR, warp, the |
| 49 | //! tpl map) are free or better on real film, and compound -- the tool the old |
| 50 | //! bars-fixture sweeps rated cheap -- is the most expensive thing to lose, so |
| 51 | //! it only goes at speed 9. MEASURED end to end on the same row: |
| 52 | //! |
| 53 | //! Filter intra (merged into speed 0 after the table above was measured) was |
| 54 | //! priced the same way, but at speed 3 rather than 0 -- two sequential arms on |
| 55 | //! film A native, `lanes/fi-s3-{on,off}.log`: ON +54.6 / +24.3 at 43.1s/13.7s |
| 56 | //! anchor = 3.15, OFF +55.1 / +24.7 at 39.6s/14.2s = 2.79. It buys 0.5 BD |
| 57 | //! points for 12.8% wall = 0.039 points per 1% wall, which lands BETWEEN the |
| 58 | //! levers speed 3 already cuts (CfL + angle, 0.031) and the next one it keeps |
| 59 | //! (coefficient breakout, 0.041) -- i.e. right at the greedy frontier, inside |
| 60 | //! this gate's own noise. It ships ON at preset 0 only, where the byte pins |
| 61 | //! live, and off above it, because a preset whose whole purpose is wall does |
| 62 | //! not spend 12.8% of it on half a BD point. |
| 63 | //! |
| 64 | //! # The Pareto table, RE-MEASURED 2026-09-08 (lane-pareto2) |
| 65 | //! |
| 66 | //! Every row is `encode::tests::bd_rate_screen_native` on THIS head: 12 |
| 67 | //! frames, gop 12, four quantizers, the native crops (film A 1920x768, film B |
| 68 | //! and the capture 1920x1024), one tile, one thread; BD-rate vs libaom |
| 69 | //! `cpu-used 6` / vs rav1e `speed 6`. The arms ran THREE at a time on a box |
| 70 | //! carrying two other lanes (load 9-25), so the wall is read ONLY as the |
| 71 | //! ours:rav1e-speed-6 ratio inside one arm -- `x rav1e` below -- and the fps |
| 72 | //! column is our own 48 coded frames over our own ladder wall in that same |
| 73 | //! arm. BD is exact across runs; wall is not -- the shipped preset-6 row was |
| 74 | //! re-run with the invariant suite alongside, so its wall columns are the |
| 75 | //! most depressed of the table; the SERIAL pair (control 75.2s, both levers |
| 76 | //! 95.6s on the film A row) is what prices this lane's change: +27% wall for |
| 77 | //! 2.8 BD points, and film B gains 3.4 points on top of that for free. |
| 78 | //! |
| 79 | //! | preset | film A | film B | screen capture | x rav1e s6 (A/B/screen) | 1-thread fps (A/B/screen) | |
| 80 | //! |---|---|---|---|---|---| |
| 81 | //! | 0 | +21.7 / -4.4 | +26.9 / -0.6 | +19.8 / -30.5 | 10.9 / 9.5 / 7.5 | 0.24 / 0.28 / 0.37 | |
| 82 | //! | 3 | +22.3 / -4.1 | +27.3 / -0.3 | +23.7 / -28.4 | 7.4 / 6.6 / 4.4 | 0.40 / 0.48 / 0.60 | |
| 83 | //! | 6 (as it shipped) | +26.6 / -0.4 | +34.7 / +6.4 | +23.1 / -28.5 | 2.2 / 3.9 / 3.0 | 0.71 / 0.47 / 0.71 | |
| 84 | //! | **6 (this lane)** | **+23.0 / -3.2** | **+30.7 / +3.0** | **+23.2 / -28.5** | 3.9 / 2.5 / 2.8 | 0.33 / 0.44 / 0.70 | |
| 85 | //! | 8 | +61.1 / +23.5 | +75.6 / +38.4 | +50.8 / -13.8 | 1.0 / 1.5 / 1.3 | 1.50 / 1.34 / 2.10 | |
| 86 | //! | 10 | +112.0 / +64.4 | +155.0 / +102.7 | +106.0 / +12.7 | 0.8 / 1.4 / 0.6 | 2.46 / 2.03 / 4.17 | |
| 87 | //! |
| 88 | //! The whole ladder moved since it was composed (2026-09-07): the encoder is |
| 89 | //! four points BETTER than rav1e `speed 6` on film A at preset 0 where the |
| 90 | //! old table read +23.4, so every "the keep rule fails at every preset" |
| 91 | //! statement that table carried is dead. PARITY WITH rav1e `speed 6` IS |
| 92 | //! REACHED AT PRESET 6 on film A and on the screen capture; on film B it is |
| 93 | //! reached at preset 3 (-0.3), preset 6 sitting between rav1e `speed 8` |
| 94 | //! (+3.5) and `speed 10` (+28.7). |
| 95 | //! |
| 96 | //! # Against the reference encoders at THEIR fast presets |
| 97 | //! |
| 98 | //! Measured in the SAME arms as the shipped preset-6 row above |
| 99 | //! (`EC_AV1_PARETO_REFS=1`, which runs each reference's fast ladder through |
| 100 | //! `external_ladder` right after ours), so the wall column is comparable |
| 101 | //! WITHIN a row. `libaom cpu-used 8` codes the same bytes as `cpu-used 6` in |
| 102 | //! this ffmpeg -- it reads +0.0% against it on all three rows, one point on |
| 103 | //! the plot, not two. |
| 104 | //! |
| 105 | //! | row | encoder | vs libaom cpu-6 | vs rav1e s6 | 4-point ladder wall (rav1e s6 in that arm) | |
| 106 | //! |---|---|---|---|---| |
| 107 | //! | film A | ours preset 6 (pre-lane) | +26.6 | -0.4 | 67.6s (31.3s) | |
| 108 | //! | film A | rav1e speed 8 | +29.0 | +2.0 | 24.1s | |
| 109 | //! | film A | rav1e speed 10 | +45.3 | +17.1 | 8.4s | |
| 110 | //! | film A | libaom cpu-used 8 | +0.0 | -20.1 | 15.4s | |
| 111 | //! | film A | SVT-AV1 preset 8 | +24.1 | -1.9 | 2.4s | |
| 112 | //! | film A | SVT-AV1 preset 10 | +45.3 | +12.1 | 2.0s | |
| 113 | //! | film B | ours preset 6 (pre-lane) | +34.7 | +6.4 | 103.0s (26.4s) | |
| 114 | //! | film B | rav1e speed 8 | +37.3 | +3.5 | 20.5s | |
| 115 | //! | film B | rav1e speed 10 | +61.4 | +28.7 | 10.5s | |
| 116 | //! | film B | libaom cpu-used 8 | +0.0 | -22.2 | 32.3s | |
| 117 | //! | film B | SVT-AV1 preset 8 | +41.7 | +7.4 | 2.9s | |
| 118 | //! | film B | SVT-AV1 preset 10 | +65.9 | +23.3 | 2.0s | |
| 119 | //! | screen | ours preset 6 (pre-lane) | +23.1 | -28.5 | 68.0s (22.6s) | |
| 120 | //! | screen | rav1e speed 8 | +84.2 | +4.5 | 13.8s | |
| 121 | //! | screen | rav1e speed 10 | +332.5 | +103.4 | 9.8s | |
| 122 | //! | screen | libaom cpu-used 8 | +0.0 | -42.4 | 17.6s | |
| 123 | //! | screen | SVT-AV1 preset 8 | +21.5 | -31.6 | 5.0s | |
| 124 | //! | screen | SVT-AV1 preset 10 | +39.4 | -24.5 | 1.9s | |
| 125 | //! |
| 126 | //! So the QUALITY bar is met and the WALL bar is not: at preset 6 we are |
| 127 | //! ahead of rav1e `speed 8` on film A and the capture and behind it on film |
| 128 | //! B, but we spend 2-4x rav1e `speed 6`'s wall to do it, and SVT-AV1 preset 8 |
| 129 | //! is within 2 points of us on film A at a THIRTIETH of the wall. libaom |
| 130 | //! `cpu-used 6/8` is 20 points ahead of everything on every row. |
| 131 | //! |
| 132 | //! # Per-lever re-price at preset 6 (lane-pareto2, film A row, this head) |
| 133 | //! |
| 134 | //! The ladder was composed off a lever table measured BEFORE RDOQ. This is |
| 135 | //! the same one-lever-at-a-time ablation redone AT preset 6, the fast |
| 136 | //! software preset, control +26.6 / -0.4. "gain" is BD points off the |
| 137 | //! vs-rav1e column; wall is only quoted where it decided a row (three serial |
| 138 | //! control arms measured 66.3 / 71.1 / 75.2s, so anything under ~13% wall is |
| 139 | //! below this box's floor). |
| 140 | //! |
| 141 | //! | lever re-enabled at 6 | vs libaom / rav1e | gain | shipped | |
| 142 | //! |---|---|---|---| |
| 143 | //! | **extra-reference NEWMV** | +24.4 / -2.4 | **2.0** | ON (+15..30% wall = 0.067 pts/1%) | |
| 144 | //! | **coefficient breakout 0** | +24.8 / -1.6 | **1.2** | ON (+11% wall = 0.109 pts/1%) | |
| 145 | //! | 8x8 split | +25.9 / -0.8 | 0.4 | off (half the film wall in the first table) | |
| 146 | //! | warp | +26.2 / -0.8 | 0.4 | off | |
| 147 | //! | CfL | +26.2 / -0.7 | 0.3 | off | |
| 148 | //! | chroma top-k off | +26.3 / -0.7 | 0.3 | off | |
| 149 | //! | inter var-tx | +26.3 / -0.7 | 0.3 | off | |
| 150 | //! | angle delta | +26.5 / -0.6 | 0.2 | off | |
| 151 | //! | split-RD 0.125 | +26.4 / -0.6 | 0.2 | off | |
| 152 | //! | inter-intra top-13 | +26.7 / -0.3 | 0.1 | off | |
| 153 | //! | intra top-13 | +26.7 / -0.4 | 0.0 | off | |
| 154 | //! | filter intra | +26.7 / -0.4 | 0.0 | off | |
| 155 | //! | 32x32 tx depth | +26.6 / -0.4 | 0.0 | off -- INERT at 6 (inter tx select is off) | |
| 156 | //! | compound var-tx | +26.6 / -0.4 | 0.0 | off -- inert for the same reason | |
| 157 | //! | loop restoration | +26.7 / -0.2 | -0.2 | off (re-enabling it LOSES) | |
| 158 | //! |
| 159 | //! and the other half of the greedy rule, every lever preset 6 KEEPS, taken |
| 160 | //! away one at a time: |
| 161 | //! |
| 162 | //! | lever removed from 6 | vs libaom / rav1e | cost of losing it | |
| 163 | //! |---|---|---| |
| 164 | //! | RDOQ | +41.2 / +10.2 | 10.6 | |
| 165 | //! | 64x64 inter root | +30.7 / +3.4 | 3.8 | |
| 166 | //! | key 64x64 intra root | +28.0 / +0.9 | 1.3 | |
| 167 | //! | per-superblock delta_q | +27.2 / -0.2 | 0.2 | |
| 168 | //! | tpl window 4 -> 1 | +27.0 / -0.3 | 0.1 | |
| 169 | //! |
| 170 | //! Every keep is confirmed. The two re-enables above ship (see |
| 171 | //! [`EXTRA_REF_NEW`] and [`SPLIT_BREAKOUT`]); together they read +23.0 / -3.2 |
| 172 | //! on film A in the ablation arm, 2.8 points for wall that stayed inside the |
| 173 | //! control spread of three serial arms. Presets 4 and 5 take them by |
| 174 | //! bracketing, not by their own arm; presets 3, 8 and 10 are untouched, and |
| 175 | //! preset 0 is untouched by construction (the byte pins). |
| 176 | //! |
| 177 | //! NOT RE-MEASURED, and the reason: the THREADED fps table (1080p and |
| 178 | //! 3840x1608 at 4x2 tiles / 8 threads) cannot be read on this box while two |
| 179 | //! other lanes run -- three interleaved passes of `filter_stage_wall_*` put |
| 180 | //! preset 3 BELOW preset 0 in every pass at load 16-25. The single-thread fps |
| 181 | //! column above comes from the BD arms themselves and is ordered correctly. |
| 182 | |
| 183 | use ; |
| 184 | |
| 185 | /// The highest preset. 10 is the fastest, as in rav1e. |
| 186 | pub const MAX_SPEED: u8 = 10; |
| 187 | |
| 188 | /// 255 = "not read yet"; the env read happens once and the value is a plain |
| 189 | /// atomic afterwards, so a caller can set it without touching the process |
| 190 | /// environment. |
| 191 | static SPEED: AtomicU8 = new; |
| 192 | |
| 193 | /// This process's speed preset, 0..=[`MAX_SPEED`]. |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | /// Sets the preset for everything encoded afterwards in this process. |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | /// `TABLE[speed()]`, the shape every lever below is read through. |
| 216 | pub |
| 217 | |
| 218 | |
| 219 | |
| 220 | // --------------------------------------------------------------------------- |
| 221 | // The lever tables. Index 0 of each is the shipped default of the constant |
| 222 | // named in the comment; the rest is this lane's composition (see the report |
| 223 | // table for what each step measured). |
| 224 | // --------------------------------------------------------------------------- |
| 225 | |
| 226 | /// `encode::B64_ROOT`: the 64x64 `PARTITION_NONE` skip trial at the |
| 227 | /// superblock root. At preset 0 it is a bit saver AND a wall saver -- every |
| 228 | /// native row improves on both columns (film A +44.2/+15.7 -> +43.0/+15.0, |
| 229 | /// film B +70.5/+35.2 -> +64.7/+34.0, screen +48.2/-16.4 -> +33.4/-23.8) at |
| 230 | /// -4% to -20% wall on four of the five rows. |
| 231 | /// |
| 232 | /// lane-b64 MEASURED it off from preset 4 up: at `EC_AV1_SPEED=6` ON cost |
| 233 | /// film A +55.1/+24.8 -> +64.5/+37.5 and film B +91.5/+53.4 -> +114.6/+71.5. |
| 234 | /// The cause was named there and FIXED in lane-tx64: the trial's early-out |
| 235 | /// rode [`SPLIT_RD`], so at 0.5 (preset 6) a superblock was taken whole with |
| 236 | /// its quadrants never searched. `encode::b64_breakout_threshold` clamps that |
| 237 | /// early-out at the shipped 0.125 whatever the preset, and the same gate at |
| 238 | /// `EC_AV1_SPEED=6` now reads, every row better on both columns: |
| 239 | /// |
| 240 | /// | row | B64 off | B64 on, clamped | |
| 241 | /// |---|---|---| |
| 242 | /// | bars 1080p | +88.9 / +54.8 | +79.5 / +47.2 | |
| 243 | /// | bars 2160p | +91.6 / +49.8 | +72.6 / +35.1 | |
| 244 | /// | film A | +55.1 / +24.8 | +51.0 / +21.7 | |
| 245 | /// | film B | +91.5 / +53.4 | +77.9 / +44.3 | |
| 246 | /// | screen | +57.7 / -11.7 | +40.3 / -20.0 | |
| 247 | /// |
| 248 | /// at 28.1s vs 30.8s (film A), 31.3s vs 28.0s (film B), 14.3s vs 15.2s |
| 249 | /// (screen). So it is on at every preset. |
| 250 | pub const B64_ROOT: = ; |
| 251 | |
| 252 | /// `encode::rdoq_on`: rate-distortion optimised quantisation |
| 253 | /// ([`crate::tile::rdoq`], lane-rdoq). MEASURED at both ends of the range on |
| 254 | /// the 12-frame native gate (BD vs libaom `cpu-used 6` / rav1e `speed 6`, |
| 255 | /// our wall): |
| 256 | /// |
| 257 | /// | row | preset 0 off | preset 0 on | preset 6 off | preset 6 on | |
| 258 | /// |---|---|---|---|---| |
| 259 | /// | film A | +37.1 / +7.3 (77s) | +24.4 / -1.8 (138s) | +46.0 / +14.5 (32s) | +30.4 / +2.9 (60s) | |
| 260 | /// | film B | +52.5 / +22.3 (78s) | +35.5 / +7.6 (130s) | +67.8 / +35.0 (30s) | +43.5 / +14.2 (51s) | |
| 261 | /// | screen | +33.4 / -23.8 (45s) | +28.1 / -25.7 (79s) | +40.3 / -20.0 (15s) | +34.9 / -22.0 (34s) | |
| 262 | /// |
| 263 | /// It costs about 2x wall and pays at BOTH ends, and it DOMINATES the ladder: |
| 264 | /// preset 6 with it on is better than preset 0 with it off on every row and |
| 265 | /// on both columns, at less wall. So it is on up to preset 6. The top rungs |
| 266 | /// (7..=10) are the real-time ones and are UNMEASURED here, so they keep the |
| 267 | /// cheaper choice rather than an assumed one; `EC_AV1_RDOQ=1` turns it on |
| 268 | /// there. |
| 269 | pub const RDOQ: = |
| 270 | |
| 271 | ; |
| 272 | |
| 273 | /// `encode::I64_ROOT`: the KEY frame's 64x64 intra root. On at every preset |
| 274 | /// (see the lane-i64 report's speed-6 arm); its early-out reads |
| 275 | /// `encode::b64_breakout_threshold`, the same preset-clamped 0.125 the inter |
| 276 | /// root uses, so the preset's looser `SPLIT_RD` never withholds four quadrant |
| 277 | /// searches here either. |
| 278 | pub const I64_ROOT: = ; |
| 279 | |
| 280 | /// `encode::deltaq_res_log2`: the per-superblock quantizer's `delta_q_res` |
| 281 | /// LOG2 (2 = a step of 4 qindex), or `4` for "no delta_q syntax at all". |
| 282 | /// |
| 283 | /// ON (res 4) AT PRESETS 5 AND 6, off everywhere else, and never on a screen |
| 284 | /// frame -- `encode_inter_frame` gates the whole map on |
| 285 | /// `!allow_screen_content_tools`, the same content gate `b64_residual` and |
| 286 | /// `b64_compound` take, so a desktop capture codes no delta syntax and stays |
| 287 | /// byte-identical to the pre-lane encoder. |
| 288 | /// |
| 289 | /// lane-deltaq measured the mapping sweep with the tpl lookahead still cut to |
| 290 | /// one picture, so the map it read was inert and every arm was flat. With the |
| 291 | /// window back (lane-tplwin) lane-dq2 re-measured and lane-dq3 shipped it, |
| 292 | /// 12-frame `bd_rate_screen_native`, BD vs libaom / vs rav1e, off -> on: |
| 293 | /// |
| 294 | /// | preset | film A | film B | screen capture | |
| 295 | /// |---|---|---|---| |
| 296 | /// | 6 | +27.2/-0.2 -> +26.6/-0.4 | +35.2/+6.6 -> +34.7/+6.4 | +26.0/-27.2, byte-identical | |
| 297 | /// | 5 | +26.6/-0.7 -> +25.8/-1.1 | +33.3/+4.9 -> +32.8/+4.6 | gated off | |
| 298 | /// | 4 | +23.7/-2.9 -> +23.1/-3.1 | +29.9/+2.0 -> +30.2/+2.6 | gated off | |
| 299 | /// |
| 300 | /// Both films gain on both columns at 5 and 6 (the four q points of the |
| 301 | /// capture row code the identical byte counts on and off). PRESET 4 REJECTS |
| 302 | /// -- film B goes the wrong way on both columns there. Preset 3 rejects |
| 303 | /// (lane-dq2: film B worse on both columns) and preset 0 is neutral, so they |
| 304 | /// stay off. Coarser steps (res 8) were worse everywhere in lane-deltaq's |
| 305 | /// sweep. The syntax is proven three ways |
| 306 | /// (`a_moving_detail_clip_codes_two_delta_q_levels_both_decoders_read_exactly`); |
| 307 | /// `EC_AV1_DELTAQ=2` forces it on at any preset, `EC_AV1_DELTAQ=0` off. |
| 308 | /// Above preset 6 it is inert anyway -- [`TPL_DEPTH`] cuts the lookahead to |
| 309 | /// one picture there, so there is no map to vary the quantizer by. |
| 310 | pub const DELTAQ_RES: = ; |
| 311 | |
| 312 | /// lane-dq: the strength of libaom's OBJECTIVE per-superblock mapping |
| 313 | /// ([`crate::encode::deltaq_libaom`]) -- `0` keeps the shipped |
| 314 | /// `deltaq_for_factor` derivation, anything above it takes that fraction of |
| 315 | /// libaom's own offset. Only meaningful where [`DELTAQ_RES`] is on. |
| 316 | /// |
| 317 | /// Preset 0 only, at 0.25. The census (`EC_AV1_DQ_CENSUS=1`) says the two |
| 318 | /// mappings read the SAME tpl map into offsets an order of magnitude apart -- |
| 319 | /// on film B's 12-frame window, ours is `-4..8` with `|mean| 3.0` while |
| 320 | /// libaom's is `-24..32` with `|mean| 14` -- so a strength is the only honest |
| 321 | /// knob between them. Measured on the 48-picture long-GOP gate (BD vs libaom |
| 322 | /// / rav1e), which is the shape his exports have: |
| 323 | /// |
| 324 | /// | arm | film A | film B | |
| 325 | /// |---|---|---| |
| 326 | /// | control (no delta_q) | +25.2/-7.2 | +86.7/+7.3 | |
| 327 | /// | shipped mapping | +24.6/-7.3 | +86.1/+7.5 | |
| 328 | /// | **objective, 0.25** | **+24.4/-7.5** | **+86.0/+7.3** | |
| 329 | /// | objective, 0.5 | +23.8/-7.6 | +86.5/+7.9 | |
| 330 | /// | objective, 1.0 | +24.0/-7.0 | +88.4/+9.7 | |
| 331 | /// |
| 332 | /// 0.25 is the only arm down on both films on the libaom column with neither |
| 333 | /// rav1e column worse; 0.5 buys film A another 0.6 and gives film B back 0.6. |
| 334 | /// The 12-frame gate reads the same arm as flat (film A +21.0/-4.8 -> |
| 335 | /// +20.7/-4.8, film B +24.9/-1.9 -> +24.8/-1.7) and the screen capture is |
| 336 | /// BYTE-IDENTICAL at every arm -- `encode_inter_frame` codes no delta syntax |
| 337 | /// on a screen frame at all (lane-dq3's content gate). |
| 338 | pub const DQ_TPL_K: = ; |
| 339 | |
| 340 | /// lane-arfq: a per-LEVEL multiplier on [`DQ_TPL_K`], indexed by |
| 341 | /// [`crate::encode::DqLevel`] -- `[top ARF, mid ARF, leaf]`. The key frame is |
| 342 | /// absent because it codes no `delta_q` syntax at all. |
| 343 | /// |
| 344 | /// `EC_AV1_DQ_K=<top>:<mid>:<leaf>` overrides it for an A/B. |
| 345 | /// |
| 346 | /// The top ARF is coded 1.5x the preset's strength (0.375 at preset 0, where |
| 347 | /// the leaves keep 0.25): it feeds a whole mini-GOP, and the census |
| 348 | /// (`EC_AV1_DQ_CENSUS=1`, film B 48 pictures) says the objective mapping is |
| 349 | /// normalised BY the frame's own dependence ratio, so the top ARF's much |
| 350 | /// higher `r_frame` (2.91 vs the leaves' 1.74) buys it nothing at all -- |
| 351 | /// what a level's strength moves is the CONTRAST inside that frame. Long-GOP |
| 352 | /// gate (48 pictures, BD vs libaom / rav1e): |
| 353 | /// |
| 354 | /// | top-ARF strength | film A | film B | |
| 355 | /// |---|---|---| |
| 356 | /// | 0.25 (flat, control) | +24.0/-7.6 | +85.8/+7.1 | |
| 357 | /// | **0.375** | **+23.5/-8.0** | **+85.3/+6.7** | |
| 358 | /// | 0.5 | +23.0/-8.2 | +86.0/+7.3 | |
| 359 | /// | 0.75 | +22.7/-8.4 | +86.8/+7.8 | |
| 360 | /// | 1.0 | +21.8/-8.9 | +88.7/+9.1 | |
| 361 | /// |
| 362 | /// Film A goes on improving with strength and film B turns at 0.375, which is |
| 363 | /// the last point down on all four columns; 0.5 is also the point where the |
| 364 | /// 12-frame gate hands film B back 0.4 (0.375 costs it 0.1). See |
| 365 | /// `lanes/arfq.report.md`. |
| 366 | pub const DQ_LEVEL_K: = ; |
| 367 | |
| 368 | /// lane-arfpred: the strength of the top ARF's SOURCE temporal filter |
| 369 | /// ([`crate::encode::arf_temporal_filter`]) -- `0` is off, higher filters |
| 370 | /// harder (the weight of a motion-compensated neighbour is |
| 371 | /// `exp(-mse / strength)`). `EC_AV1_ARF_TF=<strength>` overrides it. |
| 372 | /// |
| 373 | /// The top ARF carries 55% of a 48-picture film B stream at 6992 B a frame |
| 374 | /// against rav1e's 3872 at a FINER quantizer, and the per-frame census says |
| 375 | /// 61% of that gap is residual, not syntax -- while `arf_pred_census` says |
| 376 | /// the anchor's own lag is worth only 7% of its prediction SAD (lag 8 1.199 |
| 377 | /// vs lag 4 1.114 per pixel), so what the residual codes is mostly source |
| 378 | /// grain. Filtering it out of the picture the anchor is coded from is the |
| 379 | /// mechanism libaom uses (`arnr`) and rav1e 0.8.1 does not have at all. |
| 380 | /// Long-GOP gate (48 pictures, BD vs libaom / rav1e), strength 3 against the |
| 381 | /// control: film A +23.5/-8.0 -> **+22.7/-7.9**, film B +85.3/+6.7 -> |
| 382 | /// **+79.0/+2.7**. Film B takes 6.3 and 4.0 points off; film A takes 0.8 off |
| 383 | /// the libaom column and hands back 0.1 on the rav1e one, which is the |
| 384 | /// keep rule's "one column >=0.5 down, the other flat" clause. It is also |
| 385 | /// FASTER (film B two-point probe 167 s -> 147 s): the anchor has fewer |
| 386 | /// coefficients to code. Uniform over the presets -- above preset 6 |
| 387 | /// [`TPL_DEPTH`] leaves the group window empty and the filter is inert by |
| 388 | /// construction. |
| 389 | /// |
| 390 | /// Strength is single-peaked and SHARP: the film B two-point probe reads |
| 391 | /// -1.4% bytes at equal PSNR at 3, +3.4% at 8, +6.9% at 15 and +15.8% at 30 |
| 392 | /// (`lanes/arfpred.report.md` section 3). Hard filtering does remove 6-7% of |
| 393 | /// the stream's bytes and gives all of it back in quality, because the leaves |
| 394 | /// still carry the grain the anchor no longer has. |
| 395 | /// |
| 396 | /// lane-arftf SWEPT IT ON THE DECIDING GATE (48 pictures, film A / film B, |
| 397 | /// BD vs libaom `cpu-used 6` / rav1e `speed 6`, lower is better) -- the probe |
| 398 | /// of lane-arfpred mispredicts this lever's sign, so only these count: |
| 399 | /// |
| 400 | /// | strength | film A | film B | |
| 401 | /// |---|---|---| |
| 402 | /// | 1 | +22.6/-8.1 | +81.6/+4.8 | |
| 403 | /// | **2 (ships)** | **+22.2/-8.2** | **+78.6/+2.7** | |
| 404 | /// | 3 (was) | +22.7/-7.9 | +79.0/+2.7 | |
| 405 | /// | 5 | +23.9/-7.4 | +83.6/+5.1 | |
| 406 | /// |
| 407 | /// The curve is single-peaked at 2 and bracketed on both sides; 2 is down on |
| 408 | /// all four columns against the shipped 3 (film A -0.5/-0.3, film B |
| 409 | /// -0.4/0.0). |
| 410 | pub const ARF_TF: = ; |
| 411 | |
| 412 | /// lane-arftf: the same filter on the MID ARF (the second hidden frame of a |
| 413 | /// group), whose window is the group's later leaves -- so it filters FORWARD |
| 414 | /// where the top ARF filters backward. `EC_AV1_ARF_TF_MID=<strength>` |
| 415 | /// overrides it; `0` is off, which is where the long-GOP gate left it: |
| 416 | /// filtering the mid ARF at the same strength as the top one reads film A |
| 417 | /// +22.2/-8.3 and film B +78.9/+2.6 against the top-only +22.2/-8.2 and |
| 418 | /// +78.6/+2.7 -- inside the noise on three columns and 0.3 WORSE on film B's |
| 419 | /// libaom one, so the mechanism does not pay a second time one level down. |
| 420 | pub const ARF_TF_MID: = ; |
| 421 | |
| 422 | /// lane-arftf: how many window pictures [`crate::encode::arf_temporal_filter`] |
| 423 | /// averages in. The top ARF is its group's LAST picture and the next group's |
| 424 | /// sources are not buffered when it is coded, so the window holds only |
| 425 | /// display-PAST neighbours and this widens the filter backwards only (a |
| 426 | /// symmetric +-2 needs a one-group lookahead the encoder does not have). |
| 427 | /// `EC_AV1_ARF_TF_WIN=<n>` overrides it. |
| 428 | /// |
| 429 | /// 4 (past-only +-2) is REFUTED on the long-GOP gate at strength 2: film A |
| 430 | /// +22.8/-7.8 and film B +78.9/+2.8 against 2's +22.2/-8.2 and +78.6/+2.7 -- |
| 431 | /// worse on three of the four columns. The census's 14.3% SAD removal was |
| 432 | /// measured with two neighbours on EACH side; four pictures of one-sided |
| 433 | /// past is a different (and worse) window, and the anchor drifts away from |
| 434 | /// the leaves it has to predict. |
| 435 | /// |
| 436 | /// lane-lookahead gave the encoder the future half ([`LOOKAHEAD`]) and swept |
| 437 | /// the SYMMETRIC window (this many past neighbours and [`ARF_TF_WIN_FUT`] |
| 438 | /// future ones) on the long-GOP gate at strength 2: |
| 439 | /// |
| 440 | /// | window | film A | film B | |
| 441 | /// |---|---|---| |
| 442 | /// | +-0 (2 past, the control) | +22.0/-8.4 | +76.5/+1.2 | |
| 443 | /// | +-1 | +21.4/-8.8 | +74.3/+0.3 | |
| 444 | /// | +-2 | +21.2/-8.8 | +72.3/-0.9 | |
| 445 | /// | **+-3 (ships)** | **+21.2/-8.8** | **+72.1/-1.2** | |
| 446 | /// | +-4 | +21.5/-8.7 | +72.5/-1.0 | |
| 447 | /// |
| 448 | /// Bracketed on both sides and down on all four columns against the control |
| 449 | /// (film A -0.8/-0.4, film B -4.4/-2.4). The census's shape is confirmed: |
| 450 | /// what a wider window cost past-only, it buys symmetric. |
| 451 | pub const ARF_TF_WIN: = ; |
| 452 | |
| 453 | /// lane-lookahead: how many DISPLAY-FUTURE neighbours the top ARF's temporal |
| 454 | /// filter averages in, on top of [`ARF_TF_WIN`] past ones. Non-zero needs |
| 455 | /// [`LOOKAHEAD`] -- the future pictures are the next group's sources, which |
| 456 | /// the encoder buffers only with the lookahead on. |
| 457 | /// `EC_AV1_ARF_TF_WIN_FUT=<n>` overrides it. The sweep is [`ARF_TF_WIN`]'s |
| 458 | /// table (the two move together, +-n); strength 3 at +-2 loses to strength 2 |
| 459 | /// (film A +21.5/-8.7, film B +73.1/-0.7 against +21.2/-8.8 and +72.3/-0.9), |
| 460 | /// so [`ARF_TF`] stays where lane-arftf put it. |
| 461 | pub const ARF_TF_WIN_FUT: = ; |
| 462 | |
| 463 | /// lane-arfmode: the top ARF's offer set, as a bitmask -- `1` the group's |
| 464 | /// own anchor ([`crate::encode::DqLevel::TopArf`]) offers no INTRA |
| 465 | /// candidate at any block size (the whole-32 search and the 16x16/8x8 |
| 466 | /// leaves), `2` a 16x16 leaf under it is not offered the 8x8 split, `4` the |
| 467 | /// leaves offer no compound candidates; combinations OR, `0` (the default) |
| 468 | /// is bit-exact with the pre-lane encoder. `EC_AV1_ARFMODE=<n>` overrides |
| 469 | /// it. The spec-forced 8x8s at straddling edges are untouched -- only |
| 470 | /// RD-optional offers are cut; the mid and quarter hidden frames and every |
| 471 | /// shown leaf keep the full set. |
| 472 | /// |
| 473 | /// The census it answers to (lanes/arfmode.charter.md, at 0d81d6c5): the top |
| 474 | /// ARF's syntax gap against rav1e's own ARF at the same position is |
| 475 | /// film A +1337 / film B +971 B a frame across mode+mv+partition, and the |
| 476 | /// mode family is carried by syntax rav1e does not spend there -- an intra |
| 477 | /// fallback whose 4-15% area share de-optimizes the shared `intra_inter` |
| 478 | /// CDF (ours 138 B/frame against its 10 on film B), compound at 19-24% of |
| 479 | /// the area against its 0%, and an 8x8 split rate 2.4x its own. CAUTION the |
| 480 | /// same census records: on the grain film even rav1e keeps 12.3% intra area |
| 481 | /// at its ARF, so arm 1's residual risk is concentrated exactly there. |
| 482 | pub const ARFMODE: = ; |
| 483 | |
| 484 | /// lane-lookahead: whether [`crate::encoder::Av1Encoder`] holds one whole |
| 485 | /// mini-GOP of lookahead -- the next group's sources are buffered before the |
| 486 | /// current group's top ARF is coded, so that ARF has display-FUTURE pictures |
| 487 | /// available. Costs one group of latency (`mini_gop` pictures, 8 by default) |
| 488 | /// and one group of source buffer -- [`crate::encode::Picture`] holds u16 |
| 489 | /// samples, so a 3840x2160 4:2:0 picture is 24.9 MB and the group is 199 MB |
| 490 | /// on top of the group the encoder already buffered -- and nothing else: with |
| 491 | /// [`ARF_TF_WIN_FUT`] at 0 nothing reads the future half and the streams are |
| 492 | /// byte-identical. `EC_AV1_LOOKAHEAD=0|1` overrides it. What it BUYS is |
| 493 | /// [`ARF_TF_WIN_FUT`]: the symmetric filter window is the long-GOP gate's |
| 494 | /// film A -0.8/-0.4 and film B -4.4/-2.4, and the buffer is also what a |
| 495 | /// two-pass-like allocation would need. |
| 496 | pub const LOOKAHEAD: bool = true; |
| 497 | |
| 498 | /// lane-tplfut: which pictures the TOP ARF's temporal lambda map |
| 499 | /// ([`crate::encode::tpl_lambda_factors`]) propagates back through. The top |
| 500 | /// ARF is its group's LAST picture in display order, so the group's own |
| 501 | /// sources -- what [`crate::encoder::Av1Encoder::code_group`] hands it today |
| 502 | /// -- are all display-PAST, i.e. the window is time-REVERSED against every |
| 503 | /// other frame's (and against the flat path's, which always looks forward). |
| 504 | /// libaom's tpl at an ARF looks FORWARD, over the next group. With |
| 505 | /// [`LOOKAHEAD`] on those pictures are buffered, so the window is a choice: |
| 506 | /// |
| 507 | /// * `0` -- the past window (time-reversed), the shipped behaviour. |
| 508 | /// * `1` -- the display-FUTURE pictures only, nearest first, up to |
| 509 | /// `tpl_depth() - 1` of them. |
| 510 | /// * `2` -- past then future, concatenated nearest-first. NOTE the chain has |
| 511 | /// a discontinuity in the middle (the coarse pass between the last past |
| 512 | /// neighbour and the nearest future one spans the whole group). |
| 513 | /// * `3` -- future-only over the WHOLE next group, ignoring `tpl_depth()`. |
| 514 | /// |
| 515 | /// Falls back to `0`'s window whenever no future picture is buffered (the |
| 516 | /// lookahead off, or the end of the stream). `EC_AV1_TPL_FUT=<n>` overrides |
| 517 | /// it, and `EC_AV1_TPL_FUT_HALF=<n>` moves mode 2's split (default half the |
| 518 | /// budget each side). |
| 519 | /// |
| 520 | /// The 48-picture long-GOP gate, both films, against the past window: |
| 521 | /// |
| 522 | /// | arm | film A | film B | wall A | wall B | |
| 523 | /// |---|---|---|---|---| |
| 524 | /// | 0, past (the control) | +21.3/-8.8 | +72.1/-1.2 | 671.1s | 461.6s | |
| 525 | /// | 1, future only | +22.0/-8.6 | +73.1/-1.1 | 629.6s | 583.1s | |
| 526 | /// | **2, 3 past then 4 future (ships)** | **+21.2/-8.8** | **+71.6/-1.5** | 692.3s | 462.5s | |
| 527 | /// | 3, the whole next group | +21.9/-8.7 | +72.7/-1.4 | 573.1s | 455.7s | |
| 528 | /// |
| 529 | /// A future-ONLY window is worse than the past one on every column: the |
| 530 | /// nearest past neighbours are what the map's propagation is carried by (the |
| 531 | /// witness sees the same thing -- mode 2 at its default split is byte- |
| 532 | /// identical to mode 0 on a 128x128 fixture, and only moves once the past |
| 533 | /// half is cut to one). Mode 2 is film B -0.5/-0.3 and film A -0.1/0.0, so it |
| 534 | /// keeps by the lane's rule (one row >=0.5 down, the other flat within |
| 535 | /// +-0.3) at +3.2% / +0.2% wall. |
| 536 | pub const TPL_FUT: = ; |
| 537 | |
| 538 | /// lane-tplhalf: mode 2's SPLIT -- how many display-PAST neighbours the top |
| 539 | /// ARF's window opens with; the rest of [`TPL_FUT_WIN`] comes from the |
| 540 | /// buffered future. `EC_AV1_TPL_FUT_HALF=<n>` overrides it, and the value is |
| 541 | /// clamped up to 1 (a zero past half is mode 1, refuted). |
| 542 | /// |
| 543 | /// Swept on the 48-picture long-GOP gate at `TPL_DEPTH = 8` (budget 7), |
| 544 | /// BD-rate vs libaom / vs rav1e, lower better: |
| 545 | /// |
| 546 | /// | past half | film A | film B | wall A | wall B | |
| 547 | /// |---|---|---|---|---| |
| 548 | /// | 1 (6 future) | +21.1/-8.9 | +71.2/-1.9 | 548.5s | 429.1s | |
| 549 | /// | **2 (5 future, ships)** | **+20.9/-9.0** | **+71.0/-1.8** | 551.3s | 442.3s | |
| 550 | /// | 3 (4 future, the old default) | +21.1/-8.9 | +71.5/-1.5 | 547.0s | 423.0s | |
| 551 | /// | 5 (2 future) | +21.1/-8.9 | +71.5/-1.6 | 561.8s | 438.6s | |
| 552 | /// |
| 553 | /// Bracketed on both sides: 2 is down on all four columns against 3, and 1 |
| 554 | /// and 5 are both worse than it. Presets 3..6 run `TPL_DEPTH = 4`, where the |
| 555 | /// old `(depth-1)/2` split was 1 -- left there, unswept. |
| 556 | pub const TPL_FUT_HALF: = ; |
| 557 | |
| 558 | /// lane-tplhalf: how many entries mode 2's window holds in TOTAL, `0` meaning |
| 559 | /// `encode::tpl_depth() - 1` (the budget every other tpl path uses). |
| 560 | /// `EC_AV1_TPL_FUT_WIN=<n>` overrides it. The winning split takes its whole |
| 561 | /// future side from the budget's edge, so the budget was swept apart from |
| 562 | /// it (class `instrument at bound`) and apart from `EC_AV1_TPL_D`, which |
| 563 | /// deepens EVERY frame's lambda pass. 48-picture long-GOP, half=2: |
| 564 | /// |
| 565 | /// | window | film A | film B | |
| 566 | /// |---|---|---| |
| 567 | /// | 7 (`tpl_depth-1`, the split's own arm) | +20.9/-9.0 | +71.0/-1.8 | |
| 568 | /// | 9 | +21.0/-9.0 | +70.7/-2.0 | |
| 569 | /// | **11 (ships at presets 0..=2)** | **+20.9/-9.0** | **+70.4/-2.2** | |
| 570 | /// |
| 571 | /// 11 is film B -0.6/-0.4 against 7 with film A flat -- the keep rule -- and |
| 572 | /// saturates the one-group lookahead (2 past + 8 future available). Presets |
| 573 | /// 3..=6 keep 0 (`depth-1` = 3 at `TPL_DEPTH=4`), unswept. `TPL_D=10` at |
| 574 | /// half=2 was byte-identical to WIN=9: extra depth on non-ARF frames is |
| 575 | /// unused because a pyramid leaf's window is the group's own successors. |
| 576 | pub const TPL_FUT_WIN: = ; |
| 577 | |
| 578 | /// lane-arfpred: the qindex below which the ARF temporal filter is OFF -- |
| 579 | /// libaom scales `arnr` strength with the quantizer and stops filtering at |
| 580 | /// the high-quality end for the same reason: a picture we are about to |
| 581 | /// reproduce almost exactly should not have detail averaged out of it first. |
| 582 | /// |
| 583 | /// 16 is under the gate's own finest anchor (its `q = 60` ladder point codes |
| 584 | /// the top ARF at qindex 28) and over the rate-loop floor a high bitrate |
| 585 | /// target drives the anchor to. `encoder::tests::bitrate_target_lands_within_5/// _percent_over_48_frames` is what named the floor: at 2 Mbps on the 640x384 |
| 586 | /// fixture the loop codes IDENTICAL 22237-byte anchors as at 1536 kbps, i.e. |
| 587 | /// the anchor's `base_q_idx + arf_q_offset` has clamped to 1 and the loop |
| 588 | /// cannot spend the target's remaining bytes -- and a cheaper (filtered) |
| 589 | /// anchor there makes the miss worse, not better. |
| 590 | pub const ARF_TF_QMIN: u8 = 16; |
| 591 | |
| 592 | /// `encode::SPLIT_RD_THRESHOLD`: how cheap a block has to be before its split |
| 593 | /// trial is withheld. The single biggest wall lever in the tile search. |
| 594 | pub const SPLIT_RD: = |
| 595 | |
| 596 | |
| 597 | |
| 598 | |
| 599 | |
| 600 | |
| 601 | |
| 602 | |
| 603 | |
| 604 | |
| 605 | |
| 606 | ; |
| 607 | |
| 608 | /// `encode::SPLIT_BREAKOUT_COEFFS`: libaom's coefficient-count breakout. |
| 609 | /// |
| 610 | /// lane-pareto2 RE-PRICED it at preset 6: switching the breakout OFF there |
| 611 | /// (back to the shipped 0) takes film A +26.6/-0.4 to +24.8/-1.6 -- 1.2 BD |
| 612 | /// points against rav1e `speed 6` -- for +11% wall (73.7s against the 66.3s |
| 613 | /// control) = 0.109 points per 1% wall, three times the frontier. Presets 5 |
| 614 | /// and 6 take 0; preset 5 by BRACKETING (4 already had 0), 6 measured. |
| 615 | pub const SPLIT_BREAKOUT: = |
| 616 | |
| 617 | |
| 618 | |
| 619 | |
| 620 | |
| 621 | |
| 622 | |
| 623 | |
| 624 | |
| 625 | |
| 626 | |
| 627 | ; |
| 628 | |
| 629 | /// `encode::SPLIT_INTER_8`: a 16x16 leaf may split into four 8x8 ones. |
| 630 | pub const SPLIT_8: = |
| 631 | |
| 632 | |
| 633 | |
| 634 | |
| 635 | |
| 636 | |
| 637 | |
| 638 | |
| 639 | |
| 640 | |
| 641 | |
| 642 | ; |
| 643 | |
| 644 | /// `encode::SPLIT_INTER_BLOCKS`: a 32x32 inter block may split at all |
| 645 | /// (`false` = 32x32-only partitioning). |
| 646 | pub const SPLIT_INTER: = |
| 647 | |
| 648 | |
| 649 | |
| 650 | |
| 651 | |
| 652 | |
| 653 | |
| 654 | |
| 655 | |
| 656 | |
| 657 | |
| 658 | ; |
| 659 | |
| 660 | /// `encode::leaf_second_new_mv`: a leaf searches its SECOND reference. |
| 661 | pub const LEAF_SECOND: = |
| 662 | |
| 663 | ; |
| 664 | |
| 665 | /// `encode::EXTRA_REF_NEW_MV`: GOLDEN/ALTREF get a `NEWMV` search of their own. |
| 666 | /// lane-pareto2 RE-PRICED it at preset 6 (the fast software preset) on the |
| 667 | /// 12-frame film A row of `encode::tests::bd_rate_screen_native`, this head: |
| 668 | /// re-enabling it takes +26.6/-0.4 to +24.4/-2.4, TWO BD points against rav1e |
| 669 | /// `speed 6`, for +15% .. +30% wall (86.4s against a control that measured |
| 670 | /// 66.3/71.1/75.2s over three serial arms) = 0.067 points per 1% wall, which |
| 671 | /// clears the ladder's own frontier (CfL + angle 0.031, filter intra 0.039) |
| 672 | /// by better than 1.5x. The old ranking dropped it at preset 4 off a table |
| 673 | /// measured BEFORE RDOQ; with RDOQ on, a second reference's NEWMV is worth |
| 674 | /// twice what that table said. It is ON through preset 6 now; presets 4 and 5 |
| 675 | /// follow by BRACKETING (0..3 and 6 all keep it), not by their own arm. |
| 676 | pub const EXTRA_REF_NEW: = |
| 677 | |
| 678 | |
| 679 | |
| 680 | |
| 681 | |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | |
| 687 | |
| 688 | ; |
| 689 | |
| 690 | /// `encode::LEAF_COMPOUND`: a leaf is offered compound candidates. |
| 691 | pub const LEAF_COMPOUND: = |
| 692 | |
| 693 | |
| 694 | |
| 695 | |
| 696 | |
| 697 | |
| 698 | |
| 699 | |
| 700 | |
| 701 | |
| 702 | |
| 703 | ; |
| 704 | |
| 705 | /// `encode::REFERENCE_SELECT`: compound prediction at all. |
| 706 | pub const COMPOUND: = |
| 707 | |
| 708 | |
| 709 | |
| 710 | |
| 711 | |
| 712 | |
| 713 | |
| 714 | |
| 715 | |
| 716 | |
| 717 | |
| 718 | ; |
| 719 | |
| 720 | /// `encode::warp_on`: local warped motion. |
| 721 | pub const WARP: = |
| 722 | |
| 723 | ; |
| 724 | |
| 725 | /// `encode::tx_select_inter`: var-tx / tx-depth search inside inter frames. |
| 726 | pub const TX_SELECT_INTER: = |
| 727 | |
| 728 | ; |
| 729 | |
| 730 | /// `encode::tx32_depth_search`. |
| 731 | pub const TX32_DEPTH: = |
| 732 | |
| 733 | ; |
| 734 | |
| 735 | /// `encode::compound_var_tx`. |
| 736 | pub const COMPOUND_VAR_TX: = |
| 737 | |
| 738 | ; |
| 739 | |
| 740 | /// `encode::tx_select`: the KEY frame's transform-depth search. |
| 741 | pub const TX_SELECT_KEY: = |
| 742 | |
| 743 | ; |
| 744 | |
| 745 | /// `encode::PRUNE_TOP_K`: intra luma modes fully tried on a key frame. |
| 746 | pub const PRUNE_K: = |
| 747 | |
| 748 | |
| 749 | |
| 750 | |
| 751 | |
| 752 | |
| 753 | |
| 754 | |
| 755 | |
| 756 | |
| 757 | |
| 758 | ; |
| 759 | |
| 760 | /// `encode::INTER_PRUNE_TOP_K`: the same for intra candidates inside an inter |
| 761 | /// frame. |
| 762 | pub const PRUNE_K_INTER: = |
| 763 | |
| 764 | |
| 765 | |
| 766 | |
| 767 | |
| 768 | |
| 769 | |
| 770 | |
| 771 | |
| 772 | |
| 773 | |
| 774 | ; |
| 775 | |
| 776 | /// `encode::CHROMA_TOP_K`: chroma modes fully tried. |
| 777 | pub const CHROMA_K: = |
| 778 | |
| 779 | |
| 780 | |
| 781 | |
| 782 | |
| 783 | |
| 784 | |
| 785 | |
| 786 | |
| 787 | |
| 788 | |
| 789 | ; |
| 790 | |
| 791 | /// `encode::angle_delta_on`: refining a directional intra winner's delta. |
| 792 | pub const ANGLE: = |
| 793 | |
| 794 | ; |
| 795 | |
| 796 | /// `encode::cfl_on`: chroma-from-luma in the chroma search. |
| 797 | pub const CFL: = |
| 798 | |
| 799 | ; |
| 800 | |
| 801 | /// `encode::filter_intra_on`: the five recursive filter-intra modes as intra |
| 802 | /// candidates, and with them the sequence header's `enable_filter_intra`. |
| 803 | pub const FILTER_INTRA: = |
| 804 | |
| 805 | ; |
| 806 | |
| 807 | /// `encode::RESTORATION`: the loop-restoration (Wiener) search. |
| 808 | pub const RESTORATION: = |
| 809 | |
| 810 | |
| 811 | |
| 812 | |
| 813 | |
| 814 | |
| 815 | |
| 816 | |
| 817 | |
| 818 | |
| 819 | |
| 820 | ; |
| 821 | |
| 822 | /// `encode::TPL_DEPTH`: lookahead pictures the lambda map reads (1 = off). |
| 823 | /// |
| 824 | /// MEASURED per preset (lane-tplwin, 12-frame `bd_rate_screen_native`, all |
| 825 | /// five rows, BD vs libaom `cpu-used 6` / rav1e `speed 6`; the two arms of a |
| 826 | /// batch ran side by side so only the ours:rav1e ratio inside one arm is a |
| 827 | /// wall statement). The film rows code through the pyramid, whose window is |
| 828 | /// the mini-GOP's display successors, so a depth above 8 cannot mean anything |
| 829 | /// there. |
| 830 | /// |
| 831 | /// | preset | depth | film A | film B | screen | wall vs its own depth-1 arm | |
| 832 | /// |---|---|---|---|---|---| |
| 833 | /// | 0 | 8 (shipped) | +21.7 / -4.4 | +26.9 / -0.6 | +27.8 / -26.0 | -- | |
| 834 | /// | 0 | 4 | +21.5 / -4.5 | **+27.6 / +0.1** | +27.7 / -26.1 | -8% .. +4% | |
| 835 | /// | 3 | 1 | +22.5 / -3.9 | +27.6 / +0.1 | +33.5 / -23.1 | 1.00 | |
| 836 | /// | 3 | **4** | **+22.3 / -4.1** | **+27.3 / -0.3** | **+33.4 / -23.2** | not batched | |
| 837 | /// | 3 | 8 | +22.5 / -3.9 | +27.7 / +0.1 | +32.9 / -23.4 | -2% .. -4% | |
| 838 | /// | 6 | 1 | +27.0 / -0.3 | +35.9 / +7.2 | +34.7 / -22.4 | 1.00 | |
| 839 | /// | 6 | **4** | +27.2 / -0.2 | **+35.2 / +6.6** | +34.8 / -22.3 | -8% .. +2% | |
| 840 | /// | 6 | 8 | +27.0 / -0.4 | +35.6 / +6.9 | +34.9 / -22.3 | +3% .. +8% | |
| 841 | /// |
| 842 | /// Every ladder above reproduced BYTE-IDENTICALLY on a second run of the |
| 843 | /// preset-6 depth-1 and depth-4 arms, so these BD deltas are signal; only the |
| 844 | /// wall column carries the box's noise (another lane ran throughout, load |
| 845 | /// 13-15), which is why depth 4's cost reads as a spread straddling zero. |
| 846 | /// |
| 847 | /// Read greedily, the way the lever table above is read: |
| 848 | /// |
| 849 | /// * **preset 0 keeps 8.** Shortening to 4 costs film B 0.7 points on BOTH |
| 850 | /// columns -- the largest single move in the whole sweep -- for at most 8% |
| 851 | /// of that row's wall. The byte pins do not move. |
| 852 | /// * **presets 3..6 take 4**, up from the 1 that shipped before. At preset 3 |
| 853 | /// it is the best arm on every real-content row (film A -0.2/-0.2, film B |
| 854 | /// -0.3/-0.4, screen -0.1/-0.1 against depth 1) and the lookahead pass does |
| 855 | /// not appear in the wall at all. At preset 6 it buys film B 0.7/0.6 for a |
| 856 | /// wall that still measures below this box's noise, where depth 8 buys only |
| 857 | /// 0.3/0.3 and does cost a visible 3-8%. Film A moves +0.2 at preset 6, so |
| 858 | /// this is 0.5 net film points across the two rows for no measured wall -- |
| 859 | /// which clears the frontier the preset already dropped (CfL + angle at |
| 860 | /// 0.031 BD points per 1% wall, coefficient breakout at 0.041) by an order |
| 861 | /// of magnitude. |
| 862 | /// * **presets 1..2 keep 8**, unmeasured: their search is within a quarter of |
| 863 | /// preset 0's wall, so the pass is the same negligible share there, and 8 |
| 864 | /// is the optimum at the nearest MEASURED neighbour (0). The monotone rule |
| 865 | /// (`presets_are_monotone_in_speed`) forbids them going below preset 3's 4 |
| 866 | /// in any case. |
| 867 | /// * **presets 7..10 stay at 1**, unmeasured: not swept by this lane. |
| 868 | pub const TPL_DEPTH: = ; |
| 869 | |
| 870 | /// `encode::tx_type_search`: whether an intra luma transform unit searches |
| 871 | /// its own `tx_type` instead of coding `DCT_DCT` (lane-txset). The five-type |
| 872 | /// reduced-set alphabet the writer already codes is what it picks from, so a |
| 873 | /// preset that turns it off is byte-identical to the encoder before the lane. |
| 874 | pub const TX_TYPE_SEARCH: = |
| 875 | |
| 876 | ; |
| 877 | |
| 878 | /// `tx_type_candidates`: whether an INTER luma transform unit searches the |
| 879 | /// two-type `TX_SET_INTER_3` (`IDTX` vs `DCT_DCT`) the writer already codes a |
| 880 | /// symbol for, instead of always coding `DCT_DCT` (lane-txset2). On at the |
| 881 | /// presets that carry the intra search, and SCREEN CONTENT ONLY on top of it |
| 882 | /// (measured, 12-frame `bd_rate_screen_native`: the capture goes |
| 883 | /// +20.8/-30.1 -> +20.1/-30.4 while both synthetic bars rows lose twenty |
| 884 | /// points and film B 0.3 -- see `encode::inter_tx_type_candidates`). |
| 885 | /// `EC_AV1_TXSET_INTER` overrides. |
| 886 | pub const TX_TYPE_SEARCH_INTER: = |
| 887 | |
| 888 | ; |
| 889 | |
| 890 | /// `encode::wide_tx_set`: whether a frame codes `reduced_tx_set = 0`, the |
| 891 | /// wider `tx_type` alphabets (intra 8x8/4x4 seven types, inter 16x16 twelve, |
| 892 | /// inter 8x8/4x4 sixteen) instead of the reduced sets every stream this |
| 893 | /// encoder wrote before lane-txi carries. ON at preset 0, SCREEN CONTENT ONLY |
| 894 | /// like both halves of the type search itself (`encode::wide_tx_set` returns |
| 895 | /// the screen flag), so a non-screen frame codes the same |
| 896 | /// `reduced_tx_set = 1` bit and the same bytes as before. |
| 897 | /// MEASURED at preset 0 (lane-txw, 12-frame `bd_rate_screen_native`, screen |
| 898 | /// row): +19.8/-30.5 -> +14.8/-32.9 -- five BD points against libaom and 2.4 |
| 899 | /// against rav1e, on 2.8% `V_DCT` + 7.4% `H_DCT` of the row's intra units, |
| 900 | /// the two types only the seven-type `TX_SET_INTRA_1` can name. It costs |
| 901 | /// wall: 92.8s -> 123.3s for the row. Presets 1..6 carry the type search but |
| 902 | /// are UNMEASURED here, so they stay off. `EC_AV1_TXSET_WIDE` overrides. |
| 903 | pub const WIDE_TX_SET: = |
| 904 | |
| 905 | ; |
| 906 | |
| 907 | /// `filter_search`: whether the deblock ladder's +-1/+-2 refinement stage runs. |
| 908 | pub const DEBLOCK_REFINE: = |
| 909 | |
| 910 | ; |
| 911 | |
| 912 | /// `filter_search`: whether chroma gets a deblock stage of its own. |
| 913 | pub const DEBLOCK_CHROMA: = |
| 914 | |
| 915 | ; |
| 916 | |
| 917 | /// `filter_search`: how many of `CDEF_PRI` / `CDEF_SEC` each CDEF stage tries |
| 918 | /// (0 = no CDEF search at all, the frame keeps strength 0 = deblock only). |
| 919 | pub const CDEF_STRENGTHS: = ; |
| 920 | |
| 921 | /// `filter_search`: how many extra per-superblock CDEF presets the header may |
| 922 | /// carry beyond the frame winner (0 = `cdef_bits` 0). |
| 923 | pub const CDEF_PRESETS: = ; |
| 924 | |
| 925 | /// What preset `n` switches off relative to speed 0, for a gate or a bench row |
| 926 | /// to print (class `gate-blind-to-feature`: a preset that silently disables |
| 927 | /// nothing is a preset that buys nothing). |
| 928 | |
| 929 | |
| 930 | |
| 931 | |
| 932 | |
| 933 | |
| 934 | |
| 935 | |
| 936 | |
| 937 | |
| 938 | |
| 939 | |
| 940 | |
| 941 | |
| 942 | |
| 943 | |
| 944 | |
| 945 | |
| 946 | |
| 947 | |
| 948 | |
| 949 | |
| 950 | |
| 951 | |
| 952 | |
| 953 | |
| 954 | |
| 955 | |
| 956 | |
| 957 | |
| 958 | |
| 959 | |
| 960 | |
| 961 | |
| 962 | |
| 963 | |
| 964 | |
| 965 | |
| 966 | |
| 967 | |
| 968 | |
| 969 | |
| 970 | |
| 971 | |
| 972 | |
| 973 | |
| 974 | |
| 975 | |
| 976 | |
| 977 | |
| 978 | |
| 979 | |
| 980 | |
| 981 | |
| 982 | |
| 983 | |
| 984 | |
| 985 | |
| 986 | |
| 987 | |
| 988 | |
| 989 | |
| 990 | |
| 991 | // --------------------------------------------------------------------------- |
| 992 | // Test-only serialisation of the process-global encoder knobs (lane-gaterace) |
| 993 | // --------------------------------------------------------------------------- |
| 994 | |
| 995 | /// [`SPEED`] and [`crate::par::TILE_THREADS`] are PROCESS-global, so a test |
| 996 | /// that stores one of them changes what every test encoding concurrently on |
| 997 | /// another test thread codes: with the default `--test-threads`, |
| 998 | /// `every_speed_preset_decodes_sample_exact_through_both_decoders` (presets |
| 999 | /// 0..=10) and the `tile_*`/`filter_stage_*` wall tables poisoned five of the |
| 1000 | /// ignored `encoder::` gates, each of which passes standalone. The rule is |
| 1001 | /// reader/writer, not a plain mutex: a test that SETS a knob holds |
| 1002 | /// [`knob_write`] for its whole body, and every test that ENCODES (i.e. reads |
| 1003 | /// the knobs, over more than one call) holds [`knob_read`], so a setter never |
| 1004 | /// overlaps an encode. Poison is ignored deliberately -- one failing gate |
| 1005 | /// must not turn every later one into a lock panic. |
| 1006 | |
| 1007 | static KNOBS: RwLock = new; |
| 1008 | |
| 1009 | /// Held by a test that reads the process-global knobs; see [`KNOBS`]. |
| 1010 | |
| 1011 | pub |
| 1012 | |
| 1013 | |
| 1014 | |
| 1015 | |
| 1016 | |
| 1017 | /// Held by a test that SETS a process-global knob; see [`KNOBS`]. |
| 1018 | |
| 1019 | pub |
| 1020 | |
| 1021 | |
| 1022 | |
| 1023 | |
| 1024 | |
| 1025 | |
| 1026 | |
| 1027 | |
| 1028 | |
| 1029 | |
| 1030 | |
| 1031 | |
| 1032 | |
| 1033 | |
| 1034 | |
| 1035 | |
| 1036 | |
| 1037 | |
| 1038 | |
| 1039 | |
| 1040 | |
| 1041 | |
| 1042 | |
| 1043 | |
| 1044 | |
| 1045 | |
| 1046 | |
| 1047 | |
| 1048 | |
| 1049 | |
| 1050 | |
| 1051 | |
| 1052 | |
| 1053 | |
| 1054 | |
| 1055 | |
| 1056 | |
| 1057 | |
| 1058 | |
| 1059 | |
| 1060 |