Dynamically selecting intra energy based on energy variations from the previous

frame
This commit is contained in:
Jean-Marc Valin 2009-05-01 21:28:58 -04:00
parent 18a3b79d24
commit 32ec58cc3e
3 changed files with 25 additions and 6 deletions

View file

@ -536,6 +536,17 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
shortBlocks = 0;
}
ALLOC(freq, C*N, celt_sig_t); /**< Interleaved signal MDCTs */
ALLOC(bandE,st->mode->nbEBands*C, celt_ener_t);
/* Compute MDCTs */
compute_mdcts(st->mode, shortBlocks, in, freq);
compute_band_energies(st->mode, freq, bandE);
if (intra_decision(bandE, st->oldBandE, st->mode->nbEBands) || shortBlocks)
intra_ener = 1;
else
intra_ener = 0;
/* Pitch analysis: we do it early to save on the peak stack space */
/* Don't use pitch if there isn't enough data available yet, or if we're using shortBlocks */
has_pitch = st->pitch_enabled && (st->pitch_available >= MAX_PERIOD) && (!shortBlocks) && !intra_ener;
@ -553,10 +564,6 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
find_spectral_pitch(st->mode, st->mode->fft, &st->mode->psy, in, st->out_mem, st->mode->window, NULL, 2*N-2*N4, MAX_PERIOD-(2*N-2*N4), &pitch_index);
}
#endif
ALLOC(freq, C*N, celt_sig_t); /**< Interleaved signal MDCTs */
/* Compute MDCTs */
compute_mdcts(st->mode, shortBlocks, in, freq);
#ifdef EXP_PSY
ALLOC(mask, N, celt_sig_t);
@ -569,12 +576,10 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
/* Deferred allocation after find_spectral_pitch() to reduce the peak memory usage */
ALLOC(X, C*N, celt_norm_t); /**< Interleaved normalised MDCTs */
ALLOC(P, C*N, celt_norm_t); /**< Interleaved normalised pitch MDCTs*/
ALLOC(bandE,st->mode->nbEBands*C, celt_ener_t);
ALLOC(gains,st->mode->nbPBands, celt_pgain_t);
/* Band normalisation */
compute_band_energies(st->mode, freq, bandE);
normalise_bands(st->mode, freq, X, bandE);
#ifdef EXP_PSY