Commits
2026-10-23
Restore edith_codecs after local data loss (2026-10-23)Ahmet Kaan Gümüş · b7434a2
Restore edith_codecs after local data loss (2026-10-23) On 2026-10-23 an automated agent ran `rm -rf $HOME` and deleted the local repository with all of its history. This commit restores the working tree from the newest surviving copy, the host-c server lane mirror. That mirror matches local main as of the testcut Phase 2 reports, including the tool cache, the nextest fast profile and changed-crates.sh. The history before this commit was not recovered.
2026-09-16
fix(mp3): the word-buffered bit accumulator no longer shifts by 64Ahmet Kaan Gümüş · 82ba265
fix(mp3): the word-buffered bit accumulator no longer shifts by 64
push_bits computed `(value & mask) << (64 - used - n)`. For a ZERO-LENGTH run
on an empty buffer (used == 0, n == 0) that shift count is exactly 64: debug
builds panicked ("attempt to shift left with overflow") and release builds
wrapped it to a shift of 0, OR-ing the unmasked value into the accumulator.
The scalefactor coder emits such a run for every band whose slen is 0 - the
normal case when all scalefactors are zero. The debt's "used + n > 64" framing
was wrong: used < 8 always, so free >= 57 and the old subtraction never
underflowed.
Fix: n == 0 returns early; a run longer than the free space fills the word,
drains its complete bytes and starts the remainder in a fresh word (the
remainder is under eight bits, so the trailing drain is the one the un-split
path already ran). For n >= 1 with n <= free the arithmetic is unchanged and
the emitted bytes are identical, so previously working encodes are
byte-for-byte the same.
Evidence: ec-mp3 lib 22/22 (3 panicked before at the old huffman.rs:211);
edith `cargo test -p engine --test audio_export -- --test-threads=1` 14/14
(`exports_the_timeline_as_an_mp3` and `the_sound_is_written_at_the_rate_that_
was_asked_for` failed pre-fix with "export worker panicked: attempt to shift
left with overflow"); new boundary test compares byte-for-byte against a plain
MSB-first reference across n = 0, full-word and spill runs, and fails on the
old body. Both reviewed independently: SAFE TO COMMIT.2026-09-13
perf(mp3): one walk over the region prices every candidate tableAhmet Kaan Gümüş · 19b1017
perf(mp3): one walk over the region prices every candidate table best_table walked the region's pairs once per shortlisted table (up to nine pair_bits passes per region) and plan_spectrum walked a tenth time to price the winner; half the remaining profile lived in that loop. The region is now walked once, accumulating every candidate's cost in parallel, with a dead candidate dropped the moment a pair falls outside it — the same accept/reject decisions in the same order, so every bench fixture still encodes byte-identically and the suite is green. The orphaned pair_bits helper is folded into the new walk. encode: stereo CBR 37.3x -> 43.7x realtime, VBR 17.8x -> 20.9x.
perf(mp3): word-buffered granule bit emission, cost-only rate loopAhmet Kaan Gümüş · d97b1ac
perf(mp3): word-buffered granule bit emission, cost-only rate loop The profile was 45% inside BitWriter's per-bit loop and most of another 22% in code_spectrum's Vec<bool> round-trip: every rate-loop round wrote the granule's bits out and re-expanded them one bool per bit for the frame writer. BitBuf buffers the same MSB-first bitstream through a u64 accumulator; the rate loop now judges candidate gains by Huffman cost alone and the kept configuration is materialised exactly once. All eight bench fixtures encode byte-identically; the crate suite is green. encode: stereo CBR 8.2x -> 18.2x realtime, VBR 4.0x -> 10.6x.
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