Commits
2026-08-21
2026-08-20
fix(aac): run PNS noise substitution before M/S and intensity stereoAhmet Kaan Gümüş · 7efd1d7
fix(aac): run PNS noise substitution before M/S and intensity stereo ISO/IEC 14496-3 §4.6.13 fills a PNS band's spectral coefficients with scaled noise; §4.6.8.1 M/S and §4.6.8.2 intensity stereo then combine those coefficients like any other spectral data. BlockDecoder::finish ran M/S and intensity stereo first, then filled PNS bands afterward, so any band coded as PNS in one channel still read zero when the stereo tools combined it -- the pre-fill zero got mixed into the other channel's coefficient (M/S) or copied outright (intensity), corrupting a real channel's data whenever the encoder mixed PNS with stereo coding on the same band. Reordered to match every reference decoder's decode order: PNS -> M/S -> intensity stereo -> TNS. Diagnostic path: chased a consumer sweep's finding of 0.76-0.92 (and one 0.0) whole-file correlation on a set of AAC-in-mp4 screen recordings against ffmpeg. Direct ec-mp4-demux -> ec-aac-decode measurement (crates/ec-aac/tests/obs_real_content.rs), lag-searched per the existing sbr_real_library.rs pattern, reads corr=1.0000 on every non-silent file both before and after this fix -- these files' PNS usage (1-13 AUs) apparently never lands on a band the M/S mask also marks, so the reorder is a real spec-order bug but not what produced that sweep's numbers; the sweep's own method likely lacked a wide-enough lag search and caught this file family's ~1024-sample (~21ms, one AAC frame) container/decode alignment offset instead. The single 0.0000 file is genuine digital silence in both decoders. Also chased a second repro (a real AAC-LC-in-mp4 download, sequential single-decoder scan, crates/ec-aac/tests/reelh_per_frame.rs): per-AU correlation reads 1.0000 across the whole 10.4s file except one near-silent intro AU where both decoders read ~0 RMS and the correlation ratio is numerically meaningless -- no reproducible mid-stream collapse found in this file at this crate's decode layer, with or without this fix. Added crate-level tool-usage side info (EC_AAC_TOOL_SIDEINFO_DEBUG, mirroring sbr_chain's SbrSideInfoRow pattern) and five ffmpeg tool-isolation fixtures (-aac_pns/-aac_is/-aac_ms/-aac_tns, one at a time and one with all four) wired into oracle.rs, all passing at >=0.999 correlation, to pin the fixed decode order and give any future PNS/IS/M-S/TNS regression a per-tool fixture to land on.
fix(h264): drop leading pictures after a seek's open-GOP recovery pointAhmet Kaan Gümüş · 03dc6e9
fix(h264): drop leading pictures after a seek's open-GOP recovery point Root cause (crates/ec-h264/src/dpb.rs, crates/ec-h264/src/decoder.rs; mirrored in crates/ec-hw/src/dec/dpb264.rs, crates/ec-hw/src/dec/h264.rs): an open-GOP I picture is not an IDR — it is a plain I slice whose predecessors in decode order can still be referenced by pictures that follow it. A decoder started fresh at that I (exactly what a seek does) has none of those earlier references, so `build_ref_lists` pads the missing entries with whatever it has. The old code decoded and output those leading pictures anyway, handing back frames predicted from padded (garbage) references before the stream ever reaches a picture whose references are all real. Annex D.2.8 defines a `recovery_point` SEI whose absence (the common case, and this fixture's case) defaults `recovery_frame_cnt` to 0: the recovery point is the RAP's own POC, i.e. only pictures with a POC at or after the leading I's own POC are guaranteed fully referenced. The SEI itself is deliberately not parsed — the default already gives the correct threshold for the case that matters (mid-GOP seek), and a real non-zero `recovery_frame_cnt` is out of scope for this fix. `build_ref_lists` now returns whether it had to pad a list ((lists, padded)); `Decoder`/`H264Decoder` OR that per-slice into `cur_ref_padded`/`Current::ref_padded`, latch the first post-reset picture's POC into `recovery_poc` on `end_picture`/`finish_picture`, and compute `output_ok = !(ref_padded && poc < recovery_poc)`. `Dpb::store` takes that flag and marks the picture `Mark::Unused`-eligible for output gating (`pic.output = output_ok`) — it still joins the DPB as a reference and for bookkeeping, but a gated picture is never handed to a caller. `reset_pictures` clears `recovery_poc` so a later seek gets its own threshold. New test `h264_seek_matches_linear_open_gop` in both suites drives this through the real entry surface: fixtures/video/h264-open-gop.mp4 (x264 open-GOP, generated via scripts/gen-fixtures.sh) primes a fresh decoder with the leading IDR's parameter sets, resets picture state (a seek's exact contract), feeds it from the open-GOP I access unit before display frame 30, and asserts the first decoded picture matches a linear decode of frame 30. Confirmed failing before this fix (forcing output_ok true reproduces the mismatch) and passing after, on both the software decoder (crates/ec-h264/tests/conformance.rs) and the VA-API path (crates/ec-hw/tests/gpu.rs, real hardware). cargo test -p ec-h264: 70 lib + 23 conformance + 8 encode passed, 0 failed. cargo test -p ec-hw --test gpu -- --test-threads=1: 19 passed (18 pre-existing + the new one), 0 failed.
2026-08-14
test(fixtures): 24-bit ALAC, Matroska-carried audio and cover artAhmet Kaan Gümüş · abd41b6
test(fixtures): 24-bit ALAC, Matroska-carried audio and cover art 24-bit ALAC is the only path where a sample's low bytes ride uncompressed beside the residuals; Matroska-carried aac/flac/opus and a video-plus-sound mkv are what the probe delegates; the two cover-art files are the claim that a still picture is never listed as a video track. The mp4 tests drop attached pictures from their ffprobe oracle for the same reason: this crate does not list one, deliberately, and does not write one either.
test(fixtures): add 1916x1080 h264/hevc samples for the cropping rectAhmet Kaan Gümüş · 0dc3e2b
test(fixtures): add 1916x1080 h264/hevc samples for the cropping rect Every other video fixture is CTU-aligned; the local library contains BluRay remuxes at 1916x1080, which is where a conformance-window bug shows up.
feat(oracle): fixture scripts + comparison harnessAhmet Kaan Gümüş · d207f1d
feat(oracle): fixture scripts + comparison harness gen-fixtures.sh: 87 deterministic ffmpeg fixtures (10 audio codecs x mono/stereo/5.1 x 44.1/48k, 4 video codecs x mp4/mkv x 23.976/60 x 8/10-bit, 4K sample per codec). fetch-vectors.sh: JVT H.264, JCT-VC HEVC, RFC6716 Opus, cellar FLAC, Xiph Vorbis; checksum-pinned in scripts/vectors.sha256, resumable, per-set graceful failure. scan-real-library.sh: read-only ffprobe sweep of the local media dirs into fixtures/real-library-manifest.tsv (T3 gate input). tools/oracle: std-only bin driving ffmpeg/ffprobe through process pipes (bit-exact, audio-compare, video-compare); ffmpeg stays test tooling, never a crate dep.