forked from len0rd/rockbox
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
This commit is contained in:
parent
f58174f7cc
commit
bcbe317565
1 changed files with 28 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue