diff --git a/libcelt/celt.c b/libcelt/celt.c index ad400d83..824b2aa9 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -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); -#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) { + 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 + if (st->pitch_available>0 && st->pitch_availablepitch_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); diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c index 52f64106..92d5a8c9 100644 --- a/libcelt/quant_bands.c +++ b/libcelt/quant_bands.c @@ -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;inbEBands;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;inbEBands;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); } + diff --git a/libcelt/quant_bands.h b/libcelt/quant_bands.h index a90ec4fd..76b0bcf3 100644 --- a/libcelt/quant_bands.h +++ b/libcelt/quant_bands.h @@ -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);