Code simplifications for log->amplitude conversion
This commit is contained in:
parent
531f2ae7e3
commit
bc272de74b
3 changed files with 20 additions and 20 deletions
|
@ -1061,13 +1061,15 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, c
|
|||
|
||||
quant_energy_finalise(st->mode, st->start, st->end, bandE, st->oldBandE, error, fine_quant, fine_priority, nbCompressedBytes*8-ec_enc_tell(enc, 0), enc, C);
|
||||
|
||||
/* Re-synthesis of the coded audio if required */
|
||||
if (resynth)
|
||||
{
|
||||
log2Amp(st->mode, st->start, st->end, bandE, st->oldBandE, C);
|
||||
|
||||
#ifdef MEASURE_NORM_MSE
|
||||
measure_norm_mse(st->mode, X, X0, bandE, bandE0, M, N, C);
|
||||
#endif
|
||||
|
||||
/* Re-synthesis of the coded audio if required */
|
||||
if (resynth)
|
||||
{
|
||||
if (st->pitch_available>0 && st->pitch_available<MAX_PERIOD)
|
||||
st->pitch_available+=N;
|
||||
|
||||
|
@ -1828,6 +1830,8 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
|
|||
|
||||
unquant_energy_finalise(st->mode, st->start, st->end, bandE, st->oldBandE, fine_quant, fine_priority, len*8-ec_dec_tell(dec, 0), dec, C);
|
||||
|
||||
log2Amp(st->mode, st->start, st->end, bandE, st->oldBandE, C);
|
||||
|
||||
if (mdct_weight_shift)
|
||||
{
|
||||
mdct_shape(st->mode, X, 0, mdct_weight_pos+1, N, mdct_weight_shift, effEnd, C, 1, M);
|
||||
|
|
|
@ -227,15 +227,6 @@ void quant_energy_finalise(const CELTMode *m, int start, int end, celt_ener *eBa
|
|||
} while (++c < C);
|
||||
}
|
||||
}
|
||||
c=0;
|
||||
do {
|
||||
for (i=start;i<m->nbEBands;i++)
|
||||
{
|
||||
eBands[i+c*m->nbEBands] = log2Amp(oldEBands[i+c*m->nbEBands]);
|
||||
if (oldEBands[i+c*m->nbEBands] < -QCONST16(7.f,DB_SHIFT))
|
||||
oldEBands[i+c*m->nbEBands] = -QCONST16(7.f,DB_SHIFT);
|
||||
}
|
||||
} while (++c < C);
|
||||
}
|
||||
|
||||
void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_ener *eBands, celt_word16 *oldEBands, int intra, int *prob, ec_dec *dec, int _C, int LM)
|
||||
|
@ -324,13 +315,22 @@ void unquant_energy_finalise(const CELTMode *m, int start, int end, celt_ener *e
|
|||
} while (++c < C);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void log2Amp(const CELTMode *m, int start, int end,
|
||||
celt_ener *eBands, celt_word16 *oldEBands, int _C)
|
||||
{
|
||||
int c, i;
|
||||
const int C = CHANNELS(_C);
|
||||
c=0;
|
||||
do {
|
||||
for (i=start;i<m->nbEBands;i++)
|
||||
{
|
||||
eBands[i+c*m->nbEBands] = log2Amp(oldEBands[i+c*m->nbEBands]);
|
||||
celt_word16 lg = oldEBands[i+c*m->nbEBands];
|
||||
eBands[i+c*m->nbEBands] = PSHR32(celt_exp2(SHL16(lg,11-DB_SHIFT)),4);
|
||||
if (oldEBands[i+c*m->nbEBands] < -QCONST16(7.f,DB_SHIFT))
|
||||
oldEBands[i+c*m->nbEBands] = -QCONST16(7.f,DB_SHIFT);
|
||||
}
|
||||
} while (++c < C);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,16 +44,12 @@ static inline celt_word16 amp2Log(celt_word32 amp)
|
|||
return celt_log2(MAX32(QCONST32(.001f,14),SHL32(amp,2)));
|
||||
}
|
||||
|
||||
static inline celt_word32 log2Amp(celt_word16 lg)
|
||||
{
|
||||
return PSHR32(celt_exp2(SHL16(lg,11-DB_SHIFT)),4);
|
||||
}
|
||||
void log2Amp(const CELTMode *m, int start, int end,
|
||||
celt_ener *eBands, celt_word16 *oldEBands, int _C);
|
||||
|
||||
int *quant_prob_alloc(const CELTMode *m);
|
||||
void quant_prob_free(int *freq);
|
||||
|
||||
void compute_fine_allocation(const CELTMode *m, int *bits, int budget);
|
||||
|
||||
int intra_decision(celt_word16 *eBands, celt_word16 *oldEBands, int start, int end, int len, int C);
|
||||
|
||||
void quant_coarse_energy(const CELTMode *m, int start, int end, const celt_word16 *eBands, celt_word16 *oldEBands, int budget, int intra, int *prob, celt_word16 *error, ec_enc *enc, int _C, int LM, celt_word16 max_decay);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue