Added a few "restrict" keywords and changed some divisions to shifts

This commit is contained in:
Jean-Marc Valin 2008-03-22 09:01:50 +11:00
parent 3c2fe0fbee
commit a536f77202
6 changed files with 19 additions and 19 deletions

View file

@ -156,14 +156,14 @@ static inline celt_int16_t SIG2INT16(celt_sig_t x)
} }
/** Apply window and compute the MDCT for all sub-frames and all channels in a frame */ /** 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; int i, c, N4;
celt_word32_t E = 0; celt_word32_t E = 0;
VARDECL(celt_word32_t, x); VARDECL(celt_word32_t, x);
VARDECL(celt_word32_t, tmp); VARDECL(celt_word32_t, tmp);
SAVE_STACK; SAVE_STACK;
N4 = (N-overlap)/2; N4 = (N-overlap)>>1;
ALLOC(x, 2*N, celt_word32_t); ALLOC(x, 2*N, celt_word32_t);
ALLOC(tmp, N, celt_word32_t); ALLOC(tmp, N, celt_word32_t);
for (c=0;c<C;c++) for (c=0;c<C;c++)
@ -196,7 +196,7 @@ static celt_word32_t compute_mdcts(const mdct_lookup *lookup, const celt_word16_
} }
/** Compute the IMDCT and apply window for all sub-frames and all channels in a frame */ /** 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; int i, c, N4;
VARDECL(celt_word32_t, x); VARDECL(celt_word32_t, x);
@ -204,7 +204,7 @@ static void compute_inv_mdcts(const mdct_lookup *lookup, const celt_word16_t *wi
SAVE_STACK; SAVE_STACK;
ALLOC(x, 2*N, celt_word32_t); ALLOC(x, 2*N, celt_word32_t);
ALLOC(tmp, 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 (c=0;c<C;c++)
{ {
for (i=0;i<B;i++) for (i=0;i<B;i++)
@ -252,7 +252,7 @@ int EXPORT celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compre
N = st->block_size; N = st->block_size;
B = st->nb_blocks; B = st->nb_blocks;
C = st->mode->nbChannels; 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); ALLOC(in, (B+1)*C*N-2*N4, celt_sig_t);
@ -565,7 +565,7 @@ int EXPORT celt_decode(CELTDecoder *st, unsigned char *data, int len, celt_int16
N = st->block_size; N = st->block_size;
B = st->nb_blocks; B = st->nb_blocks;
C = st->mode->nbChannels; 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(freq, C*B*N, celt_sig_t); /**< Interleaved signal MDCTs */
ALLOC(X, C*B*N, celt_norm_t); /**< Interleaved normalised MDCTs */ ALLOC(X, C*B*N, celt_norm_t); /**< Interleaved normalised MDCTs */

View file

@ -62,8 +62,8 @@ void mdct_init(mdct_lookup *l,int N)
int i; int i;
int N2; int N2;
l->n = N; l->n = N;
N2 = N/2; N2 = N>>1;
l->kfft = cpx32_fft_alloc(N/4); l->kfft = cpx32_fft_alloc(N>>2);
l->trig = (kiss_twiddle_scalar*)celt_alloc(N2*sizeof(kiss_twiddle_scalar)); l->trig = (kiss_twiddle_scalar*)celt_alloc(N2*sizeof(kiss_twiddle_scalar));
/* We have enough points that sine isn't necessary */ /* We have enough points that sine isn't necessary */
#if defined(FIXED_POINT) #if defined(FIXED_POINT)
@ -93,8 +93,8 @@ void mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *ou
VARDECL(kiss_fft_scalar, f); VARDECL(kiss_fft_scalar, f);
SAVE_STACK; SAVE_STACK;
N = l->n; N = l->n;
N2 = N/2; N2 = N>>1;
N4 = N/4; N4 = N>>2;
ALLOC(f, N2, kiss_fft_scalar); ALLOC(f, N2, kiss_fft_scalar);
/* Consider the input to be compused of four blocks: [a, b, c, d] */ /* Consider the input to be compused of four blocks: [a, b, c, d] */
@ -138,8 +138,8 @@ void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *o
VARDECL(kiss_fft_scalar, f); VARDECL(kiss_fft_scalar, f);
SAVE_STACK; SAVE_STACK;
N = l->n; N = l->n;
N2 = N/2; N2 = N>>1;
N4 = N/4; N4 = N>>2;
ALLOC(f, N2, kiss_fft_scalar); ALLOC(f, N2, kiss_fft_scalar);
/* Pre-rotate */ /* Pre-rotate */

View file

@ -50,7 +50,7 @@
typedef struct { typedef struct {
int n; int n;
kiss_fft_cfg kfft; kiss_fft_cfg kfft;
kiss_twiddle_scalar *trig; kiss_twiddle_scalar * restrict trig;
} mdct_lookup; } mdct_lookup;
void mdct_init(mdct_lookup *l,int N); void mdct_init(mdct_lookup *l,int N);

View file

@ -99,7 +99,7 @@ static void normalise16(celt_word16_t *x, int len, celt_word16_t val)
#define INPUT_SHIFT 15 #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; int c, i;
celt_word32_t max_corr; celt_word32_t max_corr;
@ -109,8 +109,8 @@ void find_spectral_pitch(kiss_fftr_cfg fft, const struct PsyDecay *decay, const
int n2; int n2;
int L2; int L2;
SAVE_STACK; SAVE_STACK;
n2 = lag/2; n2 = lag>>1;
L2 = len/2; L2 = len>>1;
ALLOC(X, lag, celt_word16_t); ALLOC(X, lag, celt_word16_t);
ALLOC(curve, n2, celt_mask_t); ALLOC(curve, n2, celt_mask_t);
@ -127,7 +127,7 @@ void find_spectral_pitch(kiss_fftr_cfg fft, const struct PsyDecay *decay, const
} }
/* Applying the window in the bit-reverse domain. It's a bit weird, but it /* Applying the window in the bit-reverse domain. It's a bit weird, but it
can help save memory */ 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)] = 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]); X[2*BITREV(fft,i)+1] = MULT16_16_Q15(window[2*i+1], X[2*BITREV(fft,i)+1]);

View file

@ -135,7 +135,7 @@ void compute_masking(const struct PsyDecay *decay, celt_word16_t *X, celt_mask_t
{ {
int i; int i;
int N; int N;
N=len/2; N=len>>1;
mask[0] = MULT16_16(X[0], X[0]); mask[0] = MULT16_16(X[0], X[0]);
for (i=1;i<N;i++) 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])); mask[i] = ADD32(MULT16_16(X[i*2], X[i*2]), MULT16_16(X[i*2+1], X[i*2+1]));

View file

@ -474,7 +474,7 @@ void intra_fold(celt_norm_t *x, int N, celt_norm_t *Y, celt_norm_t *P, int B, in
celt_word16_t g; celt_word16_t g;
E = EPSILON; E = EPSILON;
if (N0 >= Nmax/2) if (N0 >= (Nmax>>1))
{ {
for (i=0;i<B;i++) for (i=0;i<B;i++)
{ {