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 @@
28 //! band's own transmitted noise floor that gain is allowed to reach28 //! band's own transmitted noise floor that gain is allowed to reach
29 //! (`bs_limiter_gains`), noise is mixed in at the transmitted floor, and29 //! (`bs_limiter_gains`), noise is mixed in at the transmitted floor, and
30 //! flagged bands get an added tone.30 //! flagged bands get an added tone.
31+#![allow(clippy::needless_range_loop)]
31 32
32 use crate::sbr_bands::BandTables;33 use crate::sbr_bands::BandTables;
33 use crate::sbr_payload::{SbrChannel, SbrHeader};34 use crate::sbr_payload::{SbrChannel, SbrHeader};
@@ -182,7 +183,11 @@ pub fn adjust(
182 break;183 break;
183 }184 }
184 let high_res = ch.freq_res.get(ei).copied().unwrap_or(0) != 0;185 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+ };
186 // The noise segment covering this envelope's time range (noise191 // The noise segment covering this envelope's time range (noise
187 // borders are a coarser subset of the envelope borders sharing the192 // borders are a coarser subset of the envelope borders sharing the
188 // same start/end points).193 // same start/end points).
@@ -213,7 +218,11 @@ pub fn adjust(
213 .and_then(|r| r.get(q).copied())218 .and_then(|r| r.get(q).copied())
214 .unwrap_or(0.0)219 .unwrap_or(0.0)
215 .max(1e-12);220 .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+ );
217 gain = gain.min(limiter_max * 64.0); // absolute ceiling: never amplify a silent cell to infinity226 gain = gain.min(limiter_max * 64.0); // absolute ceiling: never amplify a silent cell to infinity
218 for band in lo..hi {227 for band in lo..hi {
219 if band < kx || band - kx >= hf.len() {228 if band < kx || band - kx >= hf.len() {
@@ -319,7 +328,15 @@ mod tests {
319 let env_energy = vec![vec![target; tables.n_low]];328 let env_energy = vec![vec![target; tables.n_low]];
320 let noise_energy = vec![vec![0.0f64; tables.n_q]];329 let noise_energy = vec![vec![0.0f64; tables.n_q]];
321 let mut rng = NoiseGen::new(1);330 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+ );
323 340
324 // Every low-res band's average energy should land close to target.341 // Every low-res band's average energy should land close to target.
325 for b in 0..tables.n_low {342 for b in 0..tables.n_low {
@@ -368,7 +385,15 @@ mod tests {
368 let env_energy = vec![vec![1.0e6f64; tables.n_low]];385 let env_energy = vec![vec![1.0e6f64; tables.n_low]];
369 let noise_energy = vec![vec![1e-3f64; tables.n_q]];386 let noise_energy = vec![vec![1e-3f64; tables.n_q]];
370 let mut rng = NoiseGen::new(1);387 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+ );
372 for band in 0..hf.len() {397 for band in 0..hf.len() {
373 for slot in 0..slots {398 for slot in 0..slots {
374 assert!(399 assert!(
@@ -384,6 +409,9 @@ mod tests {
384 fn coupled_balance_round_trips_at_a_centred_ratio() {409 fn coupled_balance_round_trips_at_a_centred_ratio() {
385 let (l, r) = dequant_pair(10, 0, 1);410 let (l, r) = dequant_pair(10, 0, 1);
386 let e0 = dequant_env(10, 1);411 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+ );
388 }416 }
389 }417 }
crates/ec-aac/src/sbr_hf.rsmodified+4 -1
@@ -336,6 +336,9 @@ mod tests {
336 let after_fall = chirp.update(&[0])[0];336 let after_fall = chirp.update(&[0])[0];
337 let fall_step = before - after_fall;337 let fall_step = before - after_fall;
338 let rise_step = after_rise; // started from 0.0338 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+ );
340 }343 }
341 }344 }