view · edit · print · history

Encoding MP3's on the slug


For quite a while I wanted to encode .mp3 files on my slug. However as the slug does not have floating point hardware and virtually all encoders use this, this takes ages. At one point I tried 'lame' and it told me it needed about 3 hrs for one track. Not really what I had in mind.

For decoding there are some integer decoders (e.g. madplay). However integer encoders are very rare. I found one for Amiga, but this one was a rough one with not a very good quality. Therefore I was happy to notice that the new Intel Integrated Performance Primitives 5.0. (IPP 5.0).

IPP has several sample codecs (aac_dec_int, aac_enc_int, dv, h261_dec, h261_enc, h263_dec, h263_enc, h264_dec, h264_enc, jpeg, mp3_dec_int, mp3_enc_int mpeg2_dec, mpeg2_enc, mpeg2_spl, mpeg4_dec, mpeg4_enc, mpeg4_spl), a supporting streaming architecture (umc), some supporting modules and some demonstrator applications (audio_codec_con, sample_player, video_enc_con)

My interest and experiments only focused on the mp3 decoding and encoding codecs and the associated audio_codec_con sample application. All other software compiles fine with me, but has not really been tested (and I think things like h264 encoding is not really a task you want to do on a slug as it will take ages).

Constraints/Starting point

In order to get this software you'll need to have a cross environment set up on your PC. I am running openslug on my NSLU2 and my PC runs Fedora Core 3. I have already built sources before so on my PC is a full development tree. When you start you should also get such a tree. Mine is set up using MasterMakefile, but you can also get there from BuildingTheTarball.

If you haven't cross-compiled things first you probably want to try a few simpler things first.

If you want to rip audio from CD you also need other tools for that and you'll need to have the necessary modules on your system (cdrom.ko, sr_mod.ko, sg.ko).

Note that I haven't tried to make a .bb file for this. First of all there are some manual steps involved anyway. Also I do not really have enough knowledge to do that, and finally I am rather short on time. Feel free to add a .bb file yourself.

Getting the software

In order to get access to the software you'll need to execute a license agreement. This can be found at https://registrationcenter.intel.com/EvalCenter/EvalForm.aspx?ProductID=493. They will mail you a message with a license key. Attached to that message is also a copy of the license file. You'll need that one!

After registering (or even before) you can download the IPP library at http://www.intel.com/software/products/ipp/downloads/ipplin.htm. You need to get the very last file: Intel® Integrated Performance Primitives 5.0 for Linux* on the IXP4XX product line. I got version 5.0.043 from here.

Note that downloading alone is not enough. You still need to obtain a license file as mentioned before.

The last part to get are the samples. These can be found at http://www.intel.com/cd/software/products/asmo-na/eng/238686.htm. As I was interested in mp3, I went to Media Encoding and then selected Download Linux Samples. This brought me to http://www.intel.com/cd/software/products/asmo-na/eng/220044.htm where you need to accept an EULA before you can download the stuff. If you are interested in the other samples (e.g. for jpeg or speech coding) the former of these web pages will also provide you with the necessary links.

Installing the sources

After uncompressing/untarring the ipp download you'll get a directory l_ipp_ixp_p_5.0.043 (the number at the end will be different if you got a newer version).

In this directory there is an install.sh, but for me this did not work. It only gave the possibilitiy to show a few txt files. Instead I moved to the install directory and ran the program @@install@2. I used option 1 (install using the root password) and used the standard directory (/opt/intel/...). You need to install for ixp.
Apparently install.sh would have asked us for our license string. However, since we skipped this step, we need to install the key manually. Fortunately this is not a big deal. Just put the lic file that was attached to your registration confirmation email in /opt/intel/licenses/

The other thing needed is to install the sample sources. Mine came in l_ipp-sample-media_p_5.0.017.tar.gz You can unpack these at a place you see fit. It will give you a directory ipp_sample. Below it are the sample sources.

Creating the environment

The last thing is to get our compiler in place. There are no settings for our cross compiler (armeb-linux-gcc and friends). Instead the cross compiler is called xscale_be-gcc. Also the build scripts check for the directory where the compiler was installed.

There are two ways to fix this. One way is to patch all build scripts in the ipp_sample directory to change compiler name and directory. This is something you probably want to do when creating a .bb file.
I didn't do that and took the lazy way out. I just created links to my executables in the montavista directory. I started to create /opt/montavista/pro/devkit/arm/xscale_be/bin/

Next I moved to the directory with my compiler binaries (for me @.../openslug/tmp/cross/bin@@ and executed the following script:

ln armeb-linux-addr2line /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-addr2line
ln armeb-linux-ar /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-ar
ln armeb-linux-as /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-as
ln armeb-linux-c++ /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-c++
ln armeb-linux-c++filt /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-c++filt
ln armeb-linux-cpp /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-cpp
ln armeb-linux-depmod /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-depmod
ln armeb-linux-g++ /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-g++
ln armeb-linux-g77 /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-g77
ln armeb-linux-gcc /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-gcc
ln armeb-linux-gcc-3.4.4 /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-gcc-3.4.4
ln armeb-linux-generate-modprobe.conf /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-generate-modprobe.conf
ln armeb-linux-insmod /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-insmod
ln armeb-linux-insmod.static /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-insmod.static
ln armeb-linux-ld /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-ld
ln armeb-linux-lsmod /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-lsmod
ln armeb-linux-modinfo /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-modinfo
ln armeb-linux-modprobe /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-modprobe
ln armeb-linux-nm /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-nm
ln armeb-linux-objcopy /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-objcopy
ln armeb-linux-objdump /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-objdump
ln armeb-linux-ranlib /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-ranlib
ln armeb-linux-readelf /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-readelf
ln armeb-linux-rmmod /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-rmmod
ln armeb-linux-size /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-size
ln armeb-linux-strings /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-strings
ln armeb-linux-strip /opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-strip

Note that for me the compiler and /opt were on the same filesystem. Perhaps you are better off with ln -s.

For the remainder of this HowTo the opt directory does not need to be touched.

Patching the software

When compiling for the first time I got an error in ipp_sample/media/core/vm/src/vm_sys_info_linux32.c. Apparently PATH_MAX was not defined. Instead of adding the proper include, I just did a crude patch by adding #define PATH_MAX 4096 to the beginning of this file. Feel free to do a better patch and update this text.

Compiling and linking

It's getting easier and easier. For this you only need to go to ipp_sample/media and run the script buildxscale_be.sh. This will compile all sources, create libraries and applications. You will get some lines on the screen showing your progress. All lines should mention PASSED.

Testing your work

The output of the build process is in ipp_sample/media/_bin/linuxxscale_be_gcc. You'll find: audio_codec_con lib libaac_dec_i.so libaac_enc_i.so libmp3_dec_i.so libmp3_enc_i.so obj simple_player video_enc_con Of this the lib and obj subdirectories are not needed. I also did not bother with simple_player and video_enc_con. The four .so files and audio_codec_con can be copied to the slug. Also make sure that you copy a test mp3 file to the same directory. I assume this file will be called tst.mp3.

Now on the slug you can issue the command:
date; LD_LIBRARY_PATH=. ./audio_codec_con -ct mp3_dec_i tst.mp3 tst.wav;date.
I have added the date commands to do some timing. For me (with an mp3 file that lasts 2m20s decoding takes about 1 minute (on a de-underclocked slug).

Encoding a wav file can be done by:
date; LD_LIBRARY_PATH=. ./audio_codec_con -ct mp3_enc_i tst.wav tst2.mp3;date.
Here my 266 Mhz slug used about 7 minutes to re-create the mp3 file.

Closing remarks

Some last remarks that did not fit anywhere.

  • Of course you can store your .so files on any other place (e.g. /usr/local/lib) where they will be found automatically (so you can omit the LD_LIBRARY_PATH from the command above).
  • When ripping CDs? cdparanoia can be used. I have cdparanoia-III-alpha9.8 on my slug (compiled natively). When you do this be sure to use the -w option when ripping. Otherwise I guess it will create a PCM file without a wav header. audio_codec_con cannot process headerless files. -w adds the needed wav header.
  • And finally: I hope this is useful to you. If you have corrections/improvements/whatever feel free to apply them in the wiki. Should you want to get in touch with me: This page is created by eFfeM. You can find me in irc every once in a while and you can also find my email address on the mailing lists.


Alternative way for Openslug 2.7

Get the 2 files like described above. Uncompress l_ipp_ixp_p_5.0.XXX.tgz and run install.sh. Choose "1" (not "1a", "1b", "1c"...). Follow the instructions on the screen. On rpm-based system that will create a dev-tree under /opt/intel. (On debian it fails, leaving 2 rpm-files in the tmp-directory. Uncompress these). Now copy the whole dev-tree from /opt/intel onto the slug under /opt/intel.

Install the package "openslug-native" onto the slug. That will get you a native gcc. For openslug 3.10 you need to install slugos-native.

Create the directory /opt/hardhat/devkit/arm/xscale_be/bin. Inside create these links: xscale_be-addr2line -> /usr/bin/addr2line xscale_be-ar -> /usr/bin/ar xscale_be-as -> /usr/bin/as xscale_be-c++ -> /usr/bin/c++ xscale_be-c++filt -> /usr/bin/c++filt xscale_be-cpp -> /usr/bin/cpp xscale_be-depmod -> /sbin/depmod xscale_be-g++ -> /usr/bin/g++ xscale_be-gcc -> /usr/bin/gcc xscale_be-ld -> /usr/bin/ld

(You don't need them all, but i cannot remember which ones are important...)

Uncompress l_ipp-sample-media_p_5.0.XXX.tgz on the slug. Goto ipp_sample/media and run buildxscale_be.sh. Get a good book, it takes some time. The important lines start with *******, forget the "[: ==: binary operator expected"-messages. And the endresult hides under _bin.


Performance update for Debian armel

Using the Debian armel build (lenny) with substantially improved floating point performance, encoding of 128kbps mp3 files using lame and high quality (lame -b 128 -h), encoding performance is typically between 10% and 11% of realtime, so a 4 minute track takes around 38 minutes to encode.

view · edit · print · history · Last edited by 42jon.
Based on work by 42jon, eFfeM, repvik, and pumpkin0.
Originally by eFfeM.
Page last modified on August 28, 2008, at 08:06 AM