forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on f40e85cc619058a8d7bbbbeab4964c3018bca8d9Filtered to Cargo.lockClear filter

2026-08-20

diag(mkv-audio): A/B ec-matroska's AAC and AC-3/E-AC-3 delivery against mp4/ffmpeg -- refuted, not fixedAhmet Kaan Gümüş · d6466ca
diag(mkv-audio): A/B ec-matroska's AAC and AC-3/E-AC-3 delivery against mp4/ffmpeg -- refuted, not fixed

Two mkv-audio-timing tests exercise ec-matroska's own packet stream, decoded
through ec-aac/ec-ac3 exactly as the consumer does, against the sibling mp4
leg of the same OBS recordings and against ffmpeg:

- mkv_vs_mp4_aac_pipeline: 3 real OBS mkv/mp4 pairs. ASC bytes identical,
  packet counts and byte totals identical, mkv pts strictly monotonic with no
  duplicates. Decoded PCM (ours-vs-ours and each vs ffmpeg) correlates at
  1.0000, lag 0, for the two pairs with real signal; the third pair's near-
  silent audio (5180 bytes over 852 packets) reads 0.0 on every leg including
  mp4-vs-ffmpeg, which is a zero-variance correlation floor, not a defect.

- mkv_51_channel_order: the two real-library 5.1 mkv rows the consumer sweep
  flagged (ReelF, E-AC-3; ReelG, AC-3). Our channel 0 matches
  ffmpeg's channel 0 at lag 0, corr 0.9999 and 0.9955 -- no channel-order
  mismatch.

Root cause: neither of the charter's two ec-matroska-side hypotheses (lace/
pts damage to AAC packet delivery, 5.1 channel order) holds against real
files -- this crate's demux and the shared ec-aac/ec-ac3 decode of it are
byte- and sample-correct here. No code fix lands in ec-matroska because there
is nothing wrong to fix in it for these files. The 0.06-0.34 mkv-leg
correlation the consumer sweep saw, if still real, has to come from
edith_replica's own consumption of these same packets (SymTrack's pts ->
samples_at conversion, priming, or channel folding in
crates/engine/src/audio.rs) rather than from container demux or codec decode
-- reported, not fixed, since that file is out of this repo.

2026-08-19

fix(aac-sbr): apply the envelope gain before noise injection, not afterAhmet Kaan Gümüş · 90930dd
fix(aac-sbr): apply the envelope gain before noise injection, not after

sbr_env::adjust injected the transmitted noise floor into the HF QMF
signal before measuring the (envelope, band) cell's current energy and
computing the gain toward the transmitted target -- so gain was
computed from signal+noise together and then rescaled both, distorting
the noise/signal split by however much noise dominates a given cell.
Move noise injection after the gain loop (signal only informs gain,
noise is added at its own transmitted amplitude afterward), matching
the spec order. Real-file sweep correlation barely moved from this
alone (0.019/0.834 and 0.005/0.0001 before and after), so it is a
real but non-dominant contributor to the residual failure; see the
localization note left for the next pass.

Also added an EC_AAC_SBR_ENV_DEBUG-gated dump in decode_envelope that
pinpointed the dominant remaining defect: multi-envelope real-file
frames occasionally carry a raw (non-delta) envelope whose absolute
value is inconsistent with every neighbouring envelope's magnitude in
the same frame (observed: FMJ ch0 frame 24's envelope 3 reads raw=43
right after envelopes 0-2 all sit at 8-10, and the frame's own core
PCM never exceeds ~9600 in this domain, so a target energy of 2^43 is
unreachable by any correctly functioning HF patch of that content).
That corrupted value then persists and grows across frames via the
cross-frame DT envelope prediction (self.state[ch].last_env), which
does no plausibility check on what it carries forward. Root bit-level
cause not yet found: env0-2 in the same frame decode plausibly, ruling
out a bit-count bug in bs_data_extra/bs_coupling/sbr_grid/sbr_dtdf/
sbr_invf that would already have desynced env0. Next step: instrument
whether this specific raw envelope's df_env bit is being read at the
position the FIXVAR/VARFIX/VARVAR grid class actually places it, since
these real files exercise those unverified border-value grid classes
(sbr_payload.rs's honest gap) far more than the byte-exact FIXFIX
fixtures.

2026-08-14

shim(ruopus): the Opus decoder seat edith consumes, over ec-opusAhmet Kaan Gümüş · 88cf2a7
shim(ruopus): the Opus decoder seat edith consumes, over ec-opus

The last audio shim the replica's [patch.crates-io] table was missing. It
is one re-export -- `MultistreamDecoder` -- because `ec-opus`'s already
has the incumbent's signature and, more to the point, its semantics:
`with_rate(rate, streams, coupled, &mapping)` with the same layout rules
and the same panic on one the RFC forbids, and output in the *mapping's*
channel order rather than the product's.

That last one is the only decision here. Both decoders emit Vorbis order
for RFC 7845 family 1 (FL, FC, FR, BL, BR, LFE), and edith permutes it
into film order at the call site (`audio.rs:vorbis_to_film_order`), so
the shim permutes nothing: putting it here would fold every surround
track twice. The doc comment says so, since a future reader's first
instinct will be to move it.

The incumbent's feature names are declared and empty. `spectrograms` was
its FFT backend, default-on because CELT synthesis is an N/4 complex FFT
per block and the fallback decoded a 5.1 film at 0.95x realtime; the
transform behind this crate is not behind a feature at all. They are
declared regardless because a [patch.crates-io] consumer that names a
feature the patch lacks fails to *resolve*.
feat(hw): the VA-API parameter buffers, surface pool and frame readbackAhmet Kaan Gümüş · 89d28a7
feat(hw): the VA-API parameter buffers, surface pool and frame readback

The foundation of the hardware crate: every codec parameter struct
libva defines for the paths this family uses, transcribed by hand from
the system headers and checked field for field by a `const` assertion
against `crates/ec-hw/abi-probe.c`. A transcription slip is a compile
error rather than a driver reading garbage.

Around them:

- `SurfacePool`, which allocates once and recycles: a surface returns to
  the free list when the reference buffer and the caller are both done
  with it, so nothing leaks and nothing is reallocated per frame.
- `Frame`, with the two ways to reach the pixels — DRM PRIME export for
  the zero-copy path, and `vaGetImage` readback into I420 (8 or 10 bit)
  for callers that want the samples. The readback image is created once
  per stream: one `vaCreateImage`/`vaDestroyImage` pair per frame costs
  ~20 ms at 1080p on this driver, more than the decode itself.
- A typed error for every failure. Nothing here panics: edith loads this
  path as a dlopen'd plugin whose fall back to software is only as good
  as that promise.
feat(shims): rusty_h264 0.9.1 surface over ec-h264Ahmet Kaan Gümüş · f26a1d2
feat(shims): rusty_h264 0.9.1 surface over ec-h264

Decoder::decode over whole access units and the EncoderConfig/Encoder/
YuvFrame/Preset surface edith's export path calls, without the incumbent's
process-wide allocator and without its lookahead buffering: try_encode
returns the access unit of the picture it was handed, every time.
chore: relock the workspaceAhmet Kaan Gümüş · 22fb460
chore: relock the workspace

The committed lock predates several workspace members, so every cargo
invocation rewrote it; this is that rewrite, with no dependency added by
hand and none removed.
feat(opus): CELT encoder — mono/stereo/multistream, all rates, CBR+CVBRAhmet Kaan Gümüş · 52ead44
feat(opus): CELT encoder — mono/stereo/multistream, all rates, CBR+CVBR

Throughput-first CELT-only Opus encoder (RFC 6716 Section 5, coding path
mirrored symbol-for-symbol from the normative Appendix A; analysis replaced
by fast deterministic heuristics: no pitch prefilter, tf_res fixed, spread
fixed NORMAL, single-pass coarse energy):

- range.rs: full RFC 5.1 range encoder (fixed-size frames, shrink, raw-bit
  tail), tell()/tell_frac()/range-state exact against the decoder per symbol
- celt_enc.rs: forward MDCT as the exact adjoint of the decoder's inverse,
  transient/trim/dynalloc/stereo analyses, encode-side allocation, PVQ
  search (wide f32x8 lanes) + V(N,K) enumeration, Laplace coarse energy
- encoder.rs: TOC framing (configs 28..31), CBR and constrained-VBR, plain
  and self-delimited (App B) packets
- multistream_enc.rs: RFC 7845 family-1 surround (5.1 helper), per-stream
  self-delimited framing, coupled streams weighed 2:1 in the rate split
- shims/opus-rs: the opus-rs 0.1.26 surface edith consumes, mono fixed and
  no rate ceiling; root-cause doc for the incumbent's ~165 kbps cliff in
  lib.rs

Proof in tests/conformance.rs (same binary): per-packet range-state parity
encoder vs vector-verified decoder at 32..510 kbps x {mono,stereo} x all
frame sizes x CVBR; libopus (ffmpeg) decodes the whole rate table at worst
corr 0.9565 (32k stereo) to 1.0000; 5.1 order-preserved >=0.9978; reference
opus_demo 0.9995 at 256k stereo; Ogg-Opus duration exact; zero-alloc steady
state; speed floors (measured ~150-580x realtime per config).
feat(h264): CAVLC intra decoder, bit-exact on 18 JVT streamsAhmet Kaan Gümüş · f985e44
feat(h264): CAVLC intra decoder, bit-exact on 18 JVT streams

I-slice scope: I_4x4 / I_16x16 / I_PCM, full CAVLC residual decode,
all intra prediction modes, 4x4 inverse transform + DC Hadamard,
dequant with scaling-list support, and the complete in-loop deblocking
filter. Everything outside scope (CABAC, FMO, interlace, non-I slices,
8x8 transform, 4:2:2/4:4:4, >8-bit) refuses with a named Unsupported
error backed by tests on real conformance streams - never wrong pixels.

Perf-first layout: padded planes sized for future inter overreach;
per-MB state in flat struct-of-arrays (nz counts, intra modes, QP,
slice ids) with no per-MB heap objects; a register-cached BitCursor for
slice data; residual parse fused with reconstruction so empty blocks
cost one coeff_token read; wide i16x16 SIMD for horizontal deblock
edges (a gather/scatter vertical variant measured slower and stayed
scalar). Steady-state decode loop is zero-alloc, proven by a counting
allocator in the conformance harness.

Conformance: first IDR bit-exact vs the JVT reference YUV and ffmpeg on
18 CAVLC streams incl. multi-slice and I_PCM; 6 CABAC/FMO/interlaced
streams verified to refuse by name; deterministic corrupt-input sweep
(truncations + 2000 single-byte mutations) never panics.

Measured on this machine, single thread, deblock included: 1324 ns/MB
(193 Mpx/s) on BA1_Sony_D at idle; 1007 ns/MB (254 Mpx/s) on the
no-deblock NL1_Sony_D even under background load.
feat(riff): WAV reader/writer and the hound shim over itAhmet Kaan Gümüş · 5dd56cf
feat(riff): WAV reader/writer and the hound shim over it

ec-riff writes and reads RIFF/WAVE: 8/16/24/32-bit integer PCM and 32-bit
float, mono through 7.1, any sample rate. The writer streams and patches the
RIFF, data and fact sizes in finalize (best-effort on drop), and emits
WAVE_FORMAT_EXTENSIBLE with a channel mask whenever a file has more than two
channels or more than 16 bits. The reader walks the chunk list rather than
assuming fmt-then-data, so LIST/INFO, fact and odd-sized chunks with their pad
byte are skipped, and a truncated or unpatched data size yields what is
actually there. RF64, ADPCM and 64-bit float are refused by name.

shims/hound carries package name hound 3.5.1 over ec-riff, covering exactly
what edith consumes: WavWriter::create/write_sample/finalize, WavSpec,
SampleFormat and an Error with the incumbent's variants.

Checks: cargo test -p ec-riff -p hound (10 tests), and the emitted oracle
artifacts compared against ffmpeg's own decode - 5 written formats and the 6
wav fixtures all PASS at corr 1.000000, RMS delta 0.
feat(dsp): FFT/DCT/MDCT/window primitivesAhmet Kaan Gümüş · 09790f6
feat(dsp): FFT/DCT/MDCT/window primitives

Radix-4/radix-2 Stockham FFT (power-of-two, 1..65536, f32 and f64),
real-input wrapper on the N/2 complex trick, DCT-II/III via Makhoul and
DCT-IV via an N/2 FFT, MDCT/IMDCT folded onto DCT-IV (AAC 2048/256 and
Vorbis/CELT sizes go through an N/4-point FFT), and sine/KBD/Vorbis
windows with fused application.

No feature gates: the fast transform is the only transform, and the only
O(n^2) code in the crate is the reference DFT/DCT/MDCT behind cfg(test).
Hot loops vectorise through wide on chunks_exact, so the bounds checks
fold; the scalar remainder is the same expression.

Accuracy vs the f64 reference, sizes 8..8192: 3.1e-15 f64, 1.3e-7 f32;
f32 forward+inverse round trip 1.6e-7 to n=32768; MDCT TDAC 2.2e-15 f64
/ 4.8e-7 f32 with every window shipped.
feat(oracle): fixture scripts + comparison harnessAhmet Kaan Gümüş · d207f1d
feat(oracle): fixture scripts + comparison harness

gen-fixtures.sh: 87 deterministic ffmpeg fixtures (10 audio codecs x mono/stereo/5.1 x 44.1/48k, 4 video codecs x mp4/mkv x 23.976/60 x 8/10-bit, 4K sample per codec).
fetch-vectors.sh: JVT H.264, JCT-VC HEVC, RFC6716 Opus, cellar FLAC, Xiph Vorbis; checksum-pinned in scripts/vectors.sha256, resumable, per-set graceful failure.
scan-real-library.sh: read-only ffprobe sweep of the local media dirs into fixtures/real-library-manifest.tsv (T3 gate input).
tools/oracle: std-only bin driving ffmpeg/ffprobe through process pipes (bit-exact, audio-compare, video-compare); ffmpeg stays test tooling, never a crate dep.
feat(core): workspace + ec-core IR foundationAhmet Kaan Gümüş · a3c0049
feat(core): workspace + ec-core IR foundation

Cargo workspace (crates/*, shims/*, tools/*) and ec-core, the IR every
crate in the family builds on:

- timebase: reduced rational TimeBase + Timestamp, all i128-exact integer
  math, four rounding modes. 24000/1001 is representable and stays exact;
  cross-base ordering compares instants without rounding first.
- packet: Buf (refcounted byte range, cheap clone and slice) + Packet with
  optional pts/dts/duration, flags and side data.
- frame: VideoFrame over validated planes (I420/I422/I444, 10-bit I010/
  I210/I410, NV12/NV21, P010/P016, gray, packed RGB/BGRA) with CICP colour
  code points, AudioFrame with named channel positions (5.1 = FL FR FC LFE
  BL BR) interleaved or planar.
- bitio: MSB and LSB bit readers/writers, exp-Golomb ue/se both ways,
  truncation reported as NeedMore instead of panicking, exp-Golomb prefix
  bounded so a fuzzer cannot spin.
- error: NeedMore/Eof/Unsupported{what,why}/Corrupt{context}/Io; a refusal
  always names what was refused and why.
- registry: CodecId for every codec edith touches (video, audio, subtitle),
  CodecParameters/StreamInfo, and the Demuxer/Muxer/Decoder/Encoder
  contracts. Codecs are push/pull (send_packet/receive_frame) because
  packets and frames do not correspond one to one and end of stream has to
  be drainable.

forbid(unsafe_code), warn(missing_docs), no dependencies, no async.