Fix stereo support; correctly deallocate bits_stereo.
This commit is contained in:
parent
60d0837ea0
commit
b6a3b0c464
2 changed files with 30 additions and 7 deletions
|
@ -355,9 +355,15 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, ce
|
||||||
int tell;
|
int tell;
|
||||||
int q;
|
int q;
|
||||||
celt_word16_t n;
|
celt_word16_t n;
|
||||||
|
celt_int16_t * const *BPbits;
|
||||||
|
|
||||||
int curr_balance, curr_bits;
|
int curr_balance, curr_bits;
|
||||||
|
|
||||||
|
if (C>1 && stereo_mode[i]==0)
|
||||||
|
BPbits = m->bits_stereo;
|
||||||
|
else
|
||||||
|
BPbits = m->bits;
|
||||||
|
|
||||||
tell = ec_enc_tell(enc, 4);
|
tell = ec_enc_tell(enc, 4);
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
balance -= tell;
|
balance -= tell;
|
||||||
|
@ -366,14 +372,14 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, ce
|
||||||
if (curr_balance > 3)
|
if (curr_balance > 3)
|
||||||
curr_balance = 3;
|
curr_balance = 3;
|
||||||
curr_balance = balance / curr_balance;
|
curr_balance = balance / curr_balance;
|
||||||
q = bits2pulses(m, m->bits[i], pulses[i]+curr_balance);
|
q = bits2pulses(m, BPbits[i], pulses[i]+curr_balance);
|
||||||
curr_bits = m->bits[i][q];
|
curr_bits = BPbits[i][q];
|
||||||
remaining_bits -= curr_bits;
|
remaining_bits -= curr_bits;
|
||||||
if (remaining_bits < 0)
|
if (remaining_bits < 0)
|
||||||
{
|
{
|
||||||
q--;
|
q--;
|
||||||
remaining_bits += curr_bits;
|
remaining_bits += curr_bits;
|
||||||
curr_bits = m->bits[i][q];
|
curr_bits = BPbits[i][q];
|
||||||
remaining_bits -= curr_bits;
|
remaining_bits -= curr_bits;
|
||||||
}
|
}
|
||||||
balance += pulses[i] + tell;
|
balance += pulses[i] + tell;
|
||||||
|
@ -434,9 +440,15 @@ void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P,
|
||||||
int tell;
|
int tell;
|
||||||
int q;
|
int q;
|
||||||
celt_word16_t n;
|
celt_word16_t n;
|
||||||
|
celt_int16_t * const *BPbits;
|
||||||
|
|
||||||
int curr_balance, curr_bits;
|
int curr_balance, curr_bits;
|
||||||
|
|
||||||
|
if (C>1 && stereo_mode[i]==0)
|
||||||
|
BPbits = m->bits_stereo;
|
||||||
|
else
|
||||||
|
BPbits = m->bits;
|
||||||
|
|
||||||
tell = ec_dec_tell(dec, 4);
|
tell = ec_dec_tell(dec, 4);
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
balance -= tell;
|
balance -= tell;
|
||||||
|
@ -445,14 +457,14 @@ void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P,
|
||||||
if (curr_balance > 3)
|
if (curr_balance > 3)
|
||||||
curr_balance = 3;
|
curr_balance = 3;
|
||||||
curr_balance = balance / curr_balance;
|
curr_balance = balance / curr_balance;
|
||||||
q = bits2pulses(m, m->bits[i], pulses[i]+curr_balance);
|
q = bits2pulses(m, BPbits[i], pulses[i]+curr_balance);
|
||||||
curr_bits = m->bits[i][q];
|
curr_bits = BPbits[i][q];
|
||||||
remaining_bits -= curr_bits;
|
remaining_bits -= curr_bits;
|
||||||
if (remaining_bits < 0)
|
if (remaining_bits < 0)
|
||||||
{
|
{
|
||||||
q--;
|
q--;
|
||||||
remaining_bits += curr_bits;
|
remaining_bits += curr_bits;
|
||||||
curr_bits = m->bits[i][q];
|
curr_bits = BPbits[i][q];
|
||||||
remaining_bits -= curr_bits;
|
remaining_bits -= curr_bits;
|
||||||
}
|
}
|
||||||
balance += pulses[i] + tell;
|
balance += pulses[i] + tell;
|
||||||
|
|
|
@ -394,7 +394,6 @@ CELTMode *celt_mode_create(celt_int32_t Fs, int channels, int frame_size, int *e
|
||||||
if (mode->nbChannels>=2)
|
if (mode->nbChannels>=2)
|
||||||
mode->bits_stereo = (const celt_int16_t **)compute_alloc_cache(mode, mode->nbChannels);
|
mode->bits_stereo = (const celt_int16_t **)compute_alloc_cache(mode, mode->nbChannels);
|
||||||
|
|
||||||
mode->bits_stereo = NULL;
|
|
||||||
#ifndef SHORTCUTS
|
#ifndef SHORTCUTS
|
||||||
psydecay_init(&mode->psy, MAX_PERIOD/2, mode->Fs);
|
psydecay_init(&mode->psy, MAX_PERIOD/2, mode->Fs);
|
||||||
#endif
|
#endif
|
||||||
|
@ -430,6 +429,18 @@ void celt_mode_destroy(CELTMode *mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
celt_free((int**)mode->bits);
|
celt_free((int**)mode->bits);
|
||||||
|
if (mode->bits_stereo != NULL)
|
||||||
|
{
|
||||||
|
for (i=0;i<mode->nbEBands;i++)
|
||||||
|
{
|
||||||
|
if (mode->bits_stereo[i] != prevPtr)
|
||||||
|
{
|
||||||
|
prevPtr = mode->bits_stereo[i];
|
||||||
|
celt_free((int*)mode->bits_stereo[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
celt_free((int**)mode->bits_stereo);
|
||||||
|
}
|
||||||
if (check_mode(mode) != CELT_OK)
|
if (check_mode(mode) != CELT_OK)
|
||||||
return;
|
return;
|
||||||
celt_free((int*)mode->eBands);
|
celt_free((int*)mode->eBands);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue