diff --git a/libcelt/_kiss_fft_guts.h b/libcelt/_kiss_fft_guts.h index 4c39073d..38a2fba0 100644 --- a/libcelt/_kiss_fft_guts.h +++ b/libcelt/_kiss_fft_guts.h @@ -23,7 +23,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */ #include "kiss_fft.h" - /* Explanation of macros dealing with complex math: @@ -40,20 +39,16 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND #ifdef DOUBLE_PRECISION -# define FRACBITS 31 # define SAMPPROD long long #define SAMP_MAX 2147483647 #define TWID_MAX 32767 #define TRIG_UPSCALE 1 -#define EXT32(a) (a) #else /* DOUBLE_PRECISION */ -# define FRACBITS 15 # define SAMPPROD opus_int32 #define SAMP_MAX 32767 #define TRIG_UPSCALE 1 -#define EXT32(a) EXTEND32(a) #endif /* !DOUBLE_PRECISION */ @@ -65,10 +60,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); } #endif -# define smul(a,b) ( (SAMPPROD)(a)*(b) ) -# define sround( x ) (kiss_fft_scalar)( ( (x) + ((SAMPPROD)1<<(FRACBITS-1)) ) >> FRACBITS ) - - # define S_MUL(a,b) MULT16_32_Q15(b, a) # define C_MUL(m,a,b) \ @@ -108,13 +99,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND do {(res).r = ADD32((res).r,(a).r); (res).i = SUB32((res).i,(a).i); \ }while(0) - - - #else /* not FIXED_POINT*/ -#define EXT32(a) (a) - # define S_MUL(a,b) ( (a)*(b) ) #define C_MUL(m,a,b) \ do{ (m).r = (a).r*(b).r - (a).i*(b).i;\ @@ -131,8 +117,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND (c).i *= (s); }while(0) #endif - - #ifndef CHECK_OVERFLOW_OP # define CHECK_OVERFLOW_OP(a,op,b) /* noop */ #endif @@ -193,5 +177,4 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND (x)->i = TRIG_UPSCALE*celt_cos_norm((phase)-32768);\ }while(0) - #endif /* KISS_FFT_GUTS_H */ diff --git a/libcelt/arch.h b/libcelt/arch.h index 1ce1cda6..b025b3d1 100644 --- a/libcelt/arch.h +++ b/libcelt/arch.h @@ -71,8 +71,6 @@ static inline void _celt_fatal(const char *str, const char *file, int line) #endif #define IMUL32(a,b) ((a)*(b)) -#define UMUL32(a,b) ((opus_int32)(a)*(opus_int32)(b)) -#define UMUL16_16(a,b) ((opus_int32)(a)*(opus_int32)(b)) #define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */ #define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */ @@ -99,30 +97,16 @@ typedef opus_val32 celt_ener; typedef opus_val32 celt_mask; #define Q15ONE 32767 -#define Q30ONE 1073741823 #define SIG_SHIFT 12 #define NORM_SCALING 16384 -#define NORM_SCALING_1 (1.f/16384.f) -#define NORM_SHIFT 14 - -#define ENER_SCALING 16384.f -#define ENER_SCALING_1 (1.f/16384.f) -#define ENER_SHIFT 14 - -#define PGAIN_SCALING 32768.f -#define PGAIN_SCALING_1 (1.f/32768.f) -#define PGAIN_SHIFT 15 #define DB_SHIFT 10 #define EPSILON 1 -#define VERY_SMALL 0 -#define VERY_LARGE32 ((opus_val32)2147483647) #define VERY_LARGE16 ((opus_val16)32767) #define Q15_ONE ((opus_val16)32767) -#define Q15_ONE_1 (1.f/32768.f) #define SCALEIN(a) (a) #define SCALEOUT(a) (a) @@ -147,7 +131,6 @@ typedef opus_val32 celt_mask; #endif - #else /* FIXED_POINT */ typedef float opus_val16; @@ -160,21 +143,12 @@ typedef float celt_pgain; typedef float celt_mask; #define Q15ONE 1.0f -#define Q30ONE 1.0f #define NORM_SCALING 1.f -#define NORM_SCALING_1 1.f -#define ENER_SCALING 1.f -#define ENER_SCALING_1 1.f -#define PGAIN_SCALING 1.f -#define PGAIN_SCALING_1 1.f #define EPSILON 1e-15f -#define VERY_SMALL 1e-15f -#define VERY_LARGE32 1e15f #define VERY_LARGE16 1e15f #define Q15_ONE ((opus_val16)1.f) -#define Q15_ONE_1 ((opus_val16)1.f) #define QCONST16(x,bits) (x) #define QCONST32(x,bits) (x) @@ -187,11 +161,8 @@ typedef float celt_mask; #define SHL16(a,shift) (a) #define SHR32(a,shift) (a) #define SHL32(a,shift) (a) -#define PSHR16(a,shift) (a) #define PSHR32(a,shift) (a) #define VSHR32(a,shift) (a) -#define SATURATE16(x,a) (x) -#define SATURATE32(x,a) (x) #define PSHR(a,shift) (a) #define SHR(a,shift) (a) @@ -210,21 +181,13 @@ typedef float celt_mask; #define MULT16_16(a,b) ((opus_val32)(a)*(opus_val32)(b)) #define MAC16_16(c,a,b) ((c)+(opus_val32)(a)*(opus_val32)(b)) -#define MULT16_32_Q11(a,b) ((a)*(b)) -#define MULT16_32_Q13(a,b) ((a)*(b)) -#define MULT16_32_Q14(a,b) ((a)*(b)) #define MULT16_32_Q15(a,b) ((a)*(b)) #define MULT16_32_Q16(a,b) ((a)*(b)) -#define MULT16_32_P15(a,b) ((a)*(b)) #define MULT32_32_Q31(a,b) ((a)*(b)) -#define MAC16_32_Q11(c,a,b) ((c)+(a)*(b)) #define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) -#define MAC16_16_Q11(c,a,b) ((c)+(a)*(b)) -#define MAC16_16_Q13(c,a,b) ((c)+(a)*(b)) -#define MAC16_16_P13(c,a,b) ((c)+(a)*(b)) #define MULT16_16_Q11_32(a,b) ((a)*(b)) #define MULT16_16_Q13(a,b) ((a)*(b)) #define MULT16_16_Q14(a,b) ((a)*(b)) @@ -234,31 +197,13 @@ typedef float celt_mask; #define MULT16_16_P14(a,b) ((a)*(b)) #define DIV32_16(a,b) (((opus_val32)(a))/(opus_val16)(b)) -#define PDIV32_16(a,b) (((opus_val32)(a))/(opus_val16)(b)) #define DIV32(a,b) (((opus_val32)(a))/(opus_val32)(b)) -#define PDIV32(a,b) (((opus_val32)(a))/(opus_val32)(b)) #define SCALEIN(a) ((a)*CELT_SIG_SCALE) #define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE)) #endif /* !FIXED_POINT */ - -#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) - -/* 2 on TI C5x DSP */ -#define BYTES_PER_CHAR 2 -#define BITS_PER_CHAR 16 -#define LOG2_BITS_PER_CHAR 4 - -#else /* CONFIG_TI_C54X */ - -#define BYTES_PER_CHAR 1 -#define BITS_PER_CHAR 8 -#define LOG2_BITS_PER_CHAR 3 - -#endif /* !CONFIG_TI_C54X */ - #ifndef GLOBAL_STACK_SIZE #ifdef FIXED_POINT #define GLOBAL_STACK_SIZE 100000 diff --git a/libcelt/bands.c b/libcelt/bands.c index f86dea3e..7952de0c 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -296,10 +296,8 @@ void anti_collapse(const CELTMode *m, celt_norm *_X, unsigned char *collapse_mas renormalise_vector(X, N0<>10)/3-1; #else - qg = floor(.5+gain1*32/3)-1; + qg = (int)floor(.5f+gain1*32/3)-1; #endif qg = IMAX(0, IMIN(7, qg)); ec_enc_bit_logp(enc, 1, 1); diff --git a/libcelt/celt.h b/libcelt/celt.h index 29e28539..7a3064dd 100644 --- a/libcelt/celt.h +++ b/libcelt/celt.h @@ -71,7 +71,6 @@ extern "C" { /** Memory allocation has failed */ #define CELT_ALLOC_FAIL -7 - /* Encoder/decoder Requests */ #define CELT_SET_COMPLEXITY_REQUEST 2 @@ -122,8 +121,6 @@ extern "C" { #define CELT_SET_END_BAND_REQUEST 10001 #define CELT_SET_END_BAND(x) CELT_SET_END_BAND_REQUEST, _celt_check_int(x) - - /** Contains the state of an encoder. One encoder state is needed for each stream. It is initialised once at the beginning of the stream. Do *not* re-initialise the state for every frame. @@ -142,7 +139,6 @@ typedef struct CELTDecoder CELTDecoder; bad */ typedef struct CELTMode CELTMode; - /** \defgroup codec Encoding and decoding */ /* @{ */ @@ -308,7 +304,6 @@ CELT_EXPORT int celt_decode(CELTDecoder *st, const unsigned char *data, int len, */ CELT_EXPORT int celt_decoder_ctl(CELTDecoder * st, int request, ...); - /** Returns the English string that corresponds to an error code * @param error Error code (negative for an error, 0 for success * @return Constant string (must NOT be freed) @@ -317,7 +312,6 @@ CELT_EXPORT const char *celt_strerror(int error); /* @} */ - #ifdef __cplusplus } #endif diff --git a/libcelt/cwrs.c b/libcelt/cwrs.c index 940acbe2..dfc943e4 100644 --- a/libcelt/cwrs.c +++ b/libcelt/cwrs.c @@ -71,7 +71,6 @@ int log2_frac(opus_uint32 val, int frac) #ifndef SMALL_FOOTPRINT - #define MASK32 (0xFFFFFFFF) /*INV_TABLE[i] holds the multiplicative inverse of (2*i+1) mod 2**32.*/ @@ -267,11 +266,6 @@ static inline opus_uint32 imusdiv32even(opus_uint32 _a,opus_uint32 _b, #ifndef SMALL_FOOTPRINT -/*Compute U(1,_k).*/ -static inline unsigned ucwrs1(int _k){ - return _k?1:0; -} - /*Compute V(1,_k).*/ static inline unsigned ncwrs1(int _k){ return _k?2:1; @@ -539,7 +533,6 @@ static void cwrsi(int _n,int _k,opus_uint32 _i,int *_y,opus_uint32 *_u){ while(++j<_n); } - /*Returns the index of the given combination of K elements chosen from a set of size 1 with associated sign bits. _y: The vector of pulses, whose sum of absolute values is K. diff --git a/libcelt/dump_modes.c b/libcelt/dump_modes.c index a3976936..abc84e30 100644 --- a/libcelt/dump_modes.c +++ b/libcelt/dump_modes.c @@ -38,7 +38,7 @@ #define INT16 "%d" #define INT32 "%d" -#define FLOAT "%f" +#define FLOAT "%0.9ff" #ifdef FIXED_POINT #define WORD16 INT16 @@ -48,7 +48,6 @@ #define WORD32 FLOAT #endif - void dump_modes(FILE *file, CELTMode **modes, int nb_modes) { int i, j, k; @@ -167,7 +166,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) mode->Fs, mdctSize, k); fprintf (file, "%d,\t/* nfft */\n", mode->mdct.kfft[k]->nfft); #ifndef FIXED_POINT - fprintf (file, "%f,\t/* scale */\n", mode->mdct.kfft[k]->scale); + fprintf (file, "%0.9ff,\t/* scale */\n", mode->mdct.kfft[k]->scale); #endif fprintf (file, "%d,\t/* shift */\n", mode->mdct.kfft[k]->shift); fprintf (file, "{"); diff --git a/libcelt/ecintrin.h b/libcelt/ecintrin.h index 3a502c7c..e6a68a57 100644 --- a/libcelt/ecintrin.h +++ b/libcelt/ecintrin.h @@ -57,25 +57,7 @@ are just as fast, and do not require any special target architecture. Earlier gcc versions (3.x) compiled both code to the same assembly instructions, because of the way they represented ((_b)>(_a)) internally.*/ -#define EC_MAXI(_a,_b) ((_a)-((_a)-(_b)&-((_b)>(_a)))) -#define EC_MINI(_a,_b) ((_a)+((_b)-(_a)&-((_b)<(_a)))) -/*This has a chance of compiling branchless, and is just as fast as the - bit-twiddling method, which is slightly less portable, since it relies on a - sign-extended rightshift, which is not guaranteed by ANSI (but present on - every relevant platform).*/ -#define EC_SIGNI(_a) (((_a)>0)-((_a)<0)) -/*Slightly more portable than relying on a sign-extended right-shift (which is - not guaranteed by ANSI), and just as fast, since gcc (3.x and 4.x both) - compile it into the right-shift anyway.*/ -#define EC_SIGNMASK(_a) (-((_a)<0)) -/*Clamps an integer into the given range. - If _a>_c, then the lower bound _a is respected over the upper bound _c (this - behavior is required to meet our documented API behavior). - _a: The lower bound. - _b: The value to clamp. - _c: The upper boud.*/ -#define EC_CLAMPI(_a,_b,_c) (EC_MAXI(_a,EC_MINI(_b,_c))) - +# define EC_MINI(_a,_b) ((_a)+((_b)-(_a)&-((_b)<(_a)))) /*Count leading zeros. This macro should only be used for implementing ec_ilog(), if it is defined. @@ -116,8 +98,6 @@ static __inline int ec_bsr(unsigned long _x){ # define EC_ILOG(_x) (EC_CLZ0-EC_CLZ(_x)) #else int ec_ilog(opus_uint32 _v); - # define EC_ILOG(_x) (ec_ilog(_x)) #endif - #endif diff --git a/libcelt/entcode.c b/libcelt/entcode.c index e6a6a3cc..984987ee 100644 --- a/libcelt/entcode.c +++ b/libcelt/entcode.c @@ -32,8 +32,6 @@ #include "entcode.h" #include "arch.h" - - #if !defined(EC_CLZ) int ec_ilog(opus_uint32 _v){ /*On a Pentium M, this branchless version tested as the fastest on @@ -59,7 +57,6 @@ int ec_ilog(opus_uint32 _v){ } #endif - opus_uint32 ec_tell_frac(ec_ctx *_this){ opus_uint32 nbits; opus_uint32 r; diff --git a/libcelt/entcode.h b/libcelt/entcode.h index 0da95b7e..2792ada9 100644 --- a/libcelt/entcode.h +++ b/libcelt/entcode.h @@ -33,8 +33,6 @@ # include # include "ecintrin.h" - - /*OPT: ec_window must be at least 32 bits, but if you have fast arithmetic on a larger type, you can speed up the decoder by using it here.*/ typedef opus_uint32 ec_window; @@ -42,8 +40,6 @@ typedef struct ec_ctx ec_ctx; typedef struct ec_ctx ec_enc; typedef struct ec_ctx ec_dec; - - # define EC_WINDOW_SIZE ((int)sizeof(ec_window)*CHAR_BIT) /*The number of bits to use for the range-coded part of unsigned integers.*/ @@ -53,8 +49,6 @@ typedef struct ec_ctx ec_dec; 3 => 1/8th bits.*/ # define BITRES 3 - - /*The entropy encoder/decoder context. We use the same structure for both, so that common functions like ec_tell() can be used on either one.*/ @@ -89,12 +83,6 @@ struct ec_ctx{ int error; }; - -/*Shared functions.*/ -static inline void ec_reset(ec_ctx *_this){ - _this->offs=_this->end_offs=0; -} - static inline opus_uint32 ec_range_bytes(ec_ctx *_this){ return _this->offs; } diff --git a/libcelt/entdec.c b/libcelt/entdec.c index 83203df8..47d710bd 100644 --- a/libcelt/entdec.c +++ b/libcelt/entdec.c @@ -35,8 +35,6 @@ #include "entdec.h" #include "mfrngcod.h" - - /*A range decoder. This is an entropy decoder based upon \cite{Mar79}, which is itself a rediscovery of the FIFO arithmetic code introduced by \cite{Pas76}. @@ -94,8 +92,6 @@ URL="http://www.stanford.edu/class/ee398/handouts/papers/Moffat98ArithmCoding.pdf" }*/ - - static int ec_read_byte(ec_dec *_this){ return _this->offs<_this->storage?_this->buf[_this->offs++]:0; } @@ -105,7 +101,6 @@ static int ec_read_byte_from_end(ec_dec *_this){ _this->buf[_this->storage-++(_this->end_offs)]:0; } - /*Normalizes the contents of val and rng so that rng lies entirely in the high-order symbol.*/ static void ec_dec_normalize(ec_dec *_this){ @@ -144,7 +139,6 @@ void ec_dec_init(ec_dec *_this,unsigned char *_buf,opus_uint32 _storage){ _this->nbits_total=EC_CODE_BITS+1; } - unsigned ec_decode(ec_dec *_this,unsigned _ft){ unsigned s; _this->ext=_this->rng/_ft; diff --git a/libcelt/entdec.h b/libcelt/entdec.h index dfe694d8..719fdb24 100644 --- a/libcelt/entdec.h +++ b/libcelt/entdec.h @@ -30,8 +30,6 @@ # include # include "entcode.h" - - /*Initializes the decoder. _buf: The input buffer to use. Return: 0 on success, or a negative value on error.*/ diff --git a/libcelt/entenc.c b/libcelt/entenc.c index cae1afa8..62462edb 100644 --- a/libcelt/entenc.c +++ b/libcelt/entenc.c @@ -33,8 +33,6 @@ #include "entenc.h" #include "mfrngcod.h" - - /*A range encoder. See entdec.c and the references for implementation details \cite{Mar79,MNW98}. @@ -59,8 +57,6 @@ URL="http://www.stanford.edu/class/ee398/handouts/papers/Moffat98ArithmCoding.pdf" }*/ - - static int ec_write_byte(ec_enc *_this,unsigned _value){ if(_this->offs+_this->end_offs>=_this->storage)return -1; _this->buf[_this->offs++]=(unsigned char)_value; @@ -73,7 +69,6 @@ static int ec_write_byte_at_end(ec_enc *_this,unsigned _value){ return 0; } - /*Outputs a symbol, with a carry bit. If there is a potential to propagate a carry over several symbols, they are buffered until it can be determined whether or not an actual carry will diff --git a/libcelt/entenc.h b/libcelt/entenc.h index bc608825..847f77c8 100644 --- a/libcelt/entenc.h +++ b/libcelt/entenc.h @@ -30,8 +30,6 @@ # include # include "entcode.h" - - /*Initializes the encoder. _buf: The buffer to store output bytes in. _size: The size of the buffer, in chars.*/ diff --git a/libcelt/fixed_c5x.h b/libcelt/fixed_c5x.h index d7d82eef..1672f22a 100644 --- a/libcelt/fixed_c5x.h +++ b/libcelt/fixed_c5x.h @@ -70,20 +70,10 @@ static inline long IMUL32(long i, long j) #undef MULT16_32_Q15 #define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),(b)),15)) - #define celt_ilog2(x) (30 - _lnorm(x)) #define OVERRIDE_CELT_ILOG2 #define celt_maxabs16(x, len) MAX16(maxval((DATA *)x, len),-minval((DATA *)x, len)) #define OVERRIDE_CELT_MAXABS16 -#define OVERRIDE_FIND_MAX16 -static inline int find_max16(opus_val16 *x, int len) -{ - DATA max_corr16 = -VERY_LARGE16; - DATA pitch16 = 0; - maxvec((DATA *)x, len, &max_corr16, &pitch16); - return pitch16; -} - #endif /* FIXED_C5X_H */ diff --git a/libcelt/fixed_c6x.h b/libcelt/fixed_c6x.h index 48f07e64..746fe081 100644 --- a/libcelt/fixed_c6x.h +++ b/libcelt/fixed_c6x.h @@ -67,14 +67,4 @@ #define celt_maxabs16(x, len) MAX16(maxval((DATA *)x, len),-minval((DATA *)x, len)) #define OVERRIDE_CELT_MAXABS16 -#define OVERRIDE_FIND_MAX16 -static inline int find_max16(opus_val16 *x, int len) -{ - DATA max_corr16 = -VERY_LARGE16; - DATA pitch16 = 0; - maxvec((DATA *)x, len, &max_corr16, &pitch16); - return pitch16; -} -#endif - #endif /* FIXED_C6X_H */ diff --git a/libcelt/fixed_debug.h b/libcelt/fixed_debug.h index de1bb58a..2f19d10f 100644 --- a/libcelt/fixed_debug.h +++ b/libcelt/fixed_debug.h @@ -40,8 +40,6 @@ long long celt_mips=0; extern long long celt_mips; #endif -#define MIPS_INC celt_mips++, - #define MULT16_16SU(a,b) ((opus_val32)(opus_val16)(a)*(opus_val32)(opus_uint16)(b)) #define MULT32_32_Q31(a,b) ADD32(ADD32(SHL32(MULT16_16(SHR32((a),16),SHR((b),16)),1), SHR32(MULT16_16SU(SHR32((a),16),((b)&0x0000ffff)),15)), SHR32(MULT16_16SU(SHR32((b),16),((a)&0x0000ffff)),15)) @@ -51,7 +49,6 @@ extern long long celt_mips; #define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits)))) #define QCONST32(x,bits) ((opus_val32)(.5+(x)*(((opus_val32)1)<<(bits)))) - #define VERIFY_SHORT(x) ((x)<=32767&&(x)>=-32768) #define VERIFY_INT(x) ((x)<=2147483647LL&&(x)>=-2147483648LL) #define VERIFY_UINT(x) ((x)<=(2147483647LLU<<1)) @@ -172,13 +169,9 @@ static inline int SHL32(long long a, int shift) return res; } -#define PSHR16(a,shift) (celt_mips--,SHR16(ADD16((a),((1<<((shift))>>1))),shift)) #define PSHR32(a,shift) (celt_mips--,SHR32(ADD32((a),(((opus_val32)(1)<<((shift))>>1))),shift)) #define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) -#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) -#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) - #define ROUND16(x,a) (celt_mips--,EXTRACT16(PSHR32((x),(a)))) #define HALF16(x) (SHR16(x,1)) #define HALF32(x) (SHR32(x,1)) @@ -286,8 +279,6 @@ static inline unsigned int _USUB32(unsigned long long a, unsigned long long b, c return res; } - - /* result fits in 16 bits */ static inline short MULT16_16_16(int a, int b) { @@ -319,10 +310,6 @@ static inline int _MULT16_16(int a, int b, char *file, int line) } #define MAC16_16(c,a,b) (celt_mips-=2,ADD32((c),MULT16_16((a),(b)))) -#define MAC16_16_Q11(c,a,b) (ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),11)))) -#define MAC16_16_Q13(c,a,b) (ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),13)))) -#define MAC16_16_P13(c,a,b) (ADD16((c),SHR32(ADD32(4096,MULT16_16((a),(b))),13))) - #define MULT16_32_QX(a, b, Q) _MULT16_32_QX(a, b, Q, __FILE__, __LINE__) static inline int _MULT16_32_QX(int a, long long b, int Q, char *file, int line) @@ -344,33 +331,7 @@ static inline int _MULT16_32_QX(int a, long long b, int Q, char *file, int line) return res; } -static inline int MULT16_32_PX(int a, long long b, int Q) -{ - long long res; - if (!VERIFY_SHORT(a) || !VERIFY_INT(b)) - { - fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d\n", Q, (int)a, (int)b); - } - if (ABS32(b)>=((opus_val32)(1)<<(15+Q))) - fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d\n", Q, (int)a, (int)b); - res = ((((long long)a)*(long long)b) + (((opus_val32)(1)<>1))>> Q; - if (!VERIFY_INT(res)) - fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d\n", Q, (int)a, (int)b,(int)res); - if (Q==15) - celt_mips+=4; - else - celt_mips+=5; - return res; -} - - -#define MULT16_32_Q11(a,b) MULT16_32_QX(a,b,11) -#define MAC16_32_Q11(c,a,b) ADD32((c),MULT16_32_Q11((a),(b))) -#define MULT16_32_Q12(a,b) MULT16_32_QX(a,b,12) -#define MULT16_32_Q13(a,b) MULT16_32_QX(a,b,13) -#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) (celt_mips-=2,ADD32((c),MULT16_32_Q15((a),(b)))) static inline int SATURATE(int a, int b) @@ -543,8 +504,6 @@ static inline int _DIV32(long long a, long long b, char *file, int line) celt_mips+=70; return res; } -#define PDIV32(a,b) DIV32(ADD32((a),(b)>>1),b) -#define PDIV32_16(a,b) DIV32_16(ADD32((a),(b)>>1),b) #undef PRINT_MIPS #define PRINT_MIPS(file) do {fprintf (file, "total complexity = %llu MIPS\n", celt_mips);} while (0); diff --git a/libcelt/fixed_generic.h b/libcelt/fixed_generic.h index b7686168..3934f4e0 100644 --- a/libcelt/fixed_generic.h +++ b/libcelt/fixed_generic.h @@ -45,11 +45,9 @@ /** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */ #define MULT32_32_Q31(a,b) ADD32(ADD32(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),15)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),15)) -/** 32x32 multiplication, followed by a 32-bit shift right. Results fits in 32 bits */ -#define MULT32_32_Q32(a,b) ADD32(ADD32(MULT16_16(SHR((a),16),SHR((b),16)), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),16)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),16)) - /** Compile-time conversion of float constant to 16-bit value */ #define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits)))) + /** Compile-time conversion of float constant to 32-bit value */ #define QCONST32(x,bits) ((opus_val32)(.5+(x)*(((opus_val32)1)<<(bits)))) @@ -72,18 +70,11 @@ /** Arithmetic shift-left of a 32-bit value */ #define SHL32(a,shift) ((opus_val32)(a) << (shift)) -/** 16-bit arithmetic shift right with rounding-to-nearest instead of rounding down */ -#define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift)) /** 32-bit arithmetic shift right with rounding-to-nearest instead of rounding down */ #define PSHR32(a,shift) (SHR32((a)+((EXTEND32(1)<<((shift))>>1)),shift)) /** 32-bit arithmetic shift right where the argument can be negative */ #define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) -/** Saturates 16-bit value to +/- a */ -#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) -/** Saturates 32-bit value to +/- a */ -#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) - /** "RAW" macros, should not be used outside of this header file */ #define SHR(a,shift) ((a) >> (shift)) #define SHL(a,shift) ((opus_val32)(a) << (shift)) @@ -105,7 +96,6 @@ /** Subtract two 32-bit values */ #define SUB32(a,b) ((opus_val32)(a)-(opus_val32)(b)) - /** 16x16 multiplication where the result fits in 16 bits */ #define MULT16_16_16(a,b) ((((opus_val16)(a))*((opus_val16)(b)))) @@ -115,28 +105,9 @@ /** 16x16 multiply-add where the result fits in 32 bits */ #define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b)))) -/** 16x32 multiplication, followed by a 12-bit shift right. Results fits in 32 bits */ -#define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12)) -/** 16x32 multiplication, followed by a 13-bit shift right. Results fits in 32 bits */ -#define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13)) -/** 16x32 multiplication, followed by a 14-bit shift right. Results fits in 32 bits */ -#define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14)) - -/** 16x32 multiplication, followed by an 11-bit shift right. Results fits in 32 bits */ -#define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)) -/** 16x32 multiply-add, followed by an 11-bit shift right. Results fits in 32 bits */ -#define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))) - -/** 16x32 multiplication, followed by a 15-bit shift right (round-to-nearest). Results fits in 32 bits */ -#define MULT16_32_P15(a,b) ADD32(MULT16_16((a),SHR((b),15)), PSHR(MULT16_16((a),((b)&0x00007fff)),15)) /** 16x32 multiply-add, followed by a 15-bit shift right. Results fits in 32 bits */ #define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))) - -#define MAC16_16_Q11(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),11))) -#define MAC16_16_Q13(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),13))) -#define MAC16_16_P13(c,a,b) (ADD32((c),SHR(ADD32(4096,MULT16_16((a),(b))),13))) - #define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11)) #define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13)) #define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14)) @@ -148,11 +119,8 @@ /** Divide a 32-bit value by a 16-bit value. Result fits in 16 bits */ #define DIV32_16(a,b) ((opus_val16)(((opus_val32)(a))/((opus_val16)(b)))) -/** Divide a 32-bit value by a 16-bit value and round to nearest. Result fits in 16 bits */ -#define PDIV32_16(a,b) ((opus_val16)(((opus_val32)(a)+((opus_val16)(b)>>1))/((opus_val16)(b)))) + /** Divide a 32-bit value by a 32-bit value. Result fits in 32 bits */ #define DIV32(a,b) (((opus_val32)(a))/((opus_val32)(b))) -/** Divide a 32-bit value by a 32-bit value and round to nearest. Result fits in 32 bits */ -#define PDIV32(a,b) (((opus_val32)(a)+((opus_val16)(b)>>1))/((opus_val32)(b))) #endif diff --git a/libcelt/float_cast.h b/libcelt/float_cast.h index ad164f74..b130b880 100644 --- a/libcelt/float_cast.h +++ b/libcelt/float_cast.h @@ -95,7 +95,6 @@ return _mm_cvtss_si32(_mm_load_ss(&value)); } #elif (defined (WIN32) || defined (_WIN32)) - #include /* Win32 doesn't seem to have these functions. @@ -120,12 +119,8 @@ #warning "Don't have the functions lrint() and lrintf ()." #warning "Replacing these functions with a standard C cast." #endif /* __GNUC__ */ - #include - #define float2int(flt) ((int)(floor(.5+flt))) - #endif - #endif /* FLOAT_CAST_H */ diff --git a/libcelt/kiss_fft.c b/libcelt/kiss_fft.c index 5a42f3c9..98b3effb 100644 --- a/libcelt/kiss_fft.c +++ b/libcelt/kiss_fft.c @@ -292,7 +292,6 @@ static void ki_bfly3( } } - static void kf_bfly5( kiss_fft_cpx * Fout, const size_t fstride, @@ -462,7 +461,6 @@ static void kf_work( } } - static void ki_work( kiss_fft_cpx * Fout, const kiss_fft_cpx * f, @@ -493,7 +491,6 @@ static void ki_work( } } - #ifdef CUSTOM_MODES static @@ -529,7 +526,6 @@ void compute_bitrev_table( } } - /* facbuf is populated by p1,m1,p2,m2, ... where p[i] * m[i] = m[i-1] @@ -582,7 +578,6 @@ static void compute_twiddles(kiss_twiddle_cpx *twiddles, int nfft) #endif } - /* * * User-callable function to allocate all necessary storage space for the fft. diff --git a/libcelt/kiss_fft.h b/libcelt/kiss_fft.h index c6ced490..ba725121 100644 --- a/libcelt/kiss_fft.h +++ b/libcelt/kiss_fft.h @@ -14,7 +14,6 @@ Redistribution and use in source and binary forms, with or without modification, THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #ifndef KISS_FFT_H #define KISS_FFT_H @@ -47,7 +46,6 @@ extern "C" { #define KISS_FFT_MALLOC celt_alloc #endif - #ifdef FIXED_POINT #include "arch.h" #define DOUBLE_PRECISION @@ -157,7 +155,6 @@ void kiss_ifft(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *f void kiss_fft_free(const kiss_fft_state *cfg); - #ifdef __cplusplus } #endif diff --git a/libcelt/laplace.c b/libcelt/laplace.c index 43c62291..c66be006 100644 --- a/libcelt/laplace.c +++ b/libcelt/laplace.c @@ -90,7 +90,6 @@ void ec_laplace_encode(ec_enc *enc, int *value, int fs, int decay) ec_encode_bin(enc, fl, fl+fs, 15); } - int ec_laplace_decode(ec_dec *dec, int fs, int decay) { int val=0; diff --git a/libcelt/mathops.h b/libcelt/mathops.h index 28d86494..6c7fc76a 100644 --- a/libcelt/mathops.h +++ b/libcelt/mathops.h @@ -48,7 +48,6 @@ unsigned isqrt32(opus_uint32 _val); #define celt_sqrt(x) ((float)sqrt(x)) #define celt_rsqrt(x) (1.f/celt_sqrt(x)) #define celt_rsqrt_norm(x) (celt_rsqrt(x)) -#define celt_acos acos #define celt_exp exp #define celt_cos_norm(x) ((float)cos((.5f*M_PI)*(x))) #define celt_atan atan @@ -106,8 +105,6 @@ static inline float celt_exp2(float x) #endif - - #ifdef FIXED_POINT #include "os_support.h" @@ -121,7 +118,6 @@ static inline opus_int16 celt_ilog2(opus_int32 x) } #endif - #ifndef OVERRIDE_CELT_MAXABS16 static inline opus_val16 celt_maxabs16(opus_val16 *x, int len) { @@ -145,7 +141,6 @@ opus_val32 celt_sqrt(opus_val32 x); opus_val16 celt_cos_norm(opus_val32 x); - static inline opus_val16 celt_log2(opus_val32 x) { int i; @@ -229,6 +224,4 @@ static inline opus_val16 celt_atan2p(opus_val16 y, opus_val16 x) } #endif /* FIXED_POINT */ - - #endif /* MATHOPS_H */ diff --git a/libcelt/mdct.c b/libcelt/mdct.c index 37cf6c17..41d45cfe 100644 --- a/libcelt/mdct.c +++ b/libcelt/mdct.c @@ -53,9 +53,7 @@ #include "mathops.h" #include "stack_alloc.h" -#ifndef M_PI -#define M_PI 3.141592653 -#endif +#define PI 3.141592653f #ifdef CUSTOM_MODES @@ -119,7 +117,7 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar #ifdef FIXED_POINT sine = TRIG_UPSCALE*(QCONST16(0.7853981f, 15)+N2)/N; #else - sine = (kiss_twiddle_scalar)2*M_PI*(.125f)/N; + sine = (kiss_twiddle_scalar)2*PI*(.125f)/N; #endif /* Consider the input to be composed of four blocks: [a, b, c, d] */ @@ -206,7 +204,6 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar RESTORE_STACK; } - void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const opus_val16 * restrict window, int overlap, int shift) { int i; @@ -225,7 +222,7 @@ void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scala #ifdef FIXED_POINT sine = TRIG_UPSCALE*(QCONST16(0.7853981f, 15)+N2)/N; #else - sine = (kiss_twiddle_scalar)2*M_PI*(.125f)/N; + sine = (kiss_twiddle_scalar)2*PI*(.125f)/N; #endif /* Pre-rotate */ @@ -330,5 +327,3 @@ void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scala } RESTORE_STACK; } - - diff --git a/libcelt/mfrngcod.h b/libcelt/mfrngcod.h index 460acbe7..ca94c87e 100644 --- a/libcelt/mfrngcod.h +++ b/libcelt/mfrngcod.h @@ -43,14 +43,6 @@ # define EC_CODE_TOP (((opus_uint32)1U)<>EC_SYM_BITS) -/*Code for which propagating carries are possible.*/ -# define EC_CODE_CARRY (((opus_uint32)EC_SYM_MAX)<HPLTPredCodGain = SKP_max_float( psEncCtrl->LTPredCodGain - 0.5 * psEnc->prevLTPredCodGain, 0.0f ) + psEnc->HPLTPredCodGain = SKP_max_float( psEncCtrl->LTPredCodGain - 0.5f * psEnc->prevLTPredCodGain, 0.0f ) + 0.5f * psEnc->HPLTPredCodGain; psEnc->prevLTPredCodGain = psEncCtrl->LTPredCodGain;