diff --git a/celt/bands.c b/celt/bands.c index b88513ab..f38b6626 100644 --- a/celt/bands.c +++ b/celt/bands.c @@ -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. */ -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; 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. */ -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; 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 */ /* 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; const opus_int16 *eBands = m->eBands; N = M*m->shortMdctSize; celt_assert2(C<=2, "denormalise_bands() not implemented for >2 channels"); c=0; do { - celt_sig * restrict f; - const celt_norm * restrict x; + celt_sig * OPUS_RESTRICT f; + const celt_norm * OPUS_RESTRICT x; f = freq+c*N; x = X+c*N; for (i=0;ieBands; + const opus_int16 * OPUS_RESTRICT eBands = m->eBands; int decision; 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 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]); if (N<=8) continue; @@ -1175,8 +1175,8 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, { int i; opus_int32 remaining_bits; - const opus_int16 * restrict eBands = m->eBands; - celt_norm * restrict norm, * restrict norm2; + const opus_int16 * OPUS_RESTRICT eBands = m->eBands; + celt_norm * OPUS_RESTRICT norm, * OPUS_RESTRICT norm2; VARDECL(celt_norm, _norm); VARDECL(celt_norm, lowband_scratch); int B; @@ -1206,7 +1206,7 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, int N; opus_int32 curr_balance; int effective_lowband=-1; - celt_norm * restrict X, * restrict Y; + celt_norm * OPUS_RESTRICT X, * OPUS_RESTRICT Y; int tf_change=0; unsigned x_cm; unsigned y_cm; diff --git a/celt/bands.h b/celt/bands.h index cce16a09..9ff8ffd7 100644 --- a/celt/bands.h +++ b/celt/bands.h @@ -51,14 +51,14 @@ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *band * @param X Spectrum (returned normalised) * @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 * @param m Mode data * @param X Spectrum (returned de-normalised) * @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_LIGHT (1) diff --git a/celt/celt.c b/celt/celt.c index cfdfaafe..4f16887d 100644 --- a/celt/celt.c +++ b/celt/celt.c @@ -291,7 +291,7 @@ static inline opus_val16 SIG2WORD16(celt_sig x) #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 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 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) { @@ -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 all channels in a frame */ static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X, - celt_sig * restrict out_mem[], - celt_sig * restrict overlap_mem[], int C, int LM) + celt_sig * OPUS_RESTRICT out_mem[], + celt_sig * OPUS_RESTRICT overlap_mem[], int C, int LM) { int c; const int N = mode->shortMdctSize< 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; opus_int32 bits; @@ -1056,8 +1056,8 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f silence = 1; c=0; do { int count = 0; - const opus_val16 * restrict pcmp = pcm+c; - celt_sig * restrict inp = in+c*(N+st->overlap)+st->overlap; + const opus_val16 * OPUS_RESTRICT pcmp = pcm+c; + celt_sig * OPUS_RESTRICT inp = in+c*(N+st->overlap)+st->overlap; for (i=0;i>1); - const kiss_fft_scalar * restrict xp2 = in+N2-1+(overlap>>1); - kiss_fft_scalar * restrict yp = f; - const opus_val16 * restrict wp1 = window+(overlap>>1); - const opus_val16 * restrict wp2 = window+(overlap>>1)-1; + const kiss_fft_scalar * OPUS_RESTRICT xp1 = in+(overlap>>1); + const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+N2-1+(overlap>>1); + kiss_fft_scalar * OPUS_RESTRICT yp = f; + const opus_val16 * OPUS_RESTRICT wp1 = window+(overlap>>1); + const opus_val16 * OPUS_RESTRICT wp2 = window+(overlap>>1)-1; for(i=0;i<(overlap>>2);i++) { /* 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 */ { - kiss_fft_scalar * restrict yp = f; + kiss_fft_scalar * OPUS_RESTRICT yp = f; const kiss_twiddle_scalar *t = &l->trig[0]; for(i=0;itrig[0]; /* Temp pointers to make it really clear to the compiler what we're doing */ for(i=0;itrig[0]; for(i=0;itrig[0]; for(i=0;i>1; /* Mirror on both sides for TDAC */ { - kiss_fft_scalar * restrict fp1 = f2+N4-1; - kiss_fft_scalar * restrict xp1 = out+N2-1; - kiss_fft_scalar * restrict yp1 = out+N4-overlap/2; - const opus_val16 * restrict wp1 = window; - const opus_val16 * restrict wp2 = window+overlap-1; + kiss_fft_scalar * OPUS_RESTRICT fp1 = f2+N4-1; + kiss_fft_scalar * OPUS_RESTRICT xp1 = out+N2-1; + kiss_fft_scalar * OPUS_RESTRICT yp1 = out+N4-overlap/2; + const opus_val16 * OPUS_RESTRICT wp1 = window; + const opus_val16 * OPUS_RESTRICT wp2 = window+overlap-1; for(i = 0; i< N4-overlap/2; i++) { *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 * restrict xp2 = out+N2; - kiss_fft_scalar * restrict yp2 = out+N-1-(N4-overlap/2); - const opus_val16 * restrict wp1 = window; - const opus_val16 * restrict wp2 = window+overlap-1; + kiss_fft_scalar * OPUS_RESTRICT fp2 = f2+N4; + kiss_fft_scalar * OPUS_RESTRICT xp2 = out+N2; + kiss_fft_scalar * OPUS_RESTRICT yp2 = out+N-1-(N4-overlap/2); + const opus_val16 * OPUS_RESTRICT wp1 = window; + const opus_val16 * OPUS_RESTRICT wp2 = window+overlap-1; for(i = 0; i< N4-overlap/2; i++) { *xp2 = *fp2; diff --git a/celt/mdct.h b/celt/mdct.h index 5ec26d0a..201f28b4 100644 --- a/celt/mdct.h +++ b/celt/mdct.h @@ -42,6 +42,7 @@ #ifndef MDCT_H #define MDCT_H +#include "opus_defines.h" #include "kiss_fft.h" #include "arch.h" @@ -49,7 +50,7 @@ typedef struct { int n; int maxshift; const kiss_fft_state *kfft[4]; - const kiss_twiddle_scalar * restrict trig; + const kiss_twiddle_scalar * OPUS_RESTRICT trig; } mdct_lookup; 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 (scales implicitly by 1/2) */ 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 diff --git a/celt/pitch.c b/celt/pitch.c index 8e906878..c2f08ec1 100644 --- a/celt/pitch.c +++ b/celt/pitch.c @@ -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 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 i, j; diff --git a/celt/pitch.h b/celt/pitch.h index 2509d64b..2757071a 100644 --- a/celt/pitch.h +++ b/celt/pitch.h @@ -36,10 +36,10 @@ #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); -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); opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, diff --git a/celt/vq.c b/celt/vq.c index a2a4fd36..98a0f36c 100644 --- a/celt/vq.c +++ b/celt/vq.c @@ -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 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 i; diff --git a/include/opus_defines.h b/include/opus_defines.h index aad47fc4..a16bd648 100644 --- a/include/opus_defines.h +++ b/include/opus_defines.h @@ -84,6 +84,18 @@ extern "C" { # 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 * NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out * some paranoid null checks. */