Replace C99 restrict keyword with OPUS_RESTRICT.

We had previously advised people to -Drestrict on
non-C99 compilers, but this creates problems for
some of the MSVC headers. Instead this just
uses a macro and defines it sanely.
This commit is contained in:
Gregory Maxwell 2012-07-18 12:12:35 -04:00
parent 31e8a84592
commit de0b5324b6
10 changed files with 84 additions and 71 deletions

View file

@ -111,7 +111,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *band
} }
/* Normalise each band such that the energy is one. */ /* Normalise each band such that the energy is one. */
void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bandE, int end, int C, int M) void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, celt_norm * OPUS_RESTRICT X, const celt_ener *bandE, int end, int C, int M)
{ {
int i, c, N; int i, c, N;
const opus_int16 *eBands = m->eBands; const opus_int16 *eBands = m->eBands;
@ -153,7 +153,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *band
} }
/* Normalise each band such that the energy is one. */ /* Normalise each band such that the energy is one. */
void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bandE, int end, int C, int M) void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, celt_norm * OPUS_RESTRICT X, const celt_ener *bandE, int end, int C, int M)
{ {
int i, c, N; int i, c, N;
const opus_int16 *eBands = m->eBands; const opus_int16 *eBands = m->eBands;
@ -172,15 +172,15 @@ void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_nor
#endif /* FIXED_POINT */ #endif /* FIXED_POINT */
/* De-normalise the energy to produce the synthesis from the unit-energy bands */ /* De-normalise the energy to produce the synthesis from the unit-energy bands */
void denormalise_bands(const CELTMode *m, const celt_norm * restrict X, celt_sig * restrict freq, const celt_ener *bandE, int end, int C, int M) void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X, celt_sig * OPUS_RESTRICT freq, const celt_ener *bandE, int end, int C, int M)
{ {
int i, c, N; int i, c, N;
const opus_int16 *eBands = m->eBands; const opus_int16 *eBands = m->eBands;
N = M*m->shortMdctSize; N = M*m->shortMdctSize;
celt_assert2(C<=2, "denormalise_bands() not implemented for >2 channels"); celt_assert2(C<=2, "denormalise_bands() not implemented for >2 channels");
c=0; do { c=0; do {
celt_sig * restrict f; celt_sig * OPUS_RESTRICT f;
const celt_norm * restrict x; const celt_norm * OPUS_RESTRICT x;
f = freq+c*N; f = freq+c*N;
x = X+c*N; x = X+c*N;
for (i=0;i<end;i++) for (i=0;i<end;i++)
@ -397,7 +397,7 @@ int spreading_decision(const CELTMode *m, celt_norm *X, int *average,
{ {
int i, c, N0; int i, c, N0;
int sum = 0, nbBands=0; int sum = 0, nbBands=0;
const opus_int16 * restrict eBands = m->eBands; const opus_int16 * OPUS_RESTRICT eBands = m->eBands;
int decision; int decision;
int hf_sum=0; int hf_sum=0;
@ -412,7 +412,7 @@ int spreading_decision(const CELTMode *m, celt_norm *X, int *average,
{ {
int j, N, tmp=0; int j, N, tmp=0;
int tcount[3] = {0,0,0}; int tcount[3] = {0,0,0};
celt_norm * restrict x = X+M*eBands[i]+c*N0; celt_norm * OPUS_RESTRICT x = X+M*eBands[i]+c*N0;
N = M*(eBands[i+1]-eBands[i]); N = M*(eBands[i+1]-eBands[i]);
if (N<=8) if (N<=8)
continue; continue;
@ -1175,8 +1175,8 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end,
{ {
int i; int i;
opus_int32 remaining_bits; opus_int32 remaining_bits;
const opus_int16 * restrict eBands = m->eBands; const opus_int16 * OPUS_RESTRICT eBands = m->eBands;
celt_norm * restrict norm, * restrict norm2; celt_norm * OPUS_RESTRICT norm, * OPUS_RESTRICT norm2;
VARDECL(celt_norm, _norm); VARDECL(celt_norm, _norm);
VARDECL(celt_norm, lowband_scratch); VARDECL(celt_norm, lowband_scratch);
int B; int B;
@ -1206,7 +1206,7 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end,
int N; int N;
opus_int32 curr_balance; opus_int32 curr_balance;
int effective_lowband=-1; int effective_lowband=-1;
celt_norm * restrict X, * restrict Y; celt_norm * OPUS_RESTRICT X, * OPUS_RESTRICT Y;
int tf_change=0; int tf_change=0;
unsigned x_cm; unsigned x_cm;
unsigned y_cm; unsigned y_cm;

View file

@ -51,14 +51,14 @@ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *band
* @param X Spectrum (returned normalised) * @param X Spectrum (returned normalised)
* @param bands Square root of the energy for each band * @param bands Square root of the energy for each band
*/ */
void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bandE, int end, int C, int M); void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, celt_norm * OPUS_RESTRICT X, const celt_ener *bandE, int end, int C, int M);
/** Denormalise each band of X to restore full amplitude /** Denormalise each band of X to restore full amplitude
* @param m Mode data * @param m Mode data
* @param X Spectrum (returned de-normalised) * @param X Spectrum (returned de-normalised)
* @param bands Square root of the energy for each band * @param bands Square root of the energy for each band
*/ */
void denormalise_bands(const CELTMode *m, const celt_norm * restrict X, celt_sig * restrict freq, const celt_ener *bandE, int end, int C, int M); void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X, celt_sig * OPUS_RESTRICT freq, const celt_ener *bandE, int end, int C, int M);
#define SPREAD_NONE (0) #define SPREAD_NONE (0)
#define SPREAD_LIGHT (1) #define SPREAD_LIGHT (1)

View file

@ -291,7 +291,7 @@ static inline opus_val16 SIG2WORD16(celt_sig x)
#endif #endif
} }
static int transient_analysis(const opus_val32 * restrict in, int len, int C, static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int C,
int overlap) int overlap)
{ {
int i; int i;
@ -383,7 +383,7 @@ static int transient_analysis(const opus_val32 * restrict in, int len, int C,
/** Apply window and compute the MDCT for all sub-frames and /** Apply window and compute the MDCT for all sub-frames and
all channels in a frame */ all channels in a frame */
static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * restrict in, celt_sig * restrict out, int C, int LM) static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * OPUS_RESTRICT in, celt_sig * OPUS_RESTRICT out, int C, int LM)
{ {
if (C==1 && !shortBlocks) if (C==1 && !shortBlocks)
{ {
@ -412,8 +412,8 @@ static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * rest
/** Compute the IMDCT and apply window for all sub-frames and /** Compute the IMDCT and apply window for all sub-frames and
all channels in a frame */ all channels in a frame */
static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X, static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X,
celt_sig * restrict out_mem[], celt_sig * OPUS_RESTRICT out_mem[],
celt_sig * restrict overlap_mem[], int C, int LM) celt_sig * OPUS_RESTRICT overlap_mem[], int C, int LM)
{ {
int c; int c;
const int N = mode->shortMdctSize<<LM; const int N = mode->shortMdctSize<<LM;
@ -458,8 +458,8 @@ static void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsa
int count=0; int count=0;
c=0; do { c=0; do {
int j; int j;
celt_sig * restrict x; celt_sig * OPUS_RESTRICT x;
opus_val16 * restrict y; opus_val16 * OPUS_RESTRICT y;
celt_sig m = mem[c]; celt_sig m = mem[c];
x =in[c]; x =in[c];
y = pcm+c; y = pcm+c;
@ -879,7 +879,7 @@ static int stereo_analysis(const CELTMode *m, const celt_norm *X,
> MULT16_32_Q15(m->eBands[13]<<(LM+1), sumLR); > MULT16_32_Q15(m->eBands[13]<<(LM+1), sumLR);
} }
int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc) int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc)
{ {
int i, c, N; int i, c, N;
opus_int32 bits; opus_int32 bits;
@ -1056,8 +1056,8 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
silence = 1; silence = 1;
c=0; do { c=0; do {
int count = 0; int count = 0;
const opus_val16 * restrict pcmp = pcm+c; const opus_val16 * OPUS_RESTRICT pcmp = pcm+c;
celt_sig * restrict inp = in+c*(N+st->overlap)+st->overlap; celt_sig * OPUS_RESTRICT inp = in+c*(N+st->overlap)+st->overlap;
for (i=0;i<N;i++) for (i=0;i<N;i++)
{ {
@ -1679,13 +1679,13 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
#ifdef CUSTOM_MODES #ifdef CUSTOM_MODES
#ifdef FIXED_POINT #ifdef FIXED_POINT
int opus_custom_encode(CELTEncoder * restrict st, const opus_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes) int opus_custom_encode(CELTEncoder * OPUS_RESTRICT st, const opus_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes)
{ {
return celt_encode_with_ec(st, pcm, frame_size, compressed, nbCompressedBytes, NULL); return celt_encode_with_ec(st, pcm, frame_size, compressed, nbCompressedBytes, NULL);
} }
#ifndef DISABLE_FLOAT_API #ifndef DISABLE_FLOAT_API
int opus_custom_encode_float(CELTEncoder * restrict st, const float * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes) int opus_custom_encode_float(CELTEncoder * OPUS_RESTRICT st, const float * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes)
{ {
int j, ret, C, N; int j, ret, C, N;
VARDECL(opus_int16, in); VARDECL(opus_int16, in);
@ -1712,7 +1712,7 @@ int opus_custom_encode_float(CELTEncoder * restrict st, const float * pcm, int f
#endif /* DISABLE_FLOAT_API */ #endif /* DISABLE_FLOAT_API */
#else #else
int opus_custom_encode(CELTEncoder * restrict st, const opus_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes) int opus_custom_encode(CELTEncoder * OPUS_RESTRICT st, const opus_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes)
{ {
int j, ret, C, N; int j, ret, C, N;
VARDECL(celt_sig, in); VARDECL(celt_sig, in);
@ -1737,7 +1737,7 @@ int opus_custom_encode(CELTEncoder * restrict st, const opus_int16 * pcm, int fr
return ret; return ret;
} }
int opus_custom_encode_float(CELTEncoder * restrict st, const float * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes) int opus_custom_encode_float(CELTEncoder * OPUS_RESTRICT st, const float * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes)
{ {
return celt_encode_with_ec(st, pcm, frame_size, compressed, nbCompressedBytes, NULL); return celt_encode_with_ec(st, pcm, frame_size, compressed, nbCompressedBytes, NULL);
} }
@ -1746,7 +1746,7 @@ int opus_custom_encode_float(CELTEncoder * restrict st, const float * pcm, int f
#endif /* CUSTOM_MODES */ #endif /* CUSTOM_MODES */
int opus_custom_encoder_ctl(CELTEncoder * restrict st, int request, ...) int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...)
{ {
va_list ap; va_list ap;
@ -2008,7 +2008,7 @@ void opus_custom_decoder_destroy(CELTDecoder *st)
} }
#endif /* CUSTOM_MODES */ #endif /* CUSTOM_MODES */
static void celt_decode_lost(CELTDecoder * restrict st, opus_val16 * restrict pcm, int N, int LM) static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_RESTRICT pcm, int N, int LM)
{ {
int c; int c;
int pitch_index; int pitch_index;
@ -2269,7 +2269,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, opus_val16 * restrict pc
RESTORE_STACK; RESTORE_STACK;
} }
int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, int len, opus_val16 * restrict pcm, int frame_size, ec_dec *dec) int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec)
{ {
int c, i, N; int c, i, N;
int spread_decision; int spread_decision;
@ -2651,13 +2651,13 @@ int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, in
#ifdef CUSTOM_MODES #ifdef CUSTOM_MODES
#ifdef FIXED_POINT #ifdef FIXED_POINT
int opus_custom_decode(CELTDecoder * restrict st, const unsigned char *data, int len, opus_int16 * restrict pcm, int frame_size) int opus_custom_decode(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_int16 * OPUS_RESTRICT pcm, int frame_size)
{ {
return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL); return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL);
} }
#ifndef DISABLE_FLOAT_API #ifndef DISABLE_FLOAT_API
int opus_custom_decode_float(CELTDecoder * restrict st, const unsigned char *data, int len, float * restrict pcm, int frame_size) int opus_custom_decode_float(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, float * OPUS_RESTRICT pcm, int frame_size)
{ {
int j, ret, C, N; int j, ret, C, N;
VARDECL(opus_int16, out); VARDECL(opus_int16, out);
@ -2682,12 +2682,12 @@ int opus_custom_decode_float(CELTDecoder * restrict st, const unsigned char *dat
#else #else
int opus_custom_decode_float(CELTDecoder * restrict st, const unsigned char *data, int len, float * restrict pcm, int frame_size) int opus_custom_decode_float(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, float * OPUS_RESTRICT pcm, int frame_size)
{ {
return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL); return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL);
} }
int opus_custom_decode(CELTDecoder * restrict st, const unsigned char *data, int len, opus_int16 * restrict pcm, int frame_size) int opus_custom_decode(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_int16 * OPUS_RESTRICT pcm, int frame_size)
{ {
int j, ret, C, N; int j, ret, C, N;
VARDECL(celt_sig, out); VARDECL(celt_sig, out);
@ -2713,7 +2713,7 @@ int opus_custom_decode(CELTDecoder * restrict st, const unsigned char *data, int
#endif #endif
#endif /* CUSTOM_MODES */ #endif /* CUSTOM_MODES */
int opus_custom_decoder_ctl(CELTDecoder * restrict st, int request, ...) int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...)
{ {
va_list ap; va_list ap;

View file

@ -92,7 +92,7 @@ extern "C" {
int celt_encoder_get_size(int channels); int celt_encoder_get_size(int channels);
int celt_encode_with_ec(OpusCustomEncoder * restrict st, const opus_val16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc); int celt_encode_with_ec(OpusCustomEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc);
int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels); int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels);
@ -105,7 +105,7 @@ int celt_decoder_get_size(int channels);
int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels); int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels);
int celt_decode_with_ec(OpusCustomDecoder * restrict st, const unsigned char *data, int len, opus_val16 * restrict pcm, int frame_size, ec_dec *dec); int celt_decode_with_ec(OpusCustomDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec);
#define celt_encoder_ctl opus_custom_encoder_ctl #define celt_encoder_ctl opus_custom_encoder_ctl
#define celt_decoder_ctl opus_custom_decoder_ctl #define celt_decoder_ctl opus_custom_decoder_ctl

View file

@ -102,7 +102,7 @@ void clt_mdct_clear(mdct_lookup *l)
#endif /* CUSTOM_MODES */ #endif /* CUSTOM_MODES */
/* Forward MDCT trashes the input array */ /* Forward MDCT trashes the input array */
void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out,
const opus_val16 *window, int overlap, int shift, int stride) const opus_val16 *window, int overlap, int shift, int stride)
{ {
int i; int i;
@ -126,11 +126,11 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar
/* Window, shuffle, fold */ /* Window, shuffle, fold */
{ {
/* Temp pointers to make it really clear to the compiler what we're doing */ /* Temp pointers to make it really clear to the compiler what we're doing */
const kiss_fft_scalar * restrict xp1 = in+(overlap>>1); const kiss_fft_scalar * OPUS_RESTRICT xp1 = in+(overlap>>1);
const kiss_fft_scalar * restrict xp2 = in+N2-1+(overlap>>1); const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+N2-1+(overlap>>1);
kiss_fft_scalar * restrict yp = f; kiss_fft_scalar * OPUS_RESTRICT yp = f;
const opus_val16 * restrict wp1 = window+(overlap>>1); const opus_val16 * OPUS_RESTRICT wp1 = window+(overlap>>1);
const opus_val16 * restrict wp2 = window+(overlap>>1)-1; const opus_val16 * OPUS_RESTRICT wp2 = window+(overlap>>1)-1;
for(i=0;i<(overlap>>2);i++) for(i=0;i<(overlap>>2);i++)
{ {
/* Real part arranged as -d-cR, Imag part arranged as -b+aR*/ /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/
@ -164,7 +164,7 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar
} }
/* Pre-rotation */ /* Pre-rotation */
{ {
kiss_fft_scalar * restrict yp = f; kiss_fft_scalar * OPUS_RESTRICT yp = f;
const kiss_twiddle_scalar *t = &l->trig[0]; const kiss_twiddle_scalar *t = &l->trig[0];
for(i=0;i<N4;i++) for(i=0;i<N4;i++)
{ {
@ -185,9 +185,9 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar
/* Post-rotate */ /* Post-rotate */
{ {
/* Temp pointers to make it really clear to the compiler what we're doing */ /* Temp pointers to make it really clear to the compiler what we're doing */
const kiss_fft_scalar * restrict fp = in; const kiss_fft_scalar * OPUS_RESTRICT fp = in;
kiss_fft_scalar * restrict yp1 = out; kiss_fft_scalar * OPUS_RESTRICT yp1 = out;
kiss_fft_scalar * restrict yp2 = out+stride*(N2-1); kiss_fft_scalar * OPUS_RESTRICT yp2 = out+stride*(N2-1);
const kiss_twiddle_scalar *t = &l->trig[0]; const kiss_twiddle_scalar *t = &l->trig[0];
/* Temp pointers to make it really clear to the compiler what we're doing */ /* Temp pointers to make it really clear to the compiler what we're doing */
for(i=0;i<N4;i++) for(i=0;i<N4;i++)
@ -206,8 +206,8 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar
RESTORE_STACK; RESTORE_STACK;
} }
void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out,
const opus_val16 * restrict window, int overlap, int shift, int stride) const opus_val16 * OPUS_RESTRICT window, int overlap, int shift, int stride)
{ {
int i; int i;
int N, N2, N4; int N, N2, N4;
@ -231,9 +231,9 @@ void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scala
/* Pre-rotate */ /* Pre-rotate */
{ {
/* Temp pointers to make it really clear to the compiler what we're doing */ /* Temp pointers to make it really clear to the compiler what we're doing */
const kiss_fft_scalar * restrict xp1 = in; const kiss_fft_scalar * OPUS_RESTRICT xp1 = in;
const kiss_fft_scalar * restrict xp2 = in+stride*(N2-1); const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+stride*(N2-1);
kiss_fft_scalar * restrict yp = f2; kiss_fft_scalar * OPUS_RESTRICT yp = f2;
const kiss_twiddle_scalar *t = &l->trig[0]; const kiss_twiddle_scalar *t = &l->trig[0];
for(i=0;i<N4;i++) for(i=0;i<N4;i++)
{ {
@ -253,7 +253,7 @@ void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scala
/* Post-rotate */ /* Post-rotate */
{ {
kiss_fft_scalar * restrict fp = f; kiss_fft_scalar * OPUS_RESTRICT fp = f;
const kiss_twiddle_scalar *t = &l->trig[0]; const kiss_twiddle_scalar *t = &l->trig[0];
for(i=0;i<N4;i++) for(i=0;i<N4;i++)
@ -271,9 +271,9 @@ void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scala
} }
/* De-shuffle the components for the middle of the window only */ /* De-shuffle the components for the middle of the window only */
{ {
const kiss_fft_scalar * restrict fp1 = f; const kiss_fft_scalar * OPUS_RESTRICT fp1 = f;
const kiss_fft_scalar * restrict fp2 = f+N2-1; const kiss_fft_scalar * OPUS_RESTRICT fp2 = f+N2-1;
kiss_fft_scalar * restrict yp = f2; kiss_fft_scalar * OPUS_RESTRICT yp = f2;
for(i = 0; i < N4; i++) for(i = 0; i < N4; i++)
{ {
*yp++ =-*fp1; *yp++ =-*fp1;
@ -285,11 +285,11 @@ void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scala
out -= (N2-overlap)>>1; out -= (N2-overlap)>>1;
/* Mirror on both sides for TDAC */ /* Mirror on both sides for TDAC */
{ {
kiss_fft_scalar * restrict fp1 = f2+N4-1; kiss_fft_scalar * OPUS_RESTRICT fp1 = f2+N4-1;
kiss_fft_scalar * restrict xp1 = out+N2-1; kiss_fft_scalar * OPUS_RESTRICT xp1 = out+N2-1;
kiss_fft_scalar * restrict yp1 = out+N4-overlap/2; kiss_fft_scalar * OPUS_RESTRICT yp1 = out+N4-overlap/2;
const opus_val16 * restrict wp1 = window; const opus_val16 * OPUS_RESTRICT wp1 = window;
const opus_val16 * restrict wp2 = window+overlap-1; const opus_val16 * OPUS_RESTRICT wp2 = window+overlap-1;
for(i = 0; i< N4-overlap/2; i++) for(i = 0; i< N4-overlap/2; i++)
{ {
*xp1 = *fp1; *xp1 = *fp1;
@ -307,11 +307,11 @@ void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scala
} }
} }
{ {
kiss_fft_scalar * restrict fp2 = f2+N4; kiss_fft_scalar * OPUS_RESTRICT fp2 = f2+N4;
kiss_fft_scalar * restrict xp2 = out+N2; kiss_fft_scalar * OPUS_RESTRICT xp2 = out+N2;
kiss_fft_scalar * restrict yp2 = out+N-1-(N4-overlap/2); kiss_fft_scalar * OPUS_RESTRICT yp2 = out+N-1-(N4-overlap/2);
const opus_val16 * restrict wp1 = window; const opus_val16 * OPUS_RESTRICT wp1 = window;
const opus_val16 * restrict wp2 = window+overlap-1; const opus_val16 * OPUS_RESTRICT wp2 = window+overlap-1;
for(i = 0; i< N4-overlap/2; i++) for(i = 0; i< N4-overlap/2; i++)
{ {
*xp2 = *fp2; *xp2 = *fp2;

View file

@ -42,6 +42,7 @@
#ifndef MDCT_H #ifndef MDCT_H
#define MDCT_H #define MDCT_H
#include "opus_defines.h"
#include "kiss_fft.h" #include "kiss_fft.h"
#include "arch.h" #include "arch.h"
@ -49,7 +50,7 @@ typedef struct {
int n; int n;
int maxshift; int maxshift;
const kiss_fft_state *kfft[4]; const kiss_fft_state *kfft[4];
const kiss_twiddle_scalar * restrict trig; const kiss_twiddle_scalar * OPUS_RESTRICT trig;
} mdct_lookup; } mdct_lookup;
int clt_mdct_init(mdct_lookup *l,int N, int maxshift); int clt_mdct_init(mdct_lookup *l,int N, int maxshift);
@ -62,6 +63,6 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar
/** Compute a backward MDCT (no scaling) and performs weighted overlap-add /** Compute a backward MDCT (no scaling) and performs weighted overlap-add
(scales implicitly by 1/2) */ (scales implicitly by 1/2) */
void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out,
const opus_val16 * restrict window, int overlap, int shift, int stride); const opus_val16 * OPUS_RESTRICT window, int overlap, int shift, int stride);
#endif #endif

View file

@ -102,7 +102,7 @@ static void find_best_pitch(opus_val32 *xcorr, opus_val16 *y, int len,
} }
} }
void pitch_downsample(celt_sig * restrict x[], opus_val16 * restrict x_lp, void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x_lp,
int len, int C) int len, int C)
{ {
int i; int i;
@ -169,7 +169,7 @@ void pitch_downsample(celt_sig * restrict x[], opus_val16 * restrict x_lp,
} }
void pitch_search(const opus_val16 * restrict x_lp, opus_val16 * restrict y, void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTRICT y,
int len, int max_pitch, int *pitch) int len, int max_pitch, int *pitch)
{ {
int i, j; int i, j;

View file

@ -36,10 +36,10 @@
#include "modes.h" #include "modes.h"
void pitch_downsample(celt_sig * restrict x[], opus_val16 * restrict x_lp, void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x_lp,
int len, int C); int len, int C);
void pitch_search(const opus_val16 * restrict x_lp, opus_val16 * restrict y, void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTRICT y,
int len, int max_pitch, int *pitch); int len, int max_pitch, int *pitch);
opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,

View file

@ -109,7 +109,7 @@ static void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int
/** Takes the pitch vector and the decoded residual vector, computes the gain /** Takes the pitch vector and the decoded residual vector, computes the gain
that will give ||p+g*y||=1 and mixes the residual with the pitch. */ that will give ||p+g*y||=1 and mixes the residual with the pitch. */
static void normalise_residual(int * restrict iy, celt_norm * restrict X, static void normalise_residual(int * OPUS_RESTRICT iy, celt_norm * OPUS_RESTRICT X,
int N, opus_val32 Ryy, opus_val16 gain) int N, opus_val32 Ryy, opus_val16 gain)
{ {
int i; int i;

View file

@ -84,6 +84,18 @@ extern "C" {
# endif # endif
# endif # endif
#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
# if OPUS_GNUC_PREREQ(3,0)
# define OPUS_RESTRICT __restrict__
# elif (_MSC_VER >= 1400)
# define OPUS_RESTRICT __restrict
# else
# define OPUS_RESTRICT
# endif
#else
# define OPUS_RESTRICT restrict
#endif
/**Warning attributes for opus functions /**Warning attributes for opus functions
* NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out * NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out
* some paranoid null checks. */ * some paranoid null checks. */