Commits
2026-08-14
feat(mp3): Layer III decoder and encoder, tables measured not copiedAhmet Kaan Gümüş · 1325107
feat(mp3): Layer III decoder and encoder, tables measured not copied ec-mp3 decodes MPEG-1, MPEG-2 LSF and MPEG-2.5 Layer III and encodes CBR MPEG-1 Layer III, and shims/rusty_mp3 carries the incumbent's name, version and call shape over it. Layer III's Huffman code tables and its 512-tap polyphase window are normative data no formula produces. Instead of copying them out of an existing implementation, scripts/mp3-tables measures them against a reference decoder: it writes legal frames whose main-data bits it chooses, decodes them with ffmpeg, and reads the answer back through a model of the decode chain. Every code tree is walked to its leaves and checked for a Kraft sum of exactly 1, complete coverage of its value grid and no duplicates; the window is least-squares fitted to a 1.6e-6 residual, the f32 noise floor of the decoder measured. The same rig produced the MPEG-1 long scalefactor band widths, which came out equal to the published layouts, and it corrected two things a description would not have: the MPEG-2.5 11.025 and 12 kHz short-block layouts are the 16 kHz ones, and the short-block region boundary is three scalefactor bands rather than the fixed 36 lines that only holds where those bands are four wide. Decoder: header and CRC, side info, scalefactors (MPEG-1 with scfsi and the LSF partition scheme), all Huffman tables, requantisation, mid/side and intensity stereo, short-block reorder, alias reduction, IMDCT with the four block windows, and a DCT-based polyphase bank from ec-dsp. ID3v2 and the Xing/LAME/VBRI header frame are skipped, junk is resynced over, and free-format is refused by name rather than guessed at. Encoder: polyphase analysis (the synthesis bank's adjoint, reconstructing to its -85 dB design limit), MDCT with block switching, an FFT-based masking model whose gaps are stated in the module docs, inner rate and outer distortion loops, Huffman table and region selection, and a bit reservoir that emits frames one behind so a granule can start inside the previous frame's payload. Measured, all against ffmpeg: - decode: 47 fixtures (nine sample rates, mono/stereo/joint/simple, CBR and VBR) at correlation 1.000000, 333-3232x realtime - encode: at or above rusty_mp3 0.6.1 on the same corpus and metric at 128/192/320 kbit/s, mono and stereo, every stream decoding without an ffmpeg warning
feat(ac3): A/52 headers, bit allocation model and transform primitivesAhmet Kaan Gümüş · bd2188c
feat(ac3): A/52 headers, bit allocation model and transform primitives syncinfo/bsi (including the Annex D alternate syntax), the parametric bit allocation of section 7.2.2 with its spec tables, exponent and mantissa unpacking, and the 512/256-sample IMDCT with window and overlap-add over the shared ec-dsp FFT. Grouped mantissas are shared across exponent sets, per section 7.3.5: the group state belongs to the audio block, not to the channel.
feat(h264): registry Decoder entry, avcC extradata, mechanism-named refusalsAhmet Kaan Gümüş · 19f3903
feat(h264): registry Decoder entry, avcC extradata, mechanism-named refusals The NAL-level Decoder is what a bitstream tool wants; a demuxer wants packets. H264Decoder implements ec_core::registry::Decoder over the same decode core and adds the two things a container brings with it: parameter sets carried out of band in an avcC record (14496-15 clause 5.3.3.1), and NAL units framed by a length prefix instead of Annex B start codes. The framing is decided once, by whether extradata held an avcC, and the SPS inside it publishes the picture size before the first packet arrives. Every refusal's why-text now names the syntax element that fired and the machinery it would need, not just "not implemented" — the conformance suite proves each one against a stream that really uses the feature, so the text is the capability statement a caller reads.
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(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(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.
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(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.