Giter Site home page Giter Site logo

toots / shine Goto Github PK

View Code? Open in Web Editor NEW
387.0 25.0 62.0 1.85 MB

Super fast fixed-point MP3 encoder with JS/wasm and android native bindings.

License: Other

Shell 0.03% JavaScript 5.42% C 86.58% Makefile 2.81% HTML 0.57% M4 0.20% TypeScript 4.37%
mp3 audio android fixed-point wasm

shine's Introduction

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 perform super fast mp3 encoding on architectures without a FPU, such as armel, etc.. It is 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 macbook pro (arm64/M1 pro, FPU, December 30, 2022):

Lame, 88.7x realtime:

LAME 3.100 64bits (http://lame.sf.net)
Using polyphase lowpass filter, transition band: 16538 Hz - 17071 Hz
Encoding /tmp/decoded.wav to /tmp/lame.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
 12203/12203 (100%)|    0:03/    0:03|    0:04/    0:04|   88.773x|    0:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   kbps        LR    MS  %     long switch short %
  128.0       32.6  67.4        96.4   1.9   1.7
Writing LAME Tag...done
ReplayGain: -9.3dB
lame -b 128 /tmp/decoded.wav /tmp/lame.mp3  3.55s user 0.05s system 99% cpu 3.609 total

Shine, 318.0x realtime:

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

⚠ The following are outdated tests ⚠

On a Raspberry Pi (ARM, FPU):

Lame, 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, 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)

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. Last 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.

shine's People

Contributors

aviallon avatar ckthomas avatar felixmulder avatar lgbaldoni avatar mtgrosser avatar philippe44 avatar seven1240 avatar smblott-github avatar smimram avatar toots avatar tripulse avatar zhaoxiu-zeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shine's Issues

Compiling Error on Rpi2 Wheezy

got this messange after "make":

cd . && /bin/bash /home/pi/downloads/shine-3.1.0/missing automake-1.14 --foreign
/home/pi/downloads/shine-3.1.0/missing: Zeile 81: automake-1.14: Kommando nicht gefunden.
WARNING: 'automake-1.14' is missing on your system.
You should only need it if you modified 'Makefile.am' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'automake' program is part of the GNU Automake package:
http://www.gnu.org/software/automake
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
http://www.gnu.org/software/autoconf
http://www.gnu.org/software/m4/
http://www.perl.org/
Makefile:374: recipe for target 'Makefile.in' failed
make: *** [Makefile.in] Error 1

segfault in shine_BF_freePartHolder

Initializing and closing shine without encoding anything results in segmentation fault.
This was tested on 3.0 and latest git version. Simple workaround is to write zeros, but that's not pretty.

#include <shine/layer3.h>

int main(void)
{
        shine_t shine;
    shine_config_t config;

    shine_set_config_mpeg_defaults(&config.mpeg);
    config.mpeg.mode = STEREO;
    config.wave.channels = PCM_STEREO;
    config.wave.samplerate = 44100;

    shine = shine_initialise(&config);

    shine_close(shine);
}

gdb:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7bd2571 in shine_BF_freePartHolder () from /usr/lib/libshine.so.3
(gdb) info stack
#0  0x00007ffff7bd2571 in shine_BF_freePartHolder () from /usr/lib/libshine.so.3
#1  0x00007ffff7bd25b9 in shine_formatbits_close () from /usr/lib/libshine.so.3
#2  0x00007ffff7bd5cf1 in shine_close () from /usr/lib/libshine.so.3
#3  0x0000000000400703 in main () at shine.c:19

(Enhancement-Wish) Allow FFmpeg to compile with static libshine and libmp3lame libraries.

Hi
I saw that you have made some changes to avoid name collisions with lame.
Here ---> 6341ce5
Maybe you can make some more changes to allow FFmpeg build with static libshine and libmp3lame libraries.

FFmpeg won't compile with static libshine and libmp3lame libraries.

This is my build method
(I'm using 32-bit Ubuntu-14.04 Linux)...

cd ~/; sudo rm -rf build; mkdir build; cd build; \
wget sourceforge.net/projects/lame/files/lame/3.99/lame-3.99.5.tar.gz -qO- | tar -xz; cd lame-*; \
./configure --prefix=$HOME/build --disable-shared; \
make; make install; cd ..; \
git clone --depth 1 https://github.com/toots/shine.git; cd shine; ./bootstrap; \
./configure --prefix=$HOME/build --disable-shared; \
make; make install; cd ..; \
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git ffmpeg; cd ffmpeg; \
PKG_CONFIG_PATH=$HOME/build/lib/pkgconfig LDFLAGS=-L$HOME/build/lib CFLAGS=-I$HOME/build/include \
./configure --enable-libmp3lame --enable-libshine; make

This is the error message...
^

CC  cmdutils.o
CC  ffmpeg_opt.o
CC  ffmpeg_filter.o
CC  ffmpeg_vdpau.o
LD  ffmpeg_g
/home/user/build/lib/libmp3lame.a(takehiro.o):(.rodata+0x160): multiple definition of `slen2_tab'
/home/user/build/lib/libshine.a(tables.o):(.rodata+0xc80): first defined here
/home/user/build/lib/libmp3lame.a(takehiro.o):(.rodata+0x1a0): multiple definition of `slen1_tab'
/home/user/build/lib/libshine.a(tables.o):(.rodata+0xcc0): first defined here
collect2: error: ld returned 1 exit status
make: *** [ffmpeg_g] Error 1

make error at 3.1.0

xuzhiwendeMacBook-Pro:shine-3.1.0 xuzhiwen$ make
[ -d android/bin ] || mkdir android/bin
[ -d android/include ] || mkdir android/include
[ -d android/lib ] || mkdir android/lib
NDK_PROJECT_PATH=/Users/xuzhiwen/Documents/work/ffmpeg/shine/shine-3.1.0 ndk-build APP_BUILD_SCRIPT=/Users/xuzhiwen/Documents/work/ffmpeg/shine/shine-3.1.0/android/Library.mk
[arm64-v8a] Compile : shine <= bitstream.c
[arm64-v8a] Compile : shine <= formatbits.c
[arm64-v8a] Compile : shine <= huffman.c
[arm64-v8a] Compile : shine <= l3bitstream.c
[arm64-v8a] Compile : shine <= l3loop.c
[arm64-v8a] Compile : shine <= l3mdct.c
[arm64-v8a] Compile : shine <= l3subband.c
[arm64-v8a] Compile : shine <= layer3.c
[arm64-v8a] Compile : shine <= reservoir.c
[arm64-v8a] Compile : shine <= tables.c
[arm64-v8a] SharedLibrary : libshine.so
[arm64-v8a] Install : libshine.so => libs/arm64-v8a/libshine.so
[x86_64] Compile : shine <= bitstream.c
[x86_64] Compile : shine <= formatbits.c
[x86_64] Compile : shine <= huffman.c
[x86_64] Compile : shine <= l3bitstream.c
[x86_64] Compile : shine <= l3loop.c
[x86_64] Compile : shine <= l3mdct.c
[x86_64] Compile : shine <= l3subband.c
[x86_64] Compile : shine <= layer3.c
[x86_64] Compile : shine <= reservoir.c
[x86_64] Compile : shine <= tables.c
[x86_64] SharedLibrary : libshine.so
[x86_64] Install : libshine.so => libs/x86_64/libshine.so
[mips64] Compile : shine <= bitstream.c
[mips64] Compile : shine <= formatbits.c
[mips64] Compile : shine <= huffman.c
[mips64] Compile : shine <= l3bitstream.c
[mips64] Compile : shine <= l3loop.c
[mips64] Compile : shine <= l3mdct.c
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s: Assembler messages:
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:580: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $3,$7' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:597: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $9,$10'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:616: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $9,$11' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:629: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $9,$11'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:642: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $9,$11' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:655: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $9,$11'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:668: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $9,$11' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:681: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $8,$7'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:705: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $8' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:732: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $3,$13'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:750: Error: opcode not supported on this processor: mips64r6 (mips64r6) msub $4,$14' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:761: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:761: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:776: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $6,$14'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:795: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $13,$5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:810: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:810: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:831: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $4,$24'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:846: Error: opcode not supported on this processor: mips64r6 (mips64r6) msub $4,$15' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:857: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:857: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:872: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $6,$15'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:891: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $24,$5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:906: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:906: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:927: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $4,$18'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:942: Error: opcode not supported on this processor: mips64r6 (mips64r6) msub $4,$25' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:953: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:953: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:968: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $6,$25'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:987: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $18,$5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1002: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1002: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1023: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $4,$ra'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1038: Error: opcode not supported on this processor: mips64r6 (mips64r6) msub $4,$20' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1049: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1049: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1064: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $6,$20'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1083: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $ra,$5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1098: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1098: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1120: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $4,$8'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1136: Error: opcode not supported on this processor: mips64r6 (mips64r6) msub $4,$7' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1147: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1147: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1162: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $6,$7'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1181: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $8,$5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1196: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1196: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1218: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $4,$8'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1234: Error: opcode not supported on this processor: mips64r6 (mips64r6) msub $4,$7' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1245: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1245: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1260: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $6,$7'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1279: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $8,$5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1294: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1294: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1316: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $4,$8'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1332: Error: opcode not supported on this processor: mips64r6 (mips64r6) msub $4,$7' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1343: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1343: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1358: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $6,$7'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1377: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $8,$5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1392: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1392: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1414: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $4,$8'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1430: Error: opcode not supported on this processor: mips64r6 (mips64r6) msub $4,$7' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1441: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1441: Error: opcode not supported on this processor: mips64r6 (mips64r6) mflo $5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1456: Error: opcode not supported on this processor: mips64r6 (mips64r6) mult $6,$7'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1475: Error: opcode not supported on this processor: mips64r6 (mips64r6) madd $8,$5' /var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1490: Error: opcode not supported on this processor: mips64r6 (mips64r6) mfhi $4'
/var/folders/95/y0h1lvf10ndd8lbsc5gtyh7c0000gn/T/l3mdct-e634fb.s:1490: Error: opcode not supported on this processor: mips64r6 (mips64r6) `mflo $5'
clang: error: assembler command failed with exit code 1 (use -v to see invocation)
make[1]: *** [/Users/xuzhiwen/Documents/work/ffmpeg/shine/shine-3.1.0/obj/local/mips64/objs/shine/src/lib/l3mdct.o] Error 1
make: *** [android] Error 2

No support for live stream sources?

Hi,

Please excuse my lack of knowledge here. I have compiled ffmpeg with libshine, intending to do recording from a microphone directly to MP3 on an RPi.

I can transcode a file just fine, but when attempting to use an alsa source, I get:

"[libshine @ 0x1a67f00] free format output not supported"

I tracked this to the code where it suggests a requirement to read headers - is this basically saying "streaming from live sources not supported"? Or do I just need to adjust my ffmpeg command line?

Thanks

Can encoder be used after shine_flush

A quick question: to your knowledge, can the encoder be used again after a call to shine_flush or shall it be closed and a new one created? When I flush it and then restart, there is always a pop heard from the previous track encoded

Thank you

Configure Notes

Can you please update information on how to use this with darkice or liquidsoap.

i am trying to setup streaming client for icecast2.

i use raspberrypi and raspbian and usb sound card. there is very less info on how to do what i want.

Final frame may be truncated

If the bitstream cache doesn't happen to be filled to an int (32-bit) boundary, the final mp3 frame may be truncated, resulting in a non-fatal error when playing that final frame, e.g.:

$ mpv test.mp3 
[ffmpeg/demuxer] mp3: Estimating duration from bitrate, this may be inaccurate
 (+) Audio --aid=1 (mp3 1ch 44100Hz)
AO: [pulse] 44100Hz mono 1ch float
A: 00:00:03 / 00:00:04 (92%)
[ffmpeg/audio] mp3float: invalid new backstep -1
A: 00:00:03 / 00:00:04 (94%)

Exiting... (End of file)

Psymodel

I am not sure where to ask, but LAME and shine have similar 'calc_xmin' functions, but the shine function doesn't do anything inside other than setting l3_xmin->l[gr][ch][sfb] = 0; inside the loop. Could I get some overview of what it would take for me to port this?

If this is the wrong place, please advise the correct place to ask.

Can't reproduce emcc build of js/dist/libshine.js

Hi,

I'm currently trying to add npm support for this package.
However, right now when I go into the js folder and run make, I get a different output in dist to the one that you've uploaded.

I get a separate .js and .wasm file. I wonder if that's because we may have different emscripten versions or because there are some parameters missing in the Makefile.

Mine is:

> emcc --version
emcc (Emscripten gcc/clang-like replacement) 1.39.0 (commit ae5044e7797654f2ed5fb7c0e174e7c8ead5187b)
Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I use this code in STM32

I use libshine to compress wav file to mp3 file in STM32. STM32 is a ARM CM4 mcu with fpu.

I use your code and I find is not so fast to compress realtime.

Actually,I just test a short file with 64 frame, so I calculate the code has 0.75x realtime.

It's reasonable in stm32 casue this chip's frequence just 180Mhz. Have you ever run it in a similar chip?

I find your code has lots of change compare to the original libshine. I guess you want the code faster so you modify it, am I right?

I want to know the ram consumption, have you ever notice it? In my test is almost 100kB, I mean is very wonderful if the ram consumption less.

My English is real poor, I hope you can understand it.
Thank you very much.

Frame header padding bit incorrectly set

When encoding a 32khz WAV at a bitrate of 48kbps, shine generates a frame header of FF FB 3A C4 instead of the expected FF FB 38 C4; the padding bit is incorrectly being set.

It seems to narrow down to non-associativity of the floating-point calculation of avg_slots_per_frame in layer3.c. The calculation with samplerate=32000 and bitr=48 gives a double of 215.999999999999972... which consequently truncates incorrectly to 215.

Setting whole_slots_per_frame by first truncating to a float before converting to an int:

config->mpeg.whole_slots_per_frame = (int)(float)avg_slots_per_frame;

seems to work now and various other WAV files still convert properly. May not be the best solution however as floating point errors may still occur elsewhere.

Any plan to add 8k support?

Hi,

Nice work. Looks like it doesn't support 8K and I tried to copy the bandindex table from lame but it still doesn't work.

If you'd like to help and this I can create a pull request.

Thanks,
Seven.

Quality comparison

Project is missing quality comparison as faster algorithm with missing Psychoacoustic Model could have lower audio quality at same bitrate.

Full amplitude sine wave causes distort output

Hi...

I found the following problem, can you help me to resolve it?

  1. Input WAV file contains stereo, full amplitude (-1.0 ~ + 1.0), 10KHz, 44.1KHz S16LE sine waves
  2. The amplitude of waveform of target MP3 file cannot be stable. It falls and raises randomly within few milliseconds. This problem doesn't show up if the amplitude don't touch upper and lower bound (ex. -0.8 ~ + 0.8)
  3. The same problem shows up under different frequency (ex. 500Hz).

missing flush

Library is missing flush function. To properly handle last frames.
There is ugly workaround to fed encoder with zeroes.

Wave header parser isn't generic enough

Would be nice if pipe support could be added to allow decoding a source with i.e. ffmpeg and then encode with shineenc:

ffmpeg -y -threads 8 -loglevel fatal -i "input.aac" -ac 2 -ar 48000 -acodec pcm_s16le -f wav - | shineenc -d - output.mp3

License question

How did this come to have LGPL when the original shine seems to have been GPL?

BIG_ENDIAN problem (Error: Unknown WAVE format)

I am trying to encode this wave file (output from hexdump -C ):

00000000  52 49 46 46 24 e4 57 00  57 41 56 45 66 6d 74 20  |RIFF$.W.WAVEfmt |
00000010  10 00 00 00 01 00 02 00  80 bb 00 00 00 ee 02 00  |................|
00000020  04 00 10 00 64 61 74 61  00 e4 57 00 00 00 00 00  |....data..W.....|

This is the output from shineenc -v /tmp/sample.wav /tmp/output.mp3:
shineenc (Liquidsoap version)
Looking for chunk 'fmt '
Found chunk 'fmt ', length: 268435456
WAVE format: 256
Error: Unknown WAVE format

I am using shine package version 3.1.0-2 from OpenWRT on a GL.iNet GL-AR150 device.

Given the output above it looks shine is not properly converting byte order when reading from the file. WAVE format is 256 instead of 1 (0x0100 vs 0x0010) and length is 0x1000 0000 instead of 0x0000 0010

This seems to build Shine on Windows (CMakeLists.txt)

CMakeLists.txt

cmake_minimum_required(VERSION 3.20)
project(libshine)

include_directories(src src/lib src/bin)

add_library(
    shine STATIC
    src/lib/bitstream.c src/lib/huffman.c
    src/lib/l3bitstream.c
    src/lib/l3loop.c 
    src/lib/l3mdct.c 
    src/lib/l3subband.c
    src/lib/layer3.c
    src/lib/reservoir.c
    src/lib/tables.c)
                         
install(
    TARGETS shine
    LIBRARY DESTINATION lib  # for shared libs
    ARCHIVE DESTINATION lib) # for static libs

install(
    DIRECTORY       libshine/include/
    DESTINATION     include
    FILES_MATCHING  PATTERN "*.h")

I integrated shine into prefix, a cmake ci project system. project ion is using shine. it needs CMake projects or ones with an autoconfigure, and for this one I had a generative autotools.cmake; however cmake did not launch with the appropriate environment vars so that configure would generate and then invoke & succeed. So I made this one manually

ffmpeg:ERROR: shine not found using pkg-config

I'm build LEDE on Ubuntu 17.10.
There are Error Info:

touch /home/xpf/lede/build_dir/target-mipsel_24kc_musl/ffmpeg-full/ffmpeg-3.2.8/.prepared_f9165894b22b3b77bad3e7e50ca63601_6664517399ebbbc92a37c5bb081b5c53_check
. /home/xpf/lede/include/shell.sh; xzcat /home/xpf/lede/dl/ffmpeg-3.2.8.tar.xz | tar -C /home/xpf/lede/build_dir/target-mipsel_24kc_musl/ffmpeg-full/ffmpeg-3.2.8/.. -xf -
[ ! -d ./src/ ] || cp -fpR ./src/* /home/xpf/lede/build_dir/target-mipsel_24kc_musl/ffmpeg-full/ffmpeg-3.2.8
touch /home/xpf/lede/build_dir/target-mipsel_24kc_musl/ffmpeg-full/ffmpeg-3.2.8/.prepared_f9165894b22b3b77bad3e7e50ca63601_6664517399ebbbc92a37c5bb081b5c53
rm -f /home/xpf/lede/staging_dir/target-mipsel_24kc_musl/stamp/.ffmpeg.full_installed
( cd /home/xpf/lede/build_dir/target-mipsel_24kc_musl/ffmpeg-full/ffmpeg-3.2.8;
CFLAGS="-Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -iremap/home/xpf/lede/build_dir/target-mipsel_24kc_musl/ffmpeg-full/ffmpeg-3.2.8:ffmpeg-3.2.8 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/home/xpf/lede/staging_dir/target-mipsel_24kc_musl/usr/include -I/home/xpf/lede/staging_dir/target-mipsel_24kc_musl/include -I/home/xpf/lede/staging_dir/toolchain-mipsel_24kc_gcc-5.5.0_musl/usr/include -I/home/xpf/lede/staging_dir/toolchain-mipsel_24kc_gcc-5.5.0_musl/include/fortify -I/home/xpf/lede/staging_dir/toolchain-mipsel_24kc_gcc-5.5.0_musl/include -fpic" LDFLAGS="-L/home/xpf/lede/staging_dir/target-mipsel_24kc_musl/usr/lib -L/home/xpf/lede/staging_dir/target-mipsel_24kc_musl/lib -L/home/xpf/lede/staging_dir/toolchain-mipsel_24kc_gcc-5.5.0_musl/usr/lib -L/home/xpf/lede/staging_dir/toolchain-mipsel_24kc_gcc-5.5.0_musl/lib -znow -zrelro" ./configure --enable-cross-compile --cross-prefix="mipsel-openwrt-linux-musl-" --arch="mipsel" --target-os=linux --prefix="/usr" --pkg-config="pkg-config" --enable-shared --enable-static --enable-pthreads --enable-zlib --disable-doc --disable-debug --disable-lzma --disable-vaapi --disable-vdpau --disable-outdevs --disable-altivec --disable-vsx --disable-power8 --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-inline-asm --disable-mipsdsp --disable-mipsdspr2 --disable-mipsfpu --disable-msa --disable-mmi --disable-fast-unaligned --disable-runtime-cpudetect --disable-yasm --enable-avresample --enable-libopus --enable-small --enable-libshine )
ERROR: shine not found using pkg-config

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
[email protected] mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solve the problem.
Makefile:686: recipe for target '/home/xpf/lede/build_dir/target-mipsel_24kc_musl/ffmpeg-full/ffmpeg-3.2.8/.configured_f78b6842b4d5492e928f33d107540819' failed
make[3]: *** [/home/xpf/lede/build_dir/target-mipsel_24kc_musl/ffmpeg-full/ffmpeg-3.2.8/.configured_f78b6842b4d5492e928f33d107540819] Error 1
make[3]: Leaving directory '/home/xpf/lede/feeds/packages/multimedia/ffmpeg'
package/Makefile:109: recipe for target 'package/feeds/packages/ffmpeg/compile' failed
make[2]: *** [package/feeds/packages/ffmpeg/compile] Error 2
make[2]: Leaving directory '/home/xpf/lede'
package/Makefile:105: recipe for target '/home/xpf/lede/staging_dir/target-mipsel_24kc_musl/stamp/.package_compile' failed
make[1]: *** [/home/xpf/lede/staging_dir/target-mipsel_24kc_musl/stamp/.package_compile] Error 2
make[1]: Leaving directory '/home/xpf/lede'
/home/xpf/lede/include/toplevel.mk:216: recipe for target 'world' failed
make: *** [world] Error 2

I try to reinstall pkg-config,
I try to run ./scripts/feeds install shine
but it doesn't work.
How can I fix this? Thanks.

then,I found that “PKG_SOURCE_URL:=https://github.com/toots/shine/releases/download/$(PKG_VERSION)/” does not exist in Makefile

bit of an odd include process for cpp users

Hi This is great work. Appreciate it!

Had a bit of an issue using it though, because only this works from C++

extern "C" {
#include <shine/layer3.h>
};

Its not typical to something I try right away -- its common to have this conditional in the header. so it took me longer than I can admit to get it going ha; I had undefined calls. Appreciate the great project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.