//! Decodes an ADTS file (argv[1]) to raw interleaved f32le PCM on stdout, for //! the patch-map probe scripts (`scripts/aac-tables/sbrpatchmap.py`) to read //! our own decoder's output through the exact same FFT/comb-reading code as //! the reference decoder's, with no format translation in between. use std::io::Write; fn main() { let path = std::env::args() .nth(1) .expect("usage: adts_to_pcm "); let data = std::fs::read(&path).expect("file readable"); let mut decoder = ec_aac::AacDecoder::new(); let mut at = 0usize; let stdout = std::io::stdout(); let mut out = stdout.lock(); while at + 7 <= data.len() { let header = match ec_aac::parse_adts(&data[at..]) { Ok(h) => h, Err(_) => break, }; let end = (at + header.frame_length).min(data.len()); if let Ok(frame) = decoder.decode(&data[at..end], None) { for v in &frame.samples { out.write_all(&v.to_le_bytes()).expect("stdout writable"); } } at = end; } }