path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2013-08-31Add cf asm inline for multiplication commonly used in silk.Nils Wallménius2-0/+54
Speeds up decoding a 16kbps test file by 4.9MHz on h300. Change-Id: I8c25431c98dfa9a1c3806a84055e0847eb77a9f1
2013-08-31Put two hot silk arrays on real stack (iram)Nils Wallménius2-6/+10
Speeds up decoding of 16kbps test file by 16.7MHz on H300. Change-Id: I39c90e3b423ae8e2ee5c2b88c5dcec8d48807f77
2013-08-31Silence spurious warningNils Wallménius1-1/+1
Change-Id: I856c722e959314c0a86e9c0a3a31cb824ddb41cc
2013-08-31Sync opus codec to upstream gitNils Wallménius115-4290/+4825
Sync opus codec to upstream commit 02fed471a4568852d6618e041c4f2af0d7730ee2 (August 30 2013) This brings in a lot of optimizations but also makes the diff between our codec and the upstream much smaller as most of our optimizations have been upstreamed or supeceded. Speedups across the board for CELT mode files: 64kbps 128kbps H300 9.82MHz 15.48MHz c200 4.86MHz 9.63MHz fuze v1 10.32MHz 15.92MHz For the silk mode test file (16kbps) arm targets get a speedup of about 2MHz while the H300 is 7.8MHz slower, likely because it's now using the pseudostack more rather than the real stack which is in iram. Patches to get around that are upcomming. Change-Id: Ifecf963e461c51ac42e09dac1e91bc4bc3b12fa3
2013-08-26lua: Switch memory allocator from dl to tlsfMarcin Bukat1-3/+11
Instead of providing yet another memory allocator implementation use tlsf and simply link tlsf library. Another small improvement is to *grow* memory pool by grabbing audiobuffer instead of just switching to use audiobuf exclusively. Tested with simple lua 'memory eater' script. This patch extends tlsf lib slightly. You can provide void *get_new_area(size_t * size) function which will override weak dummy implementation provided in lib itself. This allows to automaticaly initialize memory pool as well as grow memory pool if needed (for example grab audiobuffer when pluginbuffer is exhaused). Change-Id: I841af6b6b5bbbf546c14cbf139a7723fbb982f1b
2013-08-23Change CODECFLAGS to a "simply-expanded" var to give the individualNils Wallménius3-16/+18
codec makefiles larger freedom in what they can do to it. Use this in libopus to prepend the libopus searchpaths to CODECFLAGS so that its internal config.h will be picked up before our global one. This avoids having to do a s/config.h/opus_config.h/ when syncing which will be handy soon. Change-Id: I018d729aa0c8300fa3149f22a5a8c5668b339dfa Reviewed-on: Reviewed-by: Nils Wallménius <>
2013-08-16Fix FS#12889 : Audible pop right after setting Repeat/ShuffleMichael Sevakis1-0/+3
The quickscreen calls settings_apply() and the crossfeed code wasn't checking that the right crossfeed was set before updating the filter for the custom setting, which was overwriting the Meier crossfeed data (custom and Meier share the same data space). Change-Id: Ifaa2f46fe062d4497681a2dd0d5068ec906c96a3
2013-07-11mp3_enc: Fix early snafu with stream finish on COPMichael Sevakis1-23/+14
Distractions make logic fail. It only needs one more loop and should not trigger further compression cycles after not feeding more data. Change-Id: Ie0dbb34af92e0ca5718480dd4ab4719a141717ff
2013-07-09Multithread compressing encoders on multicore targets.Michael Sevakis2-1806/+2302
For mp3_enc, split encoding duties between COP and CPU. For wavpack_enc, simply run the encoding on COP (splitting that one needs more consideration) which keeps the it and the UI from running on the same core. As a result, at least they are now useable on PP at "normal" sample rates. mp3_enc in all this gets an extensive renovation and some optimizations for speed, to reduce IRAM requirements and remove unneeded stuff. Change-Id: I215578dbe36f14e516b05a5ca70880eb01ca0ec2
2013-07-06Enable setting of global output samplerate on certain targets.Michael Sevakis17-196/+377
Replaces the NATIVE_FREQUENCY constant with a configurable frequency. The user may select 48000Hz if the hardware supports it. The default is still 44100Hz and the minimum is 44100Hz. The setting is located in the playback settings, under "Frequency". "Frequency" was duplicated in english.lang for now to avoid having to fix every .lang file for the moment and throwing everything out of sync because of the new play_frequency feature in features.txt. The next cleanup should combine it with the one included for recording and generalize the ID label. If the hardware doesn't support 48000Hz, no setting will be available. On particular hardware where very high rates are practical and desireable, the upper bound can be extended by patching. The PCM mixer can be configured to play at the full hardware frequency range. The DSP core can configure to the hardware minimum up to the maximum playback setting (some buffers must be reserved according to the maximum rate). If only 44100Hz is supported or possible on a given target for playback, using the DSP and mixer at other samperates is possible if the hardware offers them. Change-Id: I6023cf0c0baa8bc6292b6919b4dd3618a6a25622 Reviewed-on: Reviewed-by: Michael Sevakis <> Tested-by: Michael Sevakis <>
2013-06-30Update software recording engine to latest codec interface.Michael Sevakis5-1224/+862
Basically, just give it a good rewrite. Software codec recording can be implemented in a more straightforward and simple manner and made more robust through the better codec control now available. Encoded audio buffer uses a packed format instead of fixed-size chunks and uses smaller data headers leading to more efficient usage. The greatest benefit is with a VBR format like wavpack which needs to request a maximum size but only actually ends up committing part of that request. No guard buffers are used for either PCM or encoded audio. PCM is read into the codec's provided buffer and mono conversion done at that time in the core if required. Any highly-specialized sample conversion is still done within the codec itself, such as 32-bit (wavpack) or interleaved mono (mp3). There is no longer a separate filename array. All metadata goes onto the main encoded audio buffer, eliminating any predermined file limit on the buffer as well as not wasting the space for unused path queue slots. The core and codec interface is less awkward and a bit more sensible. Some less useful interface features were removed. Threads are kept on narrow code paths ie. the audio thread never calls encoding functions and the codec thread never calls file functions as before. Codecs no longer call file functions directly. Writes are buffered in the core and data written to storage in larger chunks to speed up flushing of data. In fact, codecs are no longer aware of the stream being a file at all and have no access to the fd. SPDIF frequency detection no longer requires a restart of recording or plugging the source before entering the screen. It will poll for changes and update when stopped or prerecording (which does discard now-invalid prerecorded data). I've seen to it that writing a proper header on full disk works when the format makes it reasonably practical to do so. Other cases may have incorrect data sizes but sample info will be in tact. File left that way may play anyway. mp3_enc.codec acquires the ability to write 'Info' headers with LAME tags to make it gapless (bonus). Change-Id: I670685166d5eb32ef58ef317f50b8af766ceb653 Reviewed-on: Reviewed-by: Michael Sevakis <> Tested-by: Michael Sevakis <>
2013-06-30Fix some whitespace in files changed in following commit.Michael Sevakis4-37/+37
Change-Id: Ie3f43e43076e0dcae9a10f1b0b9e4698b398acee Reviewed-on: Reviewed-by: Michael Sevakis <> Tested-by: Michael Sevakis <>
2013-06-21Remove old EQ presets.Michael Giacomelli28-436/+0
The old presets never made sense for Rockbox's EQ. They were apparently copied from some other software. We have a parametric EQ, that means that EQ bands can be made wider or narrower. Putting two identical bands side by side just wastes battery life and adds rounding error. Replacement presets are on gerrit but they need more work. In the mean time, users should probably not be using these. Change-Id: I85213100129fafd3ac0fa1a9438cb4d651bb94cb
2013-06-16Silence some (harmless) warnings.Frank Gevaerts1-1/+0
Change-Id: I8d1278b8cfaa376d2ad5a99dd552dc980c66e1da
2013-06-15Fix id3v2 album art if more than one image is present.Dominik Riebeling1-1/+8
Rockbox only uses the first album art image (APIC / PIC frame) found in id3v2 tags. When a file contains more than one image the second one is ignored but the parsealbumart() callback overwrites the already set data. This causes the metadata structure to contain an invalid pointer to the image data, resulting in no image shown. Make parsealbumart() aware of this and skip parsing when an albumart image has already been found. Fixes FS#12870. Change-Id: Id8164f319cd5e1ee868b581f8f4ad3ea69c17f77
2013-05-27Missed removing a couple unwanted includes in previous commit.Michael Sevakis3-3/+7
Get those too. Change-Id: Id2a39afe7a61d6ec0cea38633b94fe1b7122204f
2013-05-27Remove explicit config.h and system.h includes from DSP code.Michael Sevakis16-31/+34
Replace with rbcodecconfig.h and platform.h includes. Remove now- unneeded ones as well. Change-Id: I6111b71e90bf86d9fe272a7916f2d34a5c6dd724
2013-05-26SPC Codec ARMv5: I didn't have fast gauss quite right.Michael Sevakis1-5/+5
Fix wrapping hazard which did eventually manifest on the right file. Change-Id: I996a6efd3181b56fd172b5c3a526c7434f88bbbe
2013-05-23Fix return address when data_abort_handler skips faulting instruction.Boris Gjenero1-1/+1
When writing a value to PC, execution continues at that location, so subtracting 4 returns to the next instruction. Previously, two instructions after the faulting instruction were being skipped, causing safe_read functions to return true even if a data abort happened. Change-Id: I3fd02d54646323ea2050d0504e38f6d22f09c749
2013-05-23Remove dsp_callback because DSP is now library code, not app code.Michael Sevakis3-56/+9
Yep, nope, not necessary anymore. Just call functions directly. Change-Id: I21dc35f8d674c2a9c8379b7cebd5613c1f05b5eb
2013-05-23SPC Codec: Add ARMv5 optimized code. Easy peasy.Michael Sevakis4-1/+291
Why? Why not? Cuts a few MHz. Change-Id: Ied5c70b1aedd255cbe5d42b7d3028bbe47aad01d
2013-05-21SPC Codec: Simplify configuration and assume nothing need be disabled.Michael Sevakis1-33/+21
Most SoCs are these days are fast enough for realtime BRR, gaussian interpolation and echo processing. Change-Id: I180ce8ad45242c67b5e573a406b9522098a3f12b
2013-05-21SPC Codec: Have metadata parser fill in frequency and bitrate.Michael Sevakis1-0/+2
Change-Id: I6c72f4d1c79b1a99a11fb28e7d46886c08a56a75
2013-05-21SPC Codec: Need to restore a bit more data from cached waves.Michael Sevakis2-59/+53
'Nuff said. Last update wasn't quite right. Change-Id: I082a79c4e0c82b968fe2375cb82ee5c3a64a208b
2013-05-21Opus: fix glitch caused by 2e9aa3dNils Wallménius1-6/+6
Change-Id: I1519f3bf2cdf74f3d4741951973352b2678b7722
2013-05-21Fix FS#9577 - SNES player missing tracks on certain SPCsMichael Sevakis2-44/+85
Affected BRR cached waveforms but not realtime BRR decode as far as I could ascertain. BRR cached waves required loop points to be inside the initial waveform but this change removes that restriction. Change-Id: I0ef4db720e5c28bd7b2fb9ae255d27c0a7213f79
2013-05-21Fix 87021f7 errors. There is no this->echo_pos when SPC_NOECHO != 0.Michael Sevakis1-1/+1
Anyway, that's true now. Change-Id: I247ea9a10543a8b65f3e73495f0e2ea725ec533e
2013-05-21SPC Codec: Refactor for CPU and clean up some things.Michael Sevakis12-1295/+1690
CPU optimization gets its own files in which to fill-in optimizable routines. Some pointless #if 0's for profiling need removal. Those macros are empty if not profiling. Force some functions that are undesirable to be force-inlined by the compiler to be not inlined. Change-Id: Ia7b7e45380d7efb20c9b1a4d52e05db3ef6bbaab
2013-05-19Opus: fix seeking to start of trackNils Wallménius1-2/+3
Change-Id: I8a8604d6726304d04281671b475b2f75f9bfc0e5
2013-05-19Opus: avoid allocating space for comment packetsNils Wallménius1-0/+6
Fixes playback of files with large embedded album art. Change-Id: I94d336e3da968a93047dd00a5fa65e4c3423a7da
2013-05-18Fix opus craches with large embedded album artNils Wallménius4-44/+42
Use the tlsf malloc and friends instead of the silly codec_malloc to get actually working free and saner realloc that doesn't leak memory. Makes files with moderately sized embedded AA play on targets with large enough codec buffers and files with too large AA are now skipped rather than crashing. Fixes crash when playing example file in FS#12842. Change-Id: I06562955c4d9a95bd90f55738214fba462092b71
2013-05-16Introduce new hermite polynomial resampler.Michael Sevakis3-260/+543
Uses the Catmull-Rom case of Hermite cubic splines. Vastly improves the quality and accuracy of audio resampling with a rather minor additional overhead compared to the previous linear implementation. ARM and Coldfire assembly implementations included. Change-Id: Ic45d84bc66c5b312ef373198297a952167a4be26 Reviewed-on: Reviewed-by: Michael Sevakis <> Tested-by: Michael Sevakis <>
2013-05-07Rename all the "lin_resample..." stuff to simply "resample_...".Michael Sevakis4-45/+42
Change-Id: I79f44f0dcc1b23b33a5040795220713660a1d18a
2013-05-05Purge the usage of DSP_SWITCH_FREQUENCY.Michael Sevakis26-27/+26
DSP_SWITCH_FREQUENCY has been deprecated and the same enumerated value as DSP_SET_FREQUENCY since major DSP revisions were committed. This task should have been performed much earlier but, oh well, do it now. Change-Id: I3f30d651b894136a07c7e17f78fc16a7d98631ff
2013-05-04Revert "Don't set CORE_GCSECTIONS in fixedpoint.make."Dominik Riebeling1-0/+1
While it made the mini2g not crash during startup anymore further tests showed that other mini2g devices still exhibit the crash, or end up with a "No partition found" error; furthermore the device tested first still crashes on USB disconnect. Therefore the change doesn't really help with the problem, and at the expense of increasing binary size for all other targets there is no point in keeping it for now. This reverts commit 850491a043a9341ef31ffb8c02eedd2ae7b2c53e.
2013-05-04Fix missed optimization opportunity in dsp_process.Michael Sevakis1-3/+3
Input type can only change once per call because the DSP parameters are only copied at the start and input is always taken from the src buffer which means sample input format switching can be once per call instead of once per loop. Change-Id: Ifa3521753428fb0e6997e4934f24a3b915628cc7
2013-05-04Cleanup and simplify latest DSP code incarnation.Michael Sevakis15-540/+513
Some things can just be a bit simpler in handling the list of stages and some things, especially format change handling, can be simplified for each stage implementation. Format changes are sent through the configure() callback. Hide some internal details and variables from processing stages and let the core deal with it. Do some miscellaneous cleanup and keep things a bit better factored. Change-Id: I19dd8ce1d0b792ba914d426013088a49a52ecb7e
2013-04-28Don't set CORE_GCSECTIONS in fixedpoint.make.Dominik Riebeling1-1/+0
fixedpoint.make is not a subdir Makefile but a lib Makefile. Setting CORE_GCSECTIONS in it will affect the final link and make it always use --gc-sections (for SWCODEC Rockbox), since libfixedpoint is always needed (bootloader and HWCODEC don't use libfixedpoint). Fixes FS#12857. Change-Id: Ib30bd03cbcea9c339a73daf7b673868aa3cc7a88
2013-04-26Properly seek to next id3v2 frame for unsynced tags.Dominik Riebeling1-3/+10
When seeking to the next id3v2 frame we need to consider if the tag has the unsync flag set. Not doing so will likely make parsing end up in the middle of the current frame if the frame size exceeds the upper limit set during read. The latter usually happens for album art frames. Fixes FS#12849. Change-Id: Ic92853eef4374508d84df347bcc66b6661d5037d
2013-04-25Properly implement volume in warble. dB cut only.Michael Sevakis2-9/+36
Change-Id: I34b77287ba0b1a0002db3d52e893a52c50593362
2013-04-25Add $(SHARED_CFLAGS) to fixedpoint.make to quash amd64 errors in 95e23de.Michael Sevakis1-1/+1
Thanks to Frank Gevaerts. Change-Id: I6ca1d0258bfc70950d0ad5c2975d2bd88060b8a3
2013-04-26Make fixepoint.c as a shared library (libfixedpoint.a).Michael Sevakis10-32/+623
Change-Id: Icc10d6e85f890c432f191233a4d64e09f00be43d Reviewed-on: Reviewed-by: Michael Sevakis <> Tested-by: Michael Sevakis <>
2013-04-15Straighten out the mad twisted state of sound.c and related areas.Michael Sevakis3-44/+57
This is going right in since it's long overdue. If anything is goofed, drop me a line or just tweak it yourself if you know what's wrong. :-) Make HW/SW codec interface more uniform when emulating HW functionality on SWCODEC for functions such as "audiohw_set_pitch". The firmware-to- DSP plumbing is in firmware/drivers/audiohw-swcodec.c. "sound_XXX" APIs are all in sound.c with none in DSP code any longer. Reduce number of settings definitions needed by each codec by providing defaults for common ones like balance, channels and SW tone controls. Remove need for separate SIM code and tables and add virtual codec header for hosted targets. Change-Id: I3f23702bca054fc9bda40f49824ce681bb7f777b
2013-04-11Implement universal in-PCM-driver software volume control.Michael Sevakis2-21/+0
Implements double-buffered volume, balance and prescaling control in the main PCM driver when HAVE_SW_VOLUME_CONTROL is defined ensuring that all PCM is volume controlled and level changes are low in latency. Supports -73 to +6 dB using a 15-bit factor so that no large-integer math is needed. Low-level hardware drivers do not have to implement it themselves but parameters can be changed (currently defined in pcm-internal.h) to work best with a particular SoC or to provide different volume ranges. Volume and prescale calls should be made in the codec driver. It should appear as a normal hardware interface. PCM volume calls expect .1 dB units. Change-Id: Idf6316a64ef4fb8abcede10707e1e6c6d01d57db Reviewed-on: Reviewed-by: Michael Sevakis <> Tested-by: Michael Sevakis <>
2013-04-10Move fixedpoint.h to be accessible in /firmware.Michael Sevakis1-26/+3
Will need it soon enough. Combine the contents of all the various fixedpoint.h files. Not moving fixedpoint.c for now since I'm not sure where it should be and it causes some dependency issues. Change-Id: Ideacbca2ca78f9158c2b114b113c274f68e908d5
2013-03-06VGM Codec: Improve time and fade behavior. Tweak minor misc.Michael Sevakis2-20/+40
Prevents cutoff of tracks, especially short ones: * Extend looped tracks by fade length to fade at start of loop repeat. * No fade occurs for non-repeating track only having an intro. * Uses id3.tail_trim field to store fade duration. Use libGME built-in elapsed time reporting instead of custom calculation: * libGME already reports in milliseconds. * Don't advance time counter when Repeat == One. It just runs the progress over the length limit. Fix a comment about sample rate and set the reported bitrate to be accurate for 44.1 kHz stereo. Change-Id: I3ede22bda0f9a941a3fef751f4d678eb0027344c
2013-02-27more error handling for checkwpsJonathan Gordon1-0/+10
Change-Id: I03055d045c0a8e0e63e17b290cc71c54a8dc3634
2013-02-26checkwps: show a helpful error if the parser callback errors outJonathan Gordon3-1/+11
Change-Id: Ie3e35292ba8d74f0ff3d1bb3483a5e83aae0e6b6
2013-02-23Build libtlsf for all systemsFrank Gevaerts1-2/+0
libtlsf used not to be built for HWCODEC, but now that the gif viewer uses libtlsf instead of building its own copy, libtlsf is needed everywhere. Change-Id: I730719c6a20e749adb8597056d2049b7758620e4
2013-02-18Fix FSB#12826 - Mini-sound burp between track skips [with WMA].Michael Sevakis1-18/+22
Flush decoder state and frame out buffer upon a forced stop to prevent a short burst of stale audio from the previously decoding track from playing when skipping from one WMA track to another. Change-Id: I24c910c5dbd83caed2510db68d9e39a474332a79 Reviewed-on: Reviewed-by: Michael Sevakis <> Tested-by: Michael Sevakis <>