enabling denorm pitch only at low bit-rate

This commit is contained in:
Jean-Marc Valin 2009-09-16 07:57:17 -04:00
parent 00fb6b0765
commit 92ae37027f
3 changed files with 22 additions and 13 deletions

View file

@ -523,6 +523,7 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
int mdct_weight_shift = 0;
int mdct_weight_pos=0;
int gain_id=0;
int norm_rate;
SAVE_STACK;
if (check_encoder(st) != CELT_OK)
@ -659,15 +660,13 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
#endif
}
compute_band_energies(st->mode, freq, bandE);
for (i=0;i<st->mode->nbEBands*C;i++)
bandLogE[i] = amp2Log(bandE[i]);
norm_rate = (nbCompressedBytes-5)*8*(celt_uint32_t)st->mode->Fs/(C*N)>>10;
/* 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_permitted && (N <= 512)
&& (st->pitch_available >= MAX_PERIOD) && (!shortBlocks);
&& (st->pitch_available >= MAX_PERIOD) && (!shortBlocks)
&& norm_rate < 50;
if (has_pitch)
{
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);
@ -682,8 +681,9 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
ALLOC(pitch_freq, C*N, celt_sig_t); /**< Interleaved signal MDCTs */
if (has_pitch)
{
compute_mdcts(st->mode, 0, st->out_mem+pitch_index*C, pitch_freq);
has_pitch = compute_new_pitch(st->mode, freq, pitch_freq, &gain_id);
has_pitch = compute_new_pitch(st->mode, freq, pitch_freq, norm_rate, &gain_id);
}
if (has_pitch)