ref: 64209a3edf1b9d00f26775bc54b62ae3de5f4113
parent: 9a92d61ee897ba787b2e3210bc70bc7bb79ef505
author: Jean-Marc Valin <[email protected]>
date: Mon Apr 5 05:26:22 EDT 2010
A few minor optimisations (compute_allocation, denormalise_bands, deemphasis)
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -200,16 +200,23 @@
celt_fatal("denormalise_bands() not implemented for >2 channels");
for (c=0;c<C;c++)
{
+ celt_sig * restrict f;
+ const celt_norm * restrict x;
+ f = freq+c*N;
+ x = X+c*N;
for (i=0;i<m->nbEBands;i++)
{
- int j;
+ int j, end;
celt_word32 g = SHR32(bank[i+c*m->nbEBands],1);
- j=eBands[i]; do {
- freq[j+c*N] = SHL32(MULT16_32_Q15(X[j+c*N], g),2);
- } while (++j<eBands[i+1]);
+ j=eBands[i];
+ end = eBands[i+1];
+ do {
+ *f++ = SHL32(MULT16_32_Q15(*x, g),2);
+ x++;
+ } while (++j<end);
}
for (i=eBands[m->nbEBands];i<eBands[m->nbEBands+1];i++)
- freq[i+c*N] = 0;
+ *f++ = 0;
}
}
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -491,7 +491,7 @@
/*printf ("dec %d: %d %d %d %d\n", flag_bits, *intra_ener, *has_pitch, *shortBlocks, *has_fold);*/
}
-static void deemphasis(celt_sig *in, celt_word16 *pcm, int N, int _C, celt_word16 coef, celt_sig *mem)
+void deemphasis(celt_sig *in, celt_word16 *pcm, int N, int _C, celt_word16 coef, celt_sig *mem)
{
const int C = CHANNELS(_C);
int c;
@@ -498,15 +498,21 @@
for (c=0;c<C;c++)
{
int j;
+ celt_sig * restrict x;
+ celt_word16 * restrict y;
+ celt_sig m = mem[c];
+ x = &in[C*(MAX_PERIOD-N)+c];
+ y = pcm+c;
for (j=0;j<N;j++)
{
- celt_sig tmp = MAC16_32_Q15(in[C*(MAX_PERIOD-N)+C*j+c],
- coef,mem[c]);
- mem[c] = tmp;
- pcm[C*j+c] = SCALEOUT(SIG2WORD16(tmp));
+ celt_sig tmp = MAC16_32_Q15(*x, coef,m);
+ m = tmp;
+ *y = SCALEOUT(SIG2WORD16(tmp));
+ x+=C;
+ y+=C;
}
+ mem[c] = m;
}
-
}
static void mdct_shape(const CELTMode *mode, celt_norm *X, int start, int end, int N, int nbShortMdcts, int mdct_weight_shift, int _C)
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -102,7 +102,7 @@
-static void interp_bits2pulses(const CELTMode *m, int start, int *bits1, int *bits2, int total, int *bits, int *ebits, int *fine_priority, int len, int _C)
+static inline void interp_bits2pulses(const CELTMode *m, int start, int *bits1, int *bits2, int total, int *bits, int *ebits, int *fine_priority, int len, int _C)
{
int psum;
int lo, hi;