summaryrefslogtreecommitdiffstats
path: root/lib/rbcodec/codecs
AgeCommit message (Collapse)AuthorFilesLines
2024-02-02Remove ATRAC3 specific fields (channels, extradata_size) from mp3entryRoman Artiukhin4-13/+15
Also fixes typo of using never initialized id3->channels in wav metadata (introduced in 2d1937a1) Change-Id: I28cddec2b9d9bd1e756ffaa004b4f6e8528a7566
2024-01-24Codecs: mpa: Use both time and offset when resuming filesRoman Artiukhin1-1/+8
The supplied time may be more accurate than the calculated time from the bitrate (can be quite inaccurate for long vbr files and even for cbr due to padding) Change-Id: I1f8291eab45fbd91a161b51776c391a0f7886a5c
2024-01-24Codecs: mpa: Improve seek in large mp3 vbr filesRoman Artiukhin1-13/+16
Use current position as toc mark and use it if it gives better accuracy. Continuation of 3883c978 Change-Id: Ic6e8192fc43061f3c07128486dbefba7382be5ce
2024-01-21Codecs: aac: Improve ADTS stream detectionRoman Artiukhin1-4/+2
Captured ADTS streams might start from some garbage data from previous frame. We should check for sync errors even for first frame. Change-Id: I70171298b79713aeedf9fa2e6098a03063487649
2024-01-12Codecs: mp4: Re-Fix loading tracks with metadata at the end of fileRoman Artiukhin1-4/+6
first_frame_offset is not set for mp4 files so seeking to it doesn't make any sense. It can lead only to additional re-buffer request. So instead let's just allow seek back for m4a_check_sample_offset check. And do seek_buffer(0) before reading metadata (fixes possible hang introduced in fc65bdab) Change-Id: Ia7fae14b0137d73b5e263390be5f143deb7ca789
2023-12-31Codecs: mp4: Disable SBR decoding for PP5002 - PP5022 platformsroman.artiukhin2-3/+9
Includes ipod video (5G) and earlier models, sansa c200 and others players not capable to decode AAC-HE. Allows to play backward compatible files as AAC-LC. Change-Id: Ic9f5c0f255d9a4308c3414d402f8f27f4328ca94
2023-12-23Codecs: mp4: Fix loading tracks with metadata at the end of fileroman.artiukhin1-2/+1
Fixes FS#13402 Change-Id: Iafb21787e8f042e913c86b249bb2552cfdf4f4a8
2023-11-02Codecs: mp4: Fix sign overflow in seek by offsetroman.artiukhin1-1/+1
Change-Id: I52f536ae959f989c3dc70a50cb802eb1b8615642
2023-10-03Codecs: mp4: Fix seek to end of trackroman.artiukhin2-0/+4
Fix possible crash due to out of bound access. Fixes FS#13371 Change-Id: I90d28fa89ceb22e6561d33abc5f2b4c7f32d323c
2023-10-02Codecs: mp4: Ignore decode errors till next chunk present in lookup_tableroman.artiukhin1-1/+5
In files with gaps between chunks and reduced lookup_table we can't properly detect all gaps in m4a_check_sample_offset. So just ignore decode errors till next chunk present in lookup_table Change-Id: I317864dce6a2251cdb6ddb8c0ad4d7c1640cb7a1
2023-09-29Codecs: mp4: Skip FOURCC filetype chunk checkroman.artiukhin1-13/+4
Instead of FOURCC it needs ignore-case text match. Also value can contain \0 ('m4a\0' instead of expected 'm4a ').But let's simply skip it and let decoder handle it. Change-Id: I87eefcabbc9010481286257c26cee09e61d1221c
2023-09-26codec.h fix ifdef for older compilersWilliam Wilgus1-1/+1
elifdef appears to be finally supported in C23 elif defined() works everywhere Change-Id: I8ac6c215bedc81cc9ea8f79850be40cef131594b
2023-09-26Support per file logging with LOGF_ENABLE in codecsroman.artiukhin2-16/+4
Codecs mostly use custom LOGF define for logging (i.e. see aac.c). Now such logging can be enabled in single file with #define LOGF_ENABLE Change-Id: I36312fbcd2d9166fb1fe5ead31e7354342d8828d
2023-09-22Codecs: mp4: Fix seek in files with single element in lookup_tableroman.artiukhin2-8/+8
lookup_table offset shouldn't be zero terminated. And fix possible out of bound access. Change-Id: I212a5fcc1868a2ca519b0052b170e836276fe9de
2023-09-20Codecs: mp4: Accurate seek in large files with small lookup_tableroman.artiukhin3-6/+25
Read sample_byte_sizes table on demand when it can't be cached Change-Id: I2191be63ceebfd8b16e1e973e13c5b51986b6564
2023-09-19alac: Fix warnings introduced in ac82a653bbSolomon Peachy1-6/+6
Change-Id: I96fc2b8637cb95c5bd14a6d77fc4b2339c4acd49
2023-09-19libm4a: Fix warnings introduced in 001a338e51Solomon Peachy3-34/+34
Change-Id: Ia915e6f8babbd71533f22af566e5c45c2b40fbe5
2023-09-19Codecs: mp4: Reuse lookup_table index from seek in m4a_check_sample_offsetroman.artiukhin4-10/+12
Change-Id: If2fc3038ce8db8ddf2991406a5cce294a857eadc
2023-09-19Codecs: mp4: Optimize m4a_check_sample_offsetroman.artiukhin2-12/+10
Make optimization from 2358fabb actually work. Fix potential out of bound access. Remove redundant zero offset check. Change-Id: I0a0ba04670b612d410ac17a761bd08c2915721b9
2023-09-18Codecs: mp4: Small cleanuproman.artiukhin1-4/+1
Remove unnecessary frame modification Change-Id: I884152a66477efea7cfcadc638f55352ad75fc41
2023-09-18Codecs: mp4: Improve support for long files. Part 2roman.artiukhin2-42/+38
Don't store sample_to_chunk table and read data on demand instead (it's required only once for building lookup table). It allows to store 2x bigger lookup table. Change-Id: Ida79d0c281040300d6561e124fe10ebacb0e4679
2023-09-15Codecs: mp4: Fix seek in very large filesroman.artiukhin4-10/+11
Samples count requires 64 bit Change-Id: Ia54be57d7d15b3db19dbc29ff8a06671594abb4b
2023-09-09Codecs: mp4: Improve support for long files, prevent endless loopWilliam Wilgus1-2/+2
pretty unlikely but I think in a memory exaustion scenario you might roll the uint8 over to zero and crash Change-Id: If73dc64484f2d363446be068aa7bf8025407a2a7
2023-09-06Codecs: mp4: Improve support for long filesroman.artiukhin1-8/+27
Reduce lookup_table (seek accuracy) till it fits on device Fixes FS#13049 Change-Id: I934de500a4383e17b82821afa2e0396a27061707
2023-09-06Codecs: mp4: Skip unknown chunksroman.artiukhin1-1/+2
Needed for opening some m4b books (see FS#13049) Change-Id: Id289451e6b2b8a7ad1f6b9f00ef512ab9692383d
2023-08-28Fix MP3 VBR seek jumps in wrong direction for long filesroman.artiukhin1-2/+10
Fix jumps in the wrong direction by seeking relative to the current position Change-Id: I5ca3d5bcb256dd8fb1cd17e6149878190571d359
2023-07-02libmusepack: Fix inconsistent definition of an array sizeSolomon Peachy1-1/+1
Change-Id: If91eed5a0cbce44723e9581dce7de02e644f7e3e
2023-03-23Fix unified syntax in ARM inline assemblyAidan MacDonald1-3/+6
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
2023-03-23Using ARM Unified Assembler LanguageChris Chua3-13/+16
Change-Id: Iae32a8ba8eff6087330e458fafc912a12fee4509
2023-03-21plugins: Simplify plugin/codec API versioningAidan MacDonald1-13/+15
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
2023-02-07SID: Disable SID on 2MB targets, as cRSID needs a lot of RAM.Solomon Peachy2-1/+3
Also add a note that SID might not play in realtime on all targets Change-Id: Ic14b20a7c1427e31e38204ae3ecff6bd235ec1b4
2023-02-07codec: sid: use cRSID as a library for playing SID filesWolfram Sang5-1272/+75
Change-Id: Iee70933e47ff8df8f26c9a63112de4da4a8e6c17
2023-02-07codec: sid: split cRSID header into a public and a private headerWolfram Sang4-165/+176
Needed to compile cRSID as a proper library. Change-Id: I276967f46037bd65db1ff38985a781183fc26a00
2023-02-07codec: sid: add cRSID-1.0 for 21st century SID playbackWolfram Sang12-0/+2525
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.sid https://hvsc.csdb.dk/MUSICIANS/J/Jeff/Blowing.sid Change-Id: I353e12fbfd7cd8696b834616e55743e7b844a73e
2023-01-18Bump codec API version, remove dummy configure loop in dsp_init()Aidan MacDonald1-2/+2
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 541960a11061213f682d67bb036f861b2605f9d3. Change-Id: I020d826e7b4beb006d093d9c3d4f45fa5eaac717
2023-01-15rbcodec: Fix FLAC out of bounds readAidan MacDonald1-7/+12
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
2023-01-04[BugFix] Fix some Shif related UB -- ASANWilliam Wilgus1-2/+3
these are the low hanging fruit identified by ASAN cast the byte values before shift Change-Id: Ifc5645354a10c15ccd09d1343e1705857a51e011
2022-11-16codecs: alac: Improve resume accuracy and clean up rounding errorsAidan MacDonald1-31/+33
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
2022-11-16codecs: aac: Prefer to resume by time instead of offsetAidan MacDonald1-5/+5
m4a_seek_raw() is relatively inaccurate, so time-based resume should be preferred. Change-Id: I959ef165f9a99d12deb804c13d20413c1cecf867
2022-11-01codecs: mpa: Improve seek & resume accuracy for VBR filesAidan MacDonald1-55/+32
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
2022-11-01Refactor to reuse seek code for resume by timeroman.artiukhin1-36/+37
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
2022-10-13Revert "RFC: Get rid of mpegplayer plugin"Solomon Peachy3-4/+30
This reverts commit d25d24812e8120c0eb133a412287ac030eb185c9. Change-Id: I1563223e343fb1e2eda72a45823b38350025ff93
2022-10-02RFC: Get rid of mpegplayer pluginSolomon Peachy3-30/+4
It might have made sense once upon a time, but in today's world... Change-Id: I5d638e6f7a2308c50ab12bd901338f02cf426aae
2022-07-11Fix a couple of warnings uncovered by GCC12Solomon Peachy1-0/+2
Change-Id: Ib628a27bfc6f95a822e46b931ccfbed90f41b122
2022-06-21fix uninitialized warning in libopusWilliam Wilgus1-1/+1
likely this is truly a bug but I imagine much worse things happen before this point in that case Change-Id: If78465cf2ae1e5cf38ad7f087dd436b888bc9996
2022-05-02codecs: m4a: improve seek accuracyAidan MacDonald3-53/+127
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
2021-08-08As3525 wavpack_enc document some intentional switch fall throughWilliam Wilgus1-0/+1
Change-Id: I56bf439df2c05653d65f49238e886e4ef2291176
2021-08-04Document intentional fallthroughs + fix harmless unintended onesAidan MacDonald1-0/+3
Change-Id: I1ca5b1027ec30cbf61093bab35b980196ed14e6b
2021-07-25rbcodec: Fix typo in makefileAidan MacDonald1-1/+1
Hopefully this will fix all those random build failures. Change-Id: I02ff625c538a21f20b33874b4ab54ed8c893a433
2021-07-15misc: Fix up a few warnings uncovered by LTOSolomon Peachy3-17/+14
* direct use of memcpy() instead of ci->memcpy() in flac and mod * uninitialized variable in mpegplayer Change-Id: I2d08682d5f66c319780e69e3ff63d600c61d8f5a