From 4757bcce4f297c7e110fb006a337e249b2ff6161 Mon Sep 17 00:00:00 2001 From: Jin Cheng Date: Tue, 24 Mar 2026 12:10:37 +0800 Subject: [PATCH] fix(bt/bluedroid): fixed multiple high-severity issues from AI code review in SBC --- .../sbc/decoder/include/oi_codec_sbc.h | 6 +++-- .../external/sbc/decoder/srce/alloc.c | 1 - .../external/sbc/decoder/srce/bitalloc-sbc.c | 12 +++++++--- .../external/sbc/decoder/srce/bitalloc.c | 15 +++++------- .../sbc/decoder/srce/decoder-private.c | 23 ++++++++----------- .../external/sbc/decoder/srce/decoder-sbc.c | 2 +- .../external/sbc/decoder/srce/dequant.c | 4 ---- .../external/sbc/decoder/srce/framing-sbc.c | 6 ++--- .../sbc/decoder/srce/oi_codec_version.c | 4 ++-- .../external/sbc/encoder/include/sbc_dct.h | 6 ++--- .../sbc/encoder/include/sbc_encoder.h | 10 ++++---- .../sbc/encoder/srce/sbc_enc_bit_alloc_mono.c | 2 +- .../sbc/encoder/srce/sbc_enc_bit_alloc_ste.c | 6 ++--- 13 files changed, 47 insertions(+), 50 deletions(-) diff --git a/components/bt/host/bluedroid/external/sbc/decoder/include/oi_codec_sbc.h b/components/bt/host/bluedroid/external/sbc/decoder/include/oi_codec_sbc.h index 495fbf6b914..967c72515e7 100644 --- a/components/bt/host/bluedroid/external/sbc/decoder/include/oi_codec_sbc.h +++ b/components/bt/host/bluedroid/external/sbc/decoder/include/oi_codec_sbc.h @@ -372,7 +372,7 @@ OI_STATUS OI_CODEC_SBC_DecodeFrame(OI_CODEC_SBC_DECODER_CONTEXT *context, * * @param frameData Pointer to the SBC data. * - * @param frameBytes Number of bytes avaiable in the frameData buffer + * @param frameBytes Number of bytes available in the frameData buffer * */ OI_UINT8 OI_CODEC_SBC_FrameCount(OI_BYTE *frameData, @@ -447,7 +447,7 @@ OI_UINT16 OI_CODEC_SBC_CalculatePcmBytes(OI_CODEC_SBC_COMMON_CONTEXT *common); * @return pointer to text string containing codec version text * */ -OI_CHAR *OI_CODEC_Version(void); +const OI_CHAR *OI_CODEC_Version(void); /** @@ -457,11 +457,13 @@ OI_CHAR *OI_CODEC_Version(void); @{ */ +#ifdef OI_DEBUG extern const OI_CHAR *const OI_CODEC_SBC_FreqText[]; extern const OI_CHAR *const OI_CODEC_SBC_ModeText[]; extern const OI_CHAR *const OI_CODEC_SBC_SubbandsText[]; extern const OI_CHAR *const OI_CODEC_SBC_BlocksText[]; extern const OI_CHAR *const OI_CODEC_SBC_AllocText[]; +#endif /** @} diff --git a/components/bt/host/bluedroid/external/sbc/decoder/srce/alloc.c b/components/bt/host/bluedroid/external/sbc/decoder/srce/alloc.c index 3ce6dd7a461..39257b3a828 100644 --- a/components/bt/host/bluedroid/external/sbc/decoder/srce/alloc.c +++ b/components/bt/host/bluedroid/external/sbc/decoder/srce/alloc.c @@ -17,7 +17,6 @@ * ******************************************************************************/ #include "common/bt_target.h" -#include #include #if (defined(SBC_DEC_INCLUDED) && SBC_DEC_INCLUDED == TRUE) diff --git a/components/bt/host/bluedroid/external/sbc/decoder/srce/bitalloc-sbc.c b/components/bt/host/bluedroid/external/sbc/decoder/srce/bitalloc-sbc.c index 66521630dc8..9ebe21a19c8 100644 --- a/components/bt/host/bluedroid/external/sbc/decoder/srce/bitalloc-sbc.c +++ b/components/bt/host/bluedroid/external/sbc/decoder/srce/bitalloc-sbc.c @@ -25,7 +25,7 @@ @ingroup codec_internal */ -/**@addgroup codec_internal*/ +/**@addtogroup codec_internal*/ /**@{*/ #include "common/bt_target.h" #include @@ -78,7 +78,7 @@ static void stereoBitAllocation(OI_CODEC_SBC_COMMON_CONTEXT *common) } sbL = 0; sbR = nrof_subbands; - while (excess) { + while (excess && sbL < nrof_subbands) { excess = allocExcessBits(&common->bits.uint8[sbL], excess); ++sbL; if (!excess) { @@ -107,7 +107,9 @@ PRIVATE void OI_SBC_ComputeBitAllocation(OI_CODEC_SBC_COMMON_CONTEXT *common) * Using an array of function pointers prevents the compiler from creating a suboptimal * monolithic inlined bit allocation function. */ - balloc[common->frameInfo.mode](common); + if (common->frameInfo.mode < OI_ARRAYSIZE(balloc)) { + balloc[common->frameInfo.mode](common); + } } OI_UINT32 OI_CODEC_SBC_CalculateBitrate(OI_CODEC_SBC_FRAME_INFO *frame) @@ -137,6 +139,10 @@ OI_UINT16 OI_CODEC_SBC_CalculateBitpool(OI_CODEC_SBC_FRAME_INFO *frame, OI_UINT16 hdr; OI_UINT16 bits; + if ((frameLen <= SBC_HEADER_LEN) || (nrof_blocks == 0)) { + return 0; + } + if (frame->mode == SBC_JOINT_STEREO) { hdr = 9 * nrof_subbands; } else { diff --git a/components/bt/host/bluedroid/external/sbc/decoder/srce/bitalloc.c b/components/bt/host/bluedroid/external/sbc/decoder/srce/bitalloc.c index 105876dbb98..20d6ba8bde7 100644 --- a/components/bt/host/bluedroid/external/sbc/decoder/srce/bitalloc.c +++ b/components/bt/host/bluedroid/external/sbc/decoder/srce/bitalloc.c @@ -51,10 +51,11 @@ OI_UINT32 OI_SBC_MaxBitpool(OI_CODEC_SBC_FRAME_INFO *frame) case SBC_STEREO: case SBC_JOINT_STEREO: return 32 * frame->nrof_subbands; + default: + ERROR(("Invalid frame mode %d", frame->mode)); + OI_ASSERT(FALSE); } - ERROR(("Invalid frame mode %d", frame->mode)); - OI_ASSERT(FALSE); return 0; /* Should never be reached */ } @@ -102,10 +103,6 @@ INLINE OI_UINT16 OI_SBC_CalculateFrameAndHeaderlen(OI_CODEC_SBC_FRAME_INFO *fram return internal_CalculateFramelen(frame); } - -#define MIN(x, y) ((x) < (y) ? (x) : (y)) - - /* * Computes the bit need for each sample and as also returns a counts of bit needs that are greater * than one. This count is used in the first phase of bit allocation. @@ -242,7 +239,7 @@ OI_UINT computeBitneed(OI_CODEC_SBC_COMMON_CONTEXT *common, * * @param bitpool The bitpool we have to work within * - * @param bitneeds An array of bit needs (more acturately allocation prioritities) for each + * @param bitneeds An array of bit needs (more acturately allocation priorities) for each * subband across all blocks in the SBC frame * * @param subbands The number of subbands over which the adkustment is calculated. For mono and @@ -309,7 +306,7 @@ OI_INT adjustToFitBitpool(const OI_UINT bitpool, /* - * The bit allocator trys to avoid single bit allocations except as a last resort. So in the case + * The bit allocator tries to avoid single bit allocations except as a last resort. So in the case * where a bitneed of 1 was passed over during the adsjustment phase 2 bits are now allocated. */ INLINE OI_INT allocAdjustedBits(OI_UINT8 *dest, @@ -380,7 +377,7 @@ void oneChannelBitAllocation(OI_CODEC_SBC_COMMON_CONTEXT *common, ++sb; } sb = 0; - while (excess) { + while (excess && (sb < nrof_subbands)) { excess = allocExcessBits(&allocBits[sb], excess); ++sb; } diff --git a/components/bt/host/bluedroid/external/sbc/decoder/srce/decoder-private.c b/components/bt/host/bluedroid/external/sbc/decoder/srce/decoder-private.c index f198f579339..42f24da1aee 100644 --- a/components/bt/host/bluedroid/external/sbc/decoder/srce/decoder-private.c +++ b/components/bt/host/bluedroid/external/sbc/decoder/srce/decoder-private.c @@ -36,11 +36,11 @@ This file drives SBC decoding. #include "common/bt_target.h" #include "oi_codec_sbc_private.h" #include "oi_bitstream.h" -#include +#include #if (defined(SBC_DEC_INCLUDED) && SBC_DEC_INCLUDED == TRUE) -OI_CHAR *const OI_Codec_Copyright = "Copyright 2002-2007 Open Interface North America, Inc. All rights reserved"; +const OI_CHAR *const OI_Codec_Copyright = "Copyright 2002-2007 Open Interface North America, Inc. All rights reserved"; INLINE OI_STATUS internal_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_UINT32 *decoderData, @@ -50,12 +50,9 @@ INLINE OI_STATUS internal_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_BOOL enhanced, OI_BOOL msbc_enable) { - OI_UINT i; OI_STATUS status; - for (i = 0; i < sizeof(*context); i++) { - ((char *)context)[i] = 0; - } + memset(context, 0, sizeof(*context)); #ifdef SBC_ENHANCED context->enhancedEnabled = enhanced ? TRUE : FALSE; @@ -126,7 +123,7 @@ INLINE void OI_SBC_ReadHeader(OI_CODEC_SBC_COMMON_CONTEXT *common, const OI_BYTE return; } - /* Avoid filling out all these strucutures if we already remember the values + /* Avoid filling out all these structures if we already remember the values * from last time. Just in case we get a stream corresponding to data[1] == * 0, DecoderReset is responsible for ensuring the lookup table entries have * already been populated @@ -179,10 +176,10 @@ PRIVATE void OI_SBC_ReadScalefactors(OI_CODEC_SBC_COMMON_CONTEXT *common, common->frameInfo.join = 0; } i /= 2; - do { + while (i--) { *scale_factor++ = HIGH(f = *b++); *scale_factor++ = LOW(f); - } while (--i); + } /* * In this case we know that the scale factors end on a byte boundary so all we need to do * is initialize the bitstream. @@ -192,10 +189,10 @@ PRIVATE void OI_SBC_ReadScalefactors(OI_CODEC_SBC_COMMON_CONTEXT *common, OI_ASSERT(common->frameInfo.nrof_subbands == 4 && common->frameInfo.mode == SBC_JOINT_STEREO); common->frameInfo.join = HIGH(f = *b++); i = (i - 1) / 2; - do { + while(i--) { *scale_factor++ = LOW(f); *scale_factor++ = HIGH(f = *b++); - } while (--i); + } *scale_factor++ = LOW(f); /* * In 4-subband joint stereo mode, the joint stereo information ends on a half-byte @@ -218,7 +215,7 @@ PRIVATE void OI_SBC_ReadSamples(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_BITSTR OI_UINT bitPtr = global_bs->bitPtr; const OI_UINT iter_count = common->frameInfo.nrof_channels * common->frameInfo.nrof_subbands / 4; - do { + while (nrof_blocks--) { OI_UINT i; for (i = 0; i < iter_count; ++i) { OI_UINT32 sf_by4 = ((OI_UINT32 *)common->scale_factor)[i]; @@ -250,7 +247,7 @@ PRIVATE void OI_SBC_ReadSamples(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_BITSTR *s++ = dequant; } } - } while (--nrof_blocks); + } } /** diff --git a/components/bt/host/bluedroid/external/sbc/decoder/srce/decoder-sbc.c b/components/bt/host/bluedroid/external/sbc/decoder/srce/decoder-sbc.c index cb5ed049470..79750b0f10a 100644 --- a/components/bt/host/bluedroid/external/sbc/decoder/srce/decoder-sbc.c +++ b/components/bt/host/bluedroid/external/sbc/decoder/srce/decoder-sbc.c @@ -386,7 +386,7 @@ OI_UINT8 OI_CODEC_SBC_FrameCount(OI_BYTE *frameData, } /* Extract and translate required fields from Header */ - subbands = mode = blocks = frameData[1];; + subbands = mode = blocks = frameData[1]; mode = (mode & (BIT3 | BIT2)) >> 2; blocks = block_values[(blocks & (BIT5 | BIT4)) >> 4]; subbands = band_values[(subbands & BIT0)]; diff --git a/components/bt/host/bluedroid/external/sbc/decoder/srce/dequant.c b/components/bt/host/bluedroid/external/sbc/decoder/srce/dequant.c index d165c80a886..cddb6985eb2 100644 --- a/components/bt/host/bluedroid/external/sbc/decoder/srce/dequant.c +++ b/components/bt/host/bluedroid/external/sbc/decoder/srce/dequant.c @@ -104,10 +104,6 @@ #define SBC_DEQUANT_LONG_SCALED_OFFSET 1555931970 #endif -#ifndef SBC_DEQUANT_LONG_UNSCALED_OFFSET -#define SBC_DEQUANT_LONG_UNSCALED_OFFSET 2147483648 -#endif - #ifndef SBC_DEQUANT_SCALING_FACTOR #define SBC_DEQUANT_SCALING_FACTOR 1.38019122262781f #endif diff --git a/components/bt/host/bluedroid/external/sbc/decoder/srce/framing-sbc.c b/components/bt/host/bluedroid/external/sbc/decoder/srce/framing-sbc.c index 4f6056018c7..1aafb61dd6e 100644 --- a/components/bt/host/bluedroid/external/sbc/decoder/srce/framing-sbc.c +++ b/components/bt/host/bluedroid/external/sbc/decoder/srce/framing-sbc.c @@ -33,13 +33,13 @@ #if (defined(SBC_DEC_INCLUDED) && SBC_DEC_INCLUDED == TRUE) +#ifdef OI_DEBUG const OI_CHAR *const OI_CODEC_SBC_FreqText[] = { "SBC_FREQ_16000", "SBC_FREQ_32000", "SBC_FREQ_44100", "SBC_FREQ_48000" }; const OI_CHAR *const OI_CODEC_SBC_ModeText[] = { "SBC_MONO", "SBC_DUAL_CHANNEL", "SBC_STEREO", "SBC_JOINT_STEREO" }; const OI_CHAR *const OI_CODEC_SBC_SubbandsText[] = { "SBC_SUBBANDS_4", "SBC_SUBBANDS_8" }; const OI_CHAR *const OI_CODEC_SBC_BlocksText[] = { "SBC_BLOCKS_4", "SBC_BLOCKS_8", "SBC_BLOCKS_12", "SBC_BLOCKS_16" }; const OI_CHAR *const OI_CODEC_SBC_AllocText[] = { "SBC_LOUDNESS", "SBC_SNR" }; -#ifdef OI_DEBUG void OI_CODEC_SBC_DumpConfig(OI_CODEC_SBC_FRAME_INFO *frameInfo) { printf("SBC configuration\n"); @@ -48,8 +48,8 @@ void OI_CODEC_SBC_DumpConfig(OI_CODEC_SBC_FRAME_INFO *frameInfo) printf(" subbands: %d\n", frameInfo->nrof_subbands); printf(" blocks: %d\n", frameInfo->nrof_blocks); printf(" channels: %d\n", frameInfo->nrof_channels); - printf(" mode: %s\n", OI_CODEC_SBC_ModeText[frameInfo->mode]); - printf(" alloc: %s\n", OI_CODEC_SBC_AllocText[frameInfo->alloc]); + printf(" mode: %s\n", (frameInfo->mode < 4) ? OI_CODEC_SBC_ModeText[frameInfo->mode] : "INVALID"); + printf(" alloc: %s\n", (frameInfo->alloc < 2) ? OI_CODEC_SBC_AllocText[frameInfo->alloc] : "INVALID"); printf(" bitpool: %d\n", frameInfo->bitpool); } #endif /* OI_DEBUG */ diff --git a/components/bt/host/bluedroid/external/sbc/decoder/srce/oi_codec_version.c b/components/bt/host/bluedroid/external/sbc/decoder/srce/oi_codec_version.c index 95f8883016e..97b49bc6497 100644 --- a/components/bt/host/bluedroid/external/sbc/decoder/srce/oi_codec_version.c +++ b/components/bt/host/bluedroid/external/sbc/decoder/srce/oi_codec_version.c @@ -39,7 +39,7 @@ version number of the eSBC codec #if (defined(SBC_DEC_INCLUDED) && SBC_DEC_INCLUDED == TRUE) /** Version string for the BLUEmagic 3.0 protocol stack and profiles */ -PRIVATE OI_CHAR *const codecVersion = "v1.5" +PRIVATE const OI_CHAR *const codecVersion = "v1.5" #ifdef OI_SBC_EVAL " (Evaluation version)" #endif @@ -47,7 +47,7 @@ PRIVATE OI_CHAR *const codecVersion = "v1.5" /** This function returns the version string for the BLUEmagic 3.0 protocol stack and profiles */ -OI_CHAR *OI_CODEC_Version(void) +const OI_CHAR *OI_CODEC_Version(void) { return codecVersion; } diff --git a/components/bt/host/bluedroid/external/sbc/encoder/include/sbc_dct.h b/components/bt/host/bluedroid/external/sbc/encoder/include/sbc_dct.h index 165a8c1cd97..3efdee996e6 100644 --- a/components/bt/host/bluedroid/external/sbc/encoder/include/sbc_dct.h +++ b/components/bt/host/bluedroid/external/sbc/encoder/include/sbc_dct.h @@ -30,7 +30,7 @@ { \ __asm \ { \ - MUL s32OutLow,(SINT32)s16In2, (s32In1>>15) \ + MUL s32OutLow,(SINT32)s16In2, (s32In1>>15) \ } \ } #else @@ -43,8 +43,8 @@ #if (SBC_IS_64_MULT_IN_IDCT == TRUE) #define SBC_MULT_32_32(s32In2, s32In1, s32OutLow) \ { \ - s64Temp = ((SINT64) s32In2) * ((SINT64) s32In1)>>31; \ - s32OutLow = (SINT32) s64Temp; \ + s64Temp = ((SINT64) s32In2) * ((SINT64) s32In1)>>31; \ + s32OutLow = (SINT32) s64Temp; \ } #endif #else diff --git a/components/bt/host/bluedroid/external/sbc/encoder/include/sbc_encoder.h b/components/bt/host/bluedroid/external/sbc/encoder/include/sbc_encoder.h index b7b807f536b..80e9679606a 100644 --- a/components/bt/host/bluedroid/external/sbc/encoder/include/sbc_encoder.h +++ b/components/bt/host/bluedroid/external/sbc/encoder/include/sbc_encoder.h @@ -103,26 +103,26 @@ #endif /* Set SBC_IPAQ_OPT to TRUE in case the target is an ARM */ -/* 32 and 64 bit mult will be performed using SINT64 ( usualy __int64 ) cast that usualy give optimal performance if supported */ +/* 32 and 64 bit mult will be performed using SINT64 ( usually __int64 ) cast that usually give optimal performance if supported */ #ifndef SBC_IPAQ_OPT #define SBC_IPAQ_OPT TRUE #endif /* Debug only: set SBC_IS_64_MULT_IN_WINDOW_ACCU to TRUE to use 64 bit multiplication in the windowing */ -/* -> not recomended, more MIPS for the same restitution. */ +/* -> not recommended, more MIPS for the same restitution. */ #ifndef SBC_IS_64_MULT_IN_WINDOW_ACCU #define SBC_IS_64_MULT_IN_WINDOW_ACCU FALSE #endif /*SBC_IS_64_MULT_IN_WINDOW_ACCU */ /* Set SBC_IS_64_MULT_IN_IDCT to TRUE to use 64 bits multiplication in the DCT of Matrixing */ -/* -> more MIPS required for a better audio quality. comparasion with the SIG utilities shows a division by 10 of the RMS */ +/* -> more MIPS required for a better audio quality. comparison with the SIG utilities shows a division by 10 of the RMS */ /* CAUTION: It only apply in the if SBC_FAST_DCT is set to TRUE */ #ifndef SBC_IS_64_MULT_IN_IDCT #define SBC_IS_64_MULT_IN_IDCT FALSE #endif /*SBC_IS_64_MULT_IN_IDCT */ /* set SBC_IS_64_MULT_IN_QUANTIZER to TRUE to use 64 bits multiplication in the quantizer */ -/* setting this flag to FALSE add whistling noise at 5.5 and 11 KHz usualy not perceptible by human's hears. */ +/* setting this flag to FALSE add whistling noise at 5.5 and 11 KHz usually not perceptible by human's hears. */ #ifndef SBC_IS_64_MULT_IN_QUANTIZER #define SBC_IS_64_MULT_IN_QUANTIZER TRUE #endif /*SBC_IS_64_MULT_IN_IDCT */ @@ -183,7 +183,7 @@ typedef struct SBC_ENC_PARAMS_TAG { SINT16 as16PcmBuffer[SBC_MAX_NUM_FRAME * SBC_MAX_NUM_OF_BLOCKS * SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS]; #endif - SINT16 s16ScartchMemForBitAlloc[16]; + SINT16 s16ScratchMemForBitAlloc[16]; SINT32 s32SbBuffer[SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS * SBC_MAX_NUM_OF_BLOCKS]; diff --git a/components/bt/host/bluedroid/external/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c b/components/bt/host/bluedroid/external/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c index 5f10819bc0e..ab8c5eafa8f 100644 --- a/components/bt/host/bluedroid/external/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c +++ b/components/bt/host/bluedroid/external/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c @@ -62,7 +62,7 @@ void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *pstrCodecParams) SINT16 *ps16GenTabPtr; SINT32 s32NumOfSubBands = pstrCodecParams->s16NumOfSubBands; - ps16BitNeed = pstrCodecParams->s16ScartchMemForBitAlloc; + ps16BitNeed = pstrCodecParams->s16ScratchMemForBitAlloc; for (s32Ch = 0; s32Ch < pstrCodecParams->s16NumOfChannels; s32Ch++) { ps16GenBufPtr = ps16BitNeed + s32Ch * s32NumOfSubBands; diff --git a/components/bt/host/bluedroid/external/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c b/components/bt/host/bluedroid/external/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c index 0ef8e7839d2..4aa668adc8b 100644 --- a/components/bt/host/bluedroid/external/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c +++ b/components/bt/host/bluedroid/external/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c @@ -43,11 +43,11 @@ extern const SINT16 sbc_enc_as16Offset8[4][8]; void sbc_enc_bit_alloc_ste(SBC_ENC_PARAMS *pstrCodecParams) { - /* CAUTIOM -> mips optim for arm 32 require to use SINT32 instead of SINT16 */ + /* CAUTION -> mips optim for arm 32 require to use SINT32 instead of SINT16 */ /* Do not change variable type or name */ SINT32 s32MaxBitNeed; /*to store the max bits needed per sb*/ SINT32 s32BitCount; /*the used number of bits*/ - SINT32 s32SliceCount; /*to store hwo many slices can be put in bitpool*/ + SINT32 s32SliceCount; /*to store how many slices can be put in bitpool*/ SINT32 s32BitSlice; /*number of bitslices in bitpool*/ SINT32 s32Sb; /*counter for sub-band*/ SINT32 s32Ch; /*counter for channel*/ @@ -64,7 +64,7 @@ void sbc_enc_bit_alloc_ste(SBC_ENC_PARAMS *pstrCodecParams) ps16BitNeed = pstrCodecParams->as16ScaleFactor; s32MaxBitNeed = pstrCodecParams->s16MaxBitNeed; } else { - ps16BitNeed = pstrCodecParams->s16ScartchMemForBitAlloc; + ps16BitNeed = pstrCodecParams->s16ScratchMemForBitAlloc; pas16ScaleFactor = pstrCodecParams->as16ScaleFactor; s32MaxBitNeed = 0; ps16GenBufPtr = ps16BitNeed;