summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroman.artiukhin <bahusdrive@gmail.com>2023-12-22 13:40:54 +0200
committerSolomon Peachy <pizza@shaftnet.org>2023-12-31 20:44:15 -0500
commit4cd65b9d97e5fb172477b31d3dc5bc136cc6950b (patch)
tree1ea09715a6f15456d762efa22dc40617e20e393d
parentfc65bdab4e9d62fb5edf74284944a204aefd5160 (diff)
downloadrockbox-4cd65b9d97e5fb172477b31d3dc5bc136cc6950b.tar.gz
rockbox-4cd65b9d97e5fb172477b31d3dc5bc136cc6950b.zip
Codecs: mp4: Disable SBR decoding for PP5002 - PP5022 platforms
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
-rw-r--r--apps/features.txt4
-rw-r--r--firmware/export/config.h4
-rw-r--r--lib/rbcodec/codecs/libfaad/common.h4
-rw-r--r--lib/rbcodec/codecs/libfaad/specrec.c8
-rw-r--r--lib/rbcodec/metadata/aac.c2
-rw-r--r--lib/rbcodec/metadata/mp4.c5
-rw-r--r--manual/appendix/file_formats.tex8
7 files changed, 27 insertions, 8 deletions
diff --git a/apps/features.txt b/apps/features.txt
index bafaa11599..1356d20e34 100644
--- a/apps/features.txt
+++ b/apps/features.txt
@@ -300,3 +300,7 @@ clear_settings_on_hold
300#if defined(HAVE_PERCEPTUAL_VOLUME) 300#if defined(HAVE_PERCEPTUAL_VOLUME)
301perceptual_volume 301perceptual_volume
302#endif 302#endif
303
304#if defined(CODEC_AAC_SBR_DEC)
305codec_aac_he
306#endif
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 49cd6d610c..92997dc7b8 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -601,6 +601,10 @@ Lyre prototype 1 */
601//#error "unknown hwardware platform!" 601//#error "unknown hwardware platform!"
602#endif 602#endif
603 603
604#if !(CONFIG_CPU >= PP5002 && CONFIG_CPU <= PP5022) && CODEC_SIZE >= 0x80000
605#define CODEC_AAC_SBR_DEC
606#endif
607
604#ifdef __PCTOOL__ 608#ifdef __PCTOOL__
605#undef CONFIG_CPU 609#undef CONFIG_CPU
606#define CONFIG_CPU 0 610#define CONFIG_CPU 0
diff --git a/lib/rbcodec/codecs/libfaad/common.h b/lib/rbcodec/codecs/libfaad/common.h
index 8f66a14ce0..938f64e14c 100644
--- a/lib/rbcodec/codecs/libfaad/common.h
+++ b/lib/rbcodec/codecs/libfaad/common.h
@@ -135,9 +135,11 @@ extern "C" {
135 #undef ERROR_RESILIENCE 135 #undef ERROR_RESILIENCE
136#endif 136#endif
137 137
138#if CODEC_SIZE >= 0x80000 138#ifdef CODEC_AAC_SBR_DEC
139#define SBR_DEC 139#define SBR_DEC
140//#define SBR_LOW_POWER /* Does not work yet in rockbox. */ 140//#define SBR_LOW_POWER /* Does not work yet in rockbox. */
141#endif
142#if CODEC_SIZE >= 0x80000
141#define PS_DEC 143#define PS_DEC
142#endif 144#endif
143 145
diff --git a/lib/rbcodec/codecs/libfaad/specrec.c b/lib/rbcodec/codecs/libfaad/specrec.c
index 200239bddc..02deb298b9 100644
--- a/lib/rbcodec/codecs/libfaad/specrec.c
+++ b/lib/rbcodec/codecs/libfaad/specrec.c
@@ -850,9 +850,13 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics,
850#if (defined(PS_DEC) || defined(DRM_PS)) 850#if (defined(PS_DEC) || defined(DRM_PS))
851 if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0)) 851 if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0))
852 { 852 {
853 uint8_t ele = hDecoder->fr_ch_ele;
854 uint8_t ch = sce->channel; 853 uint8_t ch = sce->channel;
855 uint16_t frame_size = (hDecoder->sbr_alloced[ele]) ? 2 : 1; 854 uint16_t frame_size =
855#ifdef SBR_DEC
856 (hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) ? 2 : 1;
857#else
858 1;
859#endif
856 frame_size *= hDecoder->frameLength*sizeof(real_t); 860 frame_size *= hDecoder->frameLength*sizeof(real_t);
857 861
858 memcpy(hDecoder->time_out[ch+1], hDecoder->time_out[ch], frame_size); 862 memcpy(hDecoder->time_out[ch+1], hDecoder->time_out[ch], frame_size);
diff --git a/lib/rbcodec/metadata/aac.c b/lib/rbcodec/metadata/aac.c
index 358b2de079..372bab716e 100644
--- a/lib/rbcodec/metadata/aac.c
+++ b/lib/rbcodec/metadata/aac.c
@@ -93,11 +93,13 @@ bool get_aac_metadata(int fd, struct mp3entry *entry)
93 break; 93 break;
94 } 94 }
95 entry->bitrate = (unsigned int)((total * entry->frequency / frames + 64000) / 128000); 95 entry->bitrate = (unsigned int)((total * entry->frequency / frames + 64000) / 128000);
96#ifdef CODEC_AAC_SBR_DEC
96 if (entry->frequency <= 24000) 97 if (entry->frequency <= 24000)
97 { 98 {
98 entry->frequency <<= 1; 99 entry->frequency <<= 1;
99 entry->needs_upsampling_correction = true; 100 entry->needs_upsampling_correction = true;
100 } 101 }
102#endif
101 } 103 }
102 else 104 else
103 { 105 {
diff --git a/lib/rbcodec/metadata/mp4.c b/lib/rbcodec/metadata/mp4.c
index e05a588e7e..706a50e503 100644
--- a/lib/rbcodec/metadata/mp4.c
+++ b/lib/rbcodec/metadata/mp4.c
@@ -349,7 +349,10 @@ static bool read_mp4_esds(int fd, struct mp3entry* id3, uint32_t* size)
349 } 349 }
350 } 350 }
351 } 351 }
352 352#ifndef CODEC_AAC_SBR_DEC
353 //SBR_DEC is disabled so disable sbr implicit signalling
354 sbr_signaled = true;
355#endif
353 if (!sbr && !sbr_signaled && id3->frequency <= 24000) 356 if (!sbr && !sbr_signaled && id3->frequency <= 24000)
354 { 357 {
355 /* As stated in libfaad/mp4.c AudioSpecificConfig2: 358 /* As stated in libfaad/mp4.c AudioSpecificConfig2:
diff --git a/manual/appendix/file_formats.tex b/manual/appendix/file_formats.tex
index c40a7d35ae..dd12993d36 100644
--- a/manual/appendix/file_formats.tex
+++ b/manual/appendix/file_formats.tex
@@ -86,10 +86,10 @@
86 & \fname{.adx} 86 & \fname{.adx}
87 & Encrypted ADX is not supported.\\ 87 & Encrypted ADX is not supported.\\
88 Advanced Audio Coding 88 Advanced Audio Coding
89 & \fname{.m4a}, \fname{.m4b}, \fname{.mp4}, \fname{.rm}, \fname{.ra}, \fname{.rmvb} 89 & \fname{.aac}, \fname{.m4a}, \fname{.m4b}, \fname{.mp4}, \fname{.rm}, \fname{.ra}, \fname{.rmvb}
90 \nopt{clipv1,c200v2}{ 90 \opt{codec_aac_he}{
91 & Supports AAC-LC, -HEv1, and -HEv2 profiles\\} 91 & Supports AAC-LC, -HEv1, and -HEv2 profiles\\}
92 \opt{clipv1,c200v2}{ % low memory targets (CODEC_SIZE <= 512 KB) 92 \nopt{codec_aac_he}{ % low memory (CODEC_SIZE <= 512 KB) or slow cpu targets
93 & Supports AAC-LC profile\\} 93 & Supports AAC-LC profile\\}
94 MPEG audio 94 MPEG audio
95 & \fname{.mpa}, \fname{.mpga}, \fname{.mp1}, \fname{.mp2}, \fname{.mp3} 95 & \fname{.mpa}, \fname{.mpga}, \fname{.mp1}, \fname{.mp2}, \fname{.mp3}
@@ -122,7 +122,7 @@
122 & \\ 122 & \\
123 \end{rbtabular} 123 \end{rbtabular}
124 124
125 \note{AAC-HE profiles might not play in realtime on all devices due to CPU 125 \note{AAC-HE profiles \opt{codec_aac_he}{might not play in realtime on all devices}\nopt{codec_aac_he}{are disabled on this device} due to CPU
126 performance requirements.} 126 performance requirements.}
127 127
128 \subsection{Lossless Codecs} 128 \subsection{Lossless Codecs}