forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 5fa31c7eae5f8aca4c0a6f52154417e08b166e9e

Today

Merge branch 'simplify/c-ac3'Ahmet Kaan Gümüş · 5fa31c7Browse files
Merge branch 'simplify/c-truehd'Ahmet Kaan Gümüş · 35cac3aBrowse files
Merge branch 'simplify/c-opus'Ahmet Kaan Gümüş · 61e9e70Browse files
TrueHD tests: adapt to open FATE atmos.thd (128 AUs, 4 substreams, 32-byte ext sync)Ahmet Kaan Gümüş · 0892e43
TrueHD tests: adapt to open FATE atmos.thd (128 AUs, 4 substreams, 32-byte ext sync)

Root cause: oracle.rs first_60_seconds test capped at 60 s and required >= 59 s of
samples, but the open sample is 40960 interleaved samples (128 AUs x 40 frames x 8 ch,
ffmpeg -f s32le gives 163840 bytes). atmos_synth.rs required 1200 AUs and assumed a
3-substream 28-byte sync remux, which the open sample (4 substreams, 32-byte ext sync,
checksum at bytes 30..32 = CRC over 0..28 XOR word 28..30, verified empirically) does not match.

Fix: oracle compares the whole file against ffmpeg, every interleaved sample (all 8 channels)
exact, min 100 AUs. atmos_synth strips the object entry to build a 7.1 stream and rebuilds
Atmos from it (decodes bit-exact to the original); the object-substream test replaces the
4th substream payload in place (0x00 and 0xFF), keeping sizes, and asserts identical PCM.
Object substream is never decoded (decode.rs decoded_substreams = PCM_SUBSTREAMS) and its
payload is not parity-checked, so no check bytes need recomputing.
ec-ac3: mantissas as 2^23 integers, floor-shifted by exponent like ffmpegAhmet Kaan Gümüş · 275e634
ec-ac3: mantissas as 2^23 integers, floor-shifted by exponent like ffmpeg

ffmpeg n8.0 ac3dec.c ac3_decode_transform_coeffs_ch stores each mantissa
(dither included, ac3dec.c:412, 466) as an int at 2^23 full scale and
computes coeffs[freq] = mantissa >> exps[freq] before the float conversion
(1/4194304 gain, ac3dec.c:1290). We multiplied floats by 2^-exp, so
zero-bit dither and small mantissas on quiet bins kept bits ffmpeg drops
(up to 2^-23 per bin, ~20% of a quiet bin). The LFG generator was already
identical (av_lfg_init(0), never reseeded, ac3dec.c:124/156, default
cons_noisegen=false); the mismatch was the rounding, not the noise.

Symmetric levels and the dither now use ffmpeg's integer values
(SYMMETRIC_DEQUANT, ac3dec_data.c:57). AHT and E-AC-3 spx/cpl paths are
unchanged and still float.
ec-opus test: drop doc comment on libopus_untrimmed (no comments in code)Ahmet Kaan Gümüş · 2dcf65f
ec-opus test: drop doc comment on libopus_untrimmed (no comments in code)

Root cause: hybrid_fb_roundtrip judged lag against look_ahead 312; pinned ffmpeg 9.0.2 libopus (32 kbps, 20 ms, fullband, voip) decoded untrimmed gives wav16 lag 298 (corr 0.9994) and lag 312 at corr 0.9167. Fix stays: assert lag within 6 of libopus's own lag. This commit only removes the 3-line doc comment per the no-comments rule.
ec-opus test: judge hybrid FB lag against pinned libopus, not look_aheadAhmet Kaan Gümüş · 4a881f9
ec-opus test: judge hybrid FB lag against pinned libopus, not look_ahead

Root cause: hybrid_fb_roundtrip asserted the speech correlation lag within
look_ahead(960)=312 +/-6. Pinned ffmpeg 9.0.2 libopus (32 kbps, 20 ms,
fullband, voip, CBR) decoded untrimmed (-flags2 +skip_manual) peaks at lag
298 on wav16-mono-48000 (corr 0.9994; lag 312 corr 0.9167), and 308 on the
synthetic speech (corr 0.928). Our 298 therefore matches libopus; the
constant was wrong. Lag is now asserted within +/-6 of the libopus lag
measured by the same aligned_corr. Library code unchanged.
TrueHD: Atmos directory at 36 bytes, count from num_substreams (ffmpeg mlp_parse.c:71-74,160; mlpdec.c read_access_unit)Ahmet Kaan Gümüş · 731634a
TrueHD: Atmos directory at 36 bytes, count from num_substreams (ffmpeg mlp_parse.c:71-74,160; mlpdec.c read_access_unit)

Root cause, sync.rs AccessUnitHeader::parse: the major sync was fixed at 28 bytes.
ffmpeg mlp_get_major_sync_size adds 2 + 2*(buf[26]>>4) when buf[25]&1 (TrueHD).
atmos.thd AU0 sets buf[25]&1 with buf[26]>>4 == 1, so the directory starts at
36 (4 + 32), not 32. The entry count was inferred from end pointers landing on
the AU length; ffmpeg reads num_substreams (buf[16]>>4) and ignores trailing
bytes. atmos.thd AU25/63/102 end 4 words short of the AU length, so the walk
ran past 4 entries.

Fix: extension-aware major sync length; count from num_substreams, carried in
TrueHdFacts for access units without a major sync; the scanner skips access
units that have no known count. ffmpeg evidence: AU0 4 entries, last end
1092 bytes past dir end 44 = 1136 AU length; sub-entries 246/578/750/1136 with
the extension sync.
TrueHD: directory from major sync count, 32-byte Atmos major sync (ffmpeg 9.0.2 mlp_parse.c/mlpdec.c)Ahmet Kaan Gümüş · 2c05ed8
TrueHD: directory from major sync count, 32-byte Atmos major sync (ffmpeg 9.0.2 mlp_parse.c/mlpdec.c)

Root cause, sync.rs AccessUnitHeader::parse: (1) the major sync was fixed at 28
bytes, but ffmpeg mlp_get_major_sync_size adds 2+2*(buf[26]>>4) bytes when
buf[25]&1 (TrueHD); atmos.thd AU0 has extension bit set, so the directory
started at 32 instead of 36. (2) the entry count was inferred from end pointers
landing on the AU length; ffmpeg reads num_substreams (major sync buf[16]>>4,
mlp_parse.c:160) and ignores trailing bytes, and atmos.thd AU25/63/102 carry
32 words past the last end pointer, so the walk ran past 4 entries.

Fix: length from the extension block; count from num_substreams, carried over
from the last major sync on units without one (TrueHdDecoder::substream_count);
entries past the data are corrupt. Atmos fixture: AU0 4 entries, ends 546w
lands on 1136 bytes; num_substreams=4 with substream_info 0x80 (16-ch).
ec-mp4: drop stray 24 after QuickTime v2 lpcm block (5.1 PCM chan not found)Ahmet Kaan Gümüş · 185a642
ec-mp4: drop stray 24 after QuickTime v2 lpcm block (5.1 PCM chan not found)

Root cause: mux.rs sample_entry v2 branch wrote an extra u32 (24) after the
72-byte v2 block fields, so the chan box landed at offset 76 instead of 72.
ffprobe reads the entry's extension size (72), finds a 24-byte box whose type
is not chan, and reports channel_layout unknown for lpcm 5.1.

ffmpeg 9.0.2 reference (6ch pcm_s24le .mov): lpcm entry is 96 bytes, v2 block
ends at offset 72, chan box 0x18 'chan' tag 0x00010000 bitmap 0x3f at 72.
Fix makes the entry 96 bytes with chan at 72, byte-equal to ffmpeg.
B5: one PCM table (pcm_codec/pcm_bits) shared by ec-matroska demux and muxAhmet Kaan Gümüş · 22a6626
B5: one PCM table (pcm_codec/pcm_bits) shared by ec-matroska demux and mux

pcm_bits(CodecId) gives (big, float, bits); mux picks the A_PCM element name from it.
Mux emits no BitDepth, so bytes are unchanged for all codecs it accepted before.
BE 24/32 stay refused by mux. Doc comment removed (no comments rule).
B5: ec-probe reads PcmS24Be/PcmS32BeAhmet Kaan Gümüş · c776375
B5: ec-probe reads PcmS24Be/PcmS32Be

Demux now maps A_PCM/INT/BIG to S24Be/S32Be, which ec-probe did not read
(is_pcm and pcm() lacked them), so those tracks would fail to decode. Added
the BE arms mirroring the LE ones. Only BE 24/32 PCM tracks are affected.
Evidence: cargo check and clippy ec-probe; orchestrator runs goldens.