forge
Explore
Log in

Don't you dare go Hollow

Pin the ported analysis against a patched-libopus trace (music/tonality/slope/activity means)

Browse files at this commit

8d3a184deaf2503816111646b7ae5c40a0a86706Ahmet Kaan GümüşParent: 2d08e3d
  • test
    • pin the ported analysis against a patched-libopus trace (music/tonality/slope/activity means)
Show full message
test(opus): pin the ported analysis against a patched-libopus trace (music/tonality/slope/activity means)
crates/ec-opus/tests/conformance.rsmodified+36 -5
@@ -5734,6 +5734,18 @@ fn analysis_music_prob_separates_speech_from_music() {
5734 ("reell", "~/Music/reell.mp4", true),5734 ("reell", "~/Music/reell.mp4", true),
5735 ("reelo", "~/Music/reelo.mp3", true),5735 ("reelo", "~/Music/reelo.mp3", true),
5736 ];5736 ];
5737+ // Oracle: libopus v1.6 built from source with one fprintf of `analysis_info`
5738+ // after `run_analysis()` in `opus_encode_native`, fed the same 30 s of
5739+ // ffmpeg-decoded f32 at the same settings, 1498-1499 valid windows each.
5740+ // Means of (music_prob, tonality, tonality_slope, activity).
5741+ let oracle = |tag: &str| -> Option<[f64; 4]> {
5742+ match tag {
5743+ "hein" => Some([0.160, 0.155, -0.0876, 0.567]),
5744+ "reell" => Some([0.991, 0.362, -0.1680, 0.701]),
5745+ "reelo" => Some([0.977, 0.313, -0.1333, 0.735]),
5746+ _ => None,
5747+ }
5748+ };
5737 let mut means: Vec<(String, bool, f64)> = Vec::new();5749 let mut means: Vec<(String, bool, f64)> = Vec::new();
5738 for (tag, path, is_music) in sources {5750 for (tag, path, is_music) in sources {
5739 let src = shellexpand(path);5751 let src = shellexpand(path);
@@ -5746,7 +5758,7 @@ fn analysis_music_prob_separates_speech_from_music() {
5746 enc.set_bitrate(96_000);5758 enc.set_bitrate(96_000);
5747 enc.set_vbr_constrained(true);5759 enc.set_vbr_constrained(true);
5748 let mut out = vec![0u8; 4000];5760 let mut out = vec![0u8; 4000];
5749- let mut sum = 0.0f64;5761+ let mut sum = [0.0f64; 4];
5750 let mut n = 0usize;5762 let mut n = 0usize;
5751 let mut valid = 0usize;5763 let mut valid = 0usize;
5752 for chunk in pcm.chunks_exact(FRAME * CHANNELS) {5764 for chunk in pcm.chunks_exact(FRAME * CHANNELS) {
@@ -5755,13 +5767,32 @@ fn analysis_music_prob_separates_speech_from_music() {
5755 n += 1;5767 n += 1;
5756 if d.analysis_valid {5768 if d.analysis_valid {
5757 valid += 1;5769 valid += 1;
5758- sum += f64::from(d.music_prob);5770+ sum[0] += f64::from(d.music_prob);
5771+ sum[1] += f64::from(d.tonality);
5772+ sum[2] += f64::from(d.tonality_slope);
5773+ sum[3] += f64::from(d.activity);
5759 }5774 }
5760 }5775 }
5761 assert!(valid * 10 > n * 9, "{tag}: analysis valid on only {valid}/{n} frames");5776 assert!(valid * 10 > n * 9, "{tag}: analysis valid on only {valid}/{n} frames");
5762- let mean = sum / valid as f64;5777+ let m = sum.map(|v| v / valid as f64);
5763- println!("music_prob {tag}: mean {mean:.3} over {valid}/{n} frames (music={is_music})");5778+ println!(
5764- means.push(((*tag).to_string(), *is_music, mean));5779+ "analysis {tag}: music {:.3} tonality {:.3} slope {:.4} activity {:.3} over {valid}/{n} frames (music={is_music})",
5780+ m[0], m[1], m[2], m[3]
5781+ );
5782+ if let Some(o) = oracle(tag) {
5783+ for (i, name) in ["music_prob", "tonality", "tonality_slope", "activity"]
5784+ .iter()
5785+ .enumerate()
5786+ {
5787+ assert!(
5788+ (m[i] - o[i]).abs() < 0.02,
5789+ "{tag} {name}: ours {:.4} vs libopus {:.4}",
5790+ m[i],
5791+ o[i]
5792+ );
5793+ }
5794+ }
5795+ means.push(((*tag).to_string(), *is_music, m[0]));
5765 }5796 }
5766 if means.len() < 2 {5797 if means.len() < 2 {
5767 eprintln!("SKIP: fewer than two sources present");5798 eprintln!("SKIP: fewer than two sources present");
lanes/opus-opustonal-r1.sweep.txtadded+15 -0
@@ -0,0 +1,15 @@
1+# ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1)
2+# both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo
3+# source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap Q_ours Q_ref err_ratio minsec_ours minsec_ref drop_ours drop_ref
4+nik 64 69.1 69.2 -0.1 0.9880 0.9864 -0.0017 -81.62 -154.78 0.647 0.9762 0.9745 0 0
5+nik 96 100.9 101.0 -0.1 0.9943 0.9940 -0.0002 -32.19 -31.55 1.006 0.9882 0.9888 0 0
6+reelo 64 63.6 63.6 -0.0 0.9892 0.9866 -0.0026 -135.40 -123.36 1.071 0.9701 0.9686 0 0
7+reelo 96 93.4 93.9 -0.5 0.9946 0.9937 -0.0008 -107.07 -125.18 0.898 0.9861 0.9854 0 0
8+her 64 67.7 67.9 -0.4 0.9829 0.9794 -0.0035 -367.34 -339.00 1.109 0.9468 0.9406 0 0
9+her 96 101.0 101.5 -0.5 0.9911 0.9902 -0.0009 -208.79 -191.50 1.085 0.9720 0.9728 0 0
10+reell 64 71.3 71.3 -0.0 0.9903 0.9880 -0.0023 -369.03 -128.39 2.872 0.9712 0.9644 0 0
11+reell 96 105.3 105.4 -0.0 0.9953 0.9948 -0.0005 -165.27 -29.16 2.458 0.9847 0.9804 0 0
12+dl8a 64 65.7 65.8 -0.1 0.9882 0.9865 -0.0017 -210.74 -378.84 0.512 0.9781 0.9723 0 0
13+dl8a 96 96.5 96.8 -0.3 0.9938 0.9934 -0.0004 -156.76 -423.47 0.336 0.9874 0.9864 0 0
14+hein 64 64.8 64.9 -0.2 0.9888 0.9874 -0.0014 -344.06 -388.31 0.853 0.9318 0.9148 0 0
15+hein 96 86.8 86.9 -0.2 0.9946 0.9930 -0.0016 -117.93 -246.46 0.528 0.9689 0.9499 0 0
lanes/opus-opustonal-r2.sweep.txtadded+15 -0
@@ -0,0 +1,15 @@
1+# ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1)
2+# both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo
3+# source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap Q_ours Q_ref err_ratio minsec_ours minsec_ref drop_ours drop_ref
4+nik 64 69.0 69.2 -0.3 0.9887 0.9864 -0.0023 -87.41 -154.78 0.672 0.9772 0.9745 0 0
5+nik 96 100.8 101.0 -0.2 0.9947 0.9940 -0.0007 -38.39 -31.55 1.061 0.9891 0.9888 0 0
6+reelo 64 63.3 63.6 -0.4 0.9892 0.9866 -0.0026 -202.87 -123.36 1.510 0.9678 0.9686 0 0
7+reelo 96 92.8 93.9 -1.1 0.9945 0.9937 -0.0008 -152.87 -125.18 1.165 0.9845 0.9854 0 0
8+her 64 67.4 67.9 -0.7 0.9833 0.9794 -0.0039 -366.15 -339.00 1.104 0.9477 0.9406 0 0
9+her 96 100.3 101.5 -1.2 0.9912 0.9902 -0.0010 -203.77 -191.50 1.060 0.9729 0.9728 0 0
10+reell 64 71.3 71.3 -0.0 0.9908 0.9880 -0.0028 -351.70 -128.39 2.697 0.9716 0.9644 0 0
11+reell 96 105.3 105.4 -0.0 0.9956 0.9948 -0.0008 -301.83 -29.16 4.499 0.9850 0.9804 0 0
12+dl8a 64 65.6 65.8 -0.3 0.9888 0.9865 -0.0024 -223.26 -378.84 0.541 0.9796 0.9723 0 0
13+dl8a 96 96.5 96.8 -0.4 0.9942 0.9934 -0.0008 -198.74 -423.47 0.414 0.9882 0.9864 0 0
14+hein 64 64.6 64.9 -0.4 0.9887 0.9874 -0.0014 -129.55 -388.31 0.327 0.9287 0.9148 0 0
15+hein 96 86.7 86.9 -0.2 0.9946 0.9930 -0.0016 -84.08 -246.46 0.426 0.9680 0.9499 0 0
lanes/opus-opustonal-r3.sweep.txtadded+15 -0
@@ -0,0 +1,15 @@
1+# ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1)
2+# both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo
3+# source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap Q_ours Q_ref err_ratio minsec_ours minsec_ref drop_ours drop_ref
4+nik 64 69.1 69.2 -0.1 0.9887 0.9864 -0.0024 -83.85 -154.78 0.657 0.9766 0.9745 0 0
5+nik 96 101.0 101.0 -0.0 0.9947 0.9940 -0.0007 -30.46 -31.55 0.990 0.9889 0.9888 0 0
6+reelo 64 63.6 63.6 -0.0 0.9893 0.9866 -0.0027 -202.82 -123.36 1.510 0.9702 0.9686 0 0
7+reelo 96 93.4 93.9 -0.5 0.9947 0.9937 -0.0009 -114.74 -125.18 0.940 0.9862 0.9854 0 0
8+her 64 67.7 67.9 -0.4 0.9835 0.9794 -0.0040 -366.02 -339.00 1.104 0.9480 0.9406 0 0
9+her 96 101.1 101.5 -0.4 0.9914 0.9902 -0.0012 -206.12 -191.50 1.071 0.9729 0.9728 0 0
10+reell 64 71.3 71.3 -0.0 0.9908 0.9880 -0.0029 -351.70 -128.39 2.697 0.9721 0.9644 0 0
11+reell 96 105.3 105.4 -0.0 0.9956 0.9948 -0.0008 -301.83 -29.16 4.499 0.9855 0.9804 0 0
12+dl8a 64 65.7 65.8 -0.2 0.9890 0.9865 -0.0025 -210.46 -378.84 0.511 0.9788 0.9723 0 0
13+dl8a 96 96.6 96.8 -0.3 0.9943 0.9934 -0.0009 -181.52 -423.47 0.382 0.9882 0.9864 0 0
14+hein 64 64.7 64.9 -0.3 0.9893 0.9874 -0.0020 -181.35 -388.31 0.430 0.9348 0.9148 0 0
15+hein 96 86.7 86.9 -0.3 0.9949 0.9930 -0.0018 -77.72 -246.46 0.408 0.9707 0.9499 0 0