forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 7f487c10e98d32efa4e4b554b778d2eea5d16efdFiltered to Cargo.tomlClear filter

2026-08-13

⚡ perf(cros-codecs): a cache line is flushed once, not sixty-four timesAhmet Kaan Gümüş · 522e89f
⚡ perf(cros-codecs): a cache line is flushed once, not sixty-four times

Unmapping a DMA buffer flushed the CPU's caches back to it a *byte* at a
time -- one CLFLUSH per byte, where a CLFLUSH covers a whole 64-byte line.
That is 3.1 million instructions per 1080p picture, and it was 6.2 ms of the
8.4 ms a hardware export was spending per frame: the encoder maps its input
buffer to write the picture into, and every unmap paid it. The stride is the
cache line now. Upstream's own TODO on those lines asks for this and reports
a race when it was tried; what orders the flushes is the mfence either side,
which is still there, and the sixty-three redundant flushes per line never
were.

The same `drop` also wrote its munmap as `let _ = zip(..).map(..)` -- a lazy
iterator nobody consumes, so no mapping was ever released. An encode session
leaked its 3 MB input mapping every frame, 2.2 GB of address space over a
719-frame export. It unmaps in a `for` loop now, and it unmaps what `mmap`
actually returned: the plane addresses it used to pass are those bases plus
an offset that is not required to be page aligned, which munmap refuses.

Export throughput on the 1080p film, hardware H.264 seat, same 30 s span:
89.9 fps before, 239.6 fps after -- 10x realtime, and the file is the same
file (a ten-second span exported through both builds is byte-identical,
6,379,699 bytes, ffmpeg -v error empty). tests/hw_decode.rs (10),
tests/hw_encode.rs (3) and tests/decode_baseline.rs pass, the pixel oracle
`hardware_matches_software_on_frame_30` among them.
🔧 chore(vendor): cros-codecs learns to write HEVC, from its own branchAhmet Kaan Gümüş · 75da480
🔧 chore(vendor): cros-codecs learns to write HEVC, from its own branch

The vendored 0.0.6 decodes HEVC and encodes H.264 and AV1; the seven
commits behind cros-codecs' `hevc-vaapi-encoder` branch are what give it
the third encoder, and they are carried here verbatim rather than
rewritten:

  * `codec/h264/nalu_writer` - emulation prevention after an escaped byte
    (the same >=5-zero-run bug the vendored H.264 writer had)
  * `codec/h265/nalu_writer` - the H.265 writer that fix belongs to
  * `codec/h265/parser` - VPS, SPS and PPS builders, the SPS deriving its
    own conformance window from the resolution it is given
  * `codec/h265/synthesizer` - the parameter sets written back out as
    NALUs, which is what a driver emitting no packed headers needs
  * `encoder/h265` + `encoder.rs` - initial tunings on the config
  * `encoder/stateless/h265` - the codec and its low-delay predictor
  * `encoder/stateless/h265/vaapi` - the VA-API backend

Applied with `git apply -3`; every hunk landed clean against the local
patches already here, the only file with drift being `parser.rs`, whose
entry-point-offset and sub-layer fixes sit far from the new builders.
The c2_wrapper commit is left out (nothing here uses it) and so is the
Cargo uprev (this tree is path-patched).

Upstream's own tests for the new code pass in the source checkout: 22 in
`codec::h265`, 4 in `codec::h264::nalu_writer`. They cannot run in
`vendor/` because the published crate ships no `src/**/test_data`.
🐛 fix(decode): a seek into an open GOP is hardware's to finishAhmet Kaan Gümüş · 7652ada
🐛 fix(decode): a seek into an open GOP is hardware's to finish

A Blu-ray remux codes its GOPs open: the I picture that opens one is stored
ahead of the leading pictures that are *shown* before it, and those reference
the GOP before. Restart decoding at that random access point -- which is what
every seek, scrub and clip boundary does -- and the leading pictures have
references nobody decoded, so the plugin failed its first frame, playback fell
back to `rusty_h264`, and that decoder died on the file's I_PCM macroblocks.
Seventeen of twenty scrub steps on a 5.27 GB AVC remux ended with no picture
at all, and the three that survived cost 482 ms each in software.

The pictures are not ours to show, so they are dropped and the decode walks on
(bounded by `LEADING_LIMIT`, and only for a session that was positioned
somewhere other than the file's own start). The refusal that the tolerance
would otherwise swallow is kept at both ends: a stream read from frame 0 is
still refused the moment its first picture will not decode, and the plugin
probe now counts an immediate end of stream as a refusal rather than a pass --
a session that hands back no picture is the black-frame-and-instant-eof the
probe exists to catch.

The vendored H.264 decoder's own refusal goes with it: it failed a `frame_num`
gap outright unless the stream declared gaps allowed, which is exactly the
wrong reading here -- the gap is the editor's, made by starting in the middle
of a film, and §8.2.5.2's non-existing frames are what stands in for it. The
loop that builds them was already there, behind that flag.

Twenty of twenty scrub steps on the remux now decode in hardware, 77 ms
median against 482 ms; `seek_matches_linear_every_container` holds for every
container, and `dump_frame <file> <n> <out> seek` is what a picture reached by
a seek can be compared with the same picture reached by decoding from the
start.

2026-08-12

🐛 fix(engine): the codec stops replacing the whole program's allocatorAhmet Kaan Gümüş · c8f62cb
🐛 fix(engine): the codec stops replacing the whole program's allocator

`rusty_h264-common` declares `rusty_alloc` as the `#[global_allocator]` of
whatever links it, and its sibling decoder and encoder turn that feature on
from their own defaults -- so no downstream feature choice could decline it.
Sustained scrubbing churns decode-worker threads, and that allocator faulted
on both ends of a thread's life: on a new one's very first allocation, and
in `Heap::collect_inner` from the `thread_done` TSD destructor. Three cores.

`common` is vendored (the fifth, same idiom as the other four): the feature
stays declared so the sibling manifests still resolve, but it is empty and
the six-line declaration is gone. Not one line of codec code differs from
0.9.1 -- 360 decoded pictures across three fixtures still match ffmpeg's
`framemd5` exactly -- and the process gets glibc's malloc back.

2026-08-11

✨ fix(waveform): a film in an mkv paints its wave, and a failure says soAhmet Kaan Gümüş · ffb3105
✨ fix(waveform): a film in an mkv paints its wave, and a failure says so

A 5.1 AAC track decodes through rusty_aac, whose IMDCT ran as an 8 MB
cosine matrix -- 88% of decode time and 2x realtime, so a two-hour film
needed an hour of background decode before its lane had anything to
draw. The same file has an N/4-point FFT already, for the encoder: the
IMDCT is a DCT-IV read at an offset, so both directions now share
dsp::dct4. 40x on the fixture, 141 s for the film.

And a decode that fails is no longer a silent file: peaks() errors reach
the lane as Wave::Failed with a band that says "audio unreadable", the
reason goes to the log, and the Matroska opener logs what it swallows.
✨ feat(export): HEVC leaves the way it came in — intra, in either boxAhmet Kaan Gümüş · 12f8cb7
✨ feat(export): HEVC leaves the way it came in — intra, in either box

The one codec edith could read and never write. OxideAV's pure-Rust H.265,
vendored from git master (its released 0.0.9 is pre-encoder) with one marked
patch: the intra SPS writer had no conformance window and refused any dimension
off the 16-sample CTB grid, so 1920x1080 could not be written at all. It is now
coded padded to 1088 with the edge replicated and cropped back by the SPS, which
is what ffprobe reads out of the bitstream.

Intra-only, and every row says so: the inter modes code 1080p at 0.81 fps across
twelve cores and the intra path does 4.30 on the same picture, so the export is
an intraframe master — ProRes-shaped, large files, every frame a cut point —
rather than a delivery file nobody would wait for. The AU is a stateless
function of one frame, so frames fan out across twelve lanes and are collected
back in display order.

Two rows, `h` and `x`, because a codec and a container are two choices: the
`hvcC` record built from the encoder's own VPS/SPS/PPS goes into a Matroska
`CodecPrivate` and into an mp4 `hvc1` sample entry unchanged, so the two files
are one stream written twice. Both re-open in edith through the plugin, sound
and all.

2026-08-10

✨ feat(import): a Matroska film opens, its 10-bit picture and its 5.1 sound alikeAhmet Kaan Gümüş · b083a3b
✨ feat(import): a Matroska film opens, its 10-bit picture and its 5.1 sound alike

mkv HEVC demux (Main/Main10), a P010 pool in the hardware path read back to
I420, mkv audio through symphonia's Matroska reader with rusty_aac decoding
what symphonia's own AAC refuses (anything wider than stereo), and a BS.775
fold of 5.1 down to the stereo the output device takes.

vendor/rusty_aac is 0.5.0 with one local patch: its decoder's IMDCT caches the
cosine matrix instead of calling cos() per term, 11x faster and the difference
between playable and not.

2026-08-09

✨ feat(engine): audio decode, PipeWire output plugin, playback clockAhmet Kaan Gümüş · 229a569
✨ feat(engine): audio decode, PipeWire output plugin, playback clock

Wave 1 of the audio slice — three independent modules, app wiring
comes next:

- audio.rs: AAC-LC via standalone symphonia AacDecoder over the
  existing mp4 demuxer; priming trim read from the container elst
  (verified against ffprobe); channel identity pinned by
  zero-crossing tests on the 440/880 Hz fixture
- engine-audio: dlopen'd PipeWire cdylib (ao_* C ABI). App binary
  keeps zero libpipewire linkage; daemon absent fails open() in ~1ms.
  Fill capped at 1024 frames/callback: uncapped, PipeWire hands the
  sink-sized buffer and the position clock steps 256ms at a time.
  Stream time rate is 1/48000 regardless of stream rate — position
  is rescaled or the clock runs 8.8% fast on 44.1k content
- clock.rs: PlaybackClock, audio-driven with wall fallback; audio
  positions relative to last re-anchor so restarted streams re-sync;
  paused == frozen exactly, all re-anchoring through one path
🎉 feat: MVP decode pipeline — mp4 → H.264 → gpui previewAhmet Kaan Gümüş · 0acbf8d
🎉 feat: MVP decode pipeline — mp4 → H.264 → gpui preview

- engine: mp4 demux → Annex-B, rusty_h264 software decode, BT.601
  I420→BGRA; decode on worker thread behind a bounded channel
- engine-hw: optional VA-API decode plugin (cros-codecs) behind a
  C ABI, dlopen'd at runtime with silent software fallback; the app
  binary keeps zero libva/gbm/drm linkage so it runs on any distro
- app: gpui window, per-frame RenderImage swap + drop_image
- vendor/: cros-libva + cros-codecs with 3 LOCAL PATCH fixes (libva
  1.23 struct init, radeonsi 64x64 min context, pub surface()) —
  upstream is dormant, so vendor/ is adopted code, not a temp fork
- fixtures are gitignored; scripts/gen_fixtures.sh regenerates them