removing redundant calls to log2()
This commit is contained in:
parent
f1ce900717
commit
7a56741b2e
3 changed files with 17 additions and 13 deletions
|
@ -509,6 +509,7 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
|
||||||
VARDECL(celt_norm_t, X);
|
VARDECL(celt_norm_t, X);
|
||||||
VARDECL(celt_norm_t, P);
|
VARDECL(celt_norm_t, P);
|
||||||
VARDECL(celt_ener_t, bandE);
|
VARDECL(celt_ener_t, bandE);
|
||||||
|
VARDECL(celt_word16_t, bandLogE);
|
||||||
VARDECL(celt_pgain_t, gains);
|
VARDECL(celt_pgain_t, gains);
|
||||||
VARDECL(int, fine_quant);
|
VARDECL(int, fine_quant);
|
||||||
VARDECL(celt_word16_t, error);
|
VARDECL(celt_word16_t, error);
|
||||||
|
@ -609,6 +610,7 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
|
||||||
|
|
||||||
ALLOC(freq, C*N, celt_sig_t); /**< Interleaved signal MDCTs */
|
ALLOC(freq, C*N, celt_sig_t); /**< Interleaved signal MDCTs */
|
||||||
ALLOC(bandE,st->mode->nbEBands*C, celt_ener_t);
|
ALLOC(bandE,st->mode->nbEBands*C, celt_ener_t);
|
||||||
|
ALLOC(bandLogE,st->mode->nbEBands*C, celt_word16_t);
|
||||||
/* Compute MDCTs */
|
/* Compute MDCTs */
|
||||||
compute_mdcts(st->mode, shortBlocks, in, freq);
|
compute_mdcts(st->mode, shortBlocks, in, freq);
|
||||||
if (shortBlocks && !transient_shift)
|
if (shortBlocks && !transient_shift)
|
||||||
|
@ -678,9 +680,11 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
|
||||||
else printf ("1\n");*/
|
else printf ("1\n");*/
|
||||||
|
|
||||||
compute_band_energies(st->mode, freq, bandE);
|
compute_band_energies(st->mode, freq, bandE);
|
||||||
|
for (i=0;i<st->mode->nbEBands*C;i++)
|
||||||
|
bandLogE[i] = amp2Log(bandE[i]);
|
||||||
|
|
||||||
intra_ener = (st->force_intra || st->delayedIntra);
|
intra_ener = (st->force_intra || st->delayedIntra);
|
||||||
if (shortBlocks || intra_decision(bandE, st->oldBandE, st->mode->nbEBands))
|
if (shortBlocks || intra_decision(bandLogE, st->oldBandE, st->mode->nbEBands))
|
||||||
st->delayedIntra = 1;
|
st->delayedIntra = 1;
|
||||||
else
|
else
|
||||||
st->delayedIntra = 0;
|
st->delayedIntra = 0;
|
||||||
|
@ -813,7 +817,7 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
|
||||||
|
|
||||||
/* Bit allocation */
|
/* Bit allocation */
|
||||||
ALLOC(error, C*st->mode->nbEBands, celt_word16_t);
|
ALLOC(error, C*st->mode->nbEBands, celt_word16_t);
|
||||||
coarse_needed = quant_coarse_energy(st->mode, bandE, st->oldBandE, nbCompressedBytes*8/3, intra_ener, st->mode->prob, error, &enc);
|
coarse_needed = quant_coarse_energy(st->mode, bandLogE, st->oldBandE, nbCompressedBytes*8/3, intra_ener, st->mode->prob, error, &enc);
|
||||||
coarse_needed = ((coarse_needed*3-1)>>3)+1;
|
coarse_needed = ((coarse_needed*3-1)>>3)+1;
|
||||||
|
|
||||||
/* Variable bitrate */
|
/* Variable bitrate */
|
||||||
|
|
|
@ -47,13 +47,13 @@ const celt_word16_t eMeans[24] = {1920, -341, -512, -107, 43, 0, 0, 0, 0, 0, 0,
|
||||||
const celt_word16_t eMeans[24] = {7.5f, -1.33f, -2.f, -0.42f, 0.17f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
|
const celt_word16_t eMeans[24] = {7.5f, -1.33f, -2.f, -0.42f, 0.17f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int intra_decision(celt_ener_t *eBands, celt_word16_t *oldEBands, int len)
|
int intra_decision(celt_word16_t *eBands, celt_word16_t *oldEBands, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
celt_word32_t dist = 0;
|
celt_word32_t dist = 0;
|
||||||
for (i=0;i<len;i++)
|
for (i=0;i<len;i++)
|
||||||
{
|
{
|
||||||
celt_word16_t d = SUB16(amp2Log(eBands[i]), oldEBands[i]);
|
celt_word16_t d = SUB16(eBands[i], oldEBands[i]);
|
||||||
dist = MAC16_16(dist, d,d);
|
dist = MAC16_16(dist, d,d);
|
||||||
}
|
}
|
||||||
return SHR32(dist,16) > 2*len;
|
return SHR32(dist,16) > 2*len;
|
||||||
|
@ -84,7 +84,7 @@ void quant_prob_free(int *freq)
|
||||||
celt_free(freq);
|
celt_free(freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned quant_coarse_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, unsigned budget, int intra, int *prob, celt_word16_t *error, ec_enc *enc)
|
static unsigned quant_coarse_energy_mono(const CELTMode *m, celt_word16_t *eBands, celt_word16_t *oldEBands, unsigned budget, int intra, int *prob, celt_word16_t *error, ec_enc *enc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned bits;
|
unsigned bits;
|
||||||
|
@ -110,7 +110,7 @@ static unsigned quant_coarse_energy_mono(const CELTMode *m, celt_ener_t *eBands,
|
||||||
celt_word16_t x; /* dB */
|
celt_word16_t x; /* dB */
|
||||||
celt_word16_t f; /* Q8 */
|
celt_word16_t f; /* Q8 */
|
||||||
celt_word16_t mean = MULT16_16_Q15(Q15ONE-coef,eMeans[i]);
|
celt_word16_t mean = MULT16_16_Q15(Q15ONE-coef,eMeans[i]);
|
||||||
x = amp2Log(eBands[i]);
|
x = eBands[i];
|
||||||
#ifdef FIXED_POINT
|
#ifdef FIXED_POINT
|
||||||
f = x-mean -MULT16_16_Q15(coef,oldEBands[i])-prev;
|
f = x-mean -MULT16_16_Q15(coef,oldEBands[i])-prev;
|
||||||
/* Rounding to nearest integer here is really important! */
|
/* Rounding to nearest integer here is really important! */
|
||||||
|
@ -118,7 +118,7 @@ static unsigned quant_coarse_energy_mono(const CELTMode *m, celt_ener_t *eBands,
|
||||||
#else
|
#else
|
||||||
f = x-mean-coef*oldEBands[i]-prev;
|
f = x-mean-coef*oldEBands[i]-prev;
|
||||||
/* Rounding to nearest integer here is really important! */
|
/* Rounding to nearest integer here is really important! */
|
||||||
qi = (int)floor(.5+f);
|
qi = (int)floor(.5f+f);
|
||||||
#endif
|
#endif
|
||||||
/* If we don't have enough bits to encode all the energy, just assume something safe.
|
/* If we don't have enough bits to encode all the energy, just assume something safe.
|
||||||
We allow slightly busting the budget here */
|
We allow slightly busting the budget here */
|
||||||
|
@ -154,7 +154,7 @@ static void quant_fine_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_
|
||||||
/* Has to be without rounding */
|
/* Has to be without rounding */
|
||||||
q2 = (error[i]+QCONST16(.5f,8))>>(8-fine_quant[i]);
|
q2 = (error[i]+QCONST16(.5f,8))>>(8-fine_quant[i]);
|
||||||
#else
|
#else
|
||||||
q2 = (int)floor((error[i]+.5)*frac);
|
q2 = (int)floor((error[i]+.5f)*frac);
|
||||||
#endif
|
#endif
|
||||||
if (q2 > frac-1)
|
if (q2 > frac-1)
|
||||||
q2 = frac-1;
|
q2 = frac-1;
|
||||||
|
@ -292,7 +292,7 @@ static void unquant_energy_finalise_mono(const CELTMode *m, celt_ener_t *eBands,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned quant_coarse_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, int budget, int intra, int *prob, celt_word16_t *error, ec_enc *enc)
|
unsigned quant_coarse_energy(const CELTMode *m, celt_word16_t *eBands, celt_word16_t *oldEBands, int budget, int intra, int *prob, celt_word16_t *error, ec_enc *enc)
|
||||||
{
|
{
|
||||||
int C;
|
int C;
|
||||||
C = m->nbChannels;
|
C = m->nbChannels;
|
||||||
|
@ -307,9 +307,9 @@ unsigned quant_coarse_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned coarse_needed;
|
unsigned coarse_needed;
|
||||||
VARDECL(celt_ener_t, E);
|
VARDECL(celt_word16_t, E);
|
||||||
SAVE_STACK;
|
SAVE_STACK;
|
||||||
ALLOC(E, m->nbEBands, celt_ener_t);
|
ALLOC(E, m->nbEBands, celt_word16_t);
|
||||||
for (i=0;i<m->nbEBands;i++)
|
for (i=0;i<m->nbEBands;i++)
|
||||||
E[i] = eBands[C*i+c];
|
E[i] = eBands[C*i+c];
|
||||||
coarse_needed=quant_coarse_energy_mono(m, E, oldEBands+c*m->nbEBands, budget/C, intra, prob, error+c*m->nbEBands, enc);
|
coarse_needed=quant_coarse_energy_mono(m, E, oldEBands+c*m->nbEBands, budget/C, intra, prob, error+c*m->nbEBands, enc);
|
||||||
|
|
|
@ -53,9 +53,9 @@ void quant_prob_free(int *freq);
|
||||||
|
|
||||||
void compute_fine_allocation(const CELTMode *m, int *bits, int budget);
|
void compute_fine_allocation(const CELTMode *m, int *bits, int budget);
|
||||||
|
|
||||||
int intra_decision(celt_ener_t *eBands, celt_word16_t *oldEBands, int len);
|
int intra_decision(celt_word16_t *eBands, celt_word16_t *oldEBands, int len);
|
||||||
|
|
||||||
unsigned quant_coarse_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, int budget, int intra, int *prob, celt_word16_t *error, ec_enc *enc);
|
unsigned quant_coarse_energy(const CELTMode *m, celt_word16_t *eBands, celt_word16_t *oldEBands, int budget, int intra, int *prob, celt_word16_t *error, ec_enc *enc);
|
||||||
|
|
||||||
void quant_fine_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, celt_word16_t *error, int *fine_quant, ec_enc *enc);
|
void quant_fine_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, celt_word16_t *error, int *fine_quant, ec_enc *enc);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue