Go to file
Lu zhiping c5576bce4f changed debian/source/format to native 2022-06-27 15:40:00 +08:00
android Import Upstream version 3.1.1 2022-06-27 15:39:57 +08:00
debian changed debian/source/format to native 2022-06-27 15:40:00 +08:00
js Import Upstream version 3.1.1 2022-06-27 15:39:57 +08:00
src Import Upstream version 3.1.1 2022-06-27 15:39:57 +08:00
.gitignore Import Upstream version 3.1.1 2022-06-27 15:39:57 +08:00
COPYING Import Upstream version 3.1.1 2022-06-27 15:39:57 +08:00
ChangeLog Import Upstream version 3.1.1 2022-06-27 15:39:57 +08:00
Makefile.am Import Upstream version 3.1.1 2022-06-27 15:39:57 +08:00
README.md Import Upstream version 3.1.1 2022-06-27 15:39:57 +08:00
README.old Import Upstream version 3.1.1 2022-06-27 15:39:57 +08:00
bootstrap Import Upstream version 3.1.1 2022-06-27 15:39:57 +08:00
configure.ac Import Upstream version 3.1.1 2022-06-27 15:39:57 +08:00
libshine.sym Import Upstream version 3.1.1 2022-06-27 15:39:57 +08:00
shine.pc.in Import Upstream version 3.1.1 2022-06-27 15:39:57 +08:00

README.md

Shine: fast fixed-point mp3 encoding

shine is a blazing fast mp3 encoding library implemented in fixed-point arithmetic. The library can thus be used to performe super fast mp3 encoding on architectures without a FPU, such as armel, etc.. It is also, however, also super fast on architectures with a FPU!

How to use?

The encoding API should be quite straight forward:

#include <shine/layer3.h>
  
(...)

/* See if samplerate and bitrate are valid */
if (shine_check_config(config.wave.samplerate, config.mpeg.bitr) < 0)
  error("Unsupported samplerate/bitrate configuration.");

/* Initiate encoder */
s = shine_initialise(&config);

/* Number of samples (per channel) to feed the encoder with. */
int samples_per_pass = shine_samples_per_pass(s);

/* All the magic happens here */
while (read(buffer, infile, samples_per_pass)) {
  data = shine_encode_buffer(s,buffer,&written);
  write(data, written);
}

/* Flush and write remaining data. */
data = shine_flush(s,&written);
write(written, data);

/* Close encoder. */
shine_close(s);

How fast is it?

On a Raspberry Pi (ARM, FPU):

Lame, 3m06s, 1.8x realtime:

pi@raspberrypi ~ $ lame bla.wav bla.mp3
LAME 3.99.5 32bits (http://lame.sf.net)
Using polyphase lowpass filter, transition band: 16538 Hz - 17071 Hz
Encoding bla.wav to bla.mp3
Encoding as 44.1 kHz j-stereo MPEG-1 Layer III (11x) 128 kbps qval=3
    Frame          |  CPU time/estim | REAL time/estim | play/CPU |    ETA
 12987/12987 (100%)|    3:06/    3:06|    3:06/    3:06|   1.8216x|    0:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   kbps        LR    MS  %     long switch short %
  128.0        0.1  99.9        89.1   6.1   4.9
Writing LAME Tag...done
ReplayGain: -10.5dB

Shine, 1m35s, 3.6x realtime:

pi@raspberrypi ~ $ shineenc bla.wav bla.mp3
shineenc (Liquidsoap version)
WAVE PCM Data, stereo 44100Hz 16bit, duration: 00:05:39
MPEG-I layer III, stereo  Psychoacoustic Model: Shine
Bitrate: 128 kbps  De-emphasis: none   Original
Encoding "bla.wav" to "bla.mp3"
Finished in 00:01:35 (3.6x realtime)

Now, on a mac airbook (x86_64, FPU):

Lame, 15s, 22x realtime:

toots@zulu tmp  % lame bla.wav bla.mp3
LAME 3.99.5 64bits (http://lame.sf.net)
Using polyphase lowpass filter, transition band: 16538 Hz - 17071 Hz
Encoding bla.wav to bla.mp3
Encoding as 44.1 kHz j-stereo MPEG-1 Layer III (11x) 128 kbps qval=3
    Frame          |  CPU time/estim | REAL time/estim | play/CPU |    ETA
 12987/12987 (100%)|    0:15/    0:15|    0:17/    0:17|   22.087x|    0:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   kbps        LR    MS  %     long switch short %
  128.0        0.1  99.9        89.1   6.1   4.9
Writing LAME Tag...done
ReplayGain: -10.5dB

Shine, 9s, 37.7x realtime:

shineenc (Liquidsoap version)
WAVE PCM Data, stereo 44100Hz 16bit, duration: 00:05:39
MPEG-I layer III, stereo  Psychoacoustic Model: Shine
Bitrate: 128 kbps  De-emphasis: none   Original
Encoding "/tmp/bla.wav" to "/tmp/bla.mp3"
Finished in 00:00:09 (37.7x realtime)

On a Google Nexus 5 (ARM, FPU):

Shine, 14s, 24.2x realtime:

u0_a65@hammerhead:/mnt/sdcard $ shineenc bla.wav bla.mp3
shineenc (Liquidsoap version)
WAVE PCM Data, stereo 44100Hz 16bit, duration: 00:05:39
MPEG-I layer III, stereo  Psychoacoustic Model: Shine
Bitrate: 128 kbps  De-emphasis: none   Original
Encoding "bla.wav" to "bla.mp3"
Finished in 00:00:14 (24.2x realtime)

Limitations

The code for the encoder has been written a long time ago (see below) and the only work done on this fork consists of reorganizing the code and making a proper shared API out of it. Thus, the encoder may not be exempt of bugs.

Also, the encoding algorithm is rather simple. In particular, it does not have any Psychoacoustic Model.

A bit of history

This code was dug out from the dusty crates of those times before internet and github. It apparently was created by Gabriel Bouvigne sometime around the end of the 20th century. The encoder was converted circa 2001 by Pete Everett to fixed-point arithmetic for the RISC OS. Latest we know, Patrick Roberts had worked on the code to make it multi-platform and more library oriented. That was around 2006.

You can consult README.old and the various source files for more informations on this code.