Commits
2026-10-23
🚚 edith moves to git.tahinli.comAhmet Kaan Gümüş · b02f499
🚚 edith moves to git.tahinli.com The working tree as of 2026-10-23, as one commit on top of the last one here. It carries the work up to that date plus the test-slimming work: integration tests merged into one binary per crate, nextest config, doctest = false, debug line tables only, perf tests behind --ignored, and faster generators, reverse, undo, subtitle-export, hevc, stabilise and hear tests.
2026-09-30
docs(demux): name the dropped display height as a design gap, not an oversightAhmet Kaan Gümüş · 25cd3de
docs(demux): name the dropped display height as a design gap, not an oversight `PixelAspect::stated_size` reads a unit-0 pair's display height, checks it for the degenerate claim, and then does not use it -- a 1920x803 scope is drawn 1920x1080, because this engine's model moves the width only. That is correct today and I want it written down rather than left looking like a bug, because it stops being correct the moment any path starts honouring a stated display height: the height half is being discarded deliberately, and the reason it is safe to discard (`VideoMeta::height` is the coded height everywhere, and every consumer reads the aspect as width-only) is exactly what such a change would remove. Documentation only; no behaviour change.
fix(demux): a unit-3 DAR is judged by its raster too, not by its termsAhmet Kaan Gümüş · 8773473
fix(demux): a unit-3 DAR is judged by its raster too, not by its terms Second verification was right, and this is the same defect one match arm below the unit-0 fix: the unit-3 arm multiplied the DAR by the coded size and then judged the *derived* pair by the reduced-term bound, which is the rule unit 0 was just fixed for and unit 3 was left under. A DAR has to be brought onto the coded frame to become a pixel ratio, and that multiplies by the coded size, so what reduces afterwards carries the sizes. A 239:100 scope -- 2.39:1 -- derives 2151:1600 over a 1920x1080 coded track and the same over 3840x2160, both past the 1024 bound, while over 1440x1080 it derives 717:400 and passes. So the bound read the same ratio three different ways depending only on the frame it sat on, and refused the two frames a scope is most likely to arrive on. Measured, not inferred. `PixelAspect::stated_ratio` now takes the DAR against the coded frame unreduced and refuses only the degenerate case, so `width_factor` multiplies the coded width by it and bounds the raster with `MAX_DISPLAY_WIDTH` -- a bound on the picture rather than on the digits of a derivation. The pair itself is the engine's own model, unchanged, so every sane picture reads exactly as it did before. Witnesses, with the expected widths measured by running BASE 0c9d76c over the same fixtures rather than recomputed by me: - 239:100 over 1920x1080 coded -> 2582 (base 2582) - 239:100 over 3840x2160 coded -> 5162 (base 5162) - 239:100 over 720x576 coded -> 1376 (base 1376) RED before this change, reproduced on the same fixtures: the first two opened square at the coded size; only 720x576, which reduces to 239:125 and so passes the bound, stretched. Non-vacuity proven by mutating the arm back through `stated()` and watching the test go red. While matching base I also found and reverted a regression of my own: I had written the even-grid rounding as `next_multiple_of(2)`, which rounds UP, where the original `(x | 1) & !1` rounds DOWN. That would have silently moved every existing anamorphic picture by two columns (3840x2160 at 239:100 scales to 5163 and has always displayed 5162, not 5164). Restored to the original rounding, and the three expected widths above pin it. `a_hostile_sar_pair_is_still_refused_by_the_term_bound` holds the other half: the unit-4 SAR pair IS a ratio, so chosen bytes are still refused there, and a real 4:3 -- reduced or not -- is still read. The bound was moved off the arms it cannot judge, not dropped.
fix(demux): judge a DisplayUnit 0 pixel pair by its raster, not by its termsAhmet Kaan Gümüş · 598e6c8
fix(demux): judge a DisplayUnit 0 pixel pair by its raster, not by its terms
Verification found a real defect in the previous commit: it applied the
reduced-term ratio bound to `DisplayUnit 0`, where the `Display*` pair is a
pixel SIZE. Reducing it against the coded size carries the *sizes*, not terms,
so the bound refused the two most common letterbox ratios on exactly the arm
the fix newly enabled: on a 1440x1080 coded track, 1920x1080 (4:3) opened
correctly but 1920x803 (2.39:1 scope) and 1920x1037 (1.85:1 flat) both
opened square at 1440x1080. The unit-3 DAR spelling of the same picture
(239:100 -> 717:400) was unaffected, because a DAR pair does reduce to small
terms.
The two bounds answer two different questions and are now kept apart:
- `stated` -- for a pair that IS a ratio (an mp4 `pasp`, `DisplayUnit 4`,
a unit-3 DAR). A reduced term past 1024 means chosen bytes, and that is
the right test there.
- `stated_size` -- for a unit-0 pixel pair. It takes the stated display
WIDTH and refuses only the degenerate claims (a zero half). Width is the
only axis an aspect moves in this engine: `VideoMeta::height` is the
coded height for every file, by design and by its own documentation, so
the height half of the pair is not taken and the raster bound in
`width_factor` (`MAX_DISPLAY_WIDTH`) is what limits the result.
`width_factor` no longer applies the term bound at all, because it is the one
function every door reaches and cannot tell whether its ratio was read or
built. Judging the raster has no conflict: it catches the wrap and the zero
without refusing a scope.
Witness RED, measured on the fixture, before this change: both cinematic
ratios reported `PixelAspect { h: 1, v: 1 }` -- square.
The unit-0 witness is also restated to match this engine's model honestly: a
1920x803 scope is drawn 1920x1080 here. The width is the file's own claim; the
height is the coded one, because a pixel aspect has never moved the height in
this codebase and this lane does not change that.fix(demux): the mp4 door gets the resolution bound the Matroska one now hasAhmet Kaan Gümüş · fcb7844
fix(demux): the mp4 door gets the resolution bound the Matroska one now has
The previous commit bounded `PixelWidth`/`PixelHeight` and left the mp4 arm
reading its dimensions unchecked. The mp4 crate types a track's width and
height as `u16`, which is a smaller claim than Matroska's EBML integer but
still eight times past `MAX_RESOLUTION`: a visual sample entry of
`ff ff ff ff` is a legal 65535x65535, and it reaches the same
`display_width * height` allocation in `decode.rs`.
Both doors now refuse a stated picture past the bound, by the same
`UnsupportedDisplaySize`.
Witness, with non-vacuity proven: the test patches the first visual sample
entry's two 16-bit dimension fields of a copy of `assets/test_baseline.mp4`
(offsets 32 and 34 into the entry) to `ff ff` and asserts the open is refused
by name. With the bound removed from the source the test fails ("a 65535x65535
mp4 is refused by name, never opened"), so it bites.fix(demux): a container may not state a picture past the resolution boundAhmet Kaan Gümüş · 48ad076
fix(demux): a container may not state a picture past the resolution bound The class sweep for lane H, and it found one more instance of the same defect one layer down from the `pasp` one: `mkv_tracks` read `PixelWidth` and `PixelHeight` with a bare `ebml_uint(...) as u32`, so a Matroska header could state any picture at all and the engine opened it. `crate::MAX_RESOLUTION` (8K) already existed for exactly this, and was applied to a keystroke (`PlaybackSession::set_resolution`) and to a `.edith` `resolution` line -- but never to a container header. So 65535x65535 opened cleanly, and `decode.rs:1324` then sized its stretched planes as `display_width * height`: 6_442_254_337 bytes for one frame's luma and chroma, before a single pixel is read. The `as u32` narrowing made it worse in the other direction too -- `PixelWidth` of 2^32+1440 truncates to 1440. Both elements are now refused by name, `UnsupportedDisplaySize`, matching the existing `NoVideoTrack` / `UnsupportedRotation` convention (Display impl, Error impl, `is_it`), so the open fails with a message naming the size claimed and the maximum, and a caller can match the type rather than the prose. Witness RED: the patched fixture opened and reported `65535x65535` coded, with the test naming the 6.4 GB allocation `decode.rs` would have sized from it. A companion test holds the other half of the contract -- the ordinary fixture is inside the bound and still opens -- so the bound cannot quietly become a refusal of the library.
fix(demux): an untrusted pasp ratio cannot size a zero or wrapped rasterAhmet Kaan Gümüş · 33ee2ba
fix(demux): an untrusted pasp ratio cannot size a zero or wrapped raster
The mp4 `pasp` box is eight bytes of header and both halves went into
`PixelAspect { h, v }` unvalidated, while every other arm of that reader
validated. Four consequences, all reachable at file open, before a pixel is
drawn:
- `is_square()` treated `h == 0, v == 5` as non-square, though its own
comment claimed it covered "a degenerate one a crafted header claimed";
- `width_factor` divided by nothing, giving `h == 0` a factor of 0;
- `width_factor` narrowed `coded * h` from a u64 to a u32, and 1920 *
0x00FF_FFFF wraps to 2_147_481_728;
- both flowed into the `resize` that sizes the decode worker's stretched
planes and into `meta.width`.
`width_factor` is now total: it refuses anything `PixelAspect::stated` calls
unusable (a zero half, or a reduced pair carrying a term past 1024 -- judged
reduced, so ffmpeg's unreduced 17280/12960 spelling is judged by the picture
it names), computes in a u64 that cannot overflow, and falls back to the
coded width rather than narrowing to a zero or an oversized raster. The bound
that keeps a header claim from sizing an unsatisfiable allocation is
`MAX_DISPLAY_WIDTH`. `pasp_of` judges the read through the same `stated`, so
the aspect this engine *reports* is one it can draw.
Sane ratios are unchanged bit for bit: 4/3 over 1440x1080 is still 1920.
Witnesses:
- demux unit: six degenerate claims (both zero halves, both wrap directions)
must all read as the coded width. RED: `h:0,v:1 -> 0`,
`h:16777215,v:1 -> 2147481728`, `h:1,v:16777215 -> 0`.
- end to end: a byte-patched copy of assets/test_baseline.mp4, its eight
`pasp` payload bytes replaced, opened through the ordinary door. RED was a
hard SIGABRT -- "memory allocation of 3092375531520 bytes failed" -- not an
assertion failure, which is the whole severity of the defect.2026-09-24
fix(decode): stretch before the turn, so a rotated anamorphic file fills its canvasAhmet Kaan Gümüş · f4bc699
fix(decode): stretch before the turn, so a rotated anamorphic file fills its canvas A 1440x1080 SAR-4/3 file with a 90-degree display matrix rendered 1440x1440: the render composed turn-then-stretch, landing the ratio on the coded height, and the square raster sat letterboxed inside the 1080x1920 canvas the probe declares -- bars in the preview and baked into the export. The ratio belongs to the axis that was horizontal BEFORE the turn: the coded width is stretched by h/v and the turn then swaps the stretched pair, which is what the probe has declared all along. Render::frame and place_picture now both stretch first, the one order that agrees with the probe. The suite's rotated case had been vacuous -- the in-test fixture was a setsar file with no display matrix, asserting nothing about the turn. It now remuxes a real 90-degree matrix on (-display_rotation 90, the gen_fixtures pattern), asserts the probe's swapped stretched pair (1080x1920, not 1440x1440), and drives the render through the same assertions; the export test grows the rotated clip with preview-vs-export equality. Mutation witness: with the render reverted to turn-then-stretch the new assertions fail with exactly left (1440, 1440) / right (1080, 1920). The demux comment now names the render's order and the failure the other one produces, so the two can't drift again.
probe(demux): sample aspect ratio off the container, coded dims beside the display pairAhmet Kaan Gümüş · 66a1c40
probe(demux): sample aspect ratio off the container, coded dims beside the display pair ffmpeg's model: the decoder keeps coded pixels and carries the SAR as metadata. VideoMeta carries the pair now: coded_width/coded_height are what the samples are stored at, pixel_aspect is the ratio one coded pixel is drawn at (PixelAspect, square when nothing is stated), and width/height stay the displayed shape their docs always promised -- stretched by the aspect, then swapped by the turn, in that order. mkv: DisplayWidth/DisplayHeight/DisplayUnit read off the Video element (units 3 DAR and 4 SAR; absent, or units 0/1/2, square -- measured against ffmpeg 8.1.2, which writes a 16/9 DAR pair with unit 3 for a setsar=4/3 source and nothing at all for a square one). mp4: pasp (hSpacing/vSpacing) out of the visual sample entry, behind the same fixed 78-byte header colr and hvcC sit behind, absent = square -- measured: ffmpeg writes pasp 4/3 for setsar=4/3 and 1/1 otherwise. VhMeta's twin fields ride along so the plugin ABI can carry the same answer once a display size differs from the coded one.
♻️ refactor(media): one ISO 639 table, the demuxer's, for both sidesAhmet Kaan Gümüş · 737b171
♻️ refactor(media): one ISO 639 table, the demuxer's, for both sides The mux lane had carried its own copy of the demuxer's ISO 639-1 → 639-2 table because that one was private to its module. Make the demuxer's `pub(crate)` and have the muxer read it, so the two can no longer drift; the copies were byte-identical, all 183 entries, so nothing is dropped.
🐛 demux: close the block walk's unchecked add, and one mkv conventionAhmet Kaan Gümüş · 7a52aa1
🐛 demux: close the block walk's unchecked add, and one mkv convention
Four things the re-verification left behind, each either the same class as what
this lane already fixed or a promise its new text made.
The video block walk's own timestamp -- the one a copy reads -- was still
accumulated unchecked (`cluster_ts + i64::from(block.rel)`), one step before the
scale the subtitle walk widened: a crafted cluster near the top of what an `i64`
holds overflows the add before anything could refuse the product, and the block
is taken at a time that wrapped negative. Both walks now call one `block_ticks`,
and the unit test covers the add as well as both scales.
`VideoMeta::rotation`'s doc listed a spherical projection among the turns refused
at the door, but `projection_rotation` deliberately does not refuse those -- the
pose of a spherical projection is the sphere's orientation, not the picture's --
so the sentence says that instead of claiming a refusal no code makes.
The mkv door fed the *coded* height to the 720-line rule an untagged stream's
matrix is guessed from, where the mp4 door feeds the displayed one. That was
harmless until this lane made the two differ, and then an untagged turned `.mkv`
and its `.mp4` twin landed on different matrices: 1280x640 as stored, 640x1280 as
shown, so bt601 against bt709. Both doors now feed the height the picture is
*shown* at, and `test_rotation90tall.{mp4,mkv}` (generated, untagged in both
containers) pins it -- the assertion fails with the coded height, which was
verified by putting `video.height` back and watching it fail.
And the export test runs on the mkv twin too, because a turn reaches the export
through exactly one number (the source's `Rotation` in the export's rate table),
and only a both-doors test shows a door that reads its own spelling into that
number differently.
cargo check -p engine --all-targets: 0 warnings. cargo test -p engine --test
rotation: 5 passed. subtitles: 22 passed. cargo test -p engine --lib: 392 passed,
0 failed. rustfmt --edition 2024 reports the same nine pre-existing hunks on
demux.rs as base, none in the added code, and none on the test file.⏪ demux: keep the turn, drop the display size; widen the block walk's ticksAhmet Kaan Gümüş · 9b42f9f
⏪ demux: keep the turn, drop the display size; widen the block walk's ticks The display-size adoption is reverted: `VideoMeta.width/height` mean exactly what they meant at base again -- the coded size with the turn applied -- and nothing reads `pasp`, `DisplayWidth`, `DisplayHeight` or `DisplayUnit` any more. Reading them without applying the pixel aspect anywhere in the pixel pipeline made an anamorphic source *worse* rather than better: the canvas of a freshly opened file is built from `meta.width/height`, while `Render::frame` only rotates and placement is an aspect-preserving `Fit` of the coded frame, so a 1440x1080 source became a 1440-wide pillarboxed picture inside a 1920x1080 canvas with the bars baked into the preview and the export; and `CopyPlan::of` hands those two numbers to `CopyParams`, so an exact Matroska copy declared PixelWidth 1920 while copying 1440x1080 blocks and dropped the source's display elements -- a file that plays right nowhere. Anamorphic support is a feature slice (the stretch stage in `export::place_picture` and in the decode funnel), not a container-reader fix, so it leaves together with its fixtures and the test that asserted it. Kept, because they are the defect this lane was chartered for: the Matroska `Projection` roll is read as the turn it is (`rotation_of_roll`, `projection_rotation`, with the same refusal by name for anything that is not a quarter turn) -- now asserted for the mkv twin too, which was generated but read by nothing before. And the multiply the subtitle walk had is widened for the block walk a copy reads: `coded_block`'s `ts_ns` was `block.ts * timestamp_scale` in `i64`, where a crafted cluster timestamp overflows -- a panic in debug and a negative block time in release, silently. One `ticks_scaled` now serves both walks, and the unit test covers both (microseconds at `per_tick` 1_000, nanoseconds at 1). cargo check -p engine --all-targets: 0 warnings. cargo test -p engine --test rotation --test subtitles: 4 passed + 22 passed. cargo test -p engine --lib: 392 passed, 0 failed.
🐛 demux: read the turn and the shown size a file states for its pictureAhmet Kaan Gümüş · 30b435d
🐛 demux: read the turn and the shown size a file states for its picture
A Matroska `Projection` roll, the `DisplayWidth`/`DisplayHeight` pair and an
mp4's `pasp` box were read by neither door, so a rotated `.mkv` played and
exported sideways, and an anamorphic source -- HDV's 1440x1080, a DVD's 720x576
with a display width -- probed, previewed and exported squashed. Neither had a
message: both were silent wrong output.
The engine could already turn a picture (`scale::rotate_i420_90s`) and already
collapsed a file's coded size into its displayed one off an mp4 `tkhd` matrix.
Both doors now do the same two steps in the same order: the size the file says
the picture is shown at, then the turn. The roll is *negated* to get the quarter
count -- it counts counter-clockwise degrees where the matrix counts clockwise
turns -- and that direction is measured, not derived: the new
`test_rotation{90,180,270}.mkv` fixtures are the same quadrant source as their
`.mp4` twins (one `ProjectionPoseRoll` of +90, +180, -90, byte-verified by
walking the header), ffmpeg reads each back as the same display matrix, and both
autorotate to the same four corners -- which is what `tests/rotation.rs` asserts
corner by corner, through the preview funnel as well as the probe.
A rectangular projection mirrored or tilted out of its own plane is refused by
name like the mp4 door refuses a 45-degree matrix: mkvmerge v95 states a mirror
with a yaw, and a picture out of plane has no rendition here. A spherical
projection's pose is left alone -- on those the same elements describe the
sphere, and a flat player shows a 360 file rather than refusing it.
The subtitle walk's tick arithmetic is widened to `i128` and made fallible: the
multiply is where a corrupt cluster timestamp overflows, a panic in debug and a
negative cue time in release, silently.
Fixtures live in `assets/`, which is gitignored and symlinked to the shared pool,
so they are generated rather than committed: `scripts/gen_fixtures.sh` writes
both the mkv turns and the anamorphic pair.
Still open, and not made worse here: the anamorphic *placement*. `Composer`
letterboxes, so a 1440x1080 picture in the 1920x1080 canvas the file states gets
bars rather than its samples stretched to the shown shape -- the stretch belongs
in `export::place_picture` after its turn, and in the decode funnel for the
preview.2026-09-18
🐛 fix(media): audio routing, session audio re-arm, hw trailing-zero NALs, display-matrix rotationAhmet Kaan Gümüş · bc8b82e
🐛 fix(media): audio routing, session audio re-arm, hw trailing-zero NALs, display-matrix rotation - is_audio admits .mpeg/.mpg so mp3-with-cover files import (was fed to Mp4Demuxer) - session audio walks past trackless leading sources and re-arms when a sounding file joins a silent timeline (fixes add/remove/add silence) - engine-hw pump clears trailing cabac_zero_word bytes instead of dying with code -2; export falls back to software decode before first frame - tkhd display matrix read for mp4; 90/180/270 turns baked into preview and export pixels; other angles refused by name (UnsupportedRotation)
2026-09-12
🔁 feat(audio): the AC-3/E-AC-3 decode seat is the native ec-ac3Ahmet Kaan Gümüş · 9fab7c9
🔁 feat(audio): the AC-3/E-AC-3 decode seat is the native ec-ac3 oxideav-ac3 leaves the tree. One decoder reads both syntaxes, dispatching per packet on bsid, and hands back interleaved f32 -- the seat asks for its own A/52 §7.8.2 stereo fold on anything wider than mono, per-position coefficients from each frame's own acmod and mix levels, so no width is refused any more (the 2.1-at-3ch passthrough refusal dies with the library) and the mono digital-silence corner-cut is gone with it. Witnesses on real content, identical packets, old seat vs new: - AC-3 5.1 film: per-channel correlations 0.99965-0.99999, rms ratios 1.001; the residual is the format's unspecified dither noise -- against ffmpeg's own decode both decoders sit equally close, and the two spots where they did not agree are OLD-seat deviations (the 2.0 rematrixing decode: 0.92/0.76 vs ffmpeg, the new seat 0.99997; the LFE: 0.976 vs ffmpeg, the new seat 1.000000). - E-AC-3 5.1 film: correlations >= 0.99998 on all six channels, rms 1.000. - Decode speed 1.64-1.68x the old seat (min-of-7, ~320x realtime 5.1). - Named coverage edge, refused by name at open, not silently: Annex E dependent substreams and enhanced coupling (7.1 DD+ assembled as 5.1-plus-dependents) -- oxideav walked those, ec-ac3 refuses them. Every single-substream AC-3 and E-AC-3 track decodes. New film witness file tests/audio_ac3_film.rs (seek-landing + ffmpeg correlation on a real AC-3 5.1 film and a real E-AC-3 5.1 film, mirroring the Opus/AAC film witnesses), real_library.toml.example documents the ac3_51_film key. caps row and the codec-table comment follow the seat.
♻️ refactor(engine-hw): the VP8 decode seat is ec-vp8 native -- libvpx and its hand-written FFI are deleted, the plugin links the decoder as ordinary Rust (56 ec_vp8 symbols, no DT_NEEDED, no dlopen); VpxSession keeps its five-verb boundary (init/decode/flush/get_frame, destroy now the drop of an owned decoder) and everything above it is untouched; CAP_VP8 lights unconditionally and still never reads as a GPU seat; A/B byte-exact against the libvpx seat on the 1280x720 fixture (60/60 frames), the 2560x1321 odd-size webm (270/270) and a two-pass auto-altref stream (90/90 shown, 6 hidden produce none, seek landings identical); vp8 twins 4/4, capability_matrix+backends+caps green, --all-targets 0 warningsAhmet Kaan Gümüş · 36bd0e7
♻️ refactor(engine-hw): the VP8 decode seat is ec-vp8 native -- libvpx and its hand-written FFI are deleted, the plugin links the decoder as ordinary Rust (56 ec_vp8 symbols, no DT_NEEDED, no dlopen); VpxSession keeps its five-verb boundary (init/decode/flush/get_frame, destroy now the drop of an owned decoder) and everything above it is untouched; CAP_VP8 lights unconditionally and still never reads as a GPU seat; A/B byte-exact against the libvpx seat on the 1280x720 fixture (60/60 frames), the 2560x1321 odd-size webm (270/270) and a two-pass auto-altref stream (90/90 shown, 6 hidden produce none, seek landings identical); vp8 twins 4/4, capability_matrix+backends+caps green, --all-targets 0 warnings
✨ feat(engine): a native AV1 decode seat — ec-av1 takes AV1 sources with no plugin in the roomAhmet Kaan Gümüş · 875b31a
✨ feat(engine): a native AV1 decode seat — ec-av1 takes AV1 sources with no plugin in the room The software arm of decode.rs grows a second seat beside ec-h264: probe(), open_worker()'s plugin gate and run_span() all take Codec::Av1 as a software-covered codec, falling back to ec-av1 exactly where H.264 falls back to ec-h264. VE_SW=1 pins it, Backend::Software reports it. The seat feeds ec-av1's whole-stream door the way the demuxer assembles AV1 anyway: access units from the landing sync sample to the next one are one chunk (the sequence header the demuxer injects ahead of every sync sample is the boundary marker), and each chunk is a legal random-access stream that decodes to its end — so hidden reference frames drain and the reorder tail lands. A span stops decoding at its last asked-for picture via a sink Eof sentinel; a refusal out of ec-av1 fails the span in words mid-film, the pictures decoded so far standing, never garbage. u16 planes narrow at the seat: 0..=255 casts, 10-bit downshifts by two — the same truncation the plugin's P010 read-back performs, so both seats hand the renderer byte-identical planes. Witnesses: plugin vs seat frame-for-frame byte-exact on test_av1.mkv and on the 10-bit twin (frame 30, 0 differing bytes both); seek-landing equals linear on the software seat across a keyframe interval; a crafted broken-GOP file (keyframe-flagged inter frame) is refused by name — "no saved CDF state" — with the first GOP standing and the channel closing clean. Perf (release, funnel incl. demux+convert, identical config both sides): VA-API 2.0x the seat on 720p8 (100 vs 51 fps), 1.8x on 720p10 (95 vs 53), 4.9x on a 1920x792 10-bit film (199 vs 41 fps, seat 1.70x realtime), 3.5x on a 3840x1608 10-bit film (22 vs 6.2 fps, seat 0.26x realtime — below 1x, but so is the plugin's own 0.92x there: the BGRA conversion dominates that funnel). 1.70x realtime at 1080p-class clears the threads-wiring bar, so EC_AV1_THREADS stays opt-in. demux::needs_plugin's AV1 arm now names the export path (whose software decoder stays H.264-only) instead of claiming no software decoder exists; bit_depth()'s doc gains its second reader.
Merge branch 'lane-h264-swap' (e24fe61): the software H264 decode seat is ec-h264 native via the ec_core registry -- and the seat now emits true DISPLAY order (the rusty corner-cut scrambled B-picture content); byte-exact vs rusty on CAVLC and CABAC+B fixtures, perf 1.02-1.57x on the gate classes, 0.80x on B-frame CABAC (the DPB reorder price; lane-ech264-perf queued); rusty_h264 stays for the ENCODE seat onlyAhmet Kaan Gümüş · c612711
Merge branch 'lane-h264-swap' (e24fe61): the software H264 decode seat is ec-h264 native via the ec_core registry -- and the seat now emits true DISPLAY order (the rusty corner-cut scrambled B-picture content); byte-exact vs rusty on CAVLC and CABAC+B fixtures, perf 1.02-1.57x on the gate classes, 0.80x on B-frame CABAC (the DPB reorder price; lane-ech264-perf queued); rusty_h264 stays for the ENCODE seat only # Conflicts: # Cargo.lock # crates/engine/Cargo.toml # crates/engine/src/decode.rs # crates/engine/src/demux.rs
♻️ refactor(engine): the software H.264 seat decodes with ec-h264Ahmet Kaan Gümüş · e24fe61
♻️ refactor(engine): the software H.264 seat decodes with ec-h264
decode::run leaves `rusty_h264` for `ec_h264::H264Decoder` (path dep on
../../edith_codecs, `ec_core` beside it for the registry contract):
packets in over the demuxer's Annex-B access units, frames out through
send_packet/receive_frame with a flush at end of stream so the reorder
delay releases its tail.
Semantics: the old loop emitted pictures in decode order and counted
access units -- a corner-cut that only held for Baseline, and scrambled
exactly the B-picture streams it could not reorder. ec-h264 bumps the
DPB (clause C.4.5.3) and hands pictures back in display order, so the
landing index the demuxer's seek reports and the label each frame ships
with now count the same thing: timeline positions, which the transport,
skip_for_speed and the hardware backend already assumed. Witnessed on
test_high.mp4 (B pictures): the seat delivers 0..150 in order where the
old seat delivered the same frames reshuffled and mislabelled.
Tests: tests/sw_backends.rs is the byte-exactness witness -- ec-h264
against rusty_h264 (kept as the independent oracle) on CAVLC Baseline
and CABAC High fixtures, decode order per position and display order as
a multiset, with the reorder engaged only where the stream reorders;
hw_decode's software halves (seek_matches_linear, range_stops_at_end,
hardware_matches_software_on_frame_30) pass against the VA-API backend.
Throughput (raw demux+decode, idle machine, best of three): 1.52x
rusty_h264 on a 1080p Main export and 1.57x on a 4K Main render, 1.02x
on a 1440p High screen recording, 1.17x on CAVLC Baseline; 0.80-0.81x
on the two B-picture CABAC streams measured -- the measured price of
the full DPB the old seat skipped. cargo check -p engine: 0 warnings.
rusty_h264 stays linked for the export encode seat (Encoder,
EncoderConfig, Preset, YuvFrame) and export's own SwDecoder, so the
dep, the rusty_h264-common vendored patch (the rusty_alloc
global_allocator landmine) and their Cargo.lock entries are load-bearing
until that seat moves to ec_h264::Encoder; caps names the split honestly
('ec-h264 / rusty_h264').✨ feat(engine): software VP8 decode via dlopen'd libvpx seat in the pluginAhmet Kaan Gümüş · ba33df0
✨ feat(engine): software VP8 decode via dlopen'd libvpx seat in the plugin
VP8 was refused by a stale UNSUPPORTED claim ('no VP8 decoder'); the
vendored cros-codecs VP8 decoder is VA-API-only and the test GPU
exposes no VP8 VA-API profile, so the real seat is software: libvpx.so.9
dlopen'd inside libengine_hw.so (vpx.rs), routed before any GPU device
opens, seek = destroy+re-init on the demuxer's keyframe contract,
CAP_VP8 reported as the plugin's seat. Codec::Vp8 plumbed through
demux (V_VP8 + mp4 vp08), colorspace, refusals; export UI gains a
truthful read-only VP8 row; test_vp8.{webm,mp4} fixtures + capability
row + tests/vp8.rs decode/export twins. Verified by the authoring
session: headless playloop 270 frames 0 dropped, 50/50 seeks, live
harness-driven UI playback, cross-provider review PASS (FFI layouts
against shipped libvpx DWARF, valgrind-clean).2026-08-26
Merge branch 'worktree-agent-a4b3e198388f130b7'Ahmet Kaan Gümüş · a72c5c5
Merge branch 'worktree-agent-a4b3e198388f130b7' # Conflicts: # crates/engine/src/demux.rs
🧪 test(engine): let the cancel-walk test skip fixtures the video demuxer refusesAhmet Kaan Gümüş · 4257e49
🧪 test(engine): let the cancel-walk test skip fixtures the video demuxer refuses The Matroska fixture sweep now also finds the audio-only test_ac3.mka, which sorts first and which MkvDemuxer::open rightly refuses -- the test panicked on its own expect before measuring anything. Take the first fixture the video demuxer accepts, the shape the cue-index sweep below already uses.
🐛 fix(engine): DEBT #91 — proxy Asked phase now cancels its header readAhmet Kaan Gümüş · ba29145
🐛 fix(engine): DEBT #91 — proxy Asked phase now cancels its header read generate_if_wanted takes the same cancel flag Job::cancel later polls: a click to stop a stand-in while the header is still being read used to have nothing to set, so the read (a Matroska cluster walk) always ran to completion before the stop landed. Checked at the door once the seat is claimed and wrapped around Demuxer::open (demux::with_cancel), so a pre-set or mid-read cancel unwinds promptly and gives the seat back the same way a cancelled encode does (Claim's own Drop).
🐛 fix(engine): cancel an mp4 import mid-moov, same as the mkv armAhmet Kaan Gümüş · 8a96a5a
🐛 fix(engine): cancel an mp4 import mid-moov, same as the mkv arm Mp4Reader::read_header ran the whole moov parse uncancellable while the Matroska arm's walk polled the flag per element -- a cancelled import of a big mp4 blocked until the header finished (debts #57/#58). Wraps the BufReader<File> handed to Mp4Reader in a CancelableReader that checks demux::cancelled() on every read(), surfacing a "read cancelled" io::Error the mp4 crate propagates as-is, so is_cancelled classifies it the same way as the mkv path. No fork of the mp4 crate.
2026-08-13
🔀 merge(engine): the stand-in decides one path, and the intra file keeps its marksAhmet Kaan Gümüş · eff035e
🔀 merge(engine): the stand-in decides one path, and the intra file keeps its marks Lane P's proxy workflow meets a main that had taken S's persistent decode workers, E's pipelined export and E4's zero-copy encode. * `start_span` keeps S's reuse door and P's single substitution point at once: `picture_path(source)` is resolved *before* the door and handed to both halves of it. A worker holding the film is then asked for a span of the stand-in, declines on the path it already has (`Worker::reseek`), and `set_proxies`' seek becomes a respawn on the other file -- while a span that did not change files still costs no thread and no VA-API init. Asking the project for the path at the door, as main did, would have left every proxied span opening a worker from scratch. * `Enc::encode_dma` takes P's `intra` flag, which is not symmetry: a proxy of a file already small enough is coded at that file's own size (`proxy::size_for` -- `wanted` is true for HEVC and AV1 at any size), so an intraframe export's decoder and encoder can agree on a surface and the buffer goes straight across. Marked `false` there, an all-intra stand-in would have carried no sync point at all, which is the exact bug `gop_limit` was written against, reached by the other door. * The five other conflicts were both sides adding a field: `drop_late` and `proxies` next to each other, in the struct and in all three opens. * `enc_depth` is keyed by codec, so the intra seat takes H.264's two. Said in its doc rather than left to be re-derived: that seat is the same entrypoint with every inter dependency removed, so a picture there is finished no later than one on the seat the two was measured on. `nm -D libengine_hw.so` lists sixteen: P's `vh_enc_open_intra` beside E4's `vh_next_frame_dma`, `vh_enc_dma_geometry`, `vh_enc_frame_dma` and main's `vh_seek`. `picture_path` still has exactly one call site outside the tests, and it is in `playback` -- an export reads the film. The intra seat and the zero-copy path are read, not run: every test that would reach either is hardware-gated and the GPU is wedged.
🐛 fix(engine): "no picture in it" is a header's answer, not an extension's guessAhmet Kaan Gümüş · 627d623
🐛 fix(engine): "no picture in it" is a header's answer, not an extension's guess Two residuals of the proxy round, and the doc line that makes a hardware run measure the code it was meant to. The quiet answer for a file that is not a film was name-shaped: an audio-only `.mp4`, `.mkv` or `.mov` is a video container with no video track in it, so no extension can tell and every one of them still opened, failed and said "NO PROXY" about a song. Only the header knows, and the demuxer already knew -- it just said so in prose, which is the one thing in this engine free to be reworded. `NoVideoTrack` makes it a type: the two doors that mean *this file carries no picture at all* return it, a front-end still shows the sentence it always showed, and the proxy takes it as the same silent `None` a 1080p film gets. A picture in a codec nothing here decodes is not that class and stays loud. ...and the cap was soft by exactly what it was capping: the sweep aimed at 20 GB and then two encodes wrote gigabytes on top of it, so the disk held the cap plus a film per encode (~43 GB worst case). It now sweeps to `CACHE_CAP - reserve`, where the reserve is what those encodes will really take -- the file's own bits-per-pixel arithmetic times the 1.25 the hardware seat overshoots its asked-for rate by -- held to half the cap so a single 4K feature cannot empty the cache to make room for itself. `AT_ONCE` moves into the engine beside that arithmetic: how many encodes run at once *is* how much room the sweep must leave, and two places holding that number is one place for them to disagree. The ignored hardware tests now say to build `-p engine-hw --release` as its own step: `--tests` does not rebuild the cdylib, so the plugin beside the test binary is whatever was there last time -- and a hardware claim measured against a stale one is a claim about code nobody edited. One commit rather than two: both fixes are in `proxy.rs`, in regions a hunk split cannot separate cleanly (it was tried once and produced a corrupt intermediate), so each is named here instead.
🐛 fix(import): Cancel stops the read, not only the landingAhmet Kaan Gümüş · 4d0dd2b
🐛 fix(import): Cancel stops the read, not only the landing The Cancel beside the import line gave the window back and let the disk carry on: a cancelled cold 24 GB remux still cost its twenty seconds, and the notice said so rather than doing anything about it. The flag now reaches the walk — `demux::with_cancel` installs it as the reading thread's own, and every Matroska cluster the header index and the subtitle pass step over checks it and gives up there, with `is_cancelled` telling an abandoned read from a file that would not open. Thread-scoped rather than a parameter, deliberately: a read *is* a thread here (an import worker, an audio feeder, a decode worker), and the walk that has to stop sits five frames under an `open` with a dozen callers, none of which have anything to cancel. An mp4's header stays uncancellable — it is one read inside `mp4::Mp4Reader` with no flag to poll — so the notice and the button say the read stops "where the container lets it" instead of promising the disk went quiet. The feeder's own abandoned opens are NOT wired to this, and the corner-cut in `spawn_feeder_deferred` says why: three runs of one build over 200 cold scrub steps measured 14, 101 and 137 live workers, so that number is the machine's and not the cancel's — and cancelling every step's walk would stop the sidecar index from ever being written, which is the thing that makes the second pass over a film fast.
✨ feat(engine): a big film gets a small stand-in to cut withAhmet Kaan Gümüş · 83e561d
✨ feat(engine): a big film gets a small stand-in to cut with A proxy is the film at 1280 on its long edge, every frame an IDR, no sound in it at all: a seek lands on the frame asked for instead of on the nearest one a decoder can start from, and the mix stays the original's. Generation is the export walk given a one-clip project and a smaller canvas, so the hardware seat, the progress and the cancel are the ones a file export already had. Two switches were wanted for it: `intra_only` (one frame a GOP on the H.264 pair) and `keep_source_colour`, which carries the film's own space into the stand-in instead of converting it -- that conversion ran on the source's full 4K, cost 48 ms a frame and was the whole of a proxy's price, and leaving it to the screen means the tone-map preset can still be changed after the stand-in was made. The cache is keyed on the source's path, length and modification time, so a re-encoded original misses rather than reading a stale stand-in. A 4K HDR film: 2.35x realtime on the VA-API seat, against 0.59x before the colour switch; a cancel leaves neither the file nor its .part.
chore: rename ponytail: comment marker to corner-cut:Ahmet Kaan Gümüş · 9ba8e0a
chore: rename ponytail: comment marker to corner-cut: Marker convention renamed after uninstalling the ponytail plugin; semantics unchanged (deliberate corner-cut, known ceiling + upgrade path). Token-only rename, 81 comment lines, no code change.
2026-08-12
⚡ fix(export): the sound of a feature film is measured in a minute, not in half an hourAhmet Kaan Gümüş · 3fc6753
⚡ fix(export): the sound of a feature film is measured in a minute, not in half an hour
An mkv export of a two-and-a-half-hour film wrote zero bytes for twenty-one
minutes and then failed its own test's ten-minute cap. All of it was the Opus
fidelity gate: `ruopus` is built here without its `spectrograms` feature, so its
inverse MDCT is an O(n²) DFT with a `sin_cos` per term and decodes at 0.2x real
time. Measured on a two-minute window of a real 4K film (the new
`export_audio_cost` example, and the three `export audio:` lines it reads):
mix (E-AC-3 5.1 -> stereo) 0.7 s
Opus encode (opus-rs) 0.3 s
fidelity decode-back 24.2 s <- 98.6% of the pass
So the gate now samples: twelve five-second windows spread across the track, a
warm-up per window because CELT predicts across frames, and the *worst* window
is the answer -- which is harsher than the old whole-track sum, where a ruined
minute averaged away against two good hours. What it looks for survives
sampling: OPUS_MAX_KBPS's cliff is a rate the encoder falls off, not a defect of
one bar of music. A window with no sound in it is skipped rather than scored
0.0, which is what a silent timeline used to score before falling back to AAC.
...and the export no longer decides what it is *after* paying for the sound:
CopyPlan is consulted first, so the line on screen says "copy" from the first
second, and the audio pass owns the head of the progress bar instead of leaving
it at zero for as long as it runs.
Beside them, for the card that has been predicting the wrong export in both
directions: `planned_seats` asks the export's own gates what it would open, and
`sync_points` hands a front-end the frames a cut may be placed on.
cargo test -p engine --release --test video_copy -- --include-ignored
7 passed in 157.6 s (was: failing the 600 s cap)✨ feat(export): an untouched Matroska timeline leaves as its own packetsAhmet Kaan Gümüş · ada6ac5
✨ feat(export): an untouched Matroska timeline leaves as its own packets The picture's half of what `copy_audio` already did for the sound: where a copy says exactly what the timeline says, the coded blocks of the source are written straight into the file and no decoder or encoder is opened at all. The gate is the audio one's doctrine, not a looser one -- Matroska in and Matroska out, the source's codec is the one this format carries (HEVC for `Format::Hevc`, AV1 for `Format::Av1`), and nothing has touched a sample: no grade, no speed, no rate conversion, no gap to fill with black, no source of another size, no `ContentEncodings` packing to undo. Every span must begin on a sync point and end where the next begins, which is what placing a cut on a keyframe gives it. All or nothing per export, and that is the interesting constraint: a copied span and an encoded one cannot share one track, because this project's encoders write 8-bit SDR streams with parameter sets of their own and a container states its configuration record once -- splicing them into a Main 10 HDR source would change bit depth and colour mid-track. So the head and tail fragments of a cut that lands mid-GOP are not re-encoded into the copy; they are what makes the whole export fall back to the encoder it always used. A copy keeps its source's `Colour` as well as its `CodecPrivate`: an HDR film copied is still the HDR film, because not one of its samples was touched. The blocks are timed by their source's own timestamps (`MkvMuxer::write_block`) rather than by a frame counter, without which a stream with B-frames -- stored in decode order, timestamped in display order -- would play its groups of pictures in the order they were coded in. An open-GOP source writes leading pictures after a sync point that are shown before it and reference the group before it; at the start of a copied region those references are not in the file, so they are dropped rather than written as pictures no decoder can put back together. The region still starts at the timeline frame it owns, so the sound never drifts. Measured on a real-library 4K x265 HDR Matroska of 2h30m (167671 pictures), five minutes cut out of the middle on two sync points: the export takes 162 s and writes 10.8 GB, against a re-encode of the same timeline measured at 0.94-1.75 pictures a second -- 25 to 47 hours for the same file. Every block sampled either side of the join is its source's own bytes, the shown order is one unbroken frame grid, and the pictures two seconds either side of the join decode through this project's own decoder without an error.
🐛 fix(decode): a seek lands on the frame it names in an open-GOP streamAhmet Kaan Gümüş · ea25339
🐛 fix(decode): a seek lands on the frame it names in an open-GOP stream A picture's index everywhere above the demuxer is its rank in *display* order, but both demuxers answered a seek with the position the sync point is *stored* at. The two are the same number only while nothing is coded out of order -- and an open-GOP HEVC stream, which is what x265 writes by default and so what every film off a disc or a web rip is, stores the CRA that opens a GOP ahead of the RASL leading pictures shown before it. In `test_hevc.mkv` the keyframe shown 30th is block 28, so scrubbing to frame 45 handed back frame 47, and to a different frame again in a GOP carrying another number of leading pictures. This is the film-scrub path for a 4K HEVC library. `sync_display_order` ranks every sync point by the presentation time the container states -- Matroska block timestamps, an mp4's `stts + ctts` composition times -- and the seek picks and reports the keyframe at or before the target *on screen*. The mp4 half is that and nothing else; a track with no `ctts` box keeps the sample-id path it had, untouched. The Matroska half has one more thing to say, because its blocks are a window of ten seconds and a display rank is a statement about the whole film. The `Cues` already carry that statement: a `CueTime` over the track's frame duration is how many pictures are *shown* before that keyframe, counted by the muxer over the file. So the window is ranked among itself by timestamp -- the same function, the same rule -- and shifted onto the cue's own number, which makes the two answers one answer. A file walked whole shifts by zero: its window is the file. Kept per window rather than per seek, so scrubbing a file that has no usable cues -- the one case where the window is the whole walk -- ranks it once. `the_cue_index_and_the_whole_walk_are_the_same_index` now states the claim in display order too: the lazy window and the whole walk must name the same picture, and it is the walk's own ranking that says which. `hw_decode::seek_matches_linear_every_container` sweeps every fixture container/codec pair at targets on, either side of and away from a keyframe, plus frame 0 and the last one; it fails on the old code at `test_hevc.mkv` frame 29.
⚡ perf(demux): the walk a Matroska file still needs is written down onceAhmet Kaan Gümüş · 8651b15
⚡ perf(demux): the walk a Matroska file still needs is written down once The `Cues` path took the picture's open off the whole-cluster walk, but two callers still pay it in full: a sound track, which Matroska indexes not at all and which is walked on its own track number, and a picture whose index is absent or caught lying. On a real 10.9 GB E-AC-3 film that is the first contact with the file -- 9.7 s before a note is heard, and 298 ms every time the session reopens it, which the editor does at every seek across a clip boundary and once per export span. That walk's answer is now written beside the user's other caches, in `$XDG_CACHE_HOME/edith/mkvindex` (`~/.cache` where the desktop names none), one file per track of every Matroska file walked, and read back instead of re-walking. Correctness first, speed second. A sidecar is valid for one file and nothing else: its canonical path, its size, its modification time to the nanosecond, the segment bounds and the track number are written into the record and compared field by field on the way back. Format version in the magic, FNV-1a over the payload, every field length-checked as it is read, nothing left over at the end. Any mismatch at all -- absent, stale, damaged, another version, a hash collision on the file name -- is a miss, which means the walk runs and the file is rewritten. There is no path where a wrong index is believed. Written atomically, temporary file then rename, so a reader sees a whole index or none; a write that fails is a slow open rather than a failed one. Hand-rolled little-endian records, no new dependency: a flat table of fixed-width fields does not need a serializer, and this tree carries none. The one thing the key does not cover is the code that filled it: a build whose walk answers differently would believe every record written by the last one, and only the magic's version byte stands there. It says so at the constant, and it is bumped here for exactly that reason -- this tree's walk is not the one the lane that first wrote this format had.
⚡ perf(demux): a Matroska file is read forward without rechecking its indexAhmet Kaan Gümüş · 8d969d0
⚡ perf(demux): a Matroska file is read forward without rechecking its index Reading a cued file from end to end got slower than the whole-cluster walk it replaced -- 4.8 s to 192.8 s on a 4.9 GB AV1 remux, and worse the longer the film. The window of blocks grows by a cluster on every read and nothing trimmed it, while both index checks scanned that window from the front: every cue the walk had already passed was re-anchored per cluster, and every anchor scanned to the far end of the window twice. Quadratic in the file's length, so the numbers only looked fine on a fixture. Each cue is now checked once. `checked` is how far that has got through the cue list, and a cue the window jumped past is stepped over rather than re-examined -- the cue a seek actually anchors on is checked by `jump` itself. Both scans inside `anchor` are bounded by `REORDER`, which is what they were describing all along: the block a cue names sits at its own index less whatever was reordered across it, and only a cue that is not where it says it is pays the full scan -- once, because that answer degrades to the whole walk. The cue lookup a seek does is a binary search now, the list being sorted. 4.9 GB AV1, 282024 blocks walk 4810 ms -> 3927 ms open 2654 ms -> 0.5 ms 7.1 GB HEVC, 171432 blocks walk 6393 ms -> 5821 ms open 7326 ms -> 1.8 ms against the whole-cluster walk this replaced, same access-unit hash on both files and the same landing for every seek. Reading forward is now cheaper than the walk instead of 40x it, and the open the cue index bought stays. A read error while rebuilding the window is no longer dropped on the floor: answering a seek off a window that belongs to another part of the file is a landing nobody asked for, so the fallback is named -- the whole walk, the one index that does not depend on the window. `a_cue_that_lies_about_its_time_degrades_to_the_walk` is the other half: a real fixture with one `CueTime` moved a tick, which is a well-formed index naming a block that does not exist. The walk takes over where the read meets it, every frame still comes back, and every seek lands where the honest file's does.
⚡ perf(demux): open a Matroska file off its Cues, not off every clusterAhmet Kaan Gümüş · 84ee43f
⚡ perf(demux): open a Matroska file off its Cues, not off every cluster Opening a Matroska file walked the whole segment -- every cluster header of every gigabyte -- because Matroska carries no sample table and the frame count and the sync points had to come from somewhere. That is seconds of disk per open, and an open happens on every seek, every clip span and every export source, not once per file. Matroska has an index of its own and nothing here read it: `Cues`, one entry per keyframe, written at the far end of the segment and found through the `SeekHead` in kilobytes. Now the open parses that, and the clusters are walked only where a caller asks to read -- one cue interval at a time, ten seconds of film. Measured, cold (page cache dropped per file) and warm, on the library: file open cold open warm bytes read 4.9 GB AV1 remux 4027 -> 26 ms 469 -> 0.6 ms 9.9 MB -> 99 KB 12.1 GB 2160p HEVC 9508 -> 54 ms 958 -> 8.6 ms 13.2 MB -> 1.3 MB 1.4 GB 720p H.264 (ep) 395 -> 1.8 ms 64 -> 0.2 ms 1.5 MB -> 20 KB Same answers, not similar ones - The frame count stays exact at open: the last cue's index plus the blocks after it, counted by walking from that cue to the end of the segment. No duration-times-rate estimate, nothing corrected under the UI later. - A cue states a *timestamp*, and a stream with B-frames does not store its blocks in that order: `anchor` counts the blocks written after a cue and shown before it, which is the difference between the frames shown before it and its place in the file. Without that a 60-frame HEVC fixture reports 62 and every seek lands two frames late. - `cues_agree` checks that arithmetic against the file's own blocks wherever a walk meets a cue. A file that disagrees -- variable rate, cue times naming no block -- falls back to the whole walk rather than seeking to the wrong frame. So do files with no `Cues` at all, and tracks with no `DefaultDuration` (nothing to turn a cue time into a frame number with). - `probe_bitrate` completes the index first: it adds block lengths up and wants the file, so it pays the walk it always paid. - The `Cues` element is read whole and parsed in memory. Element by element through the file, a 2160p film's ten thousand cue points cost a `pread` apiece: 118 ms of open against 8.6. Checks - `demux::tests::the_cue_index_and_the_whole_walk_are_the_same_index`: for all 20 Matroska fixtures, the cue index and the whole walk agree on the block list, the frame count, and where every frame of the file seeks to -- asserted per frame, forwards and backwards. - `a_file_with_no_cues_is_the_walk_it_always_was`: a fixture with its `Cues` id and `SeekHead` pointer overwritten (no muxer here writes a file without an index) opens, counts and seeks identically. - `examples/mkv_open_cost.rs`: open ms, bytes through the read syscalls, seek landings and a hash of every access unit. Run against the build before this change, the three library files above agree line for line on every landing and every hash. Approach referenced from `matroska-demuxer 0.8.1` (hasenbanck), which resolves a seek the same way; the parsing is this file's own EBML reader, no dependency added.
🔒 chore(privacy): the tests name a key, the machine names the fileAhmet Kaan Gümüş · a893c91
🔒 chore(privacy): the tests name a key, the machine names the file
Nothing in this tree says what is in anybody's library or where it lives.
The handful of tests that are worth nothing against a fixture -- a real
HDR10 grade, a header-stripped BluRay remux, a disc's PGS tracks -- asked
for absolute paths written into their source, and the comments around them
recorded which films the measurements were taken on.
Both go. `engine::real_library::film(key)` reads `real_library.toml` at the
workspace root, which is gitignored: three logical keys named for what the
file *is* (`hevc_4k_hdr`, `h264_dual_audio`, `hevc_4k_pgs`), mapped to
wherever that machine keeps them. A missing manifest, a missing key or a
missing file each say so on stderr and the test passes, which is the
existence gate every one of these already had, in one line instead of five.
`real_library.toml.example` documents the shape and what each key must be.
The comments keep the technical fact and lose the title: a peak of 1759
cd/m^2 is still 1759, the 37 BCP-47 elements are still 37, and the Opus
pre-skip is still measured against ffmpeg -- on "a real 5.1 Opus remux"
rather than on a named one. The synthetic paths in the app's unit tests
("/films/…") were never real and are now anonymous too.✨ feat(subtitles): as many tracks as you want, embedded in the exportAhmet Kaan Gümüş · 28e2853
✨ feat(subtitles): as many tracks as you want, embedded in the export Subtitle tracks now work the way audio and video tracks do: add as many as you like, remove any of them, and every track with cues on the timeline is written into the exported file. Add and remove - "+ S" beside "+ V"/"+ A" imports every subtitle track in a picked file; each row carries its own "x". Pointer and keyboard doors share one implementation and refuse identically, before any chooser opens. - Project::remove_subtitles / PlaybackSession::remove_subtitles, with the index fixup in one place so a removal cannot repoint the overlay. Embedded in the output - ExportSettings.subtitles is a list; the Matroska muxer writes N tracks from number 3 up, ceiling derived from the encoding (0x7F - SUB_TRACK_FIRST) because track 127 is the all-ones VINT our own reader maps to "unknown" and would silently lose. - mp4 carries them too, as real tx3g timed text. The old "an mp4 carries none" was a false refusal: mp4 0.14 has MediaConfig::TtxtConfig all along. Samples are built from cue boundaries, so gaps are empty samples and the track spans the film. - of_mp4 reads them back, so edith re-imports its own output. Verified against a file ffmpeg muxed, which writes mdhd in microseconds where we write milliseconds. - The export set is derived from timeline_cues per call, so it cannot desync; the card names a track it leaves off, and counts past the width budget rather than eating the card. Language and title - SubtitleTrack carries language and name apart; the guess-them-back heuristic is gone. LanguageBCP47 is read and mapped to a 3-letter code (ffmpeg reads no BCP-47 at all, so writing it would have made the language invisible). A 17-track subtitle library file and a dual-language one no longer read "und". Media bitrate in properties - engine::probe_bitrate opens no decoder; all three numbers share the container's duration, so total >= video + audio holds by construction. Within 0.004% of ffprobe across the library. - Both properties cards show it; a dual-audio file says which of how many. The line picks one unit off its smallest stated component, so a real value never renders as 0.00. Off the render thread - The subtitle walk moved to the background executor at every door: 1324ms -> 0.1ms on a 3.1GB film, 234ms -> 5.0ms on a 25.4GB/35-track one. (The media walk is still on the render thread; separate slice.) False refusals removed - .mks and .mka were refused while the compiled-in Matroska reader parses them; is_matroska now takes the standard's closed set. - The audio-only "sound alone" sentence was unreachable when every pick was a bitmap track. Subtitle-free exports stay byte-identical: 294a8b0c (hevc mkv), 8c16b8b1 (default mp4).
🐛 fix(demux): a codec's support is probed per container, not inferred from a neighbourAhmet Kaan Gümüş · 4f4dcb4
🐛 fix(demux): a codec's support is probed per container, not inferred from a neighbour VP9 was decodable out of an mp4 and refused out of a .webm — `V_VP9` fell through the Matroska track dispatch into `OtherVideo` and came back as "V_VP9 video in a Matroska file is not supported", with the VA-API VP9 decoder wired in `engine-hw` the whole time. A browser-downloaded .mkv was one of those files. Both dispatches now read one table (`CODEC_IDS`), and the Matroska arm matches on `Codec` with no wildcard, so a codec added to the enum fails to compile until it has been routed rather than falling through to a refusal. A cell that is deliberately absent is a row in `UNSUPPORTED` with a reason, and the refusal quotes that reason instead of listing what is supported and leaving the user to guess. The mp4 video track comes out of `moov.traks` in file order, not a `HashMap` walk of `Mp4Reader::tracks()`: a file with two video tracks opened on a different picture from one run to the next, and a saved .edith reopened on the other one. `audio::audio_track_ids` fixed the same trap for sound; the naming half of `AudioSession::unsupported` had it too. VP9 states its bit depth in no container record — an mkv `TrackEntry` carries none and an mp4's `vpcC` is optional — so it is read off the first keyframe's uncompressed header. Assumed 8-bit, a profile 2 stream would decode into an NV12 pool and come back as garbage; 12-bit is refused by name like 12-bit AV1 and HEVC. The audio refusals said "AAC and AC-3 only" long after FLAC, MP3, Vorbis, ALAC and PCM decoded out of a Matroska file. They name the real set now, per container, because an mp4 video's sound never reaches symphonia and reads fewer codecs than an mkv does. tests/capability_matrix.rs holds all of it against real files.
🐛 fix(decode): a 4K wavefront HEVC is 33 entry points, not 32Ahmet Kaan Gümüş · 65ea910
🐛 fix(decode): a 4K wavefront HEVC is 33 entry points, not 32 A 4K wavefront HEVC film (3840x2160, CTB 64, entropy_coding_sync) writes num_entry_point_offsets = 33 in every slice header -- exactly PicHeightInCtbsY - 1, which is what ITU-T H.265 §7.4.7.1 allows -- and the vendored parser kept them in a [u32; 32]. The 33rd panicked, the plugin edge caught it, and the user got a black picture and an instant eof. The list is now sized by the stream. Same shape swept through the rest of the h265 parser, where a parsed count could outrun a fixed array: tile columns/rows (the CTB grid allows far more than the 19/21 the VA-API picture parameter holds), the long-term ref pic block, and sps/vps_max_sub_layers_minus1, which u(3) can read as 7 into 7-long arrays. Those refuse by name instead. And the door now asks the plugin for one picture before it lets a file in: a session that opens and then decodes nothing was the black screen with no explanation, so it is refused in its own words rather than in the missing-plugin ones.
2026-08-11
✨ feat(tonemap): the reference rendition converts a film at the peak the film declaresAhmet Kaan Gümüş · 27097e2
✨ feat(tonemap): the reference rendition converts a film at the peak the film declares `Demuxer::light().peak()` -- a stream's MaxCLL, or its mastering display's maximum -- has been read at every open and dropped on the floor. It now reaches `ToneMapper::new` as `declared_peak`, and `Preset::master_nits_for` is the whole composition rule: `Reference` takes the film's number (1000 stays the fallback for a file that declared nothing), `Standard` and `Vivid` keep their fixed 400 and 250, because a picked exposure that moved per file would not be a pick. One HDR film declares 1759 cd/m^2, so its 1000-nit highlights land at SDR 215 instead of clipping at white, and BT.2408 diffuse white at 145 instead of 166. Both sites that build a table have the demuxer in hand already, so nothing is promoted through `VideoMeta`: the decode funnel reads it before the worker takes the demuxer, and `source_rate` returns it off the header parse export already did -- which is what keeps preview and export on one number. A declared peak is a stranger's number and is checked before it becomes a divisor: outside 100..=10000, or a NaN, is treated as not declared. test_hdr_bright.mkv joins the fixtures for it -- the older HDR metadata ones all say 1000, which no picture can tell apart from the fallback.
✨ feat(demux): a film's real peak brightness is parsed, not assumedAhmet Kaan Gümüş · 5726307
✨ feat(demux): a film's real peak brightness is parsed, not assumed MaxCLL/MaxFALL and the mastering display's luminances, off all three places they live: a Matroska Colour element (0x55BC/0x55BD and the MasteringMetadata floats behind 0x55D0), an mp4 sample entry's clli and mdcv boxes, and -- for the web rips where the container carries none of it -- the HEVC SEI messages of the same names in the first access unit. Carried on Demuxer::light() as ContentLight, whose peak() prefers the measured content light over the display the grade was approved on. Nothing reads it yet: wiring it into the tone map, which today assumes a constant, is its own change.
✨ feat(colorspace): a file says which matrix and curve its numbers are in, and edith reads itAhmet Kaan Gümüş · 070ffe6
✨ feat(colorspace): a file says which matrix and curve its numbers are in, and edith reads it Three tiers, per field: the container's own tags (Matroska `Colour`, mp4 `colr`), then the bitstream's (H.264/HEVC SPS VUI, AV1 `color_config`), then the ffmpeg/mpv resolution rule -- 720 lines or taller is BT.709, below it BT.601, limited either way. A code that says nothing, or says something with no implementation here, falls to the next tier rather than answering wrongly. `VideoMeta` carries the answer; nothing consumes it yet. Everything still renders through the hardcoded BT.601 it always did, which is the bug this is the foundation for fixing. The bit-level walks are where this can quietly go wrong: an SPS whose scaling lists are counted wrongly lands the VUI read in the middle of a coefficient. Both are measured -- H.264 and HEVC against hand-built parameter sets (no encoder here writes SPS scaling lists), the rest against fixtures tagged in the container, tagged only in the bitstream, and tagged nowhere, plus the two real films: a 4K HDR remux that reads BT.2020/PQ and a fully untagged 720p one that reads BT.709.
✨ feat(audio): every audio track of an mkv is a row, and the second one playsAhmet Kaan Gümüş · 264c10c
✨ feat(audio): every audio track of an mkv is a row, and the second one plays A Matroska file was worth exactly one audio stream here -- whichever track the readers stumbled on first -- so the second language of a dual-audio remux was invisible and unopenable, and no mkv ever showed what language its sound was in. The header walk now collects every audio TrackEntry in file order with its number, codec id, TrackLanguage and TrackName (demux::matroska_audio_tracks), and that list is what a stream index counts in. The index picks an entry, the entry's *track number* is what each reader is then pointed at -- MkvAudio::open_track for the AC-3 blocks, SymTrack::open_track for symphonia, whose mkv reader keeps the same number as its track id -- so the two readers cannot disagree about which track a stream meant. Stream 0 is still the file's first audio track, sample for sample. Rows name their codec from the container rather than from symphonia's registry: the tracks that most need naming are exactly the ones it has no decoder for, and "opus is not supported" beats "an unsupported format". Fixture: test_multiaudio.mkv, two AAC tracks, eng 440/880 Hz and fra 220/330 Hz -- different tones because a mapping that drifts plays the other language.
🔀 merge(subtitles): a PGS cue is a picture the timeline carriesAhmet Kaan Gümüş · 1bee319
🔀 merge(subtitles): a PGS cue is a picture the timeline carries Conflicts, both in the demux lane's territory: - matroska_subtitles wanted-track filter: PGS joins S_TEXT, and both still skip a track whose ContentEncoding the demuxer cannot undo. - mkv_subtitle_blocks: the demux lane's laced walk stands; A's single-payload read and its refusal of lacing are dropped. A laced block's cues share a start, so end_of's strict > still finds the next real block. - cues_of: A's &mut signature and PGS doc, with the demux lane's unsupported early return that is the source of the refusal text.
✨ feat(demux): a header-stripped or laced Matroska track plays instead of refusingAhmet Kaan Gümüş · 5d028c2
✨ feat(demux): a header-stripped or laced Matroska track plays instead of refusing Two features every disc rip and streaming remux carries and this demuxer had no reader for: - `ContentEncodings`: header stripping (`ContentCompAlgo` 3) puts the bytes the muxer cut off the front of every frame back, and zlib (algo 0) inflates. bzlib, lzo1x, an unknown algorithm and encryption are refused *by name*, and per track -- a film whose sound cannot be read still shows its picture, and a subtitle track that cannot be read is listed with the reason like a bitmap one. - Lacing: all three headers (Xiph, fixed, EBML) read into one `Block` per frame. The frames of a lace get a timestamp each, interpolated across the gap to the block after, because six E-AC-3 frames stacked on one instant is a sound track that walks away from the picture inside a cluster. The two films this was cut for: a BluRay remux whose H.264 track is stripped of one zero byte per block (no picture at all before this), and a WEB remux whose every E-AC-3 block is fixed-laced (no sound at all before this). Both are existence-gated tests beside the hand-built EBML fixtures. zlib is `miniz_oxide`, which `image` already pulls into this build through `png`: no new crate tree and nothing new to compile.
✨ feat(subtitles): a PGS cue is a picture the timeline carries, not a row that says noAhmet Kaan Gümüş · c45b18e
✨ feat(subtitles): a PGS cue is a picture the timeline carries, not a row that says no The four S_HDMV/PGS tracks of a BluRay remux were listed and greyed: pictures, and nothing here could draw one. Now the cue IR carries a picture beside its text -- `Cue::image`, a `CueImage` holding the display set the Matroska block held -- and the rows are rows a click can pick. The decoding is `oxideav-sub-image`: the run-length walk, the palette, the YCbCr and the object fragmentation are not this project's to re-derive. What is written here is the framing between the two -- a Matroska block is a `.sup`'s segments with the `PG` magic and the timestamps taken off, so they go back on -- and the pairing PGS needs and text does not: half the blocks compose nothing, which is the disc clearing the screen, and that is where the cue before them ends. `BlockDuration` is zero on every one of them, so `end_of` now reads a zero the way it reads a missing one. Kept encoded, decoded when something is about to draw it: this film's canvas is 8 MB of RGBA and its four tracks carry eleven thousand display sets, so the IR holds the thirty megabytes the file already spends and the front-end keeps one decoded picture for as long as its cue is up. An export still writes a text track, so a track of pictures writes none and the card says "drawn, not written" before the button. A `.edith` is unchanged: it held a file and a track number and never a cue, which is why a bitmap track round-trips without the format knowing it exists.
Merge remote-tracking branch 'origin/main' into worktree-agent-ab6959260e5ee211cAhmet Kaan Gümüş · 2eb309b
Merge remote-tracking branch 'origin/main' into worktree-agent-ab6959260e5ee211c # Conflicts: # scripts/gen_fixtures.sh
Merge remote-tracking branch 'origin/main' into worktree-agent-ab6959260e5ee211cAhmet Kaan Gümüş · 0776b46
Merge remote-tracking branch 'origin/main' into worktree-agent-ab6959260e5ee211c # Conflicts: # crates/engine/src/audio.rs
🔀 merge(A3): 10-bit AV1 plays — the refusal was a stale comment, the P010 pool was ready all alongAhmet Kaan Gümüş · 9633c84Browse files
✨ feat(av1): 10-bit AV1 opens instead of being refusedAhmet Kaan Gümüş · 25aef8c
✨ feat(av1): 10-bit AV1 opens instead of being refused
The `av1C` record's `high_bitdepth` was an outright refusal ("10-bit AV1 is
not supported yet"), on a comment that had gone stale: the vendored decoder
takes its RT format from the stream and maps Depth10 to YUV420_10, and the
plugin's read-back pool is P010 whenever the demuxer says >8 -- which is how
HEVC Main 10 has been playing all along.
So `parse_av1c` reads the depth instead of refusing it, in both containers
(the mp4 `av1C` box and the Matroska `CodecPrivate`), and 12-bit stays
refused by name in the words HEVC's own depth check uses. Nothing else needs
the plugin any differently: AV1 has no software decoder at any depth, so a
machine without `libengine_hw.so` still refuses it as `needs_plugin` always
has.
Fixture: assets/test_av1_10.mkv (libaom, yuv420p10le), the AV1 seat of the
pair test_hevc.mkv/test_hevc10.mkv already make for HEVC.