forge
Explore
Log in

Don't you dare go Hollow

Fmt + clippy clean on the SBR assembly modules

Browse files at this commit

38d7a3139a3d07f57f0f83a9270f7bc6f5955daaAhmet Kaan GümüşParent: 5206266
  • chore
    • fmt + clippy clean on the SBR assembly modules
Show full message
chore(aac): fmt + clippy clean on the SBR assembly modules
crates/ec-aac/src/sbr_env.rsmodified+33 -5
@@ -28,6 +28,7 @@
2828 //! band's own transmitted noise floor that gain is allowed to reach
2929 //! (`bs_limiter_gains`), noise is mixed in at the transmitted floor, and
3030 //! flagged bands get an added tone.
31+#![allow(clippy::needless_range_loop)]
3132
3233 use crate::sbr_bands::BandTables;
3334 use crate::sbr_payload::{SbrChannel, SbrHeader};
@@ -182,7 +183,11 @@ pub fn adjust(
182183 break;
183184 }
184185 let high_res = ch.freq_res.get(ei).copied().unwrap_or(0) != 0;
185- let table = if high_res { &tables.f_high } else { &tables.f_low };
186+ let table = if high_res {
187+ &tables.f_high
188+ } else {
189+ &tables.f_low
190+ };
186191 // The noise segment covering this envelope's time range (noise
187192 // borders are a coarser subset of the envelope borders sharing the
188193 // same start/end points).
@@ -213,7 +218,11 @@ pub fn adjust(
213218 .and_then(|r| r.get(q).copied())
214219 .unwrap_or(0.0)
215220 .max(1e-12);
216- gain = gain.min((noise_here * limiter_max / current.max(1e-12)).sqrt().max(gain.min(limiter_max)));
221+ gain = gain.min(
222+ (noise_here * limiter_max / current.max(1e-12))
223+ .sqrt()
224+ .max(gain.min(limiter_max)),
225+ );
217226 gain = gain.min(limiter_max * 64.0); // absolute ceiling: never amplify a silent cell to infinity
218227 for band in lo..hi {
219228 if band < kx || band - kx >= hf.len() {
@@ -319,7 +328,15 @@ mod tests {
319328 let env_energy = vec![vec![target; tables.n_low]];
320329 let noise_energy = vec![vec![0.0f64; tables.n_q]];
321330 let mut rng = NoiseGen::new(1);
322- adjust(&mut hf, &tables, &header(1, 3), &ch, &env_energy, &noise_energy, &mut rng);
331+ adjust(
332+ &mut hf,
333+ &tables,
334+ &header(1, 3),
335+ &ch,
336+ &env_energy,
337+ &noise_energy,
338+ &mut rng,
339+ );
323340
324341 // Every low-res band's average energy should land close to target.
325342 for b in 0..tables.n_low {
@@ -368,7 +385,15 @@ mod tests {
368385 let env_energy = vec![vec![1.0e6f64; tables.n_low]];
369386 let noise_energy = vec![vec![1e-3f64; tables.n_q]];
370387 let mut rng = NoiseGen::new(1);
371- adjust(&mut hf, &tables, &header(1, 0), &ch, &env_energy, &noise_energy, &mut rng);
388+ adjust(
389+ &mut hf,
390+ &tables,
391+ &header(1, 0),
392+ &ch,
393+ &env_energy,
394+ &noise_energy,
395+ &mut rng,
396+ );
372397 for band in 0..hf.len() {
373398 for slot in 0..slots {
374399 assert!(
@@ -384,6 +409,9 @@ mod tests {
384409 fn coupled_balance_round_trips_at_a_centred_ratio() {
385410 let (l, r) = dequant_pair(10, 0, 1);
386411 let e0 = dequant_env(10, 1);
387- assert!((l - e0).abs() < 1e-9 && (r - e0).abs() < 1e-9, "{l} {r} vs {e0}");
412+ assert!(
413+ (l - e0).abs() < 1e-9 && (r - e0).abs() < 1e-9,
414+ "{l} {r} vs {e0}"
415+ );
388416 }
389417 }
crates/ec-aac/src/sbr_hf.rsmodified+4 -1
@@ -336,6 +336,9 @@ mod tests {
336336 let after_fall = chirp.update(&[0])[0];
337337 let fall_step = before - after_fall;
338338 let rise_step = after_rise; // started from 0.0
339- assert!(fall_step > rise_step * 0.5, "fall {fall_step} rise {rise_step}");
339+ assert!(
340+ fall_step > rise_step * 0.5,
341+ "fall {fall_step} rise {rise_step}"
342+ );
340343 }
341344 }