The native BD gate can price the references at their fast presets
Browse files at this commitfc10b78ce7003ca7b22987708bdd89eb4b2f6b86Parent: c29f173- test
- the native BD gate can price the references at their fast presets
2 changed files +184 -0
- crates/ec-av1/src/encode.rs +93 -0
- lanes/pareto2.md +91 -0
crates/ec-av1/src/encode.rsmodified+93 -0
| @@ -11930,6 +11930,20 @@ mod tests { | |||
| 11930 | present | 11930 | present |
| 11931 | } | 11931 | } |
| 11932 | 11932 | ||
| 11933 | + /// Whether this ffmpeg was built with `encoder` (lane-pareto2: the | ||
| 11934 | + /// SVT-AV1 Pareto rows are skipped, never failed, on a build without it). | ||
| 11935 | + fn have_encoder(encoder: &str) -> bool { | ||
| 11936 | + Command::new("ffmpeg") | ||
| 11937 | + .args(["-hide_banner", "-encoders"]) | ||
| 11938 | + .stderr(Stdio::null()) | ||
| 11939 | + .output() | ||
| 11940 | + .is_ok_and(|o| { | ||
| 11941 | + String::from_utf8_lossy(&o.stdout) | ||
| 11942 | + .lines() | ||
| 11943 | + .any(|l| l.split_whitespace().nth(1) == Some(encoder)) | ||
| 11944 | + }) | ||
| 11945 | + } | ||
| 11946 | + | ||
| 11933 | /// Decodes an AV1 OBU stream with ffmpeg and hands back the three planes. | 11947 | /// Decodes an AV1 OBU stream with ffmpeg and hands back the three planes. |
| 11934 | fn ffmpeg_decode(stream: &[u8], width: usize, height: usize) -> Picture { | 11948 | fn ffmpeg_decode(stream: &[u8], width: usize, height: usize) -> Picture { |
| 11935 | let mut child = Command::new("ffmpeg") | 11949 | let mut child = Command::new("ffmpeg") |
| @@ -16698,6 +16712,85 @@ mod tests { | |||
| 16698 | bd_rate(&aom, &ours) * 100.0, | 16712 | bd_rate(&aom, &ours) * 100.0, |
| 16699 | bd_rate(&rav1e, &ours) * 100.0, | 16713 | bd_rate(&rav1e, &ours) * 100.0, |
| 16700 | ); | 16714 | ); |
| 16715 | + // lane-pareto2: the two references at THEIR fast presets, plus | ||
| 16716 | + // SVT-AV1, measured in the SAME arm as the row above -- the only | ||
| 16717 | + // way the wall column of a Pareto table means anything (class: | ||
| 16718 | + // wall tables are comparable only inside one interleaved batch). | ||
| 16719 | + // `EC_AV1_PARETO_REFS=1` only: it roughly doubles the arm. | ||
| 16720 | + if std::env::var("EC_AV1_PARETO_REFS").ok().as_deref() == Some("1") { | ||
| 16721 | + let rav1e_at = |sp: u32| -> Vec<Vec<String>> { | ||
| 16722 | + [50, 100, 150, 200] | ||
| 16723 | + .iter() | ||
| 16724 | + .map(|q| { | ||
| 16725 | + vec![ | ||
| 16726 | + "-rav1e-params".to_string(), | ||
| 16727 | + format!( | ||
| 16728 | + "speed={sp}:quantizer={q}:tile_cols=1:tile_rows=1:threads=1" | ||
| 16729 | + ), | ||
| 16730 | + ] | ||
| 16731 | + }) | ||
| 16732 | + .collect() | ||
| 16733 | + }; | ||
| 16734 | + let aom_at = |cu: u32| -> Vec<Vec<String>> { | ||
| 16735 | + [5, 20, 35, 45] | ||
| 16736 | + .iter() | ||
| 16737 | + .map(|q| { | ||
| 16738 | + vec![ | ||
| 16739 | + "-cpu-used".to_string(), | ||
| 16740 | + cu.to_string(), | ||
| 16741 | + "-b:v".to_string(), | ||
| 16742 | + "0".to_string(), | ||
| 16743 | + "-crf".to_string(), | ||
| 16744 | + q.to_string(), | ||
| 16745 | + ] | ||
| 16746 | + }) | ||
| 16747 | + .collect() | ||
| 16748 | + }; | ||
| 16749 | + let svt_at = |pr: u32| -> Vec<Vec<String>> { | ||
| 16750 | + [20, 35, 45, 55] | ||
| 16751 | + .iter() | ||
| 16752 | + .map(|q| { | ||
| 16753 | + vec![ | ||
| 16754 | + "-preset".to_string(), | ||
| 16755 | + pr.to_string(), | ||
| 16756 | + "-crf".to_string(), | ||
| 16757 | + q.to_string(), | ||
| 16758 | + "-svtav1-params".to_string(), | ||
| 16759 | + "lp=1".to_string(), | ||
| 16760 | + ] | ||
| 16761 | + }) | ||
| 16762 | + .collect() | ||
| 16763 | + }; | ||
| 16764 | + let mut arms: Vec<(String, &str, Vec<Vec<String>>)> = vec![ | ||
| 16765 | + ("rav1e speed 8".into(), "librav1e", rav1e_at(8)), | ||
| 16766 | + ("rav1e speed 10".into(), "librav1e", rav1e_at(10)), | ||
| 16767 | + ("libaom cpu-used 8".into(), "libaom-av1", aom_at(8)), | ||
| 16768 | + ]; | ||
| 16769 | + if have_encoder("libsvtav1") { | ||
| 16770 | + arms.push(("svt-av1 preset 8".into(), "libsvtav1", svt_at(8))); | ||
| 16771 | + arms.push(("svt-av1 preset 10".into(), "libsvtav1", svt_at(10))); | ||
| 16772 | + } else { | ||
| 16773 | + eprintln!("SKIP the SVT-AV1 rows: this ffmpeg has no libsvtav1"); | ||
| 16774 | + } | ||
| 16775 | + for (label, encoder, points) in arms { | ||
| 16776 | + let (lad, wall) = external_ladder(&source, cw, ch, encoder, &points); | ||
| 16777 | + // A REFERENCE stream our decoder cannot read is a note in | ||
| 16778 | + // this table, not a gate failure: these rows exist to | ||
| 16779 | + // price the references, and `assert_ladder_decodes` keeps | ||
| 16780 | + // its teeth for the two ladders the keep table is read off. | ||
| 16781 | + let notes = | ||
| 16782 | + std::mem::take(&mut *LADDER_FAILURES.lock().expect("ladder failures")); | ||
| 16783 | + if !notes.is_empty() { | ||
| 16784 | + eprintln!("{name} {label}: {} point(s) our decoder could not read (reference row, not a gate failure)", notes.len()); | ||
| 16785 | + } | ||
| 16786 | + assert_monotone(&format!("{name}: {label}"), &lad); | ||
| 16787 | + println!( | ||
| 16788 | + "| {name} {cw}x{ch} / {label} | -- | {:+.1}% | {:+.1}% | {wall:.1}s (ours {ours_wall:.1}s, rav1e s6 {rav1e_wall:.1}s) |", | ||
| 16789 | + bd_rate(&aom, &lad) * 100.0, | ||
| 16790 | + bd_rate(&rav1e, &lad) * 100.0, | ||
| 16791 | + ); | ||
| 16792 | + } | ||
| 16793 | + } | ||
| 16701 | } | 16794 | } |
| 16702 | assert_ladder_decodes(); | 16795 | assert_ladder_decodes(); |
| 16703 | } | 16796 | } |
lanes/pareto2.mdadded+91 -0
| @@ -0,0 +1,91 @@ | |||
| 1 | +# lane-pareto2 -- working notes | ||
| 2 | + | ||
| 3 | +Head: f6c67770 (+ this lane). Box: 12 cores, TWO other lanes running throughout, | ||
| 4 | +load 9-25 (load 64 once, during the first fps sweep). Every arm is | ||
| 5 | +`encode::tests::bd_rate_screen_native` (12 frames, gop 12, four quantizers, | ||
| 6 | +1920x768 / 1920x1024 native crops, 1 tile, 1 thread), logs in | ||
| 7 | +`$HOME/.cache/pareto2/logs/`. | ||
| 8 | + | ||
| 9 | +RULE USED FOR WALL: BD is exact across runs (the same stream), wall is not. | ||
| 10 | +Phase-1 arms ran THREE at a time, so their wall is read only as the | ||
| 11 | +ours:rav1e-speed-6 ratio INSIDE one arm; the lever arms that decided a shipped | ||
| 12 | +row were re-run ONE at a time (`q5.tsv`). | ||
| 13 | + | ||
| 14 | +## Phase 1 -- the Pareto table, our presets (q1.tsv, 15 arms, all RC=0) | ||
| 15 | + | ||
| 16 | +BD-rate vs libaom `cpu-used 6` / vs rav1e `speed 6`; fps = 48 coded frames over | ||
| 17 | +our own ladder wall in that arm, `ratio` = ours:rav1e-s6 wall in the same arm. | ||
| 18 | + | ||
| 19 | +| preset | film A | film B | screen | ratio A/B/screen | 1-thread fps A/B/screen | | ||
| 20 | +|---|---|---|---|---|---| | ||
| 21 | +| 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 | | ||
| 22 | +| 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 | | ||
| 23 | +| 6 | +26.6 / -0.4 | +34.7 / +6.4 | +23.1 / -28.5 | 2.2 / 3.9 / 3.0 | 0.71 / 0.47 / 0.71 | | ||
| 24 | +| 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 | | ||
| 25 | +| 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 | | ||
| 26 | + | ||
| 27 | +## Phase 1b -- the references at THEIR fast presets, same arms (EC_AV1_PARETO_REFS=1) | ||
| 28 | + | ||
| 29 | +| row | encoder | vs libaom cpu-6 | vs rav1e s6 | ladder wall (rav1e s6 anchor in that arm) | | ||
| 30 | +|---|---|---|---|---| | ||
| 31 | +| film A | ours preset 6 | +26.6 | -0.4 | 67.6s (31.3s) | | ||
| 32 | +| film A | rav1e speed 8 | +29.0 | +2.0 | 24.1s | | ||
| 33 | +| film A | rav1e speed 10 | +45.3 | +17.1 | 8.4s | | ||
| 34 | +| film A | libaom cpu-used 8 | +0.0 | -20.1 | 15.4s | | ||
| 35 | +| film A | SVT-AV1 preset 8 | +24.1 | -1.9 | 2.4s | | ||
| 36 | +| film A | SVT-AV1 preset 10 | +45.3 | +12.1 | 2.0s | | ||
| 37 | +| film B | ours preset 6 | +34.7 | +6.4 | 103.0s (26.4s) | | ||
| 38 | +| film B | rav1e speed 8 | +37.3 | +3.5 | 20.5s | | ||
| 39 | +| film B | rav1e speed 10 | +61.4 | +28.7 | 10.5s | | ||
| 40 | +| film B | libaom cpu-used 8 | +0.0 | -22.2 | 32.3s | | ||
| 41 | +| film B | SVT-AV1 preset 8 | +41.7 | +7.4 | 2.9s | | ||
| 42 | +| film B | SVT-AV1 preset 10 | +65.9 | +23.3 | 2.0s | | ||
| 43 | +| screen | ours preset 6 | +23.1 | -28.5 | 68.0s (22.6s) | | ||
| 44 | +| screen | rav1e speed 8 | +84.2 | +4.5 | 13.8s | | ||
| 45 | +| screen | rav1e speed 10 | +332.5 | +103.4 | 9.8s | | ||
| 46 | +| screen | libaom cpu-used 8 | +0.0 | -42.4 | 17.6s | | ||
| 47 | +| screen | SVT-AV1 preset 8 | +21.5 | -31.6 | 5.0s | | ||
| 48 | +| screen | SVT-AV1 preset 10 | +39.4 | -24.5 | 1.9s | | ||
| 49 | + | ||
| 50 | +`libaom cpu-used 8` reads +0.0% against `cpu-used 6` on every row: this ffmpeg's | ||
| 51 | +libaom codes the SAME bytes at both (the old `lanes/pareto.md` run saw the same | ||
| 52 | +thing), so it is one point on the plot, not two. | ||
| 53 | + | ||
| 54 | +NOTE (open): one SVT-AV1 preset-8 screen point decodes one sample off through | ||
| 55 | +OUR decoder (`frame 0 plane Y sample 1471489: ours 53, ffmpeg 52`). Reference | ||
| 56 | +rows collect that as a note, not a gate failure; it is a real decoder finding. | ||
| 57 | + | ||
| 58 | +## Phase 2 -- per-lever re-price at preset 6, film A (q2.tsv, 21 arms, all RC=0) | ||
| 59 | + | ||
| 60 | +Control +26.6 / -0.4. "gain" = BD points the lever takes off the vs-rav1e column. | ||
| 61 | + | ||
| 62 | +| lever re-enabled at 6 | vs libaom / rav1e | gain | | ||
| 63 | +|---|---|---| | ||
| 64 | +| extra-reference NEWMV | +24.4 / -2.4 | 2.0 | | ||
| 65 | +| coefficient breakout 0 | +24.8 / -1.6 | 1.2 | | ||
| 66 | +| 8x8 split | +25.9 / -0.8 | 0.4 | | ||
| 67 | +| warp | +26.2 / -0.8 | 0.4 | | ||
| 68 | +| CfL | +26.2 / -0.7 | 0.3 | | ||
| 69 | +| chroma top-k off | +26.3 / -0.7 | 0.3 | | ||
| 70 | +| inter var-tx | +26.3 / -0.7 | 0.3 | | ||
| 71 | +| angle delta | +26.5 / -0.6 | 0.2 | | ||
| 72 | +| split-RD 0.125 | +26.4 / -0.6 | 0.2 | | ||
| 73 | +| inter-intra top-13 | +26.7 / -0.3 | 0.1 | | ||
| 74 | +| intra top-13 | +26.7 / -0.4 | 0.0 | | ||
| 75 | +| filter intra | +26.7 / -0.4 | 0.0 | | ||
| 76 | +| 32x32 tx depth | +26.6 / -0.4 | 0.0 (inert: inter tx select is off at 6) | | ||
| 77 | +| compound var-tx | +26.6 / -0.4 | 0.0 (same cause) | | ||
| 78 | +| loop restoration | +26.7 / -0.2 | -0.2 (worse) | | ||
| 79 | + | ||
| 80 | +| lever preset 6 KEEPS, disabled | vs libaom / rav1e | cost of losing it | | ||
| 81 | +|---|---|---| | ||
| 82 | +| RDOQ | +41.2 / +10.2 | 10.6 | | ||
| 83 | +| 64x64 inter root | +30.7 / +3.4 | 3.8 | | ||
| 84 | +| key 64x64 intra root | +28.0 / +0.9 | 1.3 | | ||
| 85 | +| tpl window 4 -> 1 | +27.0 / -0.3 | 0.1 | | ||
| 86 | +| per-SB delta_q | +27.2 / -0.2 | 0.2 | | ||
| 87 | + | ||
| 88 | +## Phase 3 -- wall of the two candidates, serial arms | ||
| 89 | + | ||
| 90 | +See `q3.tsv`/`q5.tsv` logs; the threaded fps sweep (`fps2.log`) is NOT usable at | ||
| 91 | +this box load -- preset 3 read slower than preset 0 in every pass. | ||