forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 2fb2a9c742d98da97545604d23f00a22f06e04b5Filtered to crates/ec-truehd/src/sync.rsClear filter

Today

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).

2026-10-23

Restore edith_codecs after local data loss (2026-10-23)Ahmet Kaan Gümüş · b7434a2
Restore edith_codecs after local data loss (2026-10-23)

On 2026-10-23 an automated agent ran `rm -rf $HOME` and deleted the local
repository with all of its history. This commit restores the working tree
from the newest surviving copy, the host-c server lane mirror. That mirror
matches local main as of the testcut Phase 2 reports, including the tool
cache, the nextest fast profile and changed-crates.sh. The history before
this commit was not recovered.

2026-08-27

feat(truehd): a lossless stereo encoder, foreign-decoder verifiedAhmet Kaan Gümüş · c3703cb
feat(truehd): a lossless stereo encoder, foreign-decoder verified

Adds TrueHdEncoder: single-substream stereo, one restart header per
access unit, no matrixing or FIR/IIR prediction — every sample is a
raw 24-bit offset-binary residual, which the crate's own decoder
reconstructs exactly. Round-trips bit-exact through both this crate's
own decoder and, decisively, ffmpeg's independent TrueHD/MLP decoder
(the major sync's CRC-16 and the AU-header/directory parity nibble,
neither validated by our own decoder, had to be derived from ffmpeg's
mlp.c/mlp_parse.c/mlpdec.c source to satisfy a foreign decoder).

2026-08-20

fix(truehd-sync): refuse a 4th substream at parse time, not afterAhmet Kaan Gümüş · 969dce1
fix(truehd-sync): refuse a 4th substream at parse time, not after

The >=4 substream guard sat at the top of the directory loop, checked
against the count from the previous iteration, so it only fired on a
5th entry. A well-formed 4-entry directory (the real object-audio
shape) whose last pointer landed on the AU end broke out of the loop
first, parsing Ok(4); only channel_layout() later caught it, and as a
generic Corrupt rather than naming the 4th substream as Unsupported.

Move the check to after the push, so any 4th entry is refused by name
regardless of whether it also terminates the directory.
feat(truehd): lossless substream decode — 2/6/8-ch presentations bit-exact, 16-ch object substream refusedAhmet Kaan Gümüş · 2f6b7e8
feat(truehd): lossless substream decode — 2/6/8-ch presentations bit-exact, 16-ch object substream refused

Decodes: restart headers (14-bit sync, CRC-8 poly 0x1D verified), decoding
parameters (presence flags, block size, primitive matrices, output shift,
quant step, FIR≤8/IIR≤4 with carried history, Huffman offset/codebook/LSBs),
residuals through the three codebooks (read off an external encoder's mono
output, then oracle-checked), per-substream parity and the lossless-check
byte, rematrixing with both noise generators (23-bit LFSR 2-channel noise for
0x31EA; 256-entry dither table for 0x31EB, every entry solved by constraint
intersection against the external decoder on the real 7.1 track), output
shift, interleaved S32 left-justified 24-bit. TrueHD 7.1 (assignment 0x4F)
lands on FL FR FC LFE BL BR SL SR via [0,1,2,3,6,7,4,5]. MLP major sync's
rate-code offset fixed (data[9], not data[8]).

Refused by name (Error::Unsupported): the 4th / 16-channel object substream,
any substream with more than 8 matrix channels, 8-ch presentations whose
channel assignment is not the standard 7.1 mask, reserved rate codes.
Not validated: the per-substream CRC-8 check byte (generator/span unknown;
parsed and skipped, see corner-cut in decode.rs).

Oracle (tests/oracle.rs, skipped without ffmpeg / the remux): first 60 s of
the real 7.1 remux 23 040 000 / 23 040 000 samples exact, 0 lossless-check,
0 parity, 0 restart-CRC, 0 length failures over 72 000 access units;
externally encoded MLP and TrueHD mono/stereo/5.1 streams all bit-exact.
feat(truehd): new ec-truehd crate — access-unit framing and major syncAhmet Kaan Gümüş · f77ac31
feat(truehd): new ec-truehd crate — access-unit framing and major sync

frame_length, major sync detection (format id + sample rate) and the
per-substream directory, all calibrated bit-for-bit against a real 7.1
Blu-ray remux (AU count matches ffprobe exactly: 1,270,169). Substream
decode itself is stubbed as Unsupported, named for H2; the 4th
(object/16-ch) substream is out of scope and refused by name.