Fixes some minor issues found by scan build

This commit is contained in:
Jean-Marc Valin 2013-11-09 18:28:40 -05:00
parent a599ccd217
commit ca6fac041b
6 changed files with 9 additions and 12 deletions

View file

@ -492,7 +492,7 @@ int spreading_decision(const CELTMode *m, celt_norm *X, int *average,
*tapset_decision=0;
}
/*printf("%d %d %d\n", hf_sum, *hf_average, *tapset_decision);*/
celt_assert(nbBands>0); /*M*(eBands[end]-eBands[end-1]) <= 8 assures this*/
celt_assert(nbBands>0); /* end has to be non-zero */
sum /= nbBands;
/* Recursive averaging */
sum = (sum+*average)>>1;
@ -869,7 +869,6 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X,
int q;
int curr_bits;
int imid=0, iside=0;
int N_B=N;
int B0=B;
opus_val16 mid=0, side=0;
unsigned cm=0;
@ -891,8 +890,6 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X,
spread = ctx->spread;
ec = ctx->ec;
N_B /= B;
/* If we need 1.5 more bit than we can produce, split the band in two. */
cache = m->cache.bits + m->cache.index[(LM+1)*m->nbEBands+i];
if (LM != -1 && b > cache[cache[0]]+12 && N>2)
@ -1072,7 +1069,6 @@ static unsigned quant_band(struct band_ctx *ctx, celt_norm *X,
longBlocks = B0==1;
N_B /= B;
N_B0 = N_B;
/* Special case for one sample */
if (N==1)

View file

@ -240,7 +240,6 @@ static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int
ALLOC(tmp, len, opus_val16);
len2=len/2;
tf_max = 0;
for (c=0;c<C;c++)
{
opus_val32 mean;

View file

@ -95,6 +95,8 @@
#define SAVE_STACK
#define RESTORE_STACK
#define ALLOC_STACK
/* C99 does not allow VLAs of size zero */
#define ALLOC_NONE 1
#elif defined(USE_ALLOCA)
@ -109,6 +111,7 @@
#define SAVE_STACK
#define RESTORE_STACK
#define ALLOC_STACK
#define ALLOC_NONE 0
#else
@ -146,6 +149,7 @@ extern char *global_stack_top;
#define VARDECL(type, var) type *var
#define ALLOC(var, size, type) var = PUSH(global_stack, size, type)
#define SAVE_STACK char *_saved_stack = global_stack;
#define ALLOC_NONE 0
#endif /* VAR_ARRAYS */

View file

@ -305,7 +305,7 @@ opus_int silk_Decode( /* O Returns error co
/* Set up pointers to temp buffers */
ALLOC( samplesOut2_tmp,
decControl->nChannelsAPI == 2 ? *nSamplesOut : 0, opus_int16 );
decControl->nChannelsAPI == 2 ? *nSamplesOut : ALLOC_NONE, opus_int16 );
if( decControl->nChannelsAPI == 2 ) {
resample_out_ptr = samplesOut2_tmp;
} else {

View file

@ -317,7 +317,6 @@ void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info_out, con
}
relativeE = 0;
frame_loudness = 0;
bandwidth_mask = 0;
for (b=0;b<NB_TBANDS;b++)
{
float E=0, tE=0, nE=0;
@ -597,7 +596,6 @@ void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info_out, con
if (tonal->speech_confidence_count==0)
tonal->speech_confidence = .1f;
}
psum = MAX16(tonal->speech_confidence, MIN16(tonal->music_confidence, psum));
}
if (tonal->last_music != (tonal->music_prob>.5f))
tonal->last_transition=0;

View file

@ -297,8 +297,8 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
}
}
pcm_transition_silk_size = 0;
pcm_transition_celt_size = 0;
pcm_transition_silk_size = ALLOC_NONE;
pcm_transition_celt_size = ALLOC_NONE;
if (data!=NULL && st->prev_mode > 0 && (
(mode == MODE_CELT_ONLY && st->prev_mode != MODE_CELT_ONLY && !st->prev_redundancy)
|| (mode != MODE_CELT_ONLY && st->prev_mode == MODE_CELT_ONLY) )
@ -327,7 +327,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
}
/* Don't allocate any memory when in CELT-only mode */
pcm_silk_size = (mode != MODE_CELT_ONLY) ? IMAX(F10, frame_size)*st->channels : 0;
pcm_silk_size = (mode != MODE_CELT_ONLY) ? IMAX(F10, frame_size)*st->channels : ALLOC_NONE;
ALLOC(pcm_silk, pcm_silk_size, opus_int16);
/* SILK processing */