forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 8dbd683068d7f87f21dcc4ed1dfdca786d82c52bFiltered to crates/ec-matroska/src/ebml.rsClear filter

2026-08-14

fix(probe): the head of a file is exact, and a default track is the flagged oneAhmet Kaan Gümüş · c665d19
fix(probe): the head of a file is exact, and a default track is the flagged one

Three gaps the symphonia swap (edith W7) found, all at the start of a file or
at the pick of a track:

- **An MP3 is gapless.** The LAME tag's encoder delay and padding went unread,
  so a `.mp3` claimed the silence around its sound as part of it and its
  samples arrived 25 ms behind the `.flac` of the same tone.
  `StreamInfo::initial_padding` now states the delay (the tag's, plus Layer
  III's own 529 samples of synthesis delay) and the duration ends at the last
  audible sample. Measured against ffmpeg on eight fixtures and three files of
  a real library: lag 0, correlation 1.0000, where the mp3 was 1105 samples
  late before.
- **A seek to the beginning goes there.** `candidate` started at the nearest
  *cue*, and a cue naming another track can sit past our own first block: this
  muxer opens a cluster at every video keyframe and cues the video alone, so a
  file whose first cluster holds only sound lost that cluster on every seek to
  zero. Another track's cue now backs off one entry, and a target before
  everything indexed starts at the first cluster.
- **`FlagDefault` picks the track.** `default_stream` answered with the first
  stream of a kind, so a dual-audio remux that marked its second track default
  opened in the other language. `StreamInfo::default` carries the flag where a
  file really wrote it (the element's absent value is 1, which is why
  "flagged" and "eligible" have to be different questions), and the symphonia
  shim's `default_track` reads it.

The shim gains the surface that carries these: `Track::delay`, the umbrella's
feature names (no-ops -- ec-probe serves every format unconditionally -- but a
`[patch.crates-io]` consumer naming `features = ["mkv"]` must still resolve).

Checks: `ec_probe` `the_head_of_a_file_is_exact` (gapless arithmetic exact
against ffmpeg, and no seek lands past a first packet) and `ec_matroska`
`the_first_cluster_is_reachable_when_no_cue_names_it` (fails without the cue
back-off: the audio restarts at 21 ms instead of 0).
fix(matroska): the SeekHead really points at the Cues, and four track facts a host needsAhmet Kaan Gümüş · c2c209e
fix(matroska): the SeekHead really points at the Cues, and four track facts a host needs

The `SeekHead` stated the `Cues` position twice off the segment: `cues_at` was
already relative and the table subtracted the segment body again, so the pointer
landed in the middle of a cluster. This crate's own demuxer never noticed --
finding no `Cues` there it falls back to the cluster-header walk and reads the
file perfectly -- while symphonia's reader follows the pointer, meets an element
that cannot be there and refuses the file outright. Found by driving an exported
`.mkv` back through symphonia. The remux test now resolves every `SeekHead`
entry and asserts the element it lands on is the one it names.

Four accessors a host cannot do without, all off the `Tracks` element that was
already parsed:

- `track_codec_id` -- the file's own `CodecID` (`A_EAC3`, `S_HDMV/PGS`), which
  says more than the `CodecId` it maps to and is what a copy and a refusal name.
- `track_title` -- `TrackName`, now parsed and now written: `set_track_title`
  puts it back, so a subtitle track called "Signs" survives a remux.
- `track_refusal` / `track_is_plain` -- what a `ContentEncodings` this cannot
  undo did, asked at the header instead of a cluster later, so one unreadable
  subtitle track is listed beside the readable ones rather than failing the file.
- `unread_tracks` -- the `TrackEntry`s this crate hands no stream for, with
  their type: "MPEG-2 video nothing here decodes" is an answer, "no video track"
  is a lie about the same file.

And `set_track_delay`, which writes `CodecDelay` for a track whose encoder delay
only the caller knows: Opus states its own pre-skip in the `OpusHead` and is
unaffected, AAC's is one access unit and nothing in the file says so -- a track
written without it plays ~21 ms early against the picture.
feat(matroska): EBML grammar and Matroska/WebM demuxerAhmet Kaan Gümüş · 4888147
feat(matroska): EBML grammar and Matroska/WebM demuxer

The element grammar both directions share (variable-length ids and sizes,
in-memory child walks, the unknown-length rule) and the reader on top of it:
segment and track walk, cluster walk, SimpleBlock and BlockGroup, all three
lacings, ContentEncodings undone (zlib through ec-inflate, header stripping
put back, everything else refused by name), and cue-driven seeking on the one
reader a file was opened with.

Ported from the engine's own demuxer, restructured around the ec-core Demuxer
contract: packets stream out of one cluster-sized allocation instead of a
frame index built for a video editor, and every track of the file becomes a
StreamInfo rather than one picture track plus a sound list.