Skip to content

Ultra MP3 Encoder (PoC)

Pre-release
Pre-release

Choose a tag to compare

@IgorCv2 IgorCv2 released this 26 Nov 01:18

Ultra is an experimental MP3 encoder based on the Helix MP3 Encoder (hmp3 5.2.4). It is an unofficial project, not affiliated with or endorsed by RealNetworks. The files it makes are ordinary MP3s that play anywhere.

The new code in this release was written with the help of AI, under developer direction.

What's different

A retuned model of hearing. Like every MP3 encoder, Ultra uses a model of hearing to decide where noise will be least audible and how to spend its bits. The Helix encoder's model ran on settings chosen by hand around 2000. These have been re-fitted with the help of Zimtohrli, a model of human hearing published by Google. Zimtohrli was only used to choose the new settings; while encoding, the model works on its own. The new settings are used by default.

An optional second opinion while encoding. Ultra also has a slower search mode. In this mode the encoder still makes its normal decision for each short slice of audio (about 13 ms). It then also tries a few nearby versions with slightly more or slightly less noise, a few dB either way, and it can also adjust single frequency bands. It decodes each version inside the encoder and uses Zimtohrli to pick the best balance between sound and file size. This mode is off by default.

Lossless repacking. Every frame is repacked with the most compact coding for exactly the same audio. Files are about 2% smaller and sound identical.

Zimtohrli doesn't decide on its own

The encoder's own model still makes the main decisions, and Zimtohrli only chooses among small adjustments to them. Any single measurement has blind spots, so fixed safeguards keep the search away from the places where it could be fooled:

  • Pre-echo: the model decides block switching and pre-echo control before the search, and they are never changed.
  • Transients: slices with sudden attacks keep exactly the bits the model gives them, and the slices around an attack can only gain bits, never lose them.
  • High frequencies: nothing above 16 kHz is adjusted, and the bandwidth is unchanged.
  • Holes in the sound: a version that saves bits is rejected if it would drop a frequency band that the model's version keeps.
  • Bad moments: a version that saves bits is rejected if its stretch of audio comes out more than 25% worse than the model's version, and noise never rises by more than 3 dB in any slice.
  • Stereo: the model makes the stereo decision first and it is kept, and both channels always get the same adjustment.

When single bands are adjusted, these limits apply to each band.

How Ultra uses Zimtohrli

Ultra doesn't call the Zimtohrli library: it has its own C translation, which matches Google's Python version to within 0.03% on a full clip, with the hearing model unchanged. The main difference is that it scores only the stretch of audio a decision can affect, about 0.4 s, instead of the whole file. The model's settings were fitted with a patched version of Google's Zimtohrli. README.md explains how the score is calculated.

Download and build

Ultra-MP3-Encoder-proof-of-concept-src.zip contains the full source code and the test scripts. Build it with make (Linux or MSYS2) or Visual Studio. README.md explains the options, including how to turn on the search mode. GitHub's automatic "Source code" downloads come from the main branch, which doesn't include these changes.

SHA-256: 0a1eb4ee36ad4831b77bf6fb823dc1aa21c24500d5d4812980bc97d307f6eacd

License: the Helix code in hmp3/ is under RealNetworks' RPSL (hmp3/LICENSE.txt), and every changed or added file lists its changes and their dates. Code adapted from Zimtohrli is under Apache-2.0 (hmp3/LICENSE-zimtohrli.txt), and the other files are MIT (LICENSE). Provided as is, without warranty. RealNetworks and Helix are trademarks of RealNetworks, Inc.