GCC 4.9 always emits assembly with divided syntax. Setting unified
syntax in inline assembly causes the assembler to complain about
GCC's generated code, because the directive extends past the scope
of the inline asm. Fix this by setting divided mode at the end of
the inline assembly block.
The assembler directives are hidden behind macros because later
versions of GCC won't need this workaround: they can be told to
use the unified syntax with -masm-syntax-unified.
Change-Id: Ic09e729e5bbb6fd44d08dac348daf6f55c75d7d8
Replace the minimum version bound with a check on the size of
the API struct. The version only needs to be incremented for
ABI breaking changes. Additions to the API won't need to touch
the version number, resulting in fewer merge conflicts.
Change-Id: I916a04a7bf5890dcf5d615ce30087643165f8e1f
Plain import of the library parts first. Adaptions to Rockbox will
follow. A *lot* of kudos go to Mihaly Horvath for creating this library
from his already lightweight cSID-light, mainly for Rockbox. Besides a
lot of other things, he made his algorithms integer-only and
significantly improved the C64 emulation, so finally RSIDs could be
played as well as PSIDs. TinySID was nice for what it is, but this is a
quantum leap in SID playback quality for Rockbox. Check for example:
https://hvsc.csdb.dk/MUSICIANS/P/Page_Jason/Eighth.sidhttps://hvsc.csdb.dk/MUSICIANS/J/Jeff/Blowing.sid
Change-Id: I353e12fbfd7cd8696b834616e55743e7b844a73e
It turns out removing DSP_INIT broke the codec ABI and caused
old codecs to crash; the loop and mdelay() was a red herring.
This reverts commit 541960a110.
Change-Id: I020d826e7b4beb006d093d9c3d4f45fa5eaac717
Commit 6bcd830490 ported an optimization to decode_subframe_fixed()
from FFmpeg (upstream commit 08965b22e2). This contains an out of
bounds read, which doesn't affect the decoder output, but makes ASAN
complain.
FFmpeg fixed the out of bounds read (upstream commit 0ec7b71de8) but
that appears to increase code size a lot.
Inlining the initialization of a, b, c, d into the switch produces
similar code as the non-bounds-checked version with only a handful
of instructions of overhead (checked on MIPS & ARM).
Change-Id: I053fac4efc4676b133eb7545c80e23f37fb00d86
Not really sure how best to deal with the warnings (redefinition of
ARRAYLEN, etc.) short of splitting things out of system.h but this
is good enough for now.
Change-Id: Ibea9f693d128c7995f564f0f5c81d572462a5553
It seems removing this causes a crash on the Clip+ when playing
any file. Appears to be a timing-related issue as replacing the
loop with an mdelay() also fixes it. Needs further investigation
to identify the real cause of the problem, see FS#13386.
Change-Id: Ia93a2887a79b376de50563d6bb3bbc79cee11a1c
Turns out (~PTR_MASK) != (0xFFFFFFFF - PTR_MASK) in 64 bit land
tmp_b = (bhdr_t*) ( (intptr_t)b->prev_hdr & BLOCK_SIZE );
using ~STATE_MASK or even #define BLOCK_SIZE (~PTR_MASK) resolves the issue
switching BLOCK_SIZE TO ~STATE_MASK appears to fix it
Also define BLOCK_SIZE (~PTR_MASK)
Fix a few signed / unsigned errors
Change-Id: Ica59db0faa2df408831c23312243ae19259dba6b
Carrying this library is somewhat of a maintenance burden because
some Rockbox APIs are mocked or duplicated in the test suite and
thus need to be fixed up when refactoring.
It's also unused & incomplete, so there's no good reason to keep
it in tree any more.
Change-Id: If39c62744b4edc0d81b1b6608ee5df69430e6581
Refactor DSP init routines so there is a dedicated init function
for the stages that need it. Remove the DSP_INIT configure message.
This allows the init code to be safely marked INIT_ATTR, saving a
bit of code size, and allowing the linker to verify that there are
no unsafe references to the init routines.
Change-Id: I1702f0f579bbb300a6fe7d0e67b13aa2e9dd7f8a
Makes dsp_sample_input.c a bit less messy, and dependencies
are more explicit. There's possibly a minor loss of inlining
but it isn't a big deal.
Change-Id: I30f923a0ca758f2b113d32852d1f65586dff0cd1
All of these are technically unsafe cross-section references but
most aren't reported by the linker, probably due to inlining. In
practice there was no problem because the affected code was only
run at init time anyway.
For now, remove INIT_ATTR until the init code can be refactored
to avoid the problematic references. This should also save code
size by moving more code to the init section.
dsp_init() gets to keep its attribute because it's already OK.
Change-Id: Idc9ac0e02cb07f31d186686e0382275c02a85dbb
haas surround is causing a seg fault
it appears process is null see https://www.rockbox.org/tracker/task/13382
for details
when the low_latency_callback is enabled it happens less frequently
lets default to an empty process that way there are no NULL pointers to call
Change-Id: Ib72ba1a58cbb20cef04b5ea50964adadeee74a75
Resume by offset was obviously inaccurate for ALAC -- it tried
to convert the offset to an elapsed time using the approximate
bitrate, which is going to be wrong for VBR files. This became
a problem since commit 26ffcd8f9f restored the ability to resume
by offset.
It turns out that m4a_seek_raw() has terrible resolution since
it can only seek to chunk boundaries, and lies about the real
sample position; basically the same issue that affected seeking
described in commit 4dd3c2b33e. Resuming by offset is still not
very accurate because of this. Prefer to resume by time first,
which is normally highly accurate (and never worse than offset)
but use the file offset if it's the only thing we have.
There were a couple time calculations still using 32-bit math,
so clean those up too to reduce issues due to rounding errors.
Change-Id: Idd3bccd67505f4e59e784d92e45ea80a273975bb
The codec used 32-bit math for elapsed time <-> file position
calculations. The rounding errors seem to be the cause of poor
seek/resume accuracy on long VBR files; switching to 64-bit math
makes things much better.
Change-Id: Iba638d9e031a891022510c31c141cc4541e3f149
It fixes Playback/Bookmarks Resume for long vbr mp3 files
It also fixes resume by time for asf files.
As a replacement for https://gerrit.rockbox.org/r/c/rockbox/+/4750
Change-Id: Iaa59b5862385f5fe91fdc2fb0b1fde8ce75c0b54
allow buflib_free to check for invalid or already freed handles
within the function -- remove all the invalid handle guards thru core_free
Change-Id: Ibdcbc82760fc93b674c42283fca420d94907df8e
This appears to be a bug in GCC 12 due to more aggressive -Waddress
warnings. According to the GCC documentation, the warning should be
suppressed because the "problem" code is coming from a macro, but it
doesn't happen for cases like "if(!SKINOFFSETTOPTR(...))" where the
macro is negated.
Assigning the result of SKINOFFSETTOPTR() to a temporary and checking
that suppresses the warning.
Change-Id: Ia37a1e06a454d29032bb8128a2f059b149ea2b83
Should make debugging crashes on native MIPS targets far easier.
This is by no means a 100% complete or robust implementation but
it seems to handle the vast majority of functions.
Change-Id: Id5f430270e02b5092b79026b6876675c784aa649
Seeking doesn't work well in M4A files with very few chunks due to
the seek method used (chunk based using the info in the 'stco' atom).
According to libm4a/demux.c the expected seek resolution using this
method is 1/4 to 1/2 seconds. However, ffmpeg generates files with a
1 megabyte chunk size, so the resolution is much worse than expected
on some files: around 30-40 seconds at 256kbps.
There was a bug with the seek position reported back to Rockbox: the
codec pretended it could seek exactly to the requested sample, but it
would only seek to the start of a chunk. This could leave the UI in a
confusing state because the real playback position was different from
what the elapsed time showed. Fix this by recalculating the reported
sample position using the chunk start.
To fix the low seek accuracy, use the table in the 'stsz' atom to skip
individual packets within a chunk. This is very accurate, but it takes
a lot of RAM to allocate the table. Currently the table is not allowed
to use more than half of the codec RAM, which should suffice for short
files on most targets. On files where the table is too large the codec
will fall back to the less accurate chunk-based seek method.
Change-Id: Ide38ea846c1cdd69691e9b1e1cd87eb0fa11cf78
UBSan reports an avalanche of unaligned pointer bugs stemming from
hardcoded 4-byte alignments used in certain places. Use sizeof(long)
instead to align to the machine word size.
Change-Id: I28e505212462c5268afa24e95df3a103ac3e2213
These operations can only be used in limited circumstances and have
exactly one user. bufgettail especially seems of dubious value; how
often do you need to read N bytes from the end of a file without
changing the file position?
strip_tags() was the only function using them, to strip off ID3v1
and APE tags off the end of buffered tracks. This would save only
32-192 bytes per track -- if the container format uses APE/ID3v1.
It hardly seems worth the effort.
Change-Id: I8fc3c1408517eda6126e75e76d76daea904b50eb
Left shifts are not defined in C if they would cause signed overflow,
so these expressions get instrumented, which makes them unusable as
switch values and triggers compile errors when compiling with UBSan.
Change-Id: I0588d4be1e00ba1cfde0eac119ead368b20d10c9
decrease size hit of initializing asf by using a union
remove init from bytes LE conversion in metadata common
-- bad idea for performance
Change-Id: I4514adc125e5da2b99d9f913ba74afd5f1345822
fix bugs introduced in the switch over to using string_option
instead of if else strcmp trees,
embedded album art should work again
skin parser had an error for 'noborder' and 'nobar'
Change-Id: I957d81e5fa8467b33bbd93d63c4428c36100acca