Cleanup: getting rid of some old bits of stereo code that are no longer useful

This commit is contained in:
Jean-Marc Valin 2009-03-29 22:29:27 -04:00
parent ca53b7c919
commit d27e6e34a5
6 changed files with 43 additions and 134 deletions

View file

@ -282,19 +282,19 @@ static void dup_band(celt_norm_t * restrict X, int len)
} }
} }
static void stereo_band_mix(const CELTMode *m, celt_norm_t *X, const celt_ener_t *bank, const int *stereo_mode, int bandID, int dir) static void stereo_band_mix(const CELTMode *m, celt_norm_t *X, const celt_ener_t *bank, int stereo_mode, int bandID, int dir)
{ {
int i = bandID; int i = bandID;
const celt_int16_t *eBands = m->eBands; const celt_int16_t *eBands = m->eBands;
const int C = CHANNELS(m); const int C = CHANNELS(m);
{ {
int j; int j;
if (stereo_mode[i] && dir <0) if (stereo_mode && dir <0)
{ {
dup_band(X+C*eBands[i], eBands[i+1]-eBands[i]); dup_band(X+C*eBands[i], eBands[i+1]-eBands[i]);
} else { } else {
celt_word16_t a1, a2; celt_word16_t a1, a2;
if (stereo_mode[i]==0) if (stereo_mode==0)
{ {
/* Do mid-side when not doing intensity stereo */ /* Do mid-side when not doing intensity stereo */
a1 = QCONST16(.70711f,14); a1 = QCONST16(.70711f,14);
@ -320,7 +320,7 @@ static void stereo_band_mix(const CELTMode *m, celt_norm_t *X, const celt_ener_t
X[j*C+1] = MULT16_16_Q14(a1,r) - MULT16_16_Q14(a2,l); X[j*C+1] = MULT16_16_Q14(a1,r) - MULT16_16_Q14(a2,l);
} }
} }
if (stereo_mode[i] && dir>0) if (stereo_mode && dir>0)
{ {
intensity_band(X+C*eBands[i], eBands[i+1]-eBands[i]); intensity_band(X+C*eBands[i], eBands[i+1]-eBands[i]);
} }
@ -398,20 +398,18 @@ void deinterleave(celt_norm_t *x, int N)
} }
/* Quantisation of the residual */ /* Quantisation of the residual */
void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, celt_mask_t *W, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, const int *stereo_mode, int *pulses, int shortBlocks, int fold, int total_bits, ec_enc *enc) void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, celt_mask_t *W, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_enc *enc)
{ {
int i, j, remaining_bits, balance; int i, j, remaining_bits, balance;
const celt_int16_t * restrict eBands = m->eBands; const celt_int16_t * restrict eBands = m->eBands;
celt_norm_t * restrict norm; celt_norm_t * restrict norm;
VARDECL(celt_norm_t, _norm); VARDECL(celt_norm_t, _norm); const celt_int16_t *pBands = m->pBands;
const int C = CHANNELS(m);
const celt_int16_t *pBands = m->pBands;
int pband=-1; int pband=-1;
int B; int B;
SAVE_STACK; SAVE_STACK;
B = shortBlocks ? m->nbShortMdcts : 1; B = shortBlocks ? m->nbShortMdcts : 1;
ALLOC(_norm, C*eBands[m->nbEBands+1], celt_norm_t); ALLOC(_norm, eBands[m->nbEBands+1], celt_norm_t);
norm = _norm; norm = _norm;
balance = 0; balance = 0;
@ -429,9 +427,6 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, ce
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; BPbits = m->bits;
tell = ec_enc_tell(enc, 4); tell = ec_enc_tell(enc, 4);
@ -454,7 +449,7 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, ce
} }
balance += pulses[i] + tell; balance += pulses[i] + tell;
n = SHL16(celt_sqrt(C*(eBands[i+1]-eBands[i])),11); n = SHL16(celt_sqrt(eBands[i+1]-eBands[i]),11);
/* If pitch is in use and this eBand begins a pitch band, encode the pitch gain flag */ /* If pitch is in use and this eBand begins a pitch band, encode the pitch gain flag */
if (pitch_used && eBands[i]< m->pitchEnd && eBands[i] == pBands[pband+1]) if (pitch_used && eBands[i]< m->pitchEnd && eBands[i] == pBands[pband+1])
@ -475,39 +470,29 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, ce
/* If pitch isn't available, use intra-frame prediction */ /* If pitch isn't available, use intra-frame prediction */
if ((eBands[i] >= m->pitchEnd && fold) || q<=0) if ((eBands[i] >= m->pitchEnd && fold) || q<=0)
{ {
intra_fold(m, X+C*eBands[i], eBands[i+1]-eBands[i], q, norm, P+C*eBands[i], eBands[i], B); intra_fold(m, X+eBands[i], eBands[i+1]-eBands[i], q, norm, P+eBands[i], eBands[i], B);
} else if (pitch_used && eBands[i] < m->pitchEnd) { } else if (pitch_used && eBands[i] < m->pitchEnd) {
for (j=C*eBands[i];j<C*eBands[i+1];j++) for (j=eBands[i];j<eBands[i+1];j++)
P[j] = MULT16_16_Q15(pgains[pband], P[j]); P[j] = MULT16_16_Q15(pgains[pband], P[j]);
} else { } else {
for (j=C*eBands[i];j<C*eBands[i+1];j++) for (j=eBands[i];j<eBands[i+1];j++)
P[j] = 0; P[j] = 0;
} }
if (q > 0) if (q > 0)
{ {
int ch=C; alg_quant(X+eBands[i], W+eBands[i], eBands[i+1]-eBands[i], q, P+eBands[i], enc);
if (C==2 && stereo_mode[i]==1)
ch = 1;
if (C==2)
{
stereo_band_mix(m, X, bandE, stereo_mode, i, 1);
stereo_band_mix(m, P, bandE, stereo_mode, i, 1);
}
alg_quant(X+C*eBands[i], W+C*eBands[i], ch*(eBands[i+1]-eBands[i]), q, P+C*eBands[i], enc);
if (C==2)
stereo_band_mix(m, X, bandE, stereo_mode, i, -1);
} else { } else {
for (j=C*eBands[i];j<C*eBands[i+1];j++) for (j=eBands[i];j<eBands[i+1];j++)
X[j] = P[j]; X[j] = P[j];
} }
for (j=C*eBands[i];j<C*eBands[i+1];j++) for (j=eBands[i];j<eBands[i+1];j++)
norm[j] = MULT16_16_Q15(n,X[j]); norm[j] = MULT16_16_Q15(n,X[j]);
} }
RESTORE_STACK; RESTORE_STACK;
} }
void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, celt_mask_t *W, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, const int *stereo_mode, int *pulses, int shortBlocks, int fold, int total_bits, ec_enc *enc) void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, celt_mask_t *W, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_enc *enc)
{ {
int i, j, remaining_bits, balance; int i, j, remaining_bits, balance;
const celt_int16_t * restrict eBands = m->eBands; const celt_int16_t * restrict eBands = m->eBands;
@ -627,7 +612,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t
if (qb==0) if (qb==0)
point_stereo_mix(m, X, bandE, i, 1); point_stereo_mix(m, X, bandE, i, 1);
else else
stereo_band_mix(m, X, bandE, stereo_mode, i, 1); stereo_band_mix(m, X, bandE, 0, i, 1);
mid = renormalise_vector(X+C*eBands[i], Q15ONE, N, C); mid = renormalise_vector(X+C*eBands[i], Q15ONE, N, C);
side = renormalise_vector(X+C*eBands[i]+1, Q15ONE, N, C); side = renormalise_vector(X+C*eBands[i]+1, Q15ONE, N, C);
@ -713,7 +698,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t
if (qb==0) if (qb==0)
point_stereo_mix(m, P, bandE, i, 1); point_stereo_mix(m, P, bandE, i, 1);
else else
stereo_band_mix(m, P, bandE, stereo_mode, i, 1); stereo_band_mix(m, P, bandE, 0, i, 1);
deinterleave(P+C*eBands[i], C*N); deinterleave(P+C*eBands[i], C*N);
/*for (j=C*eBands[i];j<C*eBands[i+1];j++) /*for (j=C*eBands[i];j<C*eBands[i+1];j++)
@ -722,7 +707,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t
if (qb==0) if (qb==0)
point_stereo_mix(m, P, bandE, i, 1); point_stereo_mix(m, P, bandE, i, 1);
else else
stereo_band_mix(m, P, bandE, stereo_mode, i, 1); stereo_band_mix(m, P, bandE, 0, i, 1);
renormalise_vector(P+C*eBands[i], Q15ONE, N, C); renormalise_vector(P+C*eBands[i], Q15ONE, N, C);
renormalise_vector(P+C*eBands[i]+1, Q15ONE, N, C); renormalise_vector(P+C*eBands[i]+1, Q15ONE, N, C);
deinterleave(P+C*eBands[i], C*N); deinterleave(P+C*eBands[i], C*N);
@ -760,7 +745,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t
interleave(X+C*eBands[i], C*N); interleave(X+C*eBands[i], C*N);
stereo_band_mix(m, X, bandE, stereo_mode, i, -1); stereo_band_mix(m, X, bandE, 0, i, -1);
renormalise_vector(X+C*eBands[i], Q15ONE, N, C); renormalise_vector(X+C*eBands[i], Q15ONE, N, C);
renormalise_vector(X+C*eBands[i]+1, Q15ONE, N, C); renormalise_vector(X+C*eBands[i]+1, Q15ONE, N, C);
for (j=0;j<C*N;j++) for (j=0;j<C*N;j++)
@ -771,20 +756,19 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t
} }
/* Decoding of the residual */ /* Decoding of the residual */
void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, const int *stereo_mode, int *pulses, int shortBlocks, int fold, int total_bits, ec_dec *dec) void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_dec *dec)
{ {
int i, j, remaining_bits, balance; int i, j, remaining_bits, balance;
const celt_int16_t * restrict eBands = m->eBands; const celt_int16_t * restrict eBands = m->eBands;
celt_norm_t * restrict norm; celt_norm_t * restrict norm;
VARDECL(celt_norm_t, _norm); VARDECL(celt_norm_t, _norm);
const int C = CHANNELS(m);
const celt_int16_t *pBands = m->pBands; const celt_int16_t *pBands = m->pBands;
int pband=-1; int pband=-1;
int B; int B;
SAVE_STACK; SAVE_STACK;
B = shortBlocks ? m->nbShortMdcts : 1; B = shortBlocks ? m->nbShortMdcts : 1;
ALLOC(_norm, C*eBands[m->nbEBands+1], celt_norm_t); ALLOC(_norm, eBands[m->nbEBands+1], celt_norm_t);
norm = _norm; norm = _norm;
balance = 0; balance = 0;
@ -797,9 +781,6 @@ void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P,
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; BPbits = m->bits;
tell = ec_dec_tell(dec, 4); tell = ec_dec_tell(dec, 4);
@ -822,7 +803,7 @@ void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P,
} }
balance += pulses[i] + tell; balance += pulses[i] + tell;
n = SHL16(celt_sqrt(C*(eBands[i+1]-eBands[i])),11); n = SHL16(celt_sqrt(eBands[i+1]-eBands[i]),11);
/* If pitch is in use and this eBand begins a pitch band, encode the pitch gain flag */ /* If pitch is in use and this eBand begins a pitch band, encode the pitch gain flag */
if (pitch_used && eBands[i] < m->pitchEnd && eBands[i] == pBands[pband+1]) if (pitch_used && eBands[i] < m->pitchEnd && eBands[i] == pBands[pband+1])
@ -842,36 +823,29 @@ void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P,
/* If pitch isn't available, use intra-frame prediction */ /* If pitch isn't available, use intra-frame prediction */
if ((eBands[i] >= m->pitchEnd && fold) || q<=0) if ((eBands[i] >= m->pitchEnd && fold) || q<=0)
{ {
intra_fold(m, X+C*eBands[i], eBands[i+1]-eBands[i], q, norm, P+C*eBands[i], eBands[i], B); intra_fold(m, X+eBands[i], eBands[i+1]-eBands[i], q, norm, P+eBands[i], eBands[i], B);
} else if (pitch_used && eBands[i] < m->pitchEnd) { } else if (pitch_used && eBands[i] < m->pitchEnd) {
for (j=C*eBands[i];j<C*eBands[i+1];j++) for (j=eBands[i];j<eBands[i+1];j++)
P[j] = MULT16_16_Q15(pgains[pband], P[j]); P[j] = MULT16_16_Q15(pgains[pband], P[j]);
} else { } else {
for (j=C*eBands[i];j<C*eBands[i+1];j++) for (j=eBands[i];j<eBands[i+1];j++)
P[j] = 0; P[j] = 0;
} }
if (q > 0) if (q > 0)
{ {
int ch=C; alg_unquant(X+eBands[i], eBands[i+1]-eBands[i], q, P+eBands[i], dec);
if (C==2 && stereo_mode[i]==1)
ch = 1;
if (C==2)
stereo_band_mix(m, P, bandE, stereo_mode, i, 1);
alg_unquant(X+C*eBands[i], ch*(eBands[i+1]-eBands[i]), q, P+C*eBands[i], dec);
if (C==2)
stereo_band_mix(m, X, bandE, stereo_mode, i, -1);
} else { } else {
for (j=C*eBands[i];j<C*eBands[i+1];j++) for (j=eBands[i];j<eBands[i+1];j++)
X[j] = P[j]; X[j] = P[j];
} }
for (j=C*eBands[i];j<C*eBands[i+1];j++) for (j=eBands[i];j<eBands[i+1];j++)
norm[j] = MULT16_16_Q15(n,X[j]); norm[j] = MULT16_16_Q15(n,X[j]);
} }
RESTORE_STACK; RESTORE_STACK;
} }
void unquant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, const int *stereo_mode, int *pulses, int shortBlocks, int fold, int total_bits, ec_dec *dec) void unquant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_dec *dec)
{ {
int i, j, remaining_bits, balance; int i, j, remaining_bits, balance;
const celt_int16_t * restrict eBands = m->eBands; const celt_int16_t * restrict eBands = m->eBands;
@ -1062,13 +1036,13 @@ void unquant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm
if (qb==0) if (qb==0)
point_stereo_mix(m, P, bandE, i, 1); point_stereo_mix(m, P, bandE, i, 1);
else else
stereo_band_mix(m, P, bandE, stereo_mode, i, 1); stereo_band_mix(m, P, bandE, 0, i, 1);
deinterleave(P+C*eBands[i], C*N); deinterleave(P+C*eBands[i], C*N);
} else if (pitch_used && eBands[i] < m->pitchEnd) { } else if (pitch_used && eBands[i] < m->pitchEnd) {
if (qb==0) if (qb==0)
point_stereo_mix(m, P, bandE, i, 1); point_stereo_mix(m, P, bandE, i, 1);
else else
stereo_band_mix(m, P, bandE, stereo_mode, i, 1); stereo_band_mix(m, P, bandE, 0, i, 1);
renormalise_vector(P+C*eBands[i], Q15ONE, N, C); renormalise_vector(P+C*eBands[i], Q15ONE, N, C);
renormalise_vector(P+C*eBands[i]+1, Q15ONE, N, C); renormalise_vector(P+C*eBands[i]+1, Q15ONE, N, C);
deinterleave(P+C*eBands[i], C*N); deinterleave(P+C*eBands[i], C*N);
@ -1105,7 +1079,7 @@ void unquant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm
interleave(X+C*eBands[i], C*N); interleave(X+C*eBands[i], C*N);
stereo_band_mix(m, X, bandE, stereo_mode, i, -1); stereo_band_mix(m, X, bandE, 0, i, -1);
renormalise_vector(X+C*eBands[i], Q15ONE, N, C); renormalise_vector(X+C*eBands[i], Q15ONE, N, C);
renormalise_vector(X+C*eBands[i]+1, Q15ONE, N, C); renormalise_vector(X+C*eBands[i]+1, Q15ONE, N, C);
for (j=0;j<C*N;j++) for (j=0;j<C*N;j++)

View file

@ -81,9 +81,9 @@ int compute_pitch_gain(const CELTMode *m, const celt_norm_t *X, const celt_norm_
* @param total_bits Total number of bits that can be used for the frame (including the ones already spent) * @param total_bits Total number of bits that can be used for the frame (including the ones already spent)
* @param enc Entropy encoder * @param enc Entropy encoder
*/ */
void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, celt_mask_t *W, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, const int *stereo_mode, int *pulses, int time_domain, int fold, int total_bits, ec_enc *enc); void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, celt_mask_t *W, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_enc *enc);
void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, celt_mask_t *W, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, const int *stereo_mode, int *pulses, int time_domain, int fold, int total_bits, ec_enc *enc); void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, celt_mask_t *W, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_enc *enc);
/** Decoding of the residual spectrum /** Decoding of the residual spectrum
* @param m Mode data * @param m Mode data
@ -92,7 +92,9 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t
* @param total_bits Total number of bits that can be used for the frame (including the ones already spent) * @param total_bits Total number of bits that can be used for the frame (including the ones already spent)
* @param dec Entropy decoder * @param dec Entropy decoder
*/ */
void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, const int *stereo_mode, int *pulses, int time_domain, int fold, int total_bits, ec_dec *dec); void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_dec *dec);
void unquant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, int pitch_used, celt_pgain_t *pgains, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_dec *dec);
void stereo_decision(const CELTMode *m, celt_norm_t * restrict X, int *stereo_mode, int len); void stereo_decision(const CELTMode *m, celt_norm_t * restrict X, int *stereo_mode, int len);

View file

@ -625,9 +625,9 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
/* Residual quantisation */ /* Residual quantisation */
if (C==1) if (C==1)
quant_bands(st->mode, X, P, NULL, has_pitch, gains, bandE, stereo_mode, pulses, shortBlocks, has_fold, nbCompressedBytes*8, &enc); quant_bands(st->mode, X, P, NULL, has_pitch, gains, bandE, pulses, shortBlocks, has_fold, nbCompressedBytes*8, &enc);
else else
quant_bands_stereo(st->mode, X, P, NULL, has_pitch, gains, bandE, stereo_mode, pulses, shortBlocks, has_fold, nbCompressedBytes*8, &enc); quant_bands_stereo(st->mode, X, P, NULL, has_pitch, gains, bandE, pulses, shortBlocks, has_fold, nbCompressedBytes*8, &enc);
/* Re-synthesis of the coded audio if required */ /* Re-synthesis of the coded audio if required */
if (st->pitch_available>0 || optional_synthesis!=NULL) if (st->pitch_available>0 || optional_synthesis!=NULL)
@ -1043,9 +1043,9 @@ int celt_decode_float(CELTDecoder * restrict st, unsigned char *data, int len, c
/* Decode fixed codebook and merge with pitch */ /* Decode fixed codebook and merge with pitch */
if (C==1) if (C==1)
unquant_bands(st->mode, X, P, has_pitch, gains, bandE, stereo_mode, pulses, shortBlocks, has_fold, len*8, &dec); unquant_bands(st->mode, X, P, has_pitch, gains, bandE, pulses, shortBlocks, has_fold, len*8, &dec);
else else
unquant_bands_stereo(st->mode, X, P, has_pitch, gains, bandE, stereo_mode, pulses, shortBlocks, has_fold, len*8, &dec); unquant_bands_stereo(st->mode, X, P, has_pitch, gains, bandE, pulses, shortBlocks, has_fold, len*8, &dec);
/* Synthesis */ /* Synthesis */
denormalise_bands(st->mode, X, freq, bandE); denormalise_bands(st->mode, X, freq, bandE);

View file

@ -116,20 +116,6 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
fprintf(file, "#endif\n"); fprintf(file, "#endif\n");
fprintf(file, "\n"); fprintf(file, "\n");
fprintf(file, "#ifndef DEF_ALLOC_ENERGY%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
fprintf(file, "#define DEF_ALLOC_ENERGY%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
fprintf (file, "static const celt_int16_t allocEnergy%d_%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbChannels, mode->nbEBands*mode->nbAllocVectors);
for (j=0;j<mode->nbAllocVectors;j++)
{
int k;
for (k=0;k<mode->nbEBands;k++)
fprintf (file, "%2d, ", mode->energy_alloc[j*mode->nbEBands+k]);
fprintf (file, "\n");
}
fprintf (file, "};\n");
fprintf(file, "#endif\n");
fprintf(file, "\n");
fprintf(file, "#ifndef DEF_ALLOC_CACHE%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels); fprintf(file, "#ifndef DEF_ALLOC_CACHE%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
fprintf(file, "#define DEF_ALLOC_CACHE%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels); fprintf(file, "#define DEF_ALLOC_CACHE%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
for (j=0;j<mode->nbEBands;j++) for (j=0;j<mode->nbEBands;j++)
@ -155,34 +141,6 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
fprintf(file, "\n"); fprintf(file, "\n");
if (mode->bits_stereo)
{
fprintf(file, "#ifndef DEF_ALLOC_STEREO_CACHE%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
fprintf(file, "#define DEF_ALLOC_STEREO_CACHE%d_%d_%d\n", mode->Fs, mode->mdctSize, mode->nbChannels);
for (j=0;j<mode->nbEBands;j++)
{
int k;
if (j==0 || (mode->bits[j] != mode->bits_stereo[j-1]))
{
fprintf (file, "static const celt_int16_t allocStereoCache_band%d_%d_%d_%d[MAX_PULSES] = {\n", j, mode->Fs, mode->mdctSize, mode->nbChannels);
for (k=0;k<MAX_PULSES;k++)
fprintf (file, "%2d, ", mode->bits_stereo[j][k]);
fprintf (file, "};\n");
} else {
fprintf (file, "#define allocStereoCache_band%d_%d_%d_%d allocStereoCache_band%d_%d_%d_%d\n", j, mode->Fs, mode->mdctSize, mode->nbChannels, j-1, mode->Fs, mode->mdctSize, mode->nbChannels);
}
}
fprintf (file, "static const celt_int16_t *allocStereoCache%d_%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbChannels, mode->nbEBands);
for (j=0;j<mode->nbEBands;j++)
{
fprintf (file, "allocStereoCache_band%d_%d_%d_%d, ", j, mode->Fs, mode->mdctSize, mode->nbChannels);
}
fprintf (file, "};\n");
fprintf(file, "#endif\n");
fprintf(file, "\n");
}
fprintf(file, "static const CELTMode mode%d_%d_%d_%d = {\n", mode->Fs, mode->nbChannels, mode->mdctSize, mode->overlap); fprintf(file, "static const CELTMode mode%d_%d_%d_%d = {\n", mode->Fs, mode->nbChannels, mode->mdctSize, mode->overlap);
fprintf(file, "0x%x,\t/* marker */\n", 0xa110ca7e); fprintf(file, "0x%x,\t/* marker */\n", 0xa110ca7e);
fprintf(file, INT32 ",\t/* Fs */\n", mode->Fs); fprintf(file, INT32 ",\t/* Fs */\n", mode->Fs);
@ -198,10 +156,6 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
fprintf(file, "%d,\t/* nbAllocVectors */\n", mode->nbAllocVectors); fprintf(file, "%d,\t/* nbAllocVectors */\n", mode->nbAllocVectors);
fprintf(file, "allocVectors%d_%d_%d,\t/* allocVectors */\n", mode->Fs, mode->mdctSize, mode->nbChannels); fprintf(file, "allocVectors%d_%d_%d,\t/* allocVectors */\n", mode->Fs, mode->mdctSize, mode->nbChannels);
fprintf(file, "allocCache%d_%d_%d,\t/* bits */\n", mode->Fs, mode->mdctSize, mode->nbChannels); fprintf(file, "allocCache%d_%d_%d,\t/* bits */\n", mode->Fs, mode->mdctSize, mode->nbChannels);
if (mode->bits_stereo)
fprintf(file, "allocStereoCache%d_%d_%d,\t/* bits_stereo */\n", mode->Fs, mode->mdctSize, mode->nbChannels);
else
fprintf(file, "0,\t/* bits_stereo */\n");
fprintf(file, "{%d, 0, 0},\t/* mdct */\n", 2*mode->mdctSize); fprintf(file, "{%d, 0, 0},\t/* mdct */\n", 2*mode->mdctSize);
fprintf(file, "0,\t/* fft */\n"); fprintf(file, "0,\t/* fft */\n");
fprintf(file, "window%d,\t/* window */\n", mode->overlap); fprintf(file, "window%d,\t/* window */\n", mode->overlap);
@ -211,7 +165,6 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
fprintf(file, "window%d,\t/* shortWindow */\n", mode->overlap); fprintf(file, "window%d,\t/* shortWindow */\n", mode->overlap);
fprintf(file, "{psy_decayR_%d},\t/* psy */\n", mode->Fs); fprintf(file, "{psy_decayR_%d},\t/* psy */\n", mode->Fs);
fprintf(file, "0,\t/* prob */\n"); fprintf(file, "0,\t/* prob */\n");
fprintf(file, "allocEnergy%d_%d_%d,\t/* energy_alloc */\n", mode->Fs, mode->mdctSize, mode->nbChannels);
fprintf(file, "0x%x,\t/* marker */\n", 0xa110ca7e); fprintf(file, "0x%x,\t/* marker */\n", 0xa110ca7e);
fprintf(file, "};\n"); fprintf(file, "};\n");
} }

View file

@ -253,7 +253,6 @@ static void compute_allocation_table(CELTMode *mode, int res)
for (j=0;j<mode->nbEBands;j++) for (j=0;j<mode->nbEBands;j++)
allocVectors[i*mode->nbEBands+j] += C; allocVectors[i*mode->nbEBands+j] += C;
}*/ }*/
mode->energy_alloc = allocEnergy;
mode->allocVectors = allocVectors; mode->allocVectors = allocVectors;
} }
@ -376,8 +375,6 @@ CELTMode *celt_mode_create(celt_int32_t Fs, int channels, int frame_size, int *e
mode->window = window; mode->window = window;
mode->bits = (const celt_int16_t **)compute_alloc_cache(mode, 1); mode->bits = (const celt_int16_t **)compute_alloc_cache(mode, 1);
if (mode->nbChannels>=2)
mode->bits_stereo = (const celt_int16_t **)compute_alloc_cache(mode, mode->nbChannels);
#ifndef SHORTCUTS #ifndef SHORTCUTS
psydecay_init(&mode->psy, MAX_PERIOD/2, mode->Fs); psydecay_init(&mode->psy, MAX_PERIOD/2, mode->Fs);
@ -414,24 +411,11 @@ 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);
celt_free((int*)mode->pBands); celt_free((int*)mode->pBands);
celt_free((int*)mode->allocVectors); celt_free((int*)mode->allocVectors);
celt_free((celt_int16_t *)mode->energy_alloc);
celt_free((celt_word16_t*)mode->window); celt_free((celt_word16_t*)mode->window);

View file

@ -89,8 +89,6 @@ struct CELTMode {
const celt_int16_t * const *bits; /**< Cache for pulses->bits mapping in each band */ const celt_int16_t * const *bits; /**< Cache for pulses->bits mapping in each band */
const celt_int16_t * const *bits_stereo; /**< Cache for pulses->bits mapping in each band */
/* Stuff that could go in the {en,de}coder, but we save space this way */ /* Stuff that could go in the {en,de}coder, but we save space this way */
mdct_lookup mdct; mdct_lookup mdct;
kiss_fftr_cfg fft; kiss_fftr_cfg fft;
@ -105,8 +103,6 @@ struct CELTMode {
struct PsyDecay psy; struct PsyDecay psy;
int *prob; int *prob;
const celt_int16_t *energy_alloc;
celt_uint32_t marker_end; celt_uint32_t marker_end;
}; };