Commit 1dab60cc by Jean-Marc Valin

Better use of the arithmetic operators

parent b781877e
 ... ... @@ -114,6 +114,20 @@ struct kiss_fft_state{ do { DIVSCALAR( (c).r , div); \ DIVSCALAR( (c).i , div); }while (0) #define C_ADD( res, a,b)\ do {(res).r=ADD32((a).r,(b).r); (res).i=ADD32((a).i,(b).i); \ }while(0) #define C_SUB( res, a,b)\ do {(res).r=SUB32((a).r,(b).r); (res).i=SUB32((a).i,(b).i); \ }while(0) #define C_ADDTO( res , a)\ do {(res).r = ADD32((res).r, (a).r); (res).i = ADD32((res).i,(a).i);\ }while(0) #define C_SUBFROM( res , a)\ do {(res).r = ADD32((res).r,(a).r); (res).i = SUB32((res).i,(a).i); \ }while(0) #else /* MIXED_PRECISION */ # define sround4( x ) (kiss_fft_scalar)( ( (x) + ((SAMPPROD)1<<(FRACBITS-1)) ) >> (FRACBITS+2) ) ... ... @@ -165,10 +179,13 @@ struct kiss_fft_state{ (c).i *= (s); }while(0) #endif #ifndef CHECK_OVERFLOW_OP # define CHECK_OVERFLOW_OP(a,op,b) /* noop */ #endif #ifndef C_ADD #define C_ADD( res, a,b)\ do { \ CHECK_OVERFLOW_OP((a).r,+,(b).r)\ ... ... @@ -194,7 +211,7 @@ struct kiss_fft_state{ CHECK_OVERFLOW_OP((res).i,-,(a).i)\ (res).r -= (a).r; (res).i -= (a).i; \ }while(0) #endif /* C_ADD defined */ #ifdef FIXED_POINT /*# define KISS_FFT_COS(phase) TRIG_UPSCALE*floor(MIN(32767,MAX(-32767,.5+32768 * cos (phase)))) ... ...
 ... ... @@ -69,8 +69,8 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t * { int shift = celt_ilog2(maxval)-10; j=eBands[i]; do { sum += MULT16_16(EXTRACT16(VSHR32(X[j*C+c],shift)), EXTRACT16(VSHR32(X[j*C+c],shift))); sum = MAC16_16(sum, EXTRACT16(VSHR32(X[j*C+c],shift)), EXTRACT16(VSHR32(X[j*C+c],shift))); } while (++j
 ... ... @@ -617,8 +617,8 @@ int celt_encode_float(CELTEncoder * restrict st, celt_sig_t * restrict pcm, unsi int j; for (j=0;jout_mem[C*(MAX_PERIOD-N)+C*j+c], MULT16_32_Q15(preemph,st->preemph_memD[c])); celt_sig_t tmp = MAC16_32_Q15(st->out_mem[C*(MAX_PERIOD-N)+C*j+c], preemph,st->preemph_memD[c]); st->preemph_memD[c] = tmp; pcm[C*j+c] = SCALEOUT(SIG2WORD16(tmp)); } ... ... @@ -825,8 +825,8 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16_t * restrict int j; for (j=0;jout_mem[C*(MAX_PERIOD-N)+C*j+c], MULT16_32_Q15(preemph,st->preemph_memD[c])); celt_sig_t tmp = MAC16_32_Q15(st->out_mem[C*(MAX_PERIOD-N)+C*j+c], preemph,st->preemph_memD[c]); st->preemph_memD[c] = tmp; pcm[C*j+c] = SCALEOUT(SIG2WORD16(tmp)); } ... ... @@ -994,8 +994,8 @@ int celt_decode_float(CELTDecoder * restrict st, unsigned char *data, int len, c int j; for (j=0;jout_mem[C*(MAX_PERIOD-N)+C*j+c], MULT16_32_Q15(preemph,st->preemph_memD[c])); celt_sig_t tmp = MAC16_32_Q15(st->out_mem[C*(MAX_PERIOD-N)+C*j+c], preemph,st->preemph_memD[c]); st->preemph_memD[c] = tmp; pcm[C*j+c] = SCALEOUT(SIG2WORD16(tmp)); } ... ...
 ... ... @@ -373,7 +373,7 @@ static inline int MULT16_32_PX(int a, long long b, int Q) #define MULT16_32_Q14(a,b) MULT16_32_QX(a,b,14) #define MULT16_32_Q15(a,b) MULT16_32_QX(a,b,15) #define MULT16_32_P15(a,b) MULT16_32_PX(a,b,15) #define MAC16_32_Q15(c,a,b) ADD32((c),MULT16_32_Q15((a),(b))) #define MAC16_32_Q15(c,a,b) (celt_mips-=2,ADD32((c),MULT16_32_Q15((a),(b)))) static inline int SATURATE(int a, int b) { ... ...