forge
Explore
Log in

Don't you dare go Hollow

Print the analysis bandwidth histogram in the diagnostics test

Browse files at this commit

38347b4d307e9eca2070e10c098dad41d71db7dfAhmet Kaan GümüşParent: 7e58ade
  • test
    • print the analysis bandwidth histogram in the diagnostics test
Show full message
test(opus): print the analysis bandwidth histogram in the diagnostics test

The detected-bandwidth clamp needs analysis.bandwidth <= 18 to do
anything; on every gate source it is 20 on every valid frame (hein
20:1500, reell 20:1498, reelo 20:1499), which is why EC_OPUS_BW_DETECT
reproduces the shipped rows byte for byte.
crates/ec-opus/tests/conformance.rsmodified+11 -0
@@ -5765,6 +5765,9 @@ fn analysis_music_prob_separates_speech_from_music() {
5765 let mut sum = [0.0f64; 4];5765 let mut sum = [0.0f64; 4];
5766 let mut n = 0usize;5766 let mut n = 0usize;
5767 let mut valid = 0usize;5767 let mut valid = 0usize;
5768+ // Histogram of the detected bandwidth index, which drives
5769+ // `opus_encoder.c`'s `detected_bandwidth` clamp.
5770+ let mut bw_hist = [0u32; 21];
5768 for chunk in pcm.chunks_exact(FRAME * CHANNELS) {5771 for chunk in pcm.chunks_exact(FRAME * CHANNELS) {
5769 enc.encode_float(chunk, FRAME, &mut out).expect("encode");5772 enc.encode_float(chunk, FRAME, &mut out).expect("encode");
5770 let d = enc.last_celt_diag();5773 let d = enc.last_celt_diag();
@@ -5775,9 +5778,17 @@ fn analysis_music_prob_separates_speech_from_music() {
5775 sum[1] += f64::from(d.tonality);5778 sum[1] += f64::from(d.tonality);
5776 sum[2] += f64::from(d.tonality_slope);5779 sum[2] += f64::from(d.tonality_slope);
5777 sum[3] += f64::from(d.activity);5780 sum[3] += f64::from(d.activity);
5781+ bw_hist[(d.analysis_bandwidth.clamp(0, 20)) as usize] += 1;
5778 }5782 }
5779 }5783 }
5780 assert!(valid * 10 > n * 9, "{tag}: analysis valid on only {valid}/{n} frames");5784 assert!(valid * 10 > n * 9, "{tag}: analysis valid on only {valid}/{n} frames");
5785+ let bw: Vec<String> = bw_hist
5786+ .iter()
5787+ .enumerate()
5788+ .filter(|&(_, &c)| c > 0)
5789+ .map(|(i, c)| format!("{i}:{c}"))
5790+ .collect();
5791+ println!("analysis {tag}: bandwidth histogram {}", bw.join(" "));
5781 let m = sum.map(|v| v / valid as f64);5792 let m = sum.map(|v| v / valid as f64);
5782 println!(5793 println!(
5783 "analysis {tag}: music {:.3} tonality {:.3} slope {:.4} activity {:.3} over {valid}/{n} frames (music={is_music})",5794 "analysis {tag}: music {:.3} tonality {:.3} slope {:.4} activity {:.3} over {valid}/{n} frames (music={is_music})",
lanes/opus-opusmode-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.9887 0.9864 -0.0024 -95.23 -154.78 0.708 0.9766 0.9745 0 0
5+nik 96 100.9 101.0 -0.1 0.9947 0.9940 -0.0007 -29.86 -31.55 0.985 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.9834 0.9794 -0.0040 -365.72 -339.00 1.103 0.9477 0.9406 0 0
9+her 96 101.0 101.5 -0.5 0.9914 0.9902 -0.0012 -202.07 -191.50 1.051 0.9728 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.9856 0.9804 0 0
12+dl8a 64 65.7 65.8 -0.1 0.9889 0.9865 -0.0025 -227.54 -378.84 0.552 0.9787 0.9723 0 0
13+dl8a 96 96.5 96.8 -0.3 0.9942 0.9934 -0.0009 -177.70 -423.47 0.374 0.9881 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.91 -246.46 0.528 0.9689 0.9499 0 0