Submit FS#12081. Check validity of channel configuration, comment unneeded code that is too inflexible to work with MAX_CHANNELS = 2. Fixes compiler warnings with GCC 4.6.0.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29784 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andree Buschmann 2011-04-26 21:30:51 +00:00
parent 05c3290608
commit dcf0f8de4a

View file

@ -77,8 +77,9 @@ static int16_t s_lt_pred_stat[MAX_CHANNELS][4*FRAME_LEN] MEM_ALIGN_ATTR;
/* static function declarations */ /* static function declarations */
static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
uint8_t *buffer, uint32_t buffer_size); uint8_t *buffer, uint32_t buffer_size);
/* not used by rockbox
static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo); static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo);
*/
char* NEAACDECAPI NeAACDecGetErrorMessage(uint8_t errcode) char* NEAACDECAPI NeAACDecGetErrorMessage(uint8_t errcode)
{ {
@ -305,6 +306,12 @@ int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer,
} }
#endif #endif
/* A maximum of MAX_CHANNELS channels is supported. */
if (*channels > MAX_CHANNELS)
{
return -1;
}
#ifdef SBR_DEC #ifdef SBR_DEC
/* implicit signalling */ /* implicit signalling */
if (*samplerate <= 24000 && !(hDecoder->config.dontUpSampleImplicitSBR)) if (*samplerate <= 24000 && !(hDecoder->config.dontUpSampleImplicitSBR))
@ -399,6 +406,13 @@ int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer,
*channels = 2; *channels = 2;
} }
#endif #endif
/* A maximum of MAX_CHANNELS channels is supported. */
if (*channels > MAX_CHANNELS)
{
return -1;
}
hDecoder->sf_index = mp4ASC.samplingFrequencyIndex; hDecoder->sf_index = mp4ASC.samplingFrequencyIndex;
hDecoder->object_type = mp4ASC.objectTypeIndex; hDecoder->object_type = mp4ASC.objectTypeIndex;
#ifdef ERROR_RESILIENCE #ifdef ERROR_RESILIENCE
@ -520,6 +534,8 @@ void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, int32_t frame)
} }
} }
/* not used by rockbox */
#if 0
static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo) static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo)
{ {
hInfo->num_front_channels = 0; hInfo->num_front_channels = 0;
@ -724,6 +740,7 @@ static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hI
} }
} }
} }
#endif
void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder, void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
NeAACDecFrameInfo *hInfo, NeAACDecFrameInfo *hInfo,
@ -882,7 +899,9 @@ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
#endif #endif
/* Make a channel configuration based on either a PCE or a channelConfiguration */ /* Make a channel configuration based on either a PCE or a channelConfiguration */
/* not used by rockbox
create_channel_config(hDecoder, hInfo); create_channel_config(hDecoder, hInfo);
*/
/* number of samples in this frame */ /* number of samples in this frame */
hInfo->samples = frame_len*output_channels; hInfo->samples = frame_len*output_channels;