summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2010-07-02 04:35:37 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2010-07-02 04:35:37 +0000
commitbcbe317565f91f2f0f10186dfa32c8847f58df9f (patch)
treeb591ffb0f950258458ee25f4bebfb1cdfc792a3b
parentf58174f7cc1c04436414350916426e2d854fa96f (diff)
downloadrockbox-bcbe317565f91f2f0f10186dfa32c8847f58df9f.tar.gz
rockbox-bcbe317565f91f2f0f10186dfa32c8847f58df9f.zip
r27225 broke AAC HE profile decoding due to missing check for buffersize. Introduce a check of needed buffersize and decide whether to use a static buffer from IRAM or faad's internal allocation routines.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27231 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/aac.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/apps/codecs/aac.c b/apps/codecs/aac.c
index 1daa7de11b..0c9aceed09 100644
--- a/apps/codecs/aac.c
+++ b/apps/codecs/aac.c
@@ -29,8 +29,9 @@ CODEC_HEADER
/* Global buffers to be used in the mdct synthesis. This way the arrays can
* be moved to IRAM for some targets */
-ALIGN real_t gb_time_buffer[2][1024] IBSS_ATTR_FAAD_LARGE_IRAM;
-ALIGN real_t gb_fb_intermed[2][1024] IBSS_ATTR_FAAD_LARGE_IRAM;
+#define GB_BUF_SIZE 1024
+ALIGN real_t gb_time_buffer[2][GB_BUF_SIZE] IBSS_ATTR_FAAD_LARGE_IRAM;
+ALIGN real_t gb_fb_intermed[2][GB_BUF_SIZE] IBSS_ATTR_FAAD_LARGE_IRAM;
/* this is the codec entry point */
enum codec_status codec_main(void)
@@ -51,6 +52,7 @@ enum codec_status codec_main(void)
int file_offset;
int framelength;
int lead_trim = 0;
+ int needed_bufsize;
unsigned int i;
unsigned char* buffer;
static NeAACDecFrameInfo frame_info;
@@ -113,11 +115,30 @@ next_track:
/* Set pointer to be able to use IRAM an to avoid alloc in decoder. Must
* be called after NeAACDecOpen(). */
- decoder->time_out[0] = &gb_time_buffer[0][0];
- decoder->time_out[1] = &gb_time_buffer[1][0];
- decoder->fb_intermed[0] = &gb_fb_intermed[0][0];
- decoder->fb_intermed[1] = &gb_fb_intermed[1][0];
-
+ /* A buffer of framelength or 2*frameLenght size must be allocated for
+ * time_out. If frameLength is too big or SBR/forceUpSampling is active,
+ * we do not use the IRAM buffer and keep faad's internal allocation (see
+ * specrec.c). */
+ needed_bufsize = decoder->frameLength;
+ if ((decoder->sbr_present_flag == 1) || (decoder->forceUpSampling == 1))
+ {
+ needed_bufsize *= 2;
+ }
+ if (needed_bufsize <= GB_BUF_SIZE)
+ {
+ decoder->time_out[0] = &gb_time_buffer[0][0];
+ decoder->time_out[1] = &gb_time_buffer[1][0];
+ }
+ /* A buffer of with frameLength elements must be allocated for fb_intermed.
+ * If frameLength is too big, we do not use the IRAM buffer and keep faad's
+ * internal allocation (see specrec.c). */
+ needed_bufsize = decoder->frameLength;
+ if (needed_bufsize <= GB_BUF_SIZE)
+ {
+ decoder->fb_intermed[0] = &gb_fb_intermed[0][0];
+ decoder->fb_intermed[1] = &gb_fb_intermed[1][0];
+ }
+
ci->id3->frequency = s;
i = 0;