Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+18 -14
+5 -3
lib/rbcodec/codecs/libffmpegFLAC/README.rockbox
··· 25 25 are present in decoder.h - mainly limiting the supported blocksize 26 26 (number of samples in a frame) to 4608. This is the default value 27 27 used by the reference FLAC encoder at all standard compression 28 - settings. 29 - 28 + settings. However, it is increasingly common for high-resolution/freq 29 + files to use 8K block sizes, so on devices that can play back such 30 + files natively and/or have sufficient processor oomph to downmix in 31 + realtime, we use that larger limit. 30 32 31 33 TESTING 32 34 ··· 39 41 40 42 This can be used to test the accuracy of the decoder by comparing the 41 43 md5sum of the WAV file produced by this decoder with a WAV file 42 - produced by the official libFLAC decoder. 44 + produced by the official libFLAC decoder. 43 45 44 46 This test program could be extended to perform an internal md5sum 45 47 calculation and comparing that against the md5sum stored in the FLAC
+7 -10
lib/rbcodec/codecs/libffmpegFLAC/bitstream.h
··· 19 19 #endif 20 20 21 21 #if (CONFIG_CPU == MCF5250) || (CONFIG_CPU == PP5022) || \ 22 - (CONFIG_CPU == PP5024) || (CONFIG_CPU == S5L8702) 22 + (CONFIG_CPU == PP5024) 23 23 #define ICODE_ATTR_FLAC ICODE_ATTR 24 24 #define IBSS_ATTR_FLAC IBSS_ATTR 25 25 /* Enough IRAM to move additional data to it. */ 26 26 #define IBSS_ATTR_FLAC_LARGE_IRAM IBSS_ATTR 27 27 #define IBSS_ATTR_FLAC_XLARGE_IRAM 28 28 #define IBSS_ATTR_FLAC_XXLARGE_IRAM 29 - 30 - #elif (CONFIG_CPU == S5L8700) || (CONFIG_CPU == S5L8701) 31 - #define ICODE_ATTR_FLAC ICODE_ATTR 32 - #define IBSS_ATTR_FLAC IBSS_ATTR 33 - /* Enough IRAM to move even more additional data to it. */ 34 - #define IBSS_ATTR_FLAC_LARGE_IRAM IBSS_ATTR 35 - #define IBSS_ATTR_FLAC_XLARGE_IRAM IBSS_ATTR 36 - #define IBSS_ATTR_FLAC_XXLARGE_IRAM 37 - 38 29 #else 39 30 #define ICODE_ATTR_FLAC ICODE_ATTR 40 31 #define IBSS_ATTR_FLAC IBSS_ATTR ··· 42 33 #define IBSS_ATTR_FLAC_LARGE_IRAM 43 34 #define IBSS_ATTR_FLAC_XLARGE_IRAM 44 35 #define IBSS_ATTR_FLAC_XXLARGE_IRAM 36 + #endif 37 + 38 + #if (ARCH == ARCH_M68K) || defined(CPU_PP) || MEMORYSIZE <= 2 39 + #define MAX_BLOCKSIZE 4608 40 + #else 41 + #define MAX_BLOCKSIZE 8192 45 42 #endif 46 43 47 44 /* Endian conversion routines for standalone compilation */
+2
lib/rbcodec/codecs/libffmpegFLAC/decoder.h
··· 4 4 #include "bitstream.h" 5 5 6 6 #define MAX_CHANNELS 7 /* Maximum supported channels, only left/right will be played back */ 7 + #ifndef MAX_BLOCKSIZE 7 8 #define MAX_BLOCKSIZE 4608 /* Maxsize in samples of one uncompressed frame */ 9 + #endif 8 10 #define MAX_FRAMESIZE 65536 /* Maxsize in bytes of one compressed frame */ 9 11 #define MIN_FRAME_SIZE 11 /* smallest valid FLAC frame possible */ 10 12
+4 -1
manual/appendix/file_formats.tex
··· 146 146 & Linear PCM 8/16/24/32 bit, IEEE float 32/64 bit, ITU-T G.711 a-law/$\mu$-law\\ 147 147 Free Lossless Audio 148 148 & \fname{.flac} 149 - & Supports multichannel playback including downmixing to stereo.\\ 149 + & Multichannel and/or high-resolution files will be downmixed to 16-bit stereo. 150 + \opt{ipod,iriverh10,sansaclip,sansam200v4,sansac200v2,iriverh100,iriverh300,iaudiox5,iaudiom5,iaudiom3,mpiohd200,mpiphd300}{ 151 + \nopt{ipodnano2g,ipod6g}{Due to resource constraints, files with large block sizes are not supported, and realtime playback may not be possible where downmixing is necessary.}} 152 + \\ 150 153 Apple Lossless 151 154 & \fname{.m4a}, \fname{.mp4} 152 155 & \\