ref: a536f772028b2ece36178d0d380f242fc8858f0c
parent: 3c2fe0fbee57a5c1f0d688b12c40025b7049c642
author: Jean-Marc Valin <[email protected]>
date: Sat Mar 22 05:01:50 EDT 2008
Added a few "restrict" keywords and changed some divisions to shifts
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -156,7 +156,7 @@
}
/** Apply window and compute the MDCT for all sub-frames and all channels in a frame */
-static celt_word32_t compute_mdcts(const mdct_lookup *lookup, const celt_word16_t *window, celt_sig_t *in, celt_sig_t *out, int N, int overlap, int B, int C)
+static celt_word32_t compute_mdcts(const mdct_lookup *lookup, const celt_word16_t * restrict window, celt_sig_t *in, celt_sig_t *out, int N, int overlap, int B, int C)
{
int i, c, N4;
celt_word32_t E = 0;
@@ -163,7 +163,7 @@
VARDECL(celt_word32_t, x);
VARDECL(celt_word32_t, tmp);
SAVE_STACK;
- N4 = (N-overlap)/2;
+ N4 = (N-overlap)>>1;
ALLOC(x, 2*N, celt_word32_t);
ALLOC(tmp, N, celt_word32_t);
for (c=0;c<C;c++)
@@ -196,7 +196,7 @@
}
/** Compute the IMDCT and apply window for all sub-frames and all channels in a frame */
-static void compute_inv_mdcts(const mdct_lookup *lookup, const celt_word16_t *window, celt_sig_t *X, celt_sig_t *out_mem, celt_sig_t *mdct_overlap, int N, int overlap, int B, int C)
+static void compute_inv_mdcts(const mdct_lookup *lookup, const celt_word16_t * restrict window, celt_sig_t *X, celt_sig_t *out_mem, celt_sig_t *mdct_overlap, int N, int overlap, int B, int C)
{
int i, c, N4;
VARDECL(celt_word32_t, x);
@@ -204,7 +204,7 @@
SAVE_STACK;
ALLOC(x, 2*N, celt_word32_t);
ALLOC(tmp, N, celt_word32_t);
- N4 = (N-overlap)/2;
+ N4 = (N-overlap)>>1;
for (c=0;c<C;c++)
{
for (i=0;i<B;i++)
@@ -252,7 +252,7 @@
N = st->block_size;
B = st->nb_blocks;
C = st->mode->nbChannels;
- N4 = (N-st->overlap)/2;
+ N4 = (N-st->overlap)>>1;
ALLOC(in, (B+1)*C*N-2*N4, celt_sig_t);
@@ -565,7 +565,7 @@
N = st->block_size;
B = st->nb_blocks;
C = st->mode->nbChannels;
- N4 = (N-st->overlap)/2;
+ N4 = (N-st->overlap)>>1;
ALLOC(freq, C*B*N, celt_sig_t); /**< Interleaved signal MDCTs */
ALLOC(X, C*B*N, celt_norm_t); /**< Interleaved normalised MDCTs */
--- a/libcelt/mdct.c
+++ b/libcelt/mdct.c
@@ -62,8 +62,8 @@
int i;
int N2;
l->n = N;
- N2 = N/2;
- l->kfft = cpx32_fft_alloc(N/4);
+ N2 = N>>1;
+ l->kfft = cpx32_fft_alloc(N>>2);
l->trig = (kiss_twiddle_scalar*)celt_alloc(N2*sizeof(kiss_twiddle_scalar));
/* We have enough points that sine isn't necessary */
#if defined(FIXED_POINT)
@@ -93,8 +93,8 @@
VARDECL(kiss_fft_scalar, f);
SAVE_STACK;
N = l->n;
- N2 = N/2;
- N4 = N/4;
+ N2 = N>>1;
+ N4 = N>>2;
ALLOC(f, N2, kiss_fft_scalar);
/* Consider the input to be compused of four blocks: [a, b, c, d] */
@@ -138,8 +138,8 @@
VARDECL(kiss_fft_scalar, f);
SAVE_STACK;
N = l->n;
- N2 = N/2;
- N4 = N/4;
+ N2 = N>>1;
+ N4 = N>>2;
ALLOC(f, N2, kiss_fft_scalar);
/* Pre-rotate */
--- a/libcelt/mdct.h
+++ b/libcelt/mdct.h
@@ -50,7 +50,7 @@
typedef struct {
int n;
kiss_fft_cfg kfft;
- kiss_twiddle_scalar *trig;
+ kiss_twiddle_scalar * restrict trig;
} mdct_lookup;
void mdct_init(mdct_lookup *l,int N);
--- a/libcelt/pitch.c
+++ b/libcelt/pitch.c
@@ -99,7 +99,7 @@
#define INPUT_SHIFT 15
-void find_spectral_pitch(kiss_fftr_cfg fft, const struct PsyDecay *decay, const celt_sig_t *x, const celt_sig_t *y, const celt_word16_t *window, int overlap, int lag, int len, int C, int *pitch)
+void find_spectral_pitch(kiss_fftr_cfg fft, const struct PsyDecay *decay, const celt_sig_t *x, const celt_sig_t *y, const celt_word16_t * restrict window, int overlap, int lag, int len, int C, int *pitch)
{
int c, i;
celt_word32_t max_corr;
@@ -109,8 +109,8 @@
int n2;
int L2;
SAVE_STACK;
- n2 = lag/2;
- L2 = len/2;
+ n2 = lag>>1;
+ L2 = len>>1;
ALLOC(X, lag, celt_word16_t);
ALLOC(curve, n2, celt_mask_t);
@@ -127,7 +127,7 @@
}
/* Applying the window in the bit-reverse domain. It's a bit weird, but it
can help save memory */
- for (i=0;i<overlap/2;i++)
+ for (i=0;i<overlap>>1;i++)
{
X[2*BITREV(fft,i)] = MULT16_16_Q15(window[2*i], X[2*BITREV(fft,i)]);
X[2*BITREV(fft,i)+1] = MULT16_16_Q15(window[2*i+1], X[2*BITREV(fft,i)+1]);
--- a/libcelt/psy.c
+++ b/libcelt/psy.c
@@ -135,7 +135,7 @@
{
int i;
int N;
- N=len/2;
+ N=len>>1;
mask[0] = MULT16_16(X[0], X[0]);
for (i=1;i<N;i++)
mask[i] = ADD32(MULT16_16(X[i*2], X[i*2]), MULT16_16(X[i*2+1], X[i*2+1]));
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -474,7 +474,7 @@
celt_word16_t g;
E = EPSILON;
- if (N0 >= Nmax/2)
+ if (N0 >= (Nmax>>1))
{
for (i=0;i<B;i++)
{