Commit 662587d9 authored by Gregory Maxwell's avatar Gregory Maxwell
Browse files

Remove many unused defines and convert some double constants to float.

parent d9636c5d
......@@ -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 */
......@@ -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
......
......@@ -296,10 +296,8 @@ void anti_collapse(const CELTMode *m, celt_norm *_X, unsigned char *collapse_mas
renormalise_vector(X, N0<<LM, Q15ONE);
} while (++c<C);
}
}
static void intensity_stereo(const CELTMode *m, celt_norm *X, celt_norm *Y, const celt_ener *bank, int bandID, int N)
{
int i = bandID;
......
......@@ -86,7 +86,6 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end,
int time_domain, int fold, int dual_stereo, int intensity, int *tf_res, int resynth,
opus_int32 total_bits, opus_int32 balance, ec_ctx *ec, int M, int codedBands, opus_uint32 *seed);
void stereo_decision(const CELTMode *m, celt_norm * restrict X, int *stereo_mode, int len, int M);
void anti_collapse(const CELTMode *m, celt_norm *_X, unsigned char *collapse_masks, int LM, int C, int CC, int size,
......
......@@ -1180,7 +1180,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
#ifdef FIXED_POINT
qg = ((gain1+1536)>>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);
......
......@@ -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
......
......@@ -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.
......
......@@ -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, "{");
......
......@@ -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
......@@ -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;
......
......@@ -33,8 +33,6 @@
# include <stddef.h>
# 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;
}
......
......@@ -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;
......
......@@ -30,8 +30,6 @@
# include <limits.h>
# include "entcode.h"
/*Initializes the decoder.
_buf: The input buffer to use.
Return: 0 on success, or a negative value on error.*/
......
......@@ -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
......
......@@ -30,8 +30,6 @@
# include <stddef.h>
# include "entcode.h"
/*Initializes the encoder.
_buf: The buffer to store output bytes in.
_size: The size of the buffer, in chars.*/
......
......@@ -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 */
......@@ -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 */
......@@ -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)<<Q)>>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);
......
......@@ -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))
......@@