Commit graph

628 commits

Author SHA1 Message Date
Solomon Peachy
caaea275eb libspc: Temporarily disable problematic armv4 asm optimization
asm volatile (
    "mov    %[t0], %[out], asr #11  \n"
    "mul    %[out], %[t0], %[envx]  \n"
    : [out]"+r"(output), [t0]"=&r"(t0)
    : [envx]"r"((int) voice->envx));

This is resulting in "Rd and Rm should be different in mul" error,
because the compiler is putting [out] and [t0] into the same
register.

After some poking there doesn't appear to be a sane way to change
the constraints, so just disable it for now.

Change-Id: I7827713c8aadb27f0bf4a6f4a3e1d910c6193686
2025-09-21 15:39:35 -04:00
James D. Smith
d86240cf91 APEv2: AA: Fix a couple of bugs.
Change-Id: I1345d53f904d9c529dd6e2a7875dab97ffc9c2f3
2025-09-16 20:29:32 -04:00
Solomon Peachy
a2c10f6189 unicode: Support characters beyond the first unicode plane
We used 16-bit variables to store the 'character code' everywhere but
this won't let us represent anything beyond U+FFFF.

This patch changes those variables to a custom type that can be 32 or 16
bits depending on the build, and adjusts numerous internal APIs and
datastructures to match.  This includes:

 * utf8decode() and friends
 * font manipulation, caching, rendering, and generation
 * on-screen keyboard
 * FAT filesystem (parsing and generating utf16 LFNs)
 * WIN32 simulator platform code

Note that this patch doesn't _enable_ >16bit unicode support; a followup
patch will turn that on for appropriate targets.

Appears to work on:

  * hosted linux, native, linux simulator in both 16/32-bit modes.

Needs testing on:

  * windows and macos simulator (16bit+32bit)

Change-Id: Iba111b27d2433019b6bff937cf1ebd2c4353a0e8
2025-09-12 09:24:30 -04:00
Solomon Peachy
471624a75d DSP: put filter_process() into IRAM on all PP50xx CPUs
(Instead of just the slowest 500x family)

Change-Id: I39229d8765ff8c07da115e71909a60546597f603
2025-09-10 08:21:23 -04:00
Solomon Peachy
01a62372ff flac: Fix build on Cowon D2.
Not enough IRAM on this target to support larger MAX_BLOCKSIZE even with
only 2ch.

Change-Id: I91675b9eb294f8af3f7d17aa9c76c7cb83ce0bd7
2025-09-09 08:09:45 -04:00
Solomon Peachy
a98a8ce131 FLAC: Conditionally increase MAX_BLOCKSIZE to 8KB
High-frequency files increasingly use a block size of over 4608B, which
means we need larger buffers to decode them.  However, larger buffers no
longer fit in IRAM on less-capable devices, hurting performance for
"normal" file playback.

On our slowest devices (M68K and PP-based devices), this is not worth
the tradeoff as they will likely not have enough CPU oomph to decode and
downmix these files in realtime.

S5L87xx-based devices have the raw performance to do this, so we decided
to err on the side of wider file compatibility at the cost of some
performance.

All other devices are unaffected.

Change-Id: I7344cf4c8c6b7b5c14f1ea67381160665d6ece5b
2025-09-08 22:51:46 -04:00
Solomon Peachy
e4e50e36f1 rbcodec: Force use of -O2 for dsp code
We already use targeted optimization for most codecs, and the
DSP code is just as performance-sensitive.

Improves mp3 decoding performance by a whopping 1% wwhen PBE is
turned on.

Change-Id: I801a6624c0f7068b6cd67961ad3b08f809b92fca
2025-09-06 08:44:32 -04:00
Solomon Peachy
695698b918 SID: Don't uselessly upconvert from 16bpp mono to 28bpp stereo
cRSID natively renders its output as a 16bit mono stream.  There's no
reason to not use it as-is, and save a bunch of CPU cycles in the
process.

Change-Id: Ib934c05e77298e377053b29db91d1f05fb65eb76
2025-09-02 20:19:22 -04:00
Solomon Peachy
84504c7471 Revert "internals: Support characters beyond the first unicode plane (WIP)"
This reverts commit d05c59f35b.
2025-08-20 16:09:49 -04:00
Solomon Peachy
d05c59f35b internals: Support characters beyond the first unicode plane (WIP)
We used 16-bit variables to store the 'character code' everywhere but
this won't let us represent anything beyond U+FFFF.

This patch changes those variables to a custom type that can be 32 or 16
bits depending on the build, and adjusts numerous internal APIs and
datastructures to match.  This includes:

 * utf8decode() and friends
 * on-screen keyboard
 * font manipulation, caching, rendering, and generation
 * VFAT code parses and generates utf16 dirents
 * WIN32 simulator reads and writes utf16 filenames

Note that this patch doesn't _enable_ >16bit unicode support; a followup
patch will turn that on for appropriate targets.

Known bugs:

  * Native players in 32-bit unicode mode generate mangled filename
    entries if they include UTF16 surrogate codepoints.  Root cause
    is unclear, and may reside in core dircache code.

Needs testing on:

 * windows simulator (16bit+32bit)

Change-Id: I193a00fe2a11a4181ddc82df2d71be52bf00b6e6
2025-08-20 16:08:43 -04:00
Solomon Peachy
a12d8e2171 fix yellow in c53e9ba27d
Change-Id: I46f222918d95373e389b16f50d7b0ac112de0f73
2025-06-27 10:08:28 -04:00
Roman Artiukhin
c53e9ba27d metadata: mp4: Fill disc/track count
Show Track Info now shows Discnum/Tracknum as "i/n" (e.g., "1/3" for disc 1 of 3). Previously, it only showed the disc/track number without the total count.

Change-Id: If6b2a73ad0fecc27aaee371f8c860031eacca796
2025-06-27 13:03:57 +03:00
Solomon Peachy
57f3f290c9 warble: Fix build in light of ci.strip_filesize
Change-Id: I8fb7b04c71f588258496cf353fb01df3b38da227
2025-05-26 11:51:26 -04:00
Roman Artiukhin
38105860dc Codecs: mp3: Move strip tags to codec
Another fix for FS#13626 (replacement for 2bd88936f7)

Change-Id: Ife5f65539457559fd908d0048d4df94649b0b894
2025-05-26 10:59:56 -04:00
Roman Artiukhin
78903e9d38 Reapply "buffering: remove bufgettail/bufcuttail"
This reverts commit 2bd88936f7. Strip tags functionlity will be moved to codec.

Change-Id: Iff28ff7a29da09632ceed30a7959cc1ee8bf3cc8
2025-05-26 10:59:56 -04:00
Roman Artiukhin
9e95b337cc Codecs: mp3: Skip attempts to recover from buffer errors when the stream has ended
Change-Id: I81a636b48ea1e55de1dc8911a20d84f0f73c43ad
2025-05-23 11:35:47 -04:00
Solomon Peachy
2bd88936f7 Revert "buffering: remove bufgettail/bufcuttail"
This reverts commit 9e93796407.

Fixes FS#13626, which is caused by non-audio ID3v1/APE tags at
the end of the audio data stream.

Change-Id: Ic69af14a5d1264b7896a54b5f2ad314022dd98ac
2025-05-20 07:51:48 -04:00
Solomon Peachy
5b1158e64a misc: Properly annotate some intentional case fallthroughs
Change-Id: Ie758f17fefac72aca1aa28a8ba1126b9334fe134
2025-04-22 20:54:37 -04:00
Solomon Peachy
4096669eb5 dsp: Partial revert of previous commit, just disable warning
The "fix" produces different asm and I don't have the bandwidth
to determine if it's functionally equivalent.

Change-Id: I822557d1244f8e8a05e7ebfc45da2643152345a4
2025-04-22 10:23:14 -04:00
Solomon Peachy
865de6b907 dsp: Another warning fix in the compressor.
Change-Id: Ie4266d4d71d7b8f2faae9c5f4924e0d07ceae4e6
2025-04-22 10:09:53 -04:00
Solomon Peachy
303f262acb dsp: Silence a warning in the compressor code
/* offset = -3db * (ratio - 1) / ratio */
    db_curve[2].offset = (int32_t)((long long)(-3 << 16)
        * (ratio - 1) / ratio);

Results in a warning: left shift of negative value [-Wshift-negative-value]

To fix this, replace the '-3' with -3UL.

(As that is effectively what is already happening)

Change-Id: I5aa269ff332703d3c2d889fa032d2fdc403ff14f
2025-04-22 09:45:24 -04:00
Solomon Peachy
8f3b8390d1 codecs: hopefully silence a -Wshift-negative warning in the metadata code
Change-Id: I023499e098bbc706c2f677a7f7a156ec58bd5b14
2025-04-22 09:00:21 -04:00
Solomon Peachy
bcf925a35f codecs: Silence two sets of warnings in musepak and wma codecs
The warnings triggered by -Wshift-negative-value are in the
upstream code, and presumably "correct"

Change-Id: I1cf20e12208f493c69e0852477d800cd417a67c6
2025-04-22 08:55:37 -04:00
Solomon Peachy
3b974e791a misc: Fix more build warnings uncovered with GCC15 and -Wunused-const-variable
Change-Id: I43f5d03d8496b2ac8b30df30b14d1c6e816ef0e2
2025-04-21 21:55:03 -04:00
Solomon Peachy
9d4632b0c3 misc: Clean up a pile of -Wunused-const-variable warnings
And re-enable the warning (applies to GCC 6+)

Change-Id: I7aa679ec65707db12de83c0433966b3821d07087
2025-04-21 21:13:59 -04:00
Roman Artiukhin
17d73c968a Codecs: mp4: Fix possible glitch at the end of song
sample_to_chunk last value was ignored in some cases leading to invalid sample value in lookup_table.

Fixes FS#13600

Change-Id: I8f066966e15c384d3185f689b68a2cc2a3abad1d
2025-04-20 13:43:15 +03:00
Aidan MacDonald
1aa9f26b02 arm: workaround to build Cortex-M7 targets with GCC 4.9
Cortex-M7 support was added in GCC 5, while GCC 4.9 only
supports the M4. The instruction set is almost identical
between both processors; the only difference is that the
M7 supports double-precision floating point and the M4
doesn't.

Since Rockbox currently doesn't use the FPU, building M7
targets as M4 works fine.

Change-Id: I5880d6e81a85fa9b3e16e08d57e7955b4493df0b
2025-04-19 13:16:36 -04:00
Aidan MacDonald
da4e02cdd3 codecs: disable incompatible ARM assembly for Cortex-M
Some assembly routines don't work on Thumb as-is. For now
just disable these so the codecs compile.

Affected codecs:

- libflac
- libmad
- libspeex
- libtta
- libwavpack

A few DSP routines need to be disabled for the same reason:

- crossfeed_process
- crossfeed_meier_process
- resample_hermite
- filter_process
- sample_output_stereo

Change-Id: I277e0719652096745a19a7e2b597eff32d8e1553
2025-04-19 13:00:17 -04:00
Aidan MacDonald
94c7c908b3 libmusepack: add ARMv7-M version of MPC_MULTIPLY_EX
We can't use Operand2 with register based shifts on ARMv7-M as it
isn't supported in the Thumb encoding. Instead, perform the shift
separately.

Change-Id: Ie96aa0a565e98bbca724dffc2ffc6d64fdb5d7c3
2025-04-19 12:26:47 -04:00
Aidan MacDonald
c249dea2b7 libsetjmp: fix unpredictable behavior warning on ARM Cortex-M
GAS warns about unpredictable behavior of "ldr sp, [a1], #4"
that exists on Cortex-M3 (errata 752419) but this warning is
incorrectly issued on other cores too (eg, Cortex-M7).

Since the fix is just one extra instruction we may as well
apply the workaround for all Cortex-M targets.

Change-Id: I0c2aa46837f776d67d0236b627af1572aa5ab307
2025-04-19 11:24:01 -04:00
Aidan MacDonald
96b6a7b4e4 arm: implement get_sp for Cortex-M
On Cortex-M we can just return SP directly, which will return
PSP/MSP depending on the current processor mode.

Note that unwarminder doesn't handle Cortex-M exception frames
yet, so a panic from an interrupt handler will currently stop
at the exception boundary.

Change-Id: I8818126c065c896d781bd52b877965a4094dee2a
2025-04-18 12:47:03 -04:00
Aidan MacDonald
a0bfcd77c8 arm: enable unified assembly syntax in more files
This makes these files compileable, or in some cases less
broken, on Cortex-M targets.

In lcd-16bit.c, newer versions of GAS complain about the
infix condition codes so we use the suffix form instead,
which requires unified syntax to compile on GCC 4.9.

Change-Id: If45166d3fc83d64c692cbb331096a966397aa9e9
2025-04-18 10:26:02 -04:00
Aidan MacDonald
639b587fc7 arm: add support for processors with hardware division
ARMv7-M has hardware division, so it doesn't require __div0
or any support functions for 32-bit division.

Change-Id: I840683a1a77d737f378899ca4bcf858216b81014
2025-04-18 09:22:48 -04:00
Roman Artiukhin
ed40c5a036 metadata: opus, vorbis, speex: Don't fill metadata buffer with album art and cuesheet
Fixup for 0847bcc1. Fixes FS#13586

Change-Id: I2af63747266bf0dea85812354caadca432dfcd32
2025-04-01 08:33:16 -04:00
Roman Artiukhin
849e8abe8d metadata: opus, vorbis, speex: Fix 0 is supplied as base64 char when parsing album art metadata
For some reason it caused a crash on asan enabled simulator builds but worked fine otherwise.

Fixup for 0847bcc1 and ac8714dd

Change-Id: Iff1c2779d5fa6889c743cdccd8e1feaf55684394
2025-03-28 10:13:16 -04:00
William Wilgus
8d2226f952 [Feature] Add failure messages to metadata logging
Previously logging just showed that the file was
passed to the function without any indication that
the parsing failed

Adds status strings to record failure to open, missing parser, parser error

Change-Id: I5234153464bab9a5f9fb765d5e1cfa59dfe0ebfe
2025-03-11 12:16:00 -04:00
Solomon Peachy
5829701fba skin_debug: Also dump the parameters to viewports
Change-Id: Ic9ae330fa6202df67f201911a09ebb7f8c165c8a
2025-03-07 09:46:54 -05:00
William Wilgus
ac8714dd64 [BugFix] vorbis.c metadata invalid index when album art b64 is NULL
Change-Id: I9d08c2e2c903c00d0b2fd25e0dceea28113874a2
2025-02-28 00:27:10 -05:00
Solomon Peachy
dc0cef8304 libopus: Re-add another optimization that was accidently dropped pre-3.15
This puts the entire ~26K decoder state structure into IRAM.

(was lost as part of 14c6bb798d, Nov 2019)

Change-Id: Idbf53657e7c0581b4e47247fc5550b59842b23f1
2025-02-12 08:51:37 -05:00
Roman Artiukhin
0847bcc110 metadata: opus, vorbis, speex: support embedded jpeg album art
It includes .opus, .ogg, .oga, .spx files

Change-Id: I3d0ee9806b05911fc8c3ce5cb761de87d4166141
2025-02-08 10:02:21 +02:00
William Wilgus
b94b0d3bf4 Skin engine, optimize hot paths
callgrind identified check_viewport and scan_int as pretty hot code paths on startup
and playback

check_viewport uses strlen to check the string has at least 4 characters
we can just check if str[3] != '\0' without walking potentially much further
and no function call..

scan_int was building a buffer for atoi to parse when we can just do it in the loop
directly

Change-Id: Ie028980333cbed4c066d8ea547a89cf4fad76808
2025-02-08 00:49:28 -05:00
William Wilgus
02c256565f [FixRed] Reove HAVE_PITCHCONTROL from bootloaders, fix warble
Change-Id: I85a3580bd5fac881ca36efc260791d03f0b8c83a
2025-01-19 01:20:58 -05:00
William Wilgus
4e271642df [Feature] Persist pitch settings through reboots part deux
Revisit this after discussion with chris_s on IRC and forum

Pitch menu now changes icon when pitch has been changed

uses NVRAM to save the pitch settings unconditionally

Manual updated

Change-Id: Idcb4c2b7fe42f7a203dc4bfc46285657f370d0fd
2025-01-19 00:29:47 -05:00
Roman Artiukhin
7f4a8891a6 metadata: mp3: Support unsync embedded jpeg album art
Support parsing alubm art from id3 metadata with "unsynchronisation scheme":
https://id3.org/id3v2.3.0#The_unsynchronisation_scheme

Change-Id: I1e2ca4ae0aa967f7e80142a04c9a7d99e38e68b2
2025-01-16 10:08:41 -05:00
William Wilgus
dca70e1816 compressor remove static delay line buffer
core_alloc works well for this and we can allow the alloc to be moved

bugfix compressor_process() possible buffer overflow

Change-Id: I701c6306c39cc1c7aa72b0dbe402b9b0d1a3fcda
2024-12-27 02:34:18 -05:00
William Wilgus
1643e0e287 [Bugfix] metadata.c copy_mp3entry() dest and orig may overlap
I meant to add this with the last patch b07d7d6
since it may supply UNBUFFERED_ID3 to the peek function
which uses UNBUFFERED_ID3 and will try to copy it back
wich is undefined behavior for memcpy

Change-Id: I91160570adac22134c84d3b37f8fcecb097d87d6
2024-12-26 01:29:02 -05:00
William Wilgus
25ab00465e metadata.c don't store encoder filename for all the decoders
there are only 4 encoder capable codecs just make it a function
and add a macro to keep it sane

Change-Id: Iac8833226434f8436bc678f3e409f462764d8fdc
2024-12-24 01:47:18 -05:00
William Wilgus
7c678f5e7a [Feature] %ft file text tags add prefix search
%ft(filename,search_text)
finds a line beginning with search_text strips search_text and returns
the remainder of the line

Change-Id: I06fe029b89aa60e4dbf34c039d180c75213519a4
2024-12-22 01:11:10 -05:00
Christian Soffke
727c800c0d Don't force gcc as host compiler + fix clang warnings
On MacOS, gcc is a symlink for clang.

Patch gets rid of the warnings produced by clang,
when it is set as HOSTCC, and fixes voicetools
compilation on MacOS when calling make voicetools
from the simulator directory.

lua rb_defines_helper:
format specifies type 'int' but the argument has
type 'long'

codecs: opus / speex (LOGF):
format '%ld' expects argument of type 'long int',
but argument 7 has type 'off_t'

gigabeat:
variable 'size' set but not used

rdf2binary:
a function declaration without a prototype is
deprecated in all versions of C

rbspeexdec:
passing 'unsigned char *' to parameter of type
'char *' converts between pointers to integer
types where one is of the unique plain 'char'
type and the other is not

hmac-sha1.c
defining a type within 'offsetof' is a Clang
extension

Change-Id: I90539906698868f9589650585d865aee9f7e8539
2024-12-20 05:29:18 +01:00
Christian Soffke
a86b1999d0 simulator: fix missing Werror option + eliminate lib duplicate
configure:
Ensure Werror option doesn't get lost when simcc resets GCCOPTS

uisimulator.make:
Remove ignored duplicate SIMLIB on Darwin

codecs.make:
Eliminate some redundancy

Change-Id: Ieee6f677fd22666cb58aa6fe53eabdc0b0f8c190
2024-12-19 15:04:46 -05:00