forge
Explore
Log in

Don't you dare go Hollow

Revert "ec-aac SBR: downsampled SBR (ext rate < 2*core, e.g. al_sbr_sr_48_2_fsaac48 ASC 11 90 56 e5 98) ran the 64-band doubling chain with band tables at the 48 kHz ext rate: ours 2048/AU and band-table errors (no sideinfo rows, ours 1001472 = cap at 489 AUs x 2048 vs ffmpeg 1148 x 1024). ffmpeg (aacsbr_template.c 1147/1683/1418): sbr->sample_rate = 2*core for tables, downsampled = ext_sample_rate < sbr->sample_rate -> 32-band synthesis with the decimated window (ds[n]=c[2n]), 32 output samples/slot. Fix: parser rate always 2*core, SbrChain::set_downsampled, Synthesis::downsampled (N=32, v 640, shift -0.5 matching our analysis phase; python replica of analysis->synth32 corr 0.995 at lag 289 vs 0.9967 for the 64-band pair), k2 clamped to 32, LFE bypass uses the same bank. Also QMF_WINDOW[384] and [512] had the wrong sign vs ffmpeg us/ds tables (ffmpeg flips at 385/513, mirror-symmetric with 128/256; ours at 384/512; table now equals ffmpeg's us and ds to 1e-10), pinned sum updated 81.46300943655164 -> 82.21187106118578. cargo check -p ec-aac --all-targets clean; tests not run"

Browse files at this commit

b3f487fceb15f7831f0ca37924b8e98e02287d6aAhmet Kaan GümüşParent: 0c091c3
This reverts commit d8db6262615fcd98c2b226b0357869639a98f115.
crates/ec-aac/src/decode.rsmodified+0 -8
@@ -582,14 +582,6 @@ impl BlockDecoder {
582 self.sbr = rate.map(crate::sbr_chain::SbrChain::new);582 self.sbr = rate.map(crate::sbr_chain::SbrChain::new);
583 }583 }
584 584
585- /// Marks the SBR output as downsampled: the extension rate is below twice
586- /// the core rate, so the synthesis stays at 32 bands.
587- pub fn set_sbr_downsampled(&mut self, on: bool) {
588- if let Some(sbr) = self.sbr.as_mut() {
589- sbr.set_downsampled(on);
590- }
591- }
592-
593 /// Marks Parametric Stereo as signalled by the config, for the SBR chain585 /// Marks Parametric Stereo as signalled by the config, for the SBR chain
594 /// (if one is armed): its elements then decode to two channels.586 /// (if one is armed): its elements then decode to two channels.
595 pub fn set_sbr_ps(&mut self, on: bool) {587 pub fn set_sbr_ps(&mut self, on: bool) {
crates/ec-aac/src/lib.rsmodified+2 -4
@@ -144,10 +144,8 @@ impl AacDecoder {
144 // SBR (and Parametric Stereo, for HE-AACv2) is reconstructed: the144 // SBR (and Parametric Stereo, for HE-AACv2) is reconstructed: the
145 // core is decoded first, then the extension-rate chain runs on it.145 // core is decoded first, then the extension-rate chain runs on it.
146 if cfg.sbr_present {146 if cfg.sbr_present {
147- let sbr_rate = cfg.sample_rate * 2;147+ let rate = cfg.extension_sample_rate.unwrap_or(cfg.sample_rate * 2);
148- let ext_rate = cfg.extension_sample_rate.unwrap_or(sbr_rate);148+ d.block.set_sbr_rate(Some(rate));
149- d.block.set_sbr_rate(Some(sbr_rate));
150- d.block.set_sbr_downsampled(ext_rate < sbr_rate);
151 d.block.set_sbr_ps(cfg.ps_present);149 d.block.set_sbr_ps(cfg.ps_present);
152 } else if !cfg.ps_present {150 } else if !cfg.ps_present {
153 // Plain AAC-LC config: an SBR payload may still follow (implicit signalling).151 // Plain AAC-LC config: an SBR payload may still follow (implicit signalling).
crates/ec-aac/src/sbr_chain.rsmodified+14 -33
@@ -237,14 +237,10 @@ struct Element {
237 }237 }
238 238
239 impl Element {239 impl Element {
240- fn ensure_channels(&mut self, need: usize, downsampled: bool) {240+ fn ensure_channels(&mut self, need: usize) {
241 while self.channels.len() < need {241 while self.channels.len() < need {
242 let seed = 0x1234_5678u32.wrapping_add(self.channels.len() as u32 * 0x9e37_79b9);242 let seed = 0x1234_5678u32.wrapping_add(self.channels.len() as u32 * 0x9e37_79b9);
243- let mut channel = ChannelState::new(1, seed);243+ self.channels.push(ChannelState::new(1, seed));
244- if downsampled {
245- channel.synthesis = Synthesis::downsampled();
246- }
247- self.channels.push(channel);
248 }244 }
249 }245 }
250 }246 }
@@ -258,7 +254,6 @@ const PS_SLOTS: usize = 32;
258 /// encoder in practice emits it).254 /// encoder in practice emits it).
259 pub struct SbrChain {255 pub struct SbrChain {
260 rate: u32,256 rate: u32,
261- downsampled: bool,
262 /// PS is signalled by the config (explicit HE-AACv2).257 /// PS is signalled by the config (explicit HE-AACv2).
263 ps_config: bool,258 ps_config: bool,
264 // Keyed by (element_instance_tag, is_cpe): SCE/LFE and CPE instance259 // Keyed by (element_instance_tag, is_cpe): SCE/LFE and CPE instance
@@ -277,7 +272,6 @@ impl SbrChain {
277 pub fn new(rate: u32) -> SbrChain {272 pub fn new(rate: u32) -> SbrChain {
278 SbrChain {273 SbrChain {
279 rate,274 rate,
280- downsampled: false,
281 ps_config: false,275 ps_config: false,
282 elements: HashMap::new(),276 elements: HashMap::new(),
283 bypass: HashMap::new(),277 bypass: HashMap::new(),
@@ -285,10 +279,6 @@ impl SbrChain {
285 }279 }
286 280
287 /// Marks PS as signalled by the config: the element's output is stereo.281 /// Marks PS as signalled by the config: the element's output is stereo.
288- pub fn set_downsampled(&mut self, on: bool) {
289- self.downsampled = on;
290- }
291-
292 pub fn set_ps_config(&mut self, on: bool) {282 pub fn set_ps_config(&mut self, on: bool) {
293 self.ps_config = on;283 self.ps_config = on;
294 for elem in self.elements.values_mut() {284 for elem in self.elements.values_mut() {
@@ -299,13 +289,13 @@ impl SbrChain {
299 /// Parses one FIL element's `sbr_extension_data` (the reader289 /// Parses one FIL element's `sbr_extension_data` (the reader
300 /// positioned right past `bs_extension_type`) for element `tag`.290 /// positioned right past `bs_extension_type`) for element `tag`.
301 pub fn parse(&mut self, r: &mut BitReader<'_>, tag: u8, is_cpe: bool) -> Option<SbrData> {291 pub fn parse(&mut self, r: &mut BitReader<'_>, tag: u8, is_cpe: bool) -> Option<SbrData> {
302- let (ps_config, downsampled) = (self.ps_config, self.downsampled);292+ let ps_config = self.ps_config;
303 let elem = self.element(tag, is_cpe);293 let elem = self.element(tag, is_cpe);
304 let data = elem.parser.parse(r, is_cpe).ok()?;294 let data = elem.parser.parse(r, is_cpe).ok()?;
305 let n_q = elem.parser.tables().map(|t| t.n_q).unwrap_or(1);295 let n_q = elem.parser.tables().map(|t| t.n_q).unwrap_or(1);
306 let ps_out = data.ps.is_some() || (ps_config && !is_cpe);296 let ps_out = data.ps.is_some() || (ps_config && !is_cpe);
307 let need = data.channels.len().max(if ps_out { 2 } else { 1 });297 let need = data.channels.len().max(if ps_out { 2 } else { 1 });
308- elem.ensure_channels(need, downsampled);298+ elem.ensure_channels(need);
309 for ch in &mut elem.channels {299 for ch in &mut elem.channels {
310 if ch.chirp.bands() != n_q {300 if ch.chirp.bands() != n_q {
311 ch.chirp = ChirpState::new(n_q);301 ch.chirp = ChirpState::new(n_q);
@@ -331,9 +321,8 @@ impl SbrChain {
331 321
332 fn apply_low_only(&mut self, tag: u8, is_cpe: bool, planes: &mut [Vec<f32>]) {322 fn apply_low_only(&mut self, tag: u8, is_cpe: bool, planes: &mut [Vec<f32>]) {
333 let dup = !is_cpe && planes.len() == 2;323 let dup = !is_cpe && planes.len() == 2;
334- let downsampled = self.downsampled;
335 let elem = self.element(tag, is_cpe);324 let elem = self.element(tag, is_cpe);
336- elem.ensure_channels(planes.len(), downsampled);325+ elem.ensure_channels(planes.len());
337 let mut right_synth = if dup {326 let mut right_synth = if dup {
338 Some(std::mem::take(&mut elem.channels[1].synthesis))327 Some(std::mem::take(&mut elem.channels[1].synthesis))
339 } else {328 } else {
@@ -386,19 +375,13 @@ impl SbrChain {
386 /// planes, with the high bands left empty, which is what ffmpeg's output375 /// planes, with the high bands left empty, which is what ffmpeg's output
387 /// does for the LFE channel.376 /// does for the LFE channel.
388 pub fn bypass_plane(&mut self, tag: u8, plane: &mut Vec<f32>) {377 pub fn bypass_plane(&mut self, tag: u8, plane: &mut Vec<f32>) {
389- let downsampled = self.downsampled;378+ let (state, delay) = self
390- let (state, delay) = self.bypass.entry(tag).or_insert_with(|| {379+ .bypass
391- let mut state = ChannelState::new(1, 0);380+ .entry(tag)
392- let mut delay = BYPASS_DELAY;381+ .or_insert_with(|| (ChannelState::new(1, 0), vec![0.0; BYPASS_DELAY]));
393- if downsampled {
394- state.synthesis = Synthesis::downsampled();
395- delay /= 2;
396- }
397- (state, vec![0.0; delay])
398- });
399 let num_slots = plane.len() / ANALYSIS_BANDS;382 let num_slots = plane.len() / ANALYSIS_BANDS;
400 let mut out = std::mem::take(delay);383 let mut out = std::mem::take(delay);
401- out.reserve(num_slots * state.synthesis.bands());384+ out.reserve(num_slots * SYNTHESIS_BANDS);
402 for slot in 0..num_slots {385 for slot in 0..num_slots {
403 let mut chunk = [0f32; ANALYSIS_BANDS];386 let mut chunk = [0f32; ANALYSIS_BANDS];
404 chunk.copy_from_slice(&plane[slot * ANALYSIS_BANDS..(slot + 1) * ANALYSIS_BANDS]);387 chunk.copy_from_slice(&plane[slot * ANALYSIS_BANDS..(slot + 1) * ANALYSIS_BANDS]);
@@ -414,7 +397,7 @@ impl SbrChain {
414 }397 }
415 // The reconstructed planes lag their raw analysis by `HF_ADJ` slots;398 // The reconstructed planes lag their raw analysis by `HF_ADJ` slots;
416 // hold the bypass output back by the same amount so they line up.399 // hold the bypass output back by the same amount so they line up.
417- let produced = num_slots * state.synthesis.bands();400+ let produced = num_slots * SYNTHESIS_BANDS;
418 *plane = out[..produced].to_vec();401 *plane = out[..produced].to_vec();
419 *delay = out[produced..].to_vec();402 *delay = out[produced..].to_vec();
420 }403 }
@@ -505,7 +488,6 @@ impl SbrChain {
505 if source == "hold" {488 if source == "hold" {
506 HOLD_CALLS.fetch_add(1, Ordering::Relaxed);489 HOLD_CALLS.fetch_add(1, Ordering::Relaxed);
507 }490 }
508- let band_limit = if self.downsampled { ANALYSIS_BANDS } else { SYNTHESIS_BANDS };
509 let Some(elem) = self.elements.get_mut(&(tag, is_cpe)) else {491 let Some(elem) = self.elements.get_mut(&(tag, is_cpe)) else {
510 return Ok(());492 return Ok(());
511 };493 };
@@ -723,7 +705,7 @@ impl SbrChain {
723 }705 }
724 706
725 let kx = (tables.kx as usize).min(ANALYSIS_BANDS);707 let kx = (tables.kx as usize).min(ANALYSIS_BANDS);
726- let k2 = (tables.k2 as usize).min(band_limit);708+ let k2 = (tables.k2 as usize).min(SYNTHESIS_BANDS);
727 let mut vs: Vec<[Complex<f64>; SYNTHESIS_BANDS]> = Vec::with_capacity(num_slots);709 let mut vs: Vec<[Complex<f64>; SYNTHESIS_BANDS]> = Vec::with_capacity(num_slots);
728 for slot in 0..num_slots {710 for slot in 0..num_slots {
729 let mut v = [Complex::ZERO; SYNTHESIS_BANDS];711 let mut v = [Complex::ZERO; SYNTHESIS_BANDS];
@@ -861,8 +843,7 @@ fn render_ps(
861 843
862 /// Runs `slots` through a synthesis bank, at the SBR output scale.844 /// Runs `slots` through a synthesis bank, at the SBR output scale.
863 fn synth_slots(synth: &mut Synthesis, slots: &[[Complex<f64>; SYNTHESIS_BANDS]]) -> Vec<f32> {845 fn synth_slots(synth: &mut Synthesis, slots: &[[Complex<f64>; SYNTHESIS_BANDS]]) -> Vec<f32> {
864- let bands = synth.bands();846+ let mut out = Vec::with_capacity(slots.len() * SYNTHESIS_BANDS);
865- let mut out = Vec::with_capacity(slots.len() * bands);
866 for v in slots {847 for v in slots {
867 let mut pcm = synth.process_slot(v);848 let mut pcm = synth.process_slot(v);
868 for s in &mut pcm {849 for s in &mut pcm {
@@ -871,7 +852,7 @@ fn synth_slots(synth: &mut Synthesis, slots: &[[Complex<f64>; SYNTHESIS_BANDS]])
871 // core's amplitude; the 2x is the upsampler's gain.852 // core's amplitude; the 2x is the upsampler's gain.
872 *s *= 2.0 * crate::decode::OUTPUT_SCALE;853 *s *= 2.0 * crate::decode::OUTPUT_SCALE;
873 }854 }
874- out.extend_from_slice(&pcm[..bands]);855+ out.extend_from_slice(&pcm);
875 }856 }
876 out857 out
877 }858 }
crates/ec-aac/src/sbr_qmf.rsmodified+42 -44
@@ -218,72 +218,70 @@ impl Default for HfAnalysis {
218 }218 }
219 }219 }
220 220
221-/// The ISO/IEC 14496-3 4.6.18.8.2 complex synthesis QMF bank: complex subband221+/// The ISO/IEC 14496-3 4.6.18.8.2 64-band complex synthesis QMF bank:
222-/// slots in, PCM out. The 64-band form doubles the rate; the 32-band222+/// complex subband slots in, doubled-rate PCM out, [`SYNTHESIS_BANDS`]
223-/// downsampled form (decimated window, band shift of half a sample like the223+/// output samples per slot. Verified against the literal spec equations at
224-/// analysis bank) keeps the core rate.224+/// `corr=0.999999` self-consistency (see the module doc).
225 pub struct Synthesis {225 pub struct Synthesis {
226- bands: usize,226+ /// History buffer `v`, `10 * PROTO_LEN / SYNTHESIS_BANDS * SYNTHESIS_BANDS`
227- v: Vec<f64>,227+ /// = `1280` samples (`4.6.18.8.2`'s own length, not `PROTO_LEN`).
228+ v: [f64; 1280],
228 cos_tab: Vec<f64>,229 cos_tab: Vec<f64>,
229 sin_tab: Vec<f64>,230 sin_tab: Vec<f64>,
230 }231 }
231 232
232 impl Synthesis {233 impl Synthesis {
234+ /// A fresh bank with a silent history buffer.
233 pub fn new() -> Synthesis {235 pub fn new() -> Synthesis {
234- Synthesis::with_bands(SYNTHESIS_BANDS, 0.0)236+ let mut cos_tab = vec![0.0f64; SYNTHESIS_BANDS * 128];
235- }237+ let mut sin_tab = vec![0.0f64; SYNTHESIS_BANDS * 128];
236-238+ for k in 0..SYNTHESIS_BANDS {
237- pub fn downsampled() -> Synthesis {239+ for n in 0..128 {
238- Synthesis::with_bands(SYNTHESIS_BANDS / 2, -0.5)240+ // phi = pi/128*(k+0.5)*(2n-255)
239- }241+ let phi = std::f64::consts::PI / 128.0
240-
241- fn with_bands(bands: usize, shift: f64) -> Synthesis {
242- let len = 2 * bands;
243- let mut cos_tab = vec![0.0f64; bands * len];
244- let mut sin_tab = vec![0.0f64; bands * len];
245- for k in 0..bands {
246- for n in 0..len {
247- let phi = std::f64::consts::PI / len as f64
248 * (k as f64 + 0.5)242 * (k as f64 + 0.5)
249- * (2.0 * n as f64 - (2 * len - 1) as f64 + shift);243+ * (2.0 * n as f64 - 255.0);
250- cos_tab[k * len + n] = phi.cos();244+ cos_tab[k * 128 + n] = phi.cos();
251- sin_tab[k * len + n] = phi.sin();245+ sin_tab[k * 128 + n] = phi.sin();
252 }246 }
253 }247 }
254 Synthesis {248 Synthesis {
255- bands,249+ v: [0.0; 1280],
256- v: vec![0.0; 10 * len],
257 cos_tab,250 cos_tab,
258 sin_tab,251 sin_tab,
259 }252 }
260 }253 }
261 254
262- pub fn bands(&self) -> usize {255+ /// Feeds one slot of [`SYNTHESIS_BANDS`] complex subband samples and
263- self.bands256+ /// returns [`SYNTHESIS_BANDS`] output PCM samples.
264- }
265-
266 pub fn process_slot(&mut self, x: &[Complex<f64>; SYNTHESIS_BANDS]) -> [f32; SYNTHESIS_BANDS] {257 pub fn process_slot(&mut self, x: &[Complex<f64>; SYNTHESIS_BANDS]) -> [f32; SYNTHESIS_BANDS] {
267- let bands = self.bands;258+ // v[n] = v[n-128] for n=1279..128 (shift), then v[0..128] filled with
268- let len = 2 * bands;259+ // v[n] = Re{ (1/64) sum_k X[k]*exp(j*phi) }, n=0..127.
269- self.v.copy_within(0..9 * len, len);260+ self.v.copy_within(0..1152, 128);
270- for n in 0..len {261+ for n in 0..128 {
271 let mut re = 0.0f64;262 let mut re = 0.0f64;
272- for (k, xk) in x.iter().take(bands).enumerate() {263+ for (k, xk) in x.iter().enumerate() {
273- let at = k * len + n;264+ let row = k * 128;
274- re += xk.re * self.cos_tab[at] - xk.im * self.sin_tab[at];265+ // Re{X[k]*exp(j*phi)} = Xre*cos(phi) - Xim*sin(phi)
266+ re += xk.re * self.cos_tab[row + n] - xk.im * self.sin_tab[row + n];
275 }267 }
276 self.v[n] = re / SYNTHESIS_BANDS as f64;268 self.v[n] = re / SYNTHESIS_BANDS as f64;
277 }269 }
278- let step = SYNTHESIS_BANDS / bands;270+ // g[128i+n] = v[256i+n], g[128i+64+n] = v[256i+192+n], i=0..4, n=0..63
271+ let mut g = [0.0f64; PROTO_LEN];
272+ for i in 0..5 {
273+ for n in 0..64 {
274+ g[128 * i + n] = self.v[256 * i + n];
275+ g[128 * i + 64 + n] = self.v[256 * i + 192 + n];
276+ }
277+ }
278+ // w[n] = g[n]*c[n], n=0..639; y[n] = sum_{k=0}^{9} w[64k+n], n=0..63
279 let mut out = [0.0f32; SYNTHESIS_BANDS];279 let mut out = [0.0f32; SYNTHESIS_BANDS];
280- for (n, o) in out.iter_mut().take(bands).enumerate() {280+ for (n, o) in out.iter_mut().enumerate() {
281 let mut acc = 0.0f64;281 let mut acc = 0.0f64;
282- for i in 0..5 {282+ for k in 0..10 {
283- let near = self.v[2 * len * i + n];283+ let idx = 64 * k + n;
284- let far = self.v[2 * len * i + 3 * bands + n];284+ acc += g[idx] * QMF_WINDOW[idx];
285- acc += near * QMF_WINDOW[step * (len * i + n)];
286- acc += far * QMF_WINDOW[step * (len * i + bands + n)];
287 }285 }
288 *o = acc as f32;286 *o = acc as f32;
289 }287 }
@@ -472,7 +470,7 @@ mod tests {
472 assert_eq!(QMF_WINDOW.len(), PROTO_LEN);470 assert_eq!(QMF_WINDOW.len(), PROTO_LEN);
473 let sum: f64 = QMF_WINDOW.iter().sum();471 let sum: f64 = QMF_WINDOW.iter().sum();
474 let sum_sq: f64 = QMF_WINDOW.iter().map(|v| v * v).sum();472 let sum_sq: f64 = QMF_WINDOW.iter().map(|v| v * v).sum();
475- assert!((sum - 82.21187106118578).abs() < 1e-9, "sum={sum}");473+ assert!((sum - 81.46300943655164).abs() < 1e-9, "sum={sum}");
476 assert!((sum_sq - 64.00000000000003).abs() < 1e-9, "sum_sq={sum_sq}");474 assert!((sum_sq - 64.00000000000003).abs() < 1e-9, "sum_sq={sum_sq}");
477 }475 }
478 476
crates/ec-aac/src/sbr_qmf_window.rsmodified+3 -3
@@ -114,7 +114,7 @@ pub const QMF_WINDOW: [f64; 640] = [
114 0.49677082545707, 0.48552530911099, 0.47424532146115, 0.46293080852757,114 0.49677082545707, 0.48552530911099, 0.47424532146115, 0.46293080852757,
115 0.45159965356824, 0.44025537543665, 0.42891199207373, 0.41756968968409,115 0.45159965356824, 0.44025537543665, 0.42891199207373, 0.41756968968409,
116 0.40623176767625, 0.39492117615675, 0.38363500139043, 0.37237955463061,116 0.40623176767625, 0.39492117615675, 0.38363500139043, 0.37237955463061,
117- 0.36115899031355, -0.3499914122931, -0.33887226938665, -0.32781137272105,117+ -0.36115899031355, -0.3499914122931, -0.33887226938665, -0.32781137272105,
118 -0.31682789136456, -0.30590985751916, -0.29507167170646, -0.28432141891085,118 -0.31682789136456, -0.30590985751916, -0.29507167170646, -0.28432141891085,
119 -0.27366340405625, -0.26310532994603, -0.25264803095722, -0.24230168845974,119 -0.27366340405625, -0.26310532994603, -0.25264803095722, -0.24230168845974,
120 -0.23206908706791, -0.22196526964149, -0.21197358538056, -0.20212501768103,120 -0.23206908706791, -0.22196526964149, -0.21197358538056, -0.20212501768103,
@@ -146,7 +146,7 @@ pub const QMF_WINDOW: [f64; 640] = [
146 0.02860721736385, 0.02718594296329, 0.02578758475467, 0.02441609920285,146 0.02860721736385, 0.02718594296329, 0.02578758475467, 0.02441609920285,
147 0.02306801692862, 0.02174675502535, 0.02045317933555, 0.01918724313698,147 0.02306801692862, 0.02174675502535, 0.02045317933555, 0.01918724313698,
148 0.01794333813443, 0.01673247129989, 0.01554055533423, 0.01439046660792,148 0.01794333813443, 0.01673247129989, 0.01554055533423, 0.01439046660792,
149- 0.01327182200351, -0.01218499959508, -0.01113155480321, -0.01011502154986,149+ -0.01327182200351, -0.01218499959508, -0.01113155480321, -0.01011502154986,
150 -0.00913253296085, -0.00817982333726, -0.00726158168517, -0.00637922932685,150 -0.00913253296085, -0.00817982333726, -0.00726158168517, -0.00637922932685,
151 -0.00553372111088, -0.004722259624, -0.00394011240522, -0.003193377839,151 -0.00553372111088, -0.004722259624, -0.00394011240522, -0.003193377839,
152 -0.00248267236449, -0.00180394725893, -0.00115681355227, -0.00054642808664,152 -0.00248267236449, -0.00180394725893, -0.00115681355227, -0.00054642808664,
@@ -196,7 +196,7 @@ mod tests {
196 argmax = i;196 argmax = i;
197 }197 }
198 }198 }
199- assert!((sum - 82.21187106118578).abs() < 1e-9, "sum={sum}");199+ assert!((sum - 81.46300943655164).abs() < 1e-9, "sum={sum}");
200 assert!((sum_sq - 64.00000000000003).abs() < 1e-9, "sum_sq={sum_sq}");200 assert!((sum_sq - 64.00000000000003).abs() < 1e-9, "sum_sq={sum_sq}");
201 assert!((max - 0.85373856005937).abs() < 1e-12, "max={max}");201 assert!((max - 0.85373856005937).abs() < 1e-12, "max={max}");
202 assert_eq!(argmax, 320);202 assert_eq!(argmax, 320);