forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiBd0fd4cbTahinli6 days ago3979 commits

bench-rows-parity.py22 lines, 973 bytesHistoryRawDownload
1#!/usr/bin/env python3
2"""bench-rows-parity.py REF.f32 OUT.f32 CHANNELS: per-channel correlation of two
3interleaved float32 streams (ffmpeg reference vs the crate's output).
4Prints one line per channel and the sample counts. Run as: python3 -I <this file> ..."""
5import sys
6import numpy as np
7
8ref = np.fromfile(sys.argv[1], dtype="<f4")
9out = np.fromfile(sys.argv[2], dtype="<f4")
10ch = int(sys.argv[3])
11n = min(len(ref), len(out)) // ch * ch
12print(f"ref_samples={len(ref) // ch} out_samples={len(out) // ch} compared={n // ch}")
13r = ref[:n].reshape(-1, ch)
14o = out[:n].reshape(-1, ch)
15worst = 1.0
16for c in range(ch):
17 a, b = r[:, c].astype(np.float64), o[:, c].astype(np.float64)
18 corr = np.corrcoef(a, b)[0, 1] if a.std() > 0 and b.std() > 0 else float("nan")
19 err = np.max(np.abs(a - b))
20 worst = min(worst, corr)
21 print(f"ch{c} corr={corr:.6f} max_abs_err={err:.6f}")
22print(f"min_corr={worst:.6f} tolerance=0.999 {'PASS' if worst >= 0.999 else 'FAIL'}")