All modes based on 2.5 ms short blocks now use the same definition

This commit is contained in:
Jean-Marc Valin 2010-07-16 15:55:30 -04:00
parent 69921c4cde
commit 3b0df0dc2a
2 changed files with 13 additions and 1 deletions

View file

@ -159,6 +159,8 @@ CELTEncoder *celt_encoder_create(const CELTMode *mode, int channels, int *error)
st->start = 0; st->start = 0;
st->end = st->mode->nbEBands; st->end = st->mode->nbEBands;
while (st->mode->eBands[st->end] > st->mode->shortMdctSize)
st->end--;
st->vbr_rate_norm = 0; st->vbr_rate_norm = 0;
st->pitch_enabled = 1; st->pitch_enabled = 1;
@ -1068,6 +1070,13 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, c
if (has_pitch) if (has_pitch)
apply_pitch(st->mode, freq, pitch_freq, gain_id, 0, C, M); apply_pitch(st->mode, freq, pitch_freq, gain_id, 0, C, M);
for (c=0;c<C;c++)
for (i=0;i<M*st->mode->eBands[st->start];i++)
freq[c*N+i] = 0;
for (c=0;c<C;c++)
for (i=M*st->mode->eBands[st->end];i<N;i++)
freq[c*N+i] = 0;
compute_inv_mdcts(st->mode, shortBlocks, freq, transient_time, transient_shift, st->out_mem, C, LM); compute_inv_mdcts(st->mode, shortBlocks, freq, transient_time, transient_shift, st->out_mem, C, LM);
/* De-emphasis and put everything back at the right place /* De-emphasis and put everything back at the right place
@ -1414,6 +1423,8 @@ CELTDecoder *celt_decoder_create(const CELTMode *mode, int channels, int *error)
st->start = 0; st->start = 0;
st->end = st->mode->nbEBands; st->end = st->mode->nbEBands;
while (st->mode->eBands[st->end] > st->mode->shortMdctSize)
st->end--;
st->decode_mem = (celt_sig*)celt_alloc((DECODE_BUFFER_SIZE+st->overlap)*C*sizeof(celt_sig)); st->decode_mem = (celt_sig*)celt_alloc((DECODE_BUFFER_SIZE+st->overlap)*C*sizeof(celt_sig));
st->out_mem = st->decode_mem+DECODE_BUFFER_SIZE-MAX_PERIOD; st->out_mem = st->decode_mem+DECODE_BUFFER_SIZE-MAX_PERIOD;

View file

@ -119,7 +119,8 @@ static celt_int16 *compute_ebands(celt_int32 Fs, int frame_size, int res, int *n
celt_int16 *eBands; celt_int16 *eBands;
int i, lin, low, high, nBark, offset=0; int i, lin, low, high, nBark, offset=0;
if (Fs == 400*(celt_int32)frame_size && Fs >= 40000) /* All modes that have 2.5 ms short blocks use the same definition */
if (Fs == 400*(celt_int32)frame_size)
{ {
*nbEBands = sizeof(eband5ms)/sizeof(eband5ms[0])-1; *nbEBands = sizeof(eband5ms)/sizeof(eband5ms[0])-1;
eBands = celt_alloc(sizeof(celt_int16)*(*nbEBands+2)); eBands = celt_alloc(sizeof(celt_int16)*(*nbEBands+2));