Realtime MP3 encoder 48kHz Stereo

psychoacoustic
Posts: 2
Joined: Sun Feb 10, 2019 4:18 am

Realtime MP3 encoder 48kHz Stereo

Postby psychoacoustic » Sun Feb 10, 2019 6:42 am

I have ported and optimised an MP3 compliant encoder to ESP32, just wondering if anyone is interested in the project. If so I will clean up the code and post it here.

Current status:
Encodes @48000Hz 16bit Stereo using between 37-43% on one core depending on where you choose to place buffers and tables
Memory:
30312bytes MALLOC_CAP_8BIT for global state
21904bytes MALLOC_CAP_8BIT encoding struct
2 * 9216bytes tables can be in IRAM
2 * 2304bytes buffers also can be in IRAM
Total: 75256

Quality: (From the Youtube Free Audio Library https://www.youtube.com/audiolibrary/music)
Captured streaming over wifi in Chrome 48kHz Joint Stereo 256kbps using Audacity saved as FLAC:
All Hail the Queen.flac
http://pc.cd/twDctalK
Alone Time.flac
http://pc.cd/n6KrtalK
In the Distance.flac
http://pc.cd/Kzq7
Mover.flac
http://pc.cd/T30rtalK
On the Windy Road.flac
http://pc.cd/5t8
Parisian Funk.flac
http://pc.cd/U9F
Names included so you can compare these with the original in the Youtube library.

Moving things into IRAM pushes performance to the 43% end, otherwise its around 37%.
By using MP3 as a format, I can stream audio to ANY web browser. All that I've tried work fine, including phones and tablets.

ESP_Sprite
Posts: 2278
Joined: Thu Nov 26, 2015 4:08 am

Re: Realtime MP3 encoder 48kHz Stereo

Postby ESP_Sprite » Mon Feb 11, 2019 4:51 am

Nice! I think it would be very useful to have as an open-source component, if you're willing to make it one. Can I ask what library you ported?

psychoacoustic
Posts: 2
Joined: Sun Feb 10, 2019 4:18 am

Re: Realtime MP3 encoder 48kHz Stereo

Postby psychoacoustic » Wed Feb 13, 2019 3:04 am

Yes of course, the encoder is called shine mp3 encoder. I started with the fixed point implementation but am abandoning that in favour of single precision floating point after some research and synthetic testing on ESP32 show that asm optimisation should be much faster using the FPU. The FPU instructions madd.s and lsiu are of particular interest as the 32bit integer options are quite limited.

Does the ESP32 have one FPU per core as would seem to be the case? Also the release notes I've found suggest a 4 instruction pipeline and up to 2 FP instructions per clock? I'm assuming that without longer instruction words this is intended to handle madd.s and msub.s by performing them as two FP instructions.

Note that shine is fast because it does not perform psychoacoustic analysis and I therefore only recommend use for streaming, not for recording.

ESP_Sprite
Posts: 2278
Joined: Thu Nov 26, 2015 4:08 am

Re: Realtime MP3 encoder 48kHz Stereo

Postby ESP_Sprite » Wed Feb 13, 2019 3:26 am

The ESP32 has indeed one FPU per core. I think the FPU is pipelined through the main Xtensa pipeline, which iirc is 7-stage, but I'm not too sure about the details there.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 18 guests