Gate the O(windows*4001*4096) whole-file drift search behind EC_AAC_SBR_TIMELINE
Browse files at this commitf6d8fb3b0bab5faa06e3127500de3a03cc7483c4Parent: 3a95342- test
- gate the O(windows*4001*4096) whole-file drift search behind EC_AAC_SBR_TIMELINE
1 changed file +28 -1
crates/ec-aac/tests/sbr_real_library.rsmodified+28 -1
| @@ -1897,7 +1897,34 @@ fn sbr_real_library_matches_reference() { | |||
| 1897 | { | 1897 | { |
| 1898 | let avail = o.len().saturating_sub(oa).min(t.len().saturating_sub(ob)); | 1898 | let avail = o.len().saturating_sub(oa).min(t.len().saturating_sub(ob)); |
| 1899 | let windows = avail / 4_096; | 1899 | let windows = avail / 4_096; |
| 1900 | - let timeline = windowed_lag_drift(o, t, oa, ob, windows); | 1900 | + // The full per-window LOCAL_LAG=+-2000 search inside |
| 1901 | + // `windowed_lag_drift` costs O(windows * 4001 * 4096) and runs | ||
| 1902 | + // ~4min/channel over a whole real-library file -- that walk | ||
| 1903 | + // is only needed when actually hunting for a drifting lag | ||
| 1904 | + // (EC_AAC_SBR_TIMELINE). By default this block instead reuses | ||
| 1905 | + // the already-established global `lag` with NO per-window | ||
| 1906 | + // search (O(windows * 4096)), which is cheap and still gives | ||
| 1907 | + // an honest whole-file windowed mean/min at that fixed lag. | ||
| 1908 | + let timeline: Vec<(i64, f64)> = | ||
| 1909 | + if std::env::var("EC_AAC_SBR_TIMELINE").is_ok() { | ||
| 1910 | + windowed_lag_drift(o, t, oa, ob, windows) | ||
| 1911 | + } else { | ||
| 1912 | + (0..windows) | ||
| 1913 | + .filter_map(|w| { | ||
| 1914 | + let base_o = (oa as i64 + lag + (w * 4_096) as i64) | ||
| 1915 | + .try_into() | ||
| 1916 | + .ok()?; | ||
| 1917 | + let base_t = ob + w * 4_096; | ||
| 1918 | + if base_o + 4_096 > o.len() || base_t + 4_096 > t.len() { | ||
| 1919 | + return None; | ||
| 1920 | + } | ||
| 1921 | + Some(( | ||
| 1922 | + lag, | ||
| 1923 | + correlation(&o[base_o..base_o + 4_096], &t[base_t..base_t + 4_096]), | ||
| 1924 | + )) | ||
| 1925 | + }) | ||
| 1926 | + .collect() | ||
| 1927 | + }; | ||
| 1901 | if std::env::var("EC_AAC_SBR_TIMELINE").is_ok() { | 1928 | if std::env::var("EC_AAC_SBR_TIMELINE").is_ok() { |
| 1902 | println!( | 1929 | println!( |
| 1903 | " ch{ch} TIMELINE ({windows} windows, {rate} Hz, window_idx@sec, local_lag, corr):" | 1930 | " ch{ch} TIMELINE ({windows} windows, {rate} Hz, window_idx@sec, local_lag, corr):" |