From dcf0f8de4a37ff1d2ea510aef75fa67977a8bdcc Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Tue, 26 Apr 2011 21:30:51 +0000 Subject: 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 --- apps/codecs/libfaad/decoder.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/codecs/libfaad/decoder.c b/apps/codecs/libfaad/decoder.c index c374ad3284..05d788597e 100644 --- a/apps/codecs/libfaad/decoder.c +++ b/apps/codecs/libfaad/decoder.c @@ -77,8 +77,9 @@ static int16_t s_lt_pred_stat[MAX_CHANNELS][4*FRAME_LEN] MEM_ALIGN_ATTR; /* static function declarations */ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, uint8_t *buffer, uint32_t buffer_size); +/* not used by rockbox static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo); - +*/ char* NEAACDECAPI NeAACDecGetErrorMessage(uint8_t errcode) { @@ -305,6 +306,12 @@ int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer, } #endif + /* A maximum of MAX_CHANNELS channels is supported. */ + if (*channels > MAX_CHANNELS) + { + return -1; + } + #ifdef SBR_DEC /* implicit signalling */ if (*samplerate <= 24000 && !(hDecoder->config.dontUpSampleImplicitSBR)) @@ -399,6 +406,13 @@ int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer, *channels = 2; } #endif + + /* A maximum of MAX_CHANNELS channels is supported. */ + if (*channels > MAX_CHANNELS) + { + return -1; + } + hDecoder->sf_index = mp4ASC.samplingFrequencyIndex; hDecoder->object_type = mp4ASC.objectTypeIndex; #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) { hInfo->num_front_channels = 0; @@ -724,6 +740,7 @@ static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hI } } } +#endif void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, @@ -882,7 +899,9 @@ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, #endif /* Make a channel configuration based on either a PCE or a channelConfiguration */ + /* not used by rockbox create_channel_config(hDecoder, hInfo); + */ /* number of samples in this frame */ hInfo->samples = frame_len*output_channels; -- cgit