FS#5607 - Speex codec interface (&library)

Attached to Project: Rockbox
Opened by Frederik (freqmod) - Tuesday, 27 June 2006, 17:26 GMT
Task Type Patches
Category Codecs
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


Tested on iPod video with gcc 3.4.3. (GCC 4.0.3 on iPod gives me the sound of silence).
Gcc 4.0.3 works with sound using the simulator on x86_64 (with the same target).
Logf gives some messages, and printf is used too (if SIMULATOR is defined).
Based on speex SVN from week 21.06.2006.
Uses arm4 assembly if ARM_CPU is defined.

Seeking and changing tracks work.
Seeks in the start backwards so you loose a bit of playback.
Vorbis metadata tags are parsed.

Includes a little workaround for a segmentation fault when using crossfade.

Decodes NB&WB speex files (up to 16kHz) realtime on iPod video.

Patch against rockbox CVS as of 25.06.2006.
This task depends upon

Closed by  Dan Everton (safetydan)
Friday, 09 February 2007, 10:22 GMT
Reason for closing:  Accepted
Additional comments about closing:  Checked in to SVN as revision 12241. Cheers.
Comment by Frederik (freqmod) - Tuesday, 27 June 2006, 19:48 GMT
Fix for skipping in the beginning of playback (caused by reallocation in libogg)

I have tried, and would very much like to see it ported to Tremor/framing, but the memory management code caused segmentation faults when libogg was working so I was not able to figure it out.

Pach must depends on speex.v003.patch
Comment by Frederik (freqmod) - Tuesday, 27 June 2006, 19:51 GMT
You'll have to remove all (2) printf's in apps/codecs/libogg/framing.c to make it compile on non simulated targets.
Comment by Paul Louden (darkkone) - Wednesday, 28 June 2006, 05:50 GMT
It's unlikely to get included (in my opinion) unless you resolve the GCC 4 things, since that's what we use for our iPod builds.
Is there any clue to what's causing it, or is it more an issue of GCC being crazy?
Comment by Jari Lammi (solarflare) - Monday, 10 July 2006, 20:34 GMT
Any change to get this patch available as an already compiled experimental build for the iPod mini 2nd gen? I have the gcc version 4.0.0 (Apple Computer, Inc. build 5026). It would be interesting to see how the Dual 80 MHz ARM 7TDMI processors inside perform with Speex if at all.
Comment by Frederik (freqmod) - Wednesday, 12 July 2006, 11:44 GMT
Removed (in a way) the silence for (stereo) using gcc 4 on ipod by editing apps/codecs/libspeex/math_approx.c:~106: change spx_sqrtf to be like:
float spx_sqrtf(float arg)
if(arg==1.0) return 1.0;
return spx_sqrt(arg); // <---------- this is the line to be added
#if 0
Comment by Dave Chapman (linuxstb) - Thursday, 20 July 2006, 08:40 GMT
This patch no longer applies to CVS (probably due to the SID codec being added). Would you be able to update it, preferably as a single patch against CVS?
Comment by Frederik (freqmod) - Friday, 21 July 2006, 16:43 GMT
New patch applies against current CVS (as of 2006.07.21 ~18.00 CET). Includes a better (but not very good) sterio square root function, please use mono speex files if possible. Seeking is not improved and it is somewhat flaky, especially in short (about 1 min) files.
Comment by Frederik (freqmod) - Friday, 21 July 2006, 18:10 GMT
Patch (to apply to to get better stereo sound
Comment by Frederik (freqmod) - Saturday, 22 July 2006, 16:43 GMT
Fixes speed (& incorperates sterio imporvement). Now speex files encoded with speexenc --vbr --agc --comp 9 --quality 5 (and source files 32kHz mono) decodes nearly realtime (with pich 90% on ipod), which means that they are listenable on a happy day :)

Patch is against speex.v004 patched sources
Comment by Frederik (freqmod) - Thursday, 03 August 2006, 11:31 GMT
v005: 32kHz UWB decodes 100% on ipod (gcc4) (with no peak meaters), skips if menues are used.
16kHz WB decodes realtime on ipod (gcc4) with boost half the time.
Crossfade works without workaround.
speex.c confirms to rockbox text format guidelines.

Patch against cvs 2006.8.3.
Comment by Frederik (freqmod) - Friday, 04 August 2006, 13:22 GMT
Not tested on big endian processors, use update be_int & le_int to use #if*def ROCKBOX_BIG_ENDIAN to have a chance.
Comment by Frederik (freqmod) - Wednesday, 30 August 2006, 19:52 GMT
Wont work with cvs due changes in id3.c and playback.c
Comment by Frederik (freqmod) - Monday, 25 September 2006, 18:06 GMT
Sync with Speex SVN & rockbox CVS, updated to compile without errors with gcc 4.0. (UWB, gets a little slower (just not realtime on iPod)).
Comment by Frederik (freqmod) - Monday, 25 September 2006, 18:40 GMT
in apps/codecs/libspeex/vq.c change:
#elif defined(SHORTCUTS) && (defined(ARM4_ASM) || defined(ARM5E_ASM))
#elif (defined(ARM4_ASM) || defined(ARM5E_ASM))
to make uwb work realtime
Comment by Frederik (freqmod) - Wednesday, 18 October 2006, 21:05 GMT
Fixed assembly and synced to cvs.
Comment by Frederik (freqmod) - Saturday, 28 October 2006, 23:42 GMT
should be better makefiles
Comment by Thom Johansen (preglow) - Monday, 30 October 2006, 17:40 GMT
This last patch is broken quite severely, could you please upload one that adds Speex support, not removes it? :)
Comment by Frederik (freqmod) - Tuesday, 07 November 2006, 09:04 GMT
I quite agree. I didn't see this before now, but now i am uploading a new synced (afaik working patch)
Comment by Adam (voltagex) - Tuesday, 16 January 2007, 07:04 GMT
Any chance of a new working version?
Comment by Frederik (freqmod) - Saturday, 27 January 2007, 18:54 GMT
This should work (tested on iPod, but it may be some faults in the diffing).
use 'patch -p0 < patch (unzipped)' to apply