Replace long long in celt/ with opus_int64.

This commit is contained in:
Gregory Maxwell 2012-08-20 10:45:53 -04:00
parent de74fc1b6b
commit 5685bd31a6
2 changed files with 40 additions and 41 deletions

View file

@ -48,7 +48,6 @@
#include "arch.h" #include "arch.h"
# define SAMPPROD long long
#define SAMP_MAX 2147483647 #define SAMP_MAX 2147483647
#define TWID_MAX 32767 #define TWID_MAX 32767
#define TRIG_UPSCALE 1 #define TRIG_UPSCALE 1

View file

@ -36,9 +36,9 @@
#ifdef CELT_C #ifdef CELT_C
#include "opus_defines.h" #include "opus_defines.h"
OPUS_EXPORT long long celt_mips=0; OPUS_EXPORT opus_int64 celt_mips=0;
#else #else
extern long long celt_mips; extern opus_int64 celt_mips;
#endif #endif
#define MULT16_16SU(a,b) ((opus_val32)(opus_val16)(a)*(opus_val32)(opus_uint16)(b)) #define MULT16_16SU(a,b) ((opus_val32)(opus_val16)(a)*(opus_val32)(opus_uint16)(b))
@ -80,9 +80,9 @@ static inline short NEG16(int x)
celt_mips++; celt_mips++;
return res; return res;
} }
static inline int NEG32(long long x) static inline int NEG32(opus_int64 x)
{ {
long long res; opus_int64 res;
if (!VERIFY_INT(x)) if (!VERIFY_INT(x))
{ {
fprintf (stderr, "NEG16: input is not int: %d\n", (int)x); fprintf (stderr, "NEG16: input is not int: %d\n", (int)x);
@ -179,9 +179,9 @@ static inline short SHL16_(int a, int shift, char *file, int line)
return res; return res;
} }
static inline int SHR32(long long a, int shift) static inline int SHR32(opus_int64 a, int shift)
{ {
long long res; opus_int64 res;
if (!VERIFY_INT(a) || !VERIFY_SHORT(shift)) if (!VERIFY_INT(a) || !VERIFY_SHORT(shift))
{ {
fprintf (stderr, "SHR32: inputs are not int: %d %d\n", (int)a, shift); fprintf (stderr, "SHR32: inputs are not int: %d %d\n", (int)a, shift);
@ -201,9 +201,9 @@ static inline int SHR32(long long a, int shift)
return res; return res;
} }
#define SHL32(a, shift) SHL32_(a, shift, __FILE__, __LINE__) #define SHL32(a, shift) SHL32_(a, shift, __FILE__, __LINE__)
static inline int SHL32_(long long a, int shift, char *file, int line) static inline int SHL32_(opus_int64 a, int shift, char *file, int line)
{ {
long long res; opus_int64 res;
if (!VERIFY_INT(a) || !VERIFY_SHORT(shift)) if (!VERIFY_INT(a) || !VERIFY_SHORT(shift))
{ {
fprintf (stderr, "SHL32: inputs are not int: %lld %d in %s: line %d\n", a, shift, file, line); fprintf (stderr, "SHL32: inputs are not int: %lld %d in %s: line %d\n", a, shift, file, line);
@ -280,9 +280,9 @@ static inline short SUB16_(int a, int b, char *file, int line)
} }
#define ADD32(a, b) ADD32_(a, b, __FILE__, __LINE__) #define ADD32(a, b) ADD32_(a, b, __FILE__, __LINE__)
static inline int ADD32_(long long a, long long b, char *file, int line) static inline int ADD32_(opus_int64 a, opus_int64 b, char *file, int line)
{ {
long long res; opus_int64 res;
if (!VERIFY_INT(a) || !VERIFY_INT(b)) if (!VERIFY_INT(a) || !VERIFY_INT(b))
{ {
fprintf (stderr, "ADD32: inputs are not int: %d %d in %s: line %d\n", (int)a, (int)b, file, line); fprintf (stderr, "ADD32: inputs are not int: %d %d in %s: line %d\n", (int)a, (int)b, file, line);
@ -303,9 +303,9 @@ static inline int ADD32_(long long a, long long b, char *file, int line)
} }
#define SUB32(a, b) SUB32_(a, b, __FILE__, __LINE__) #define SUB32(a, b) SUB32_(a, b, __FILE__, __LINE__)
static inline int SUB32_(long long a, long long b, char *file, int line) static inline int SUB32_(opus_int64 a, opus_int64 b, char *file, int line)
{ {
long long res; opus_int64 res;
if (!VERIFY_INT(a) || !VERIFY_INT(b)) if (!VERIFY_INT(a) || !VERIFY_INT(b))
{ {
fprintf (stderr, "SUB32: inputs are not int: %d %d in %s: line %d\n", (int)a, (int)b, file, line); fprintf (stderr, "SUB32: inputs are not int: %d %d in %s: line %d\n", (int)a, (int)b, file, line);
@ -327,9 +327,9 @@ static inline int SUB32_(long long a, long long b, char *file, int line)
#undef UADD32 #undef UADD32
#define UADD32(a, b) UADD32_(a, b, __FILE__, __LINE__) #define UADD32(a, b) UADD32_(a, b, __FILE__, __LINE__)
static inline unsigned int UADD32_(unsigned long long a, unsigned long long b, char *file, int line) static inline unsigned int UADD32_(opus_uint64 a, opus_uint64 b, char *file, int line)
{ {
unsigned long long res; opus_uint64 res;
if (!VERIFY_UINT(a) || !VERIFY_UINT(b)) if (!VERIFY_UINT(a) || !VERIFY_UINT(b))
{ {
fprintf (stderr, "UADD32: inputs are not uint32: %llu %llu in %s: line %d\n", a, b, file, line); fprintf (stderr, "UADD32: inputs are not uint32: %llu %llu in %s: line %d\n", a, b, file, line);
@ -351,9 +351,9 @@ static inline unsigned int UADD32_(unsigned long long a, unsigned long long b, c
#undef USUB32 #undef USUB32
#define USUB32(a, b) USUB32_(a, b, __FILE__, __LINE__) #define USUB32(a, b) USUB32_(a, b, __FILE__, __LINE__)
static inline unsigned int USUB32_(unsigned long long a, unsigned long long b, char *file, int line) static inline unsigned int USUB32_(opus_uint64 a, opus_uint64 b, char *file, int line)
{ {
unsigned long long res; opus_uint64 res;
if (!VERIFY_UINT(a) || !VERIFY_UINT(b)) if (!VERIFY_UINT(a) || !VERIFY_UINT(b))
{ {
fprintf (stderr, "USUB32: inputs are not uint32: %llu %llu in %s: line %d\n", a, b, file, line); fprintf (stderr, "USUB32: inputs are not uint32: %llu %llu in %s: line %d\n", a, b, file, line);
@ -406,7 +406,7 @@ static inline short MULT16_16_16(int a, int b)
#define MULT16_16(a, b) MULT16_16_(a, b, __FILE__, __LINE__) #define MULT16_16(a, b) MULT16_16_(a, b, __FILE__, __LINE__)
static inline int MULT16_16_(int a, int b, char *file, int line) static inline int MULT16_16_(int a, int b, char *file, int line)
{ {
long long res; opus_int64 res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
{ {
fprintf (stderr, "MULT16_16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); fprintf (stderr, "MULT16_16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line);
@ -414,7 +414,7 @@ static inline int MULT16_16_(int a, int b, char *file, int line)
celt_assert(0); celt_assert(0);
#endif #endif
} }
res = ((long long)a)*b; res = ((opus_int64)a)*b;
if (!VERIFY_INT(res)) if (!VERIFY_INT(res))
{ {
fprintf (stderr, "MULT16_16: output is not int: %d in %s: line %d\n", (int)res, file, line); fprintf (stderr, "MULT16_16: output is not int: %d in %s: line %d\n", (int)res, file, line);
@ -429,9 +429,9 @@ 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(c,a,b) (celt_mips-=2,ADD32((c),MULT16_16((a),(b))))
#define MULT16_32_QX(a, b, Q) MULT16_32_QX_(a, b, Q, __FILE__, __LINE__) #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) static inline int MULT16_32_QX_(int a, opus_int64 b, int Q, char *file, int line)
{ {
long long res; opus_int64 res;
if (!VERIFY_SHORT(a) || !VERIFY_INT(b)) if (!VERIFY_SHORT(a) || !VERIFY_INT(b))
{ {
fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line); fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line);
@ -446,7 +446,7 @@ static inline int MULT16_32_QX_(int a, long long b, int Q, char *file, int line)
celt_assert(0); celt_assert(0);
#endif #endif
} }
res = (((long long)a)*(long long)b) >> Q; res = (((opus_int64)a)*(opus_int64)b) >> Q;
if (!VERIFY_INT(res)) if (!VERIFY_INT(res))
{ {
fprintf (stderr, "MULT16_32_Q%d: output is not int: %d*%d=%d in %s: line %d\n", Q, (int)a, (int)b,(int)res, file, line); fprintf (stderr, "MULT16_32_Q%d: output is not int: %d*%d=%d in %s: line %d\n", Q, (int)a, (int)b,(int)res, file, line);
@ -464,7 +464,7 @@ static inline int MULT16_32_QX_(int a, long long b, int Q, char *file, int line)
#define MULT16_32_PX(a, b, Q) MULT16_32_PX_(a, b, Q, __FILE__, __LINE__) #define MULT16_32_PX(a, b, Q) MULT16_32_PX_(a, b, Q, __FILE__, __LINE__)
static inline int MULT16_32_PX_(int a, opus_int64 b, int Q, char *file, int line) static inline int MULT16_32_PX_(int a, opus_int64 b, int Q, char *file, int line)
{ {
long long res; opus_int64 res;
if (!VERIFY_SHORT(a) || !VERIFY_INT(b)) if (!VERIFY_SHORT(a) || !VERIFY_INT(b))
{ {
fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d in %s: line %d\n\n", Q, (int)a, (int)b, file, line); fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d in %s: line %d\n\n", Q, (int)a, (int)b, file, line);
@ -509,7 +509,7 @@ static inline int SATURATE(int a, int b)
static inline int MULT16_16_Q11_32(int a, int b) static inline int MULT16_16_Q11_32(int a, int b)
{ {
long long res; opus_int64 res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
{ {
fprintf (stderr, "MULT16_16_Q11: inputs are not short: %d %d\n", a, b); fprintf (stderr, "MULT16_16_Q11: inputs are not short: %d %d\n", a, b);
@ -517,7 +517,7 @@ static inline int MULT16_16_Q11_32(int a, int b)
celt_assert(0); celt_assert(0);
#endif #endif
} }
res = ((long long)a)*b; res = ((opus_int64)a)*b;
res >>= 11; res >>= 11;
if (!VERIFY_INT(res)) if (!VERIFY_INT(res))
{ {
@ -531,7 +531,7 @@ static inline int MULT16_16_Q11_32(int a, int b)
} }
static inline short MULT16_16_Q13(int a, int b) static inline short MULT16_16_Q13(int a, int b)
{ {
long long res; opus_int64 res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
{ {
fprintf (stderr, "MULT16_16_Q13: inputs are not short: %d %d\n", a, b); fprintf (stderr, "MULT16_16_Q13: inputs are not short: %d %d\n", a, b);
@ -539,7 +539,7 @@ static inline short MULT16_16_Q13(int a, int b)
celt_assert(0); celt_assert(0);
#endif #endif
} }
res = ((long long)a)*b; res = ((opus_int64)a)*b;
res >>= 13; res >>= 13;
if (!VERIFY_SHORT(res)) if (!VERIFY_SHORT(res))
{ {
@ -553,7 +553,7 @@ static inline short MULT16_16_Q13(int a, int b)
} }
static inline short MULT16_16_Q14(int a, int b) static inline short MULT16_16_Q14(int a, int b)
{ {
long long res; opus_int64 res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
{ {
fprintf (stderr, "MULT16_16_Q14: inputs are not short: %d %d\n", a, b); fprintf (stderr, "MULT16_16_Q14: inputs are not short: %d %d\n", a, b);
@ -561,7 +561,7 @@ static inline short MULT16_16_Q14(int a, int b)
celt_assert(0); celt_assert(0);
#endif #endif
} }
res = ((long long)a)*b; res = ((opus_int64)a)*b;
res >>= 14; res >>= 14;
if (!VERIFY_SHORT(res)) if (!VERIFY_SHORT(res))
{ {
@ -577,7 +577,7 @@ static inline short MULT16_16_Q14(int a, int b)
#define MULT16_16_Q15(a, b) MULT16_16_Q15_(a, b, __FILE__, __LINE__) #define MULT16_16_Q15(a, b) MULT16_16_Q15_(a, b, __FILE__, __LINE__)
static inline short MULT16_16_Q15_(int a, int b, char *file, int line) static inline short MULT16_16_Q15_(int a, int b, char *file, int line)
{ {
long long res; opus_int64 res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
{ {
fprintf (stderr, "MULT16_16_Q15: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); fprintf (stderr, "MULT16_16_Q15: inputs are not short: %d %d in %s: line %d\n", a, b, file, line);
@ -585,7 +585,7 @@ static inline short MULT16_16_Q15_(int a, int b, char *file, int line)
celt_assert(0); celt_assert(0);
#endif #endif
} }
res = ((long long)a)*b; res = ((opus_int64)a)*b;
res >>= 15; res >>= 15;
if (!VERIFY_SHORT(res)) if (!VERIFY_SHORT(res))
{ {
@ -600,7 +600,7 @@ static inline short MULT16_16_Q15_(int a, int b, char *file, int line)
static inline short MULT16_16_P13(int a, int b) static inline short MULT16_16_P13(int a, int b)
{ {
long long res; opus_int64 res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
{ {
fprintf (stderr, "MULT16_16_P13: inputs are not short: %d %d\n", a, b); fprintf (stderr, "MULT16_16_P13: inputs are not short: %d %d\n", a, b);
@ -608,7 +608,7 @@ static inline short MULT16_16_P13(int a, int b)
celt_assert(0); celt_assert(0);
#endif #endif
} }
res = ((long long)a)*b; res = ((opus_int64)a)*b;
res += 4096; res += 4096;
if (!VERIFY_INT(res)) if (!VERIFY_INT(res))
{ {
@ -630,7 +630,7 @@ static inline short MULT16_16_P13(int a, int b)
} }
static inline short MULT16_16_P14(int a, int b) static inline short MULT16_16_P14(int a, int b)
{ {
long long res; opus_int64 res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
{ {
fprintf (stderr, "MULT16_16_P14: inputs are not short: %d %d\n", a, b); fprintf (stderr, "MULT16_16_P14: inputs are not short: %d %d\n", a, b);
@ -638,7 +638,7 @@ static inline short MULT16_16_P14(int a, int b)
celt_assert(0); celt_assert(0);
#endif #endif
} }
res = ((long long)a)*b; res = ((opus_int64)a)*b;
res += 8192; res += 8192;
if (!VERIFY_INT(res)) if (!VERIFY_INT(res))
{ {
@ -660,7 +660,7 @@ static inline short MULT16_16_P14(int a, int b)
} }
static inline short MULT16_16_P15(int a, int b) static inline short MULT16_16_P15(int a, int b)
{ {
long long res; opus_int64 res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
{ {
fprintf (stderr, "MULT16_16_P15: inputs are not short: %d %d\n", a, b); fprintf (stderr, "MULT16_16_P15: inputs are not short: %d %d\n", a, b);
@ -668,7 +668,7 @@ static inline short MULT16_16_P15(int a, int b)
celt_assert(0); celt_assert(0);
#endif #endif
} }
res = ((long long)a)*b; res = ((opus_int64)a)*b;
res += 16384; res += 16384;
if (!VERIFY_INT(res)) if (!VERIFY_INT(res))
{ {
@ -691,9 +691,9 @@ static inline short MULT16_16_P15(int a, int b)
#define DIV32_16(a, b) DIV32_16_(a, b, __FILE__, __LINE__) #define DIV32_16(a, b) DIV32_16_(a, b, __FILE__, __LINE__)
static inline int DIV32_16_(long long a, long long b, char *file, int line) static inline int DIV32_16_(opus_int64 a, opus_int64 b, char *file, int line)
{ {
long long res; opus_int64 res;
if (b==0) if (b==0)
{ {
fprintf(stderr, "DIV32_16: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line); fprintf(stderr, "DIV32_16: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line);
@ -726,9 +726,9 @@ static inline int DIV32_16_(long long a, long long b, char *file, int line)
} }
#define DIV32(a, b) DIV32_(a, b, __FILE__, __LINE__) #define DIV32(a, b) DIV32_(a, b, __FILE__, __LINE__)
static inline int DIV32_(long long a, long long b, char *file, int line) static inline int DIV32_(opus_int64 a, opus_int64 b, char *file, int line)
{ {
long long res; opus_int64 res;
if (b==0) if (b==0)
{ {
fprintf(stderr, "DIV32: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line); fprintf(stderr, "DIV32: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line);