The top ARF tpl split ships at 2 past neighbours, and its budget is its own knob
Browse files at this commit2f91c3bdfeddd323912d268c084c218b723a7af1Parent: 54de485- feat
- the top ARF tpl split ships at 2 past neighbours, and its budget is its own knob
2 changed files +56 -3
- crates/ec-av1/src/encoder.rs +28 -3
- crates/ec-av1/src/speed.rs +28 -0
crates/ec-av1/src/encoder.rsmodified+28 -3
| @@ -1298,6 +1298,31 @@ pub(crate) fn tpl_fut() -> usize { | |||
| 1298 | .unwrap_or_else(|| crate::speed::at(&crate::speed::TPL_FUT)) | 1298 | .unwrap_or_else(|| crate::speed::at(&crate::speed::TPL_FUT)) |
| 1299 | } | 1299 | } |
| 1300 | 1300 | ||
| 1301 | +/// lane-tplhalf: mode 2's split -- how many display-PAST neighbours the top | ||
| 1302 | +/// ARF's window opens with, the rest of the budget coming from the buffered | ||
| 1303 | +/// future ([`crate::speed::TPL_FUT_HALF`], `EC_AV1_TPL_FUT_HALF=<n>`). | ||
| 1304 | +pub(crate) fn tpl_fut_half() -> usize { | ||
| 1305 | + std::env::var("EC_AV1_TPL_FUT_HALF") | ||
| 1306 | + .ok() | ||
| 1307 | + .and_then(|v| v.parse().ok()) | ||
| 1308 | + .unwrap_or_else(|| crate::speed::at(&crate::speed::TPL_FUT_HALF)) | ||
| 1309 | +} | ||
| 1310 | + | ||
| 1311 | +/// lane-tplhalf: how many entries mode 2's window holds in total, `0` meaning | ||
| 1312 | +/// `tpl_depth() - 1` -- the ARF window's budget alone, so raising it does not | ||
| 1313 | +/// deepen every other frame's lambda pass the way `EC_AV1_TPL_D` does | ||
| 1314 | +/// ([`crate::speed::TPL_FUT_WIN`], `EC_AV1_TPL_FUT_WIN=<n>`). | ||
| 1315 | +pub(crate) fn tpl_fut_win(depth: usize) -> usize { | ||
| 1316 | + match std::env::var("EC_AV1_TPL_FUT_WIN") | ||
| 1317 | + .ok() | ||
| 1318 | + .and_then(|v| v.parse().ok()) | ||
| 1319 | + .unwrap_or_else(|| crate::speed::at(&crate::speed::TPL_FUT_WIN)) | ||
| 1320 | + { | ||
| 1321 | + 0 => depth - 1, | ||
| 1322 | + n => n, | ||
| 1323 | + } | ||
| 1324 | +} | ||
| 1325 | + | ||
| 1301 | /// lane-lookahead: whether the pyramid path holds one group of lookahead | 1326 | /// lane-lookahead: whether the pyramid path holds one group of lookahead |
| 1302 | /// ([`crate::speed::LOOKAHEAD`], `EC_AV1_LOOKAHEAD=0|1`). | 1327 | /// ([`crate::speed::LOOKAHEAD`], `EC_AV1_LOOKAHEAD=0|1`). |
| 1303 | fn lookahead() -> bool { | 1328 | fn lookahead() -> bool { |
| @@ -2253,10 +2278,10 @@ impl Av1Encoder { | |||
| 2253 | // the nearest past and the nearest future neighbour spans the | 2278 | // the nearest past and the nearest future neighbour spans the |
| 2254 | // whole group), which is the arm's known cost. | 2279 | // whole group), which is the arm's known cost. |
| 2255 | (2, _, _) => { | 2280 | (2, _, _) => { |
| 2256 | - let half = std::env::var("EC_AV1_TPL_FUT_HALF").ok().and_then(|v| v.parse().ok()).unwrap_or((depth - 1) / 2); | 2281 | + let budget = tpl_fut_win(depth); |
| 2257 | let mut w = past(); | 2282 | let mut w = past(); |
| 2258 | - w.truncate(half.max(1)); | 2283 | + w.truncate(tpl_fut_half().max(1)); |
| 2259 | - let room = (depth - 1).saturating_sub(w.len()); | 2284 | + let room = budget.saturating_sub(w.len()); |
| 2260 | w.extend(arf_tpl_future(room)); | 2285 | w.extend(arf_tpl_future(room)); |
| 2261 | w | 2286 | w |
| 2262 | } | 2287 | } |
crates/ec-av1/src/speed.rsmodified+28 -0
| @@ -515,6 +515,34 @@ pub(crate) const LOOKAHEAD: bool = true; | |||
| 515 | /// +-0.3) at +3.2% / +0.2% wall. | 515 | /// +-0.3) at +3.2% / +0.2% wall. |
| 516 | pub(crate) const TPL_FUT: [usize; 11] = [2; 11]; | 516 | pub(crate) const TPL_FUT: [usize; 11] = [2; 11]; |
| 517 | 517 | ||
| 518 | +/// lane-tplhalf: mode 2's SPLIT -- how many display-PAST neighbours the top | ||
| 519 | +/// ARF's window opens with; the rest of [`TPL_FUT_WIN`] comes from the | ||
| 520 | +/// buffered future. `EC_AV1_TPL_FUT_HALF=<n>` overrides it, and the value is | ||
| 521 | +/// clamped up to 1 (a zero past half is mode 1, refuted). | ||
| 522 | +/// | ||
| 523 | +/// Swept on the 48-picture long-GOP gate at `TPL_DEPTH = 8` (budget 7), | ||
| 524 | +/// BD-rate vs libaom / vs rav1e, lower better: | ||
| 525 | +/// | ||
| 526 | +/// | past half | film A | film B | wall A | wall B | | ||
| 527 | +/// |---|---|---|---|---| | ||
| 528 | +/// | 1 (6 future) | +21.1/-8.9 | +71.2/-1.9 | 548.5s | 429.1s | | ||
| 529 | +/// | **2 (5 future, ships)** | **+20.9/-9.0** | **+71.0/-1.8** | 551.3s | 442.3s | | ||
| 530 | +/// | 3 (4 future, the old default) | +21.1/-8.9 | +71.5/-1.5 | 547.0s | 423.0s | | ||
| 531 | +/// | 5 (2 future) | +21.1/-8.9 | +71.5/-1.6 | 561.8s | 438.6s | | ||
| 532 | +/// | ||
| 533 | +/// Bracketed on both sides: 2 is down on all four columns against 3, and 1 | ||
| 534 | +/// and 5 are both worse than it. Presets 3..6 run `TPL_DEPTH = 4`, where the | ||
| 535 | +/// old `(depth-1)/2` split was 1 -- left there, unswept. | ||
| 536 | +pub(crate) const TPL_FUT_HALF: [usize; 11] = [2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1]; | ||
| 537 | + | ||
| 538 | +/// lane-tplhalf: how many entries mode 2's window holds in TOTAL, `0` meaning | ||
| 539 | +/// `encode::tpl_depth() - 1` (the budget every other tpl path uses). | ||
| 540 | +/// `EC_AV1_TPL_FUT_WIN=<n>` overrides it. It exists because the winning split | ||
| 541 | +/// takes its whole future side from the budget's edge, so the budget had to | ||
| 542 | +/// be tested apart from it (class `instrument at bound`) -- and apart from | ||
| 543 | +/// `EC_AV1_TPL_D`, which deepens EVERY frame's lambda pass, not the ARF's. | ||
| 544 | +pub(crate) const TPL_FUT_WIN: [usize; 11] = [0; 11]; | ||
| 545 | + | ||
| 518 | /// lane-arfpred: the qindex below which the ARF temporal filter is OFF -- | 546 | /// lane-arfpred: the qindex below which the ARF temporal filter is OFF -- |
| 519 | /// libaom scales `arnr` strength with the quantizer and stops filtering at | 547 | /// libaom scales `arnr` strength with the quantizer and stops filtering at |
| 520 | /// the high-quality end for the same reason: a picture we are about to | 548 | /// the high-quality end for the same reason: a picture we are about to |