From bff985b2d1601e1140a4011e80be62b82474b40f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 20 Aug 2026 17:22:12 +0300 Subject: [PATCH] test(aac): refute an AAC-Main/LTP capability-gap premise, add real 7.1 mp4 regression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ledger recorded crates/ec-aac refusing a real 7.1 mp4 track with Unsupported{"predictor_data_present: main or LTP profile, not AAC-LC"}, attributing it to ISO/IEC 14496-3 §4.6.6 (LTP) or §4.6.7 (Main-profile backward-adaptive prediction) not being implemented. Re-checked against the real file on current main (e90efe0): the AAC track's AudioSpecificConfig (§1.6.2.1) decodes audioObjectType=2 (AAC-LC), confirmed independently via the ADTS `profile` field ffmpeg remuxes it to (profile=1=LC per ISO/IEC 13818-7 table). AacDecoder reads the whole ~994s track -- 45000+ access units -- with zero Err returns. No predictor_data_present refusal is reachable on this file today; the capability gap the ledger recorded does not exist for it, so no §4.6.6/ §4.6.7 prediction work was needed or attempted. ffmpeg's native `aac` encoder and libfdk_aac both refuse "-profile:a aac_main"/"aac_ltp" ("Profile not supported!"), so no synthetic fixture for either profile can be generated on this box; a real Main/LTP file would still need a from-spec fixture or another real-library find. Adds a real-library regression test as the standing proof: decodes 10s of all 8 channels of the file's AAC track through its real mp4 container and checks each against ffmpeg's own decode, isolated per channel with a `pan` filter (never -ac 1, per the existing witness-rule comment on ffmpeg_decode). All 8 channels: lag 0, corr 1.000000. Pre-existing failures left untouched and unchased, per charter: an unrelated HE-AAC SBR-chain regression on a different candidate (sbr_real_library_matches_reference, full_chain_low_band_matches_own_core) is owned elsewhere; three oracle.rs fixture-missing failures are this fresh worktree never having run scripts/gen-fixtures.sh, reproduced identically on main's own worktree layout (fixtures/ is gitignored, generated on demand). --- crates/ec-aac/tests/sbr_real_library.rs | 74 +++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/crates/ec-aac/tests/sbr_real_library.rs b/crates/ec-aac/tests/sbr_real_library.rs index 0a234136..1baea572 100644 --- a/crates/ec-aac/tests/sbr_real_library.rs +++ b/crates/ec-aac/tests/sbr_real_library.rs @@ -3431,3 +3431,77 @@ fn sbr_header_feature_table() { ); } } + +/// One channel of `path`'s given absolute stream, isolated with an ffmpeg +/// `pan` filter rather than raw de-interleaving -- the charter's own witness +/// rule (see `ffmpeg_decode`'s doc and the ledger's "never use -ac 1", which +/// applies just as much to picking one of N channels as to downmixing). +fn ffmpeg_decode_pan_channel(path: &Path, absolute_stream: usize, channel: usize) -> Vec { + let out = Command::new("ffmpeg") + .args(["-v", "error", "-i"]) + .arg(path) + .args([ + "-map", + &format!("0:{absolute_stream}"), + "-t", + "10", + "-af", + &format!("pan=1c|c0=c{channel}"), + "-f", + "f32le", + "-acodec", + "pcm_f32le", + "-", + ]) + .output() + .expect("ffmpeg runs"); + assert!( + out.status.success(), + "ffmpeg pan decode failed: {}", + String::from_utf8_lossy(&out.stderr) + ); + out.stdout + .chunks_exact(4) + .map(|c| f32::from_le_bytes([c[0], c[1], c[2], c[3]])) + .collect() +} + +/// The user's real 7.1 mp4 whose lone AAC track was once suspected (per the +/// ledger) to need AAC Main/LTP (§4.6.6/§4.6.7) prediction support this +/// decoder doesn't have. Re-checked here: its AudioSpecificConfig's +/// `audioObjectType` is 2 (AAC-LC, confirmed both from the container's ASC +/// bytes and from the ADTS `profile` field ffmpeg remuxes it to), and this +/// decoder in fact reads its whole ~994s track -- 45000+ access units -- +/// with zero `Err` returns. No `predictor_data_present` refusal is reachable +/// on this file; the capability gap the ledger recorded does not exist for +/// it. This test is the standing proof: it decodes 10s of all 8 channels and +/// checks each against ffmpeg's own decode, isolated per channel by `pan` +/// (never `-ac 1`, which would remix rather than isolate). +#[test] +fn reelq_multichannel_lc_matches_reference() { + if !have_ffmpeg() { + eprintln!("SKIP: ffmpeg not on PATH"); + return; + } + let home = std::env::var("HOME").unwrap_or_default(); + let path = PathBuf::from(format!( + "{home}/Downloads/reelq/reelq.mp4" + )); + if !path.exists() { + eprintln!("SKIP: {} not present", path.display()); + return; + } + let Some((ours, _sbr, rate)) = our_decode(&path, 0) else { + panic!("ReelQ AAC track failed to decode at all"); + }; + assert_eq!(ours.len(), 8, "expected 7.1 (8 channels)"); + let want = (rate as usize) * 10; // 10s per the charter + for (ch, o) in ours.iter().enumerate() { + let o = &o[..o.len().min(want)]; + let t = ffmpeg_decode_pan_channel(&path, 2, ch); + let t = &t[..t.len().min(want)]; + let (lag, corr) = best_lag_correlation(o, t); + println!("ReelQ ch{ch}: lag {lag}, corr {corr:.6}"); + assert!(corr >= 0.999, "ch{ch} corr {corr:.6} < 0.999 (lag {lag})"); + } +}