forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 1bc90804e2d5b49a4004ebfbf849fb432d60a696

2026-08-14

test(mp4): fixtures, real library, remux round trip and a fuzz loopAhmet Kaan Gümüş · 1bc9080
test(mp4): fixtures, real library, remux round trip and a fuzz loop

34 mp4/mov/m4a fixtures field-compare against ffprobe and remux into
files ffmpeg decodes with the same fields; the 23.976 ones assert the
exact 24000/1001. The extension test writes av01, hvc1, vp09, colr with
mdcv/clli, udta/name and a tx3g track from cues, and reads each back
through ffprobe. Ten thousand byte mutations of a real file open, demux
and seek without a panic, and the ignored real-library test walks every
mp4-family file in the manifest to EOF against ffprobe -count_packets.
feat(mp4): the writer, with the boxes edith wrote by hand in-crateAhmet Kaan Gümüş · 7336903
feat(mp4): the writer, with the boxes edith wrote by hand in-crate

One pass: ftyp, then an mdat the samples stream into, then the moov built
from what was written (a faststart layout would have to copy the whole
mdat a second time). Sample tables are generated from the packets --
run-length stts, ctts only where something is reordered, stss only where
some sample is not a sync one, co64 where the file is big enough to need
it -- and an elst is written where the first picture is not the first
decoded one, so a reordered track does not start late.

The four boxes edith patched into the incumbent's output are written here
instead: av01+av1C, hvc1+hvcC, colr nclx (with mdcv/clli beside it, so an
HDR grade survives a remux) and udta/name for the movie and each track,
plus a tx3g entry with its style and font table.
feat(mp4): ISOBMFF box model, esds descriptors and the demuxerAhmet Kaan Gümüş · 49be010
feat(mp4): ISOBMFF box model, esds descriptors and the demuxer

The box walk checks every size against its parent and every table entry
count against the box that holds it, so a crafted header is an error and
never an allocation. The moov walk resolves the sample tables into
offset/size/dts/cts/sync per sample, reads fragments (moof/traf/trun)
into the same tables, and takes the frame rate off stts as an exact
rational -- whole track over whole track, so NTSC film stays 24000/1001
instead of decaying into 23.

A sample entry is read for what it says it is: an mp4a holding MP3 is an
MP3 track rather than a dropped one, ac-3/ec-3/alac/Opus/fLaC and the
QuickTime PCM entries are their own codecs, and an entry with no CodecId
leaves its track listed rather than decoded as something else. The esds
parser hands back the DecoderSpecificInfo as bytes, which is the field
callers previously had to rebuild from parsed fields.
feat(opus): CELT layer decoder and the single-stream decoderAhmet Kaan Gümüş · a882b8b
feat(opus): CELT layer decoder and the single-stream decoder

Full RFC 6716 Section 4.3 decode: coarse/fine/final energy with the Laplace
model, the implicit bit allocation (caps, dynalloc boosts, trim, interpolation,
skip), PVQ shapes with spreading, folding and splits, time-frequency changes,
anti-collapse, denormalisation, inverse MDCT with overlap-add, post-filter and
de-emphasis. All frame sizes 2.5-20 ms, all bandwidths NB..FB, mono and stereo.

The MDCT sizes are 15*2^k, so the N/4 FFT runs a 15-point stage over ec-dsp's
power-of-two transform rather than anything O(N^2).

Checks (tests/conformance.rs, one binary for the whole suite): the three
CELT-only RFC 6716 vectors decode with the reference range-coder state on
every packet -- 2147/2147, 4186/4186, 553/553 -- and score 99.8/99.6/99.7 %
on the opus_compare metric, reimplemented in Rust from the criterion in
Section 6 and cross-checked against the C tool (99.871 vs its 99.9 %, same
internal error 0.000315). Unit checks cover the IMDCT (overlap-add
reconstruction at every size), the 15*2^k FFT against a direct transform,
and the PVQ combinatorics.
feat(shim): hound WavReader, the read half edith's tests callAhmet Kaan Gümüş · babff90
feat(shim): hound WavReader, the read half edith's tests call

The W1 replica swap found the gap: engine's own suite reopens a WAV
export with hound::WavReader and iterates samples::<i16>(), which the
write-only shim could not compile. WavReader/spec/samples now wrap
ec_riff::WavReader, and Sample gains the reader's two constructors and a
width so TooWide and InvalidSampleFormat are decided the way the
incumbent decides them, not by a silent conversion.
feat(vp9,av1): bitstream header parsers for stateless hardware decodeAhmet Kaan Gümüş · ee46976
feat(vp9,av1): bitstream header parsers for stateless hardware decode

ec-vp9-syntax parses the superframe index and the whole uncompressed frame
header (profiles 0-3, colour config, size-from-reference, loop filter,
quantization, segmentation, tile info), carrying the state VP9 spreads across
frames: reference sizes, segmentation data and loop filter deltas. The spec
8.6.1 dequantization tables and the 8.8.1 loop filter level derivation ship
with it, so every field of VADecPictureParameterBufferVP9 and
VASegmentParameterVP9 comes out of the parse.

ec-av1-syntax parses OBU framing, the sequence header and the frame header in
full (superres, reference signalling incl. set_frame_refs, tile info, quant,
segmentation, delta q/lf, loop filter, CDEF, loop restoration, tx mode, skip
mode, global motion, film grain) plus tile group offsets, and derives the warp
shear validity VAWarpedMotionParamsAV1 asks for.

Both are BitReader-based, forbid unsafe, and answer malformed input with a
typed error rather than a panic. Verified against every VP9/AV1 fixture stream
with ffprobe as the oracle: dimensions, profile, bit depth, chroma, per-frame
key flags and shown-frame counts all agree, including 10-bit, 4:4:4,
monochrome, multi-tile, superframes and show_existing_frame.
feat(core): Packet::with_pts/with_duration buildersAhmet Kaan Gümüş · ffd766f
feat(core): Packet::with_pts/with_duration builders

The Ogg shim's caller builds a packet in one expression; these are the two
setters that chain.
feat(subs): SRT/WebVTT/ASS parsing, PGS bitmaps, oxideav shimsAhmet Kaan Gümüş · 1f445c1
feat(subs): SRT/WebVTT/ASS parsing, PGS bitmaps, oxideav shims

ec-subs carries the cue IR the family answers with (time range plus
styled runs, positioning beside them) and the SubRip and WebVTT parsers
over it; ec-ass reads ASS/SSA into the same IR, override tags included;
ec-pgs decodes Blu-ray display sets to straight RGBA canvases.

Tolerance is the point on the text side: BOM (UTF-8 and UTF-16), CRLF and
lone CR, invalid UTF-8, missing or wrong indices, dotted fractions,
trailing SubRip coordinates, overlapping and backwards cues all parse; a
block that cannot be read is skipped and counted, and only a document
with no timing line at all is refused. The PGS decoder holds an epoch
across display sets, keeps a partial segment until the rest arrives and
drops a torn set rather than the track.

shims/oxideav-{core,subtitle,ass,sub-image} carry the incumbent package
names and versions and cover exactly the surface the replica consumes, so
the swap is a [patch.crates-io] line. The replica's own call shapes are
transcribed as a test, which is what proves the swap rather than the
crates' own suites.

Checks: 34 tests green (unit plus real streams extracted from the library
by scripts/gen-subtitle-fixtures.sh); the first painted display set of a
1080p PGS track agrees with ffmpeg's own render of the same set — same
bounding box within two pixels, every reference ink pixel painted,
colours within 1/255.
test(matroska): fixture remux, seek loop and real-library sweepAhmet Kaan Gümüş · 2c0d9b8
test(matroska): fixture remux, seek loop and real-library sweep

Every mkv/webm/mka fixture is demuxed, written back out through this crate's
muxer and field-compared with ffprobe before ffmpeg decodes the result; a
hundred random seeks per fixture run on one reader each and every one lands
on a random-access point at or before its target.

The ignored sweep walks ten films of the real library end to end, matches
their per-stream packet counts against ffprobe and seeks twenty times in
each.
feat(matroska): Matroska/WebM muxer with SeekHead and CuesAhmet Kaan Gümüş · 550709b
feat(matroska): Matroska/WebM muxer with SeekHead and Cues

Streams declared, packets rescaled into the millisecond tick every Matroska
muxer writes, a cluster opened at each video keyframe, and three fields
patched at finish: the segment size, the duration and the SeekHead reserved
in front of the Info. Cues name every keyframe cluster, so a file written
here seeks in this crate's own reader and in ffmpeg.

Beyond the engine's writer, which wrote neither index: WebM doc type with the
codec subset enforced, colour and mastering metadata carried through, Opus
CodecDelay and SeekPreRoll off the OpusHead, DisplayWidth for anamorphic
sources, and BlockGroup durations for subtitle cues.
feat(matroska): EBML grammar and Matroska/WebM demuxerAhmet Kaan Gümüş · 4888147
feat(matroska): EBML grammar and Matroska/WebM demuxer

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

Ported from the engine's own demuxer, restructured around the ec-core Demuxer
contract: packets stream out of one cluster-sized allocation instead of a
frame index built for a video editor, and every track of the file becomes a
StreamInfo rather than one picture track plus a sound list.
test(ec-ogg): FLAC-in-Ogg recognition against a real streamAhmet Kaan Gümüş · 573addd
test(ec-ogg): FLAC-in-Ogg recognition against a real stream

The mapping header parse had no bytes behind it: ffmpeg makes a
FLAC-in-Ogg file from a fixture in the test, and the demuxer has to name
the codec, read the rate out of STREAMINFO and count the packets ffprobe
counts.
feat(flac): ec-flac decoder + encoder and the flacenc shimAhmet Kaan Gümüş · 339321d
feat(flac): ec-flac decoder + encoder and the flacenc shim

Decoder: metadata blocks, frame headers (fixed and variable blocking),
constant/verbatim/fixed/LPC subframes to order 32, escaped and
Rice-coded partitions, all three stereo decorrelations, 8..32-bit,
CRC-8 + CRC-16 verified per frame, STREAMINFO MD5 check, seek-table
positioning, and frame-sync resynchronisation for streams that start
mid-file. Malformed input errors, never panics.

Encoder: fixed block size, wasted-bit detection, fixed predictors,
LPC (Tukey window, Levinson-Durbin, error-feedback quantisation),
exact-cost Rice partition search, per-block stereo decision, 1..8
channels and 4..32 bits, with the input MD5 in STREAMINFO.

shims/flacenc carries package flacenc 0.5.1 over ec-flac for the exact
surface the replica calls (component::BitRepr, error::Verify,
config::Encoder, source::MemSource, encode_with_fixed_block_size,
bitsink::ByteSink).

Verified: 64/64 Xiph subset vectors decode bit-exact vs ffmpeg,
6/6 decodable uncommon vectors bit-exact, faulty vectors error out;
14/14 fixture encodes decode back bit-exact through ffmpeg at 0.961x
the size of ffmpeg's default FLAC.
feat(ec-ogg): Ogg demux/mux with Vorbis, Opus and FLAC mappingsAhmet Kaan Gümüş · 47772cb
feat(ec-ogg): Ogg demux/mux with Vorbis, Opus and FLAC mappings

RFC 3533 pages both ways: lacing (255-runs and the zero terminator),
packet reassembly across continuations, unreflected page CRC with
resync-on-damage, granule positions per mapping, BOS/EOS, and seek by
granule bisection.

Timing lives in the mapping, not in Ogg: Vorbis and FLAC count samples at
the stream rate, Opus counts 48 kHz samples including its pre-skip and
states per-packet durations in the TOC byte. Packets carry the page
granule they end on as side data, which is what lets a remux reproduce
positions the demuxer could not otherwise express.

Verified against ffprobe/ffmpeg on the nine Ogg fixtures: packet counts
and durations match, and every fixture remuxes to audio that decodes byte
for byte identical to the source.

feat(shims/oxideav-ogg): mux surface over ec-ogg

xiph_lace, open_concrete and set_page_target_bytes beside the
oxideav_core::Muxer methods, with the replica's "pts is the granule
position" convention translated here rather than at the call site.
feat(core): H.273 color model + dsp remap, ported from edith engineAhmet Kaan Gümüş · 81a11c6
feat(core): H.273 color model + dsp remap, ported from edith engine

Ports the engine's first-party colorspace model into the family IR: the
three-tier resolve (container tags over bitstream tags over the 720-line
heuristic), the H.273 code tables, the HEVC/H.264/AV1 parameter-set walks
that read a VUI colour_description, and the HDR SEI/mdcv/clli readers.

ColorInfo keeps its raw CICP triplet and gains the meaning behind it
(tags/describe/primaries and a From<ColorDescription> back out);
VideoParameters gains the ContentLight the mastering-display and
content-light metadata needs, which costs those four structs their Eq.

remap lands in ec-dsp beside the transforms: same 8.8 fixed-point
coefficients, same rounding, same no-op on a matching pair.
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(opus): range decoder and packet framingAhmet Kaan Gümüş · b05a16e
feat(opus): range decoder and packet framing

RFC 6716 Section 4.1 range decoder (exact u32 arithmetic, raw bits from the
frame end, ec_tell/ec_tell_frac) and Section 3 + Appendix B framing: TOC,
codes 0-3, padding, and the self-delimiting variant multistream needs.

Checks: symbol round-trip against a test-only range encoder written from
Section 5.1, tell/tell_frac agreement, and a malformed-input sweep that must
never panic.
feat(va): hand-written libva FFI with RAII handles and picture typestateAhmet Kaan Gümüş · 0eac457
feat(va): hand-written libva FFI with RAII handles and picture typestate

Minimal VA-API bindings for the hardware-video lane, no bindgen and no
build-time tooling. `sys` transcribes the libva 1.23 subset the family needs;
everything above it is safe.

- ABI: struct layouts asserted at compile time against numbers printed by
  abi-probe.c compiled against the system headers; `vaInitialize` version
  guard refuses libva older than 1.23 at runtime. Together these close the
  header-drift trap that broke the incumbent bindings at 1.23.
- Soundness: C enums stay `i32` in `sys`; the safe `Profile`/`Entrypoint`
  mirrors carry an `Unknown(i32)` arm, so a value from a newer driver can
  never be transmuted into an invalid Rust enum.
- RAII: Display/Config/Surface/Context/Buffer each destroy exactly what they
  created, and children hold an `Arc` of their parent, so libva's destruction
  order is a borrow-checker fact. Image and buffer mappings unmap on drop;
  PRIME exports own and close their descriptors.
- Picture typestate: New -> Rendering -> Ended -> Synced, transitions consume
  the picture; out-of-order submission does not compile.
- Caps probe reports per-pair RT formats plus driver-legal surface sizes
  (radeonsi refuses below 64x64) instead of assuming them.

55 unsafe blocks, every one SAFETY-commented. Tests run against the real GPU:
11 live tests (caps table vs vainfo, 100 pool create/destroy cycles under an
RSS bound, PRIME fd ownership, derive/map/unmap round trip) plus 4
compile_fail doctests pinning the typestate on E0599.
feat(inflate): DEFLATE/zlib decompression + miniz_oxide shimAhmet Kaan Gümüş · b73c680
feat(inflate): DEFLATE/zlib decompression + miniz_oxide shim

ec-inflate decodes RFC 1951 blocks (stored, fixed, dynamic) through a
two-level Huffman table and wraps them in the RFC 1950 header check and
Adler-32 verification. Every entry point carries the caller's output
ceiling, checked before each write, so a crafted block fails with an
error instead of taking all the memory there is; malformed input is
always an error, never a panic.

shims/miniz_oxide carries the incumbent name and version over it,
exposing the one function edith's Matroska ContentEncodings path uses,
with the same statuses and message strings so the swap needs no source
change.

Tests: round-trip against flate2 at levels 0-9 over seven input shapes
(raw and zlib), ceiling boundaries with partial output preserved,
truncation, Adler-32 mismatch, and a 10k-iteration mutation loop that
must never panic.
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.
test(fixtures): add 1916x1080 h264/hevc samples for the cropping rectAhmet Kaan Gümüş · 0dc3e2b
test(fixtures): add 1916x1080 h264/hevc samples for the cropping rect

Every other video fixture is CTU-aligned; the local library contains BluRay remuxes at 1916x1080, which is where a conformance-window bug shows up.
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.