Commits
Commits on
00c1b3ff2d80d84fef71bb6208110dedbbd95fc4Filtered to crates/ec-mp4/src/demux.rsClear filter2026-08-21
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(mp4): an nclc colr box states no range, and must not be read as oneAhmet Kaan Gümüş · 98eeb6c
fix(mp4): an nclc colr box states no range, and must not be read as one `ColorInfo` has to answer `full_range` whether or not the file stated one, so the ten-byte QuickTime `nclc` box -- which stops before the range byte -- was coming back as a *declaration* of limited range. A host resolving its colour in tiers then took that fabricated claim as the container tier and shadowed a bitstream VUI that said full range: a full-range picture displayed as limited, which is a visibly washed-out one. `colr` now returns the triplet and the `Tags` that triplet really states, and `Mp4Demuxer::color_tags(stream)` hands the second one over: an `nclx` states its range (1 + the flag), an `nclc` and an `nclx` truncated before that byte state none at all, and a track with no `colr` states nothing. `VideoParameters::color` is unchanged for every file that really carries an `nclx`. Latent rather than seen: no file in the scanned library carries an `nclc`. Fixed as a class anyway -- the same shape sits in ec-matroska, whose `Range` element is likewise absent-means-limited (`demux.rs:1214`). cargo test -p ec-mp4: 17 unit + 10 integration passed.
feat(mp4): the index, random access and late-declared streams a host needsAhmet Kaan Gümüş · d7dca0c
feat(mp4): the index, random access and late-declared streams a host needs The replica's engine reads and writes mp4 through this crate now, and five things it needs were not reachable through the two traits alone: - `Sample` is public, and `samples(stream)` hands the whole resolved table over. That table *is* the index an mp4 carries of itself -- a caller that counts frames, builds a display-order seek table or asks what a track spends reads it here instead of walking the file again. - `read_sample(stream, index)` reads one sample of one stream without moving the packet cursor: random access beside the sequential `next_packet`, for a caller holding an index of its own. - `tracks()` lists every track the container declares, in file order, with its `tkhd` id, its handler, its sample entry fourcc, its language and its edit list's `media_time`. Two things ride on it: a track whose codec this build has no id for is still listed (a picker greys such a row out rather than pretending the file has fewer tracks than it has), and `avc3` can be told from `avc1` by a host that re-injects parameter sets out of the `avcC`. - `duration_secs()` is the `mvhd`'s own length, which is what a file's byte rate is measured over -- not any one track's. - The muxer takes `add_stream` at any point before `finish`, and `set_color` after the stream is declared. Samples are written where they arrive and the sample entries are built at the end, so a track declared after the picture is already in the `mdat` costs nothing -- which is what lets an export mix and encode its sound while it writes the picture, and add its subtitles once the film's length is known. cargo test -p ec-mp4: 10 passed.
feat(mp4): ISOBMFF box model, esds descriptors and the demuxerAhmet Kaan Gümüş · 49be010
feat(mp4): ISOBMFF box model, esds descriptors and the demuxer The box walk checks every size against its parent and every table entry count against the box that holds it, so a crafted header is an error and never an allocation. The moov walk resolves the sample tables into offset/size/dts/cts/sync per sample, reads fragments (moof/traf/trun) into the same tables, and takes the frame rate off stts as an exact rational -- whole track over whole track, so NTSC film stays 24000/1001 instead of decaying into 23. A sample entry is read for what it says it is: an mp4a holding MP3 is an MP3 track rather than a dropped one, ac-3/ec-3/alac/Opus/fLaC and the QuickTime PCM entries are their own codecs, and an entry with no CodecId leaves its track listed rather than decoded as something else. The esds parser hands back the DecoderSpecificInfo as bytes, which is the field callers previously had to rebuild from parsed fields.