diff --git a/crates/ec-opus/tests/conformance.rs b/crates/ec-opus/tests/conformance.rs index fed2c898..87c804eb 100644 --- a/crates/ec-opus/tests/conformance.rs +++ b/crates/ec-opus/tests/conformance.rs @@ -5734,6 +5734,18 @@ fn analysis_music_prob_separates_speech_from_music() { ("reell", "~/Music/reell.mp4", true), ("reelo", "~/Music/reelo.mp3", true), ]; + // Oracle: libopus v1.6 built from source with one fprintf of `analysis_info` + // after `run_analysis()` in `opus_encode_native`, fed the same 30 s of + // ffmpeg-decoded f32 at the same settings, 1498-1499 valid windows each. + // Means of (music_prob, tonality, tonality_slope, activity). + let oracle = |tag: &str| -> Option<[f64; 4]> { + match tag { + "hein" => Some([0.160, 0.155, -0.0876, 0.567]), + "reell" => Some([0.991, 0.362, -0.1680, 0.701]), + "reelo" => Some([0.977, 0.313, -0.1333, 0.735]), + _ => None, + } + }; let mut means: Vec<(String, bool, f64)> = Vec::new(); for (tag, path, is_music) in sources { let src = shellexpand(path); @@ -5746,7 +5758,7 @@ fn analysis_music_prob_separates_speech_from_music() { enc.set_bitrate(96_000); enc.set_vbr_constrained(true); let mut out = vec![0u8; 4000]; - let mut sum = 0.0f64; + let mut sum = [0.0f64; 4]; let mut n = 0usize; let mut valid = 0usize; for chunk in pcm.chunks_exact(FRAME * CHANNELS) { @@ -5755,13 +5767,32 @@ fn analysis_music_prob_separates_speech_from_music() { n += 1; if d.analysis_valid { valid += 1; - sum += f64::from(d.music_prob); + sum[0] += f64::from(d.music_prob); + sum[1] += f64::from(d.tonality); + sum[2] += f64::from(d.tonality_slope); + sum[3] += f64::from(d.activity); } } assert!(valid * 10 > n * 9, "{tag}: analysis valid on only {valid}/{n} frames"); - let mean = sum / valid as f64; - println!("music_prob {tag}: mean {mean:.3} over {valid}/{n} frames (music={is_music})"); - means.push(((*tag).to_string(), *is_music, mean)); + let m = sum.map(|v| v / valid as f64); + println!( + "analysis {tag}: music {:.3} tonality {:.3} slope {:.4} activity {:.3} over {valid}/{n} frames (music={is_music})", + m[0], m[1], m[2], m[3] + ); + if let Some(o) = oracle(tag) { + for (i, name) in ["music_prob", "tonality", "tonality_slope", "activity"] + .iter() + .enumerate() + { + assert!( + (m[i] - o[i]).abs() < 0.02, + "{tag} {name}: ours {:.4} vs libopus {:.4}", + m[i], + o[i] + ); + } + } + means.push(((*tag).to_string(), *is_music, m[0])); } if means.len() < 2 { eprintln!("SKIP: fewer than two sources present"); diff --git a/lanes/opus-opustonal-r1.sweep.txt b/lanes/opus-opustonal-r1.sweep.txt new file mode 100644 index 00000000..cbe888fe --- /dev/null +++ b/lanes/opus-opustonal-r1.sweep.txt @@ -0,0 +1,15 @@ +# ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1) +# both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo +# 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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 diff --git a/lanes/opus-opustonal-r2.sweep.txt b/lanes/opus-opustonal-r2.sweep.txt new file mode 100644 index 00000000..425f24e4 --- /dev/null +++ b/lanes/opus-opustonal-r2.sweep.txt @@ -0,0 +1,15 @@ +# ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1) +# both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo +# 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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 diff --git a/lanes/opus-opustonal-r3.sweep.txt b/lanes/opus-opustonal-r3.sweep.txt new file mode 100644 index 00000000..d91d6856 --- /dev/null +++ b/lanes/opus-opustonal-r3.sweep.txt @@ -0,0 +1,15 @@ +# ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1) +# both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo +# 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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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