feat: MP3 + MP4/M4A (AAC) decode support
Closes the two format gaps v1's README explicitly deferred, after vetting real pure-Rust alternatives: MP3 via nanomp3 (MIT/Apache-2.0): a safe-Rust port of the well- established minimp3 C algorithm. The obvious `minimp3` crate is FFI to that C library and its own README discloses "multiple memory unsoundness issues" -- nanomp3 is the pure port its own README points to as the recommended alternative. Low unsafe density (~0.6% of a 6300-line file), no_std, zero dependencies. MP4/M4A (AAC-LC/HE-AAC) via mp4 (pure-Rust ISO-BMFF demux, MIT, mature since 2018) + oxideav-aac (pure-Rust AAC decode, MIT). redlux -- the most established MP4/AAC crate -- turned out to depend on fdk-aac, FFI to a C library, disqualifying it on the same grounds as symphonia. oxideav-aac's top-of-file doc comment is stale (claims "decode bodies not wired up yet") but its actual decode::StreamDecoder is complete: SBR/PS support, and a pcm_byte_exact test suite that compares decoded output sample-for-sample against a reference decoder with an honestly- reasoned tolerance model (<=1 LSB deterministic, energy-correctness only for PNS noise). Demux gives per-sample raw AAC access units + AudioSpecificConfig fields (audioObjectType/samplingFrequencyIndex/ channelConfiguration); decode_raw_data_block is oxideav-aac's transport-independent entry point that consumes them directly (no ADTS framing needed for MP4's raw-frame storage). format.rs sniffs MP4 via the ftyp box signature at offset 4, MP3 via either a leading ID3v2 tag or a raw MPEG frame sync (0xFF + top 3 bits set). Verified: 8 new tests (5 mp3, 5 mp4 unit tests across clawaudio-decode, minus overlap with sniff tests; 2 new end-to-end facade tests) against real ffmpeg-generated MP3/M4A fixtures -- decode -> resample -> spectrogram all non-degenerate, dominant frequency recovered within lossy-codec tolerance. Full workspace fmt/clippy -D warnings clean. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
35b18af10c
commit
59fededf24
Binary file not shown.
Reference in New Issue
Block a user