forge
Explore
Log in

Don't you dare go Hollow

Refute an AAC-Main/LTP capability-gap premise, add real 7.1 mp4 regression

Browse files at this commit

bff985b2d1601e1140a4011e80be62b82474b40fAhmet Kaan GümüşParent: cabc34d
  • test
    • refute an AAC-Main/LTP capability-gap premise, add real 7.1 mp4 regression
Show full message
test(aac): refute an AAC-Main/LTP capability-gap premise, add real 7.1 mp4 regression

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.rsmodified+74 -0
@@ -3431,3 +3431,77 @@ fn sbr_header_feature_table() {
3431 );3431 );
3432 }3432 }
3433 }3433 }
3434+
3435+/// One channel of `path`'s given absolute stream, isolated with an ffmpeg
3436+/// `pan` filter rather than raw de-interleaving -- the charter's own witness
3437+/// rule (see `ffmpeg_decode`'s doc and the ledger's "never use -ac 1", which
3438+/// applies just as much to picking one of N channels as to downmixing).
3439+fn ffmpeg_decode_pan_channel(path: &Path, absolute_stream: usize, channel: usize) -> Vec<f32> {
3440+ let out = Command::new("ffmpeg")
3441+ .args(["-v", "error", "-i"])
3442+ .arg(path)
3443+ .args([
3444+ "-map",
3445+ &format!("0:{absolute_stream}"),
3446+ "-t",
3447+ "10",
3448+ "-af",
3449+ &format!("pan=1c|c0=c{channel}"),
3450+ "-f",
3451+ "f32le",
3452+ "-acodec",
3453+ "pcm_f32le",
3454+ "-",
3455+ ])
3456+ .output()
3457+ .expect("ffmpeg runs");
3458+ assert!(
3459+ out.status.success(),
3460+ "ffmpeg pan decode failed: {}",
3461+ String::from_utf8_lossy(&out.stderr)
3462+ );
3463+ out.stdout
3464+ .chunks_exact(4)
3465+ .map(|c| f32::from_le_bytes([c[0], c[1], c[2], c[3]]))
3466+ .collect()
3467+}
3468+
3469+/// The user's real 7.1 mp4 whose lone AAC track was once suspected (per the
3470+/// ledger) to need AAC Main/LTP (§4.6.6/§4.6.7) prediction support this
3471+/// decoder doesn't have. Re-checked here: its AudioSpecificConfig's
3472+/// `audioObjectType` is 2 (AAC-LC, confirmed both from the container's ASC
3473+/// bytes and from the ADTS `profile` field ffmpeg remuxes it to), and this
3474+/// decoder in fact reads its whole ~994s track -- 45000+ access units --
3475+/// with zero `Err` returns. No `predictor_data_present` refusal is reachable
3476+/// on this file; the capability gap the ledger recorded does not exist for
3477+/// it. This test is the standing proof: it decodes 10s of all 8 channels and
3478+/// checks each against ffmpeg's own decode, isolated per channel by `pan`
3479+/// (never `-ac 1`, which would remix rather than isolate).
3480+#[test]
3481+fn reelq_multichannel_lc_matches_reference() {
3482+ if !have_ffmpeg() {
3483+ eprintln!("SKIP: ffmpeg not on PATH");
3484+ return;
3485+ }
3486+ let home = std::env::var("HOME").unwrap_or_default();
3487+ let path = PathBuf::from(format!(
3488+ "{home}/Downloads/reelq/reelq.mp4"
3489+ ));
3490+ if !path.exists() {
3491+ eprintln!("SKIP: {} not present", path.display());
3492+ return;
3493+ }
3494+ let Some((ours, _sbr, rate)) = our_decode(&path, 0) else {
3495+ panic!("ReelQ AAC track failed to decode at all");
3496+ };
3497+ assert_eq!(ours.len(), 8, "expected 7.1 (8 channels)");
3498+ let want = (rate as usize) * 10; // 10s per the charter
3499+ for (ch, o) in ours.iter().enumerate() {
3500+ let o = &o[..o.len().min(want)];
3501+ let t = ffmpeg_decode_pan_channel(&path, 2, ch);
3502+ let t = &t[..t.len().min(want)];
3503+ let (lag, corr) = best_lag_correlation(o, t);
3504+ println!("ReelQ ch{ch}: lag {lag}, corr {corr:.6}");
3505+ assert!(corr >= 0.999, "ch{ch} corr {corr:.6} < 0.999 (lag {lag})");
3506+ }
3507+}