Shine 4.0.0 is out

A fixed-point MP3 encoder, now with a psychoacoustic model.

Shine is a fixed-point MP3 encoder: it runs on devices without a floating-point unit, and it's fast everywhere else too. The last release was in 2017, and this one is a big one: shine finally has a psychoacoustic model.

What's new

Speed and quality

Encoding speed at 44.1 kHz stereo 128 kbps: shine's fast mode 1630x, shine 425x, LAME -q 7 310x, FDK AAC-LC 240x, LAME default 154x realtime

Quality against bitrate at 44.1 kHz stereo, 64 to 192 kbps: shine above LAME at 64 kbps and level with it from 96, FDK AAC-LC highest up to 128 kbps, shine's fast mode lowest

How this was made

Most of this release was written with an AI coding assistant. The programmer set the direction and the constraints (fixed point, no libm, no floating point in the library), reviewed every change, did the listening and made the design decisions.

A clean-room spec. LAME served as the reference model, but its code never reached the encoder. The work ran in three passes, each reading only what the previous one wrote: first a description of how LAME's psychoacoustic model behaves, then a spec for shine written from that description, with MUST/SHOULD/MAY rules, named constants and known pitfalls, and finally a fixed-point implementation written from the spec alone. The spec lives in doc/psy and is complete enough to rebuild the model without the code. It remains the source of truth: every later change went into the spec first, then into the code.

Optimization loops. Quality tuning is automated around PEAQ. A special build exposes the model's constants as knobs, candidates are screened on a few clips, and the survivors face a gate on the full 53-clip corpus: no clip may lose more than 5 points, and the mean may not drop. What passes goes into the spec, then into the code, and the release build must produce exactly the same streams as the gated one. Hundreds of candidates went through this loop, with blind listening tests as checkpoints.

CPU time got a loop of its own. We profiled each encoding step, read the assembly the compiler produced for the hot ones, and tried vectorization options: compiler flags, loop shapes, intrinsics. An option stayed only if it was faster and bit-identical to the reference, and was then written directly into the code. The result is a set of NEON and AVX2 kernels picked at run time, all matching the portable C version bit for bit.

Tooling. With an assistant, tooling is cheap to build, so we built a lot of it: a quality report and a quality gate that score any encoder against LAME and FDK AAC, a speed and memory report, per-step profiles, disassembly of the built encoder to see what the compiler vectorized, and timed test builds of each vectorization option, compared bit for bit against the reference. Add to that a reference oracle for the fixed-point model, a check that keeps floating point out of the library, golden hashes that pin the output on every architecture, diagnosis scripts for block types, bit usage and error spectra, the README charts and the blind-test page. CI covers x86, ARM, s390x (big-endian), WebAssembly and sanitizers.

Upgrading

This release breaks the API and the ABI, so you'll need to recompile. The new header is shine/shine.h, and every name is now prefixed (SHINE_MONO, mpeg.bitrate, ...). Your 3.x code should still build as is through shine/layer3.h; the compiler will just point out each old name you're using. Everything is listed in the ChangeLog.

The JavaScript package, @toots/shine.js, goes to 2.0.0: it's now an ES module compiled to WebAssembly, and it gets the model too.

Come listen

Those scores come from a model of human hearing, not from people. So what do your ears say? There's a blind test that puts shine 4.0 next to LAME and AAC (Fraunhofer's FDK) on 15 music and speech clips. The results update live, right next to what the model predicted: https://toots.github.io/shine/listen/

It's eight short tests, about fifteen minutes with headphones. Every answer helps, especially if your ears disagree with the scores.