forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

implicit_ps.rs39 lines, 1.2 KiBHistoryRawDownload
1//! Implicit Parametric Stereo: an ADTS stream whose headers say plain AAC-LC,
2//! and whose SBR extension carries a PS extension, is HE-AACv2 by its payload.
3//! `ps_implicit` reports it once that PS extension has been decoded.
4
5use std::path::Path;
6
7use ec_aac::AacDecoder;
8
9#[test]
10fn implicit_he_aac_v2_reports_implicit_ps() {
11 let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/data/he/he_v2_stereo.aac");
12 let data = std::fs::read(&path).expect("he_v2_stereo.aac is committed");
13
14 let mut decoder = AacDecoder::new();
15 decoder.decode(&data, None).expect("the stream decodes");
16
17 assert!(
18 decoder.sbr_implicit(),
19 "the SBR payload switches implicit SBR on"
20 );
21 assert!(
22 decoder.ps_implicit(),
23 "the PS extension is seen in an implicit stream"
24 );
25}
26
27#[test]
28fn explicit_he_aac_v1_has_no_implicit_ps() {
29 let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/data/he/he_v1_stereo.aac");
30 let data = std::fs::read(&path).expect("he_v1_stereo.aac is committed");
31
32 let mut decoder = AacDecoder::new();
33 decoder.decode(&data, None).expect("the stream decodes");
34
35 assert!(
36 !decoder.ps_implicit(),
37 "a v1 stream carries no PS extension"
38 );
39}