Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/celt-0.7.0.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2009-06-14 06:59:43 +0400
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2009-06-14 07:02:54 +0400
commit7a56741b2ee901fbf6cafd6c8fe1e1c63ff7709e (patch)
treea520355e42644e38a606ffe3ead38763a6dfc846
parentf1ce900717877c334cafab734716df343007b3c1 (diff)
removing redundant calls to log2()
-rw-r--r--libcelt/celt.c8
-rw-r--r--libcelt/quant_bands.c18
-rw-r--r--libcelt/quant_bands.h4
3 files changed, 17 insertions, 13 deletions
diff --git a/libcelt/celt.c b/libcelt/celt.c
index 785a246..9052040 100644
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -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, P);
VARDECL(celt_ener_t, bandE);
+ VARDECL(celt_word16_t, bandLogE);
VARDECL(celt_pgain_t, gains);
VARDECL(int, fine_quant);
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(bandE,st->mode->nbEBands*C, celt_ener_t);
+ ALLOC(bandLogE,st->mode->nbEBands*C, celt_word16_t);
/* Compute MDCTs */
compute_mdcts(st->mode, shortBlocks, in, freq);
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");*/
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);
- if (shortBlocks || intra_decision(bandE, st->oldBandE, st->mode->nbEBands))
+ if (shortBlocks || intra_decision(bandLogE, st->oldBandE, st->mode->nbEBands))
st->delayedIntra = 1;
else
st->delayedIntra = 0;
@@ -813,7 +817,7 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
/* Bit allocation */
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;
/* Variable bitrate */
diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c
index 323bf4a..75b555b 100644
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -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};
#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;
celt_word32_t dist = 0;
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);
}
return SHR32(dist,16) > 2*len;
@@ -84,7 +84,7 @@ void quant_prob_free(int *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;
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 f; /* Q8 */
celt_word16_t mean = MULT16_16_Q15(Q15ONE-coef,eMeans[i]);
- x = amp2Log(eBands[i]);
+ x = eBands[i];
#ifdef FIXED_POINT
f = x-mean -MULT16_16_Q15(coef,oldEBands[i])-prev;
/* 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
f = x-mean-coef*oldEBands[i]-prev;
/* Rounding to nearest integer here is really important! */
- qi = (int)floor(.5+f);
+ qi = (int)floor(.5f+f);
#endif
/* If we don't have enough bits to encode all the energy, just assume something safe.
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 */
q2 = (error[i]+QCONST16(.5f,8))>>(8-fine_quant[i]);
#else
- q2 = (int)floor((error[i]+.5)*frac);
+ q2 = (int)floor((error[i]+.5f)*frac);
#endif
if (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;
C = m->nbChannels;
@@ -307,9 +307,9 @@ unsigned quant_coarse_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16
{
int i;
unsigned coarse_needed;
- VARDECL(celt_ener_t, E);
+ VARDECL(celt_word16_t, E);
SAVE_STACK;
- ALLOC(E, m->nbEBands, celt_ener_t);
+ ALLOC(E, m->nbEBands, celt_word16_t);
for (i=0;i<m->nbEBands;i++)
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);
diff --git a/libcelt/quant_bands.h b/libcelt/quant_bands.h
index 9528210..e7527af 100644
--- a/libcelt/quant_bands.h
+++ b/libcelt/quant_bands.h
@@ -53,9 +53,9 @@ void quant_prob_free(int *freq);
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);