aboutsummaryrefslogtreecommitdiff
path: root/libspeexdsp/fixed_debug.h
diff options
context:
space:
mode:
Diffstat (limited to 'libspeexdsp/fixed_debug.h')
-rw-r--r--libspeexdsp/fixed_debug.h74
1 files changed, 42 insertions, 32 deletions
diff --git a/libspeexdsp/fixed_debug.h b/libspeexdsp/fixed_debug.h
index 54f3866..dbf02f1 100644
--- a/libspeexdsp/fixed_debug.h
+++ b/libspeexdsp/fixed_debug.h
@@ -7,18 +7,18 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
-
+
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
-
+
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
-
+
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
-
+
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
@@ -101,7 +101,7 @@ static inline int _EXTEND32(int x, char *file, int line)
}
#define SHR16(a, shift) _SHR16(a, shift, __FILE__, __LINE__)
-static inline short _SHR16(int a, int shift, char *file, int line)
+static inline short _SHR16(int a, int shift, char *file, int line)
{
int res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift))
@@ -115,7 +115,7 @@ static inline short _SHR16(int a, int shift, char *file, int line)
return res;
}
#define SHL16(a, shift) _SHL16(a, shift, __FILE__, __LINE__)
-static inline short _SHL16(int a, int shift, char *file, int line)
+static inline short _SHL16(int a, int shift, char *file, int line)
{
int res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift))
@@ -129,7 +129,7 @@ static inline short _SHL16(int a, int shift, char *file, int line)
return res;
}
-static inline int SHR32(long long a, int shift)
+static inline int SHR32(long long a, int shift)
{
long long res;
if (!VERIFY_INT(a) || !VERIFY_SHORT(shift))
@@ -144,7 +144,7 @@ static inline int SHR32(long long a, int shift)
spx_mips++;
return res;
}
-static inline int SHL32(long long a, int shift)
+static inline int SHL32(long long a, int shift)
{
long long res;
if (!VERIFY_INT(a) || !VERIFY_SHORT(shift))
@@ -171,7 +171,7 @@ static inline int SHL32(long long a, int shift)
//#define SHL(a,shift) ((a) << (shift))
#define ADD16(a, b) _ADD16(a, b, __FILE__, __LINE__)
-static inline short _ADD16(int a, int b, char *file, int line)
+static inline short _ADD16(int a, int b, char *file, int line)
{
int res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -188,7 +188,7 @@ static inline short _ADD16(int a, int b, char *file, int line)
}
#define SUB16(a, b) _SUB16(a, b, __FILE__, __LINE__)
-static inline short _SUB16(int a, int b, char *file, int line)
+static inline short _SUB16(int a, int b, char *file, int line)
{
int res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -203,7 +203,7 @@ static inline short _SUB16(int a, int b, char *file, int 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(long long a, long long b, char *file, int line)
{
long long res;
if (!VERIFY_INT(a) || !VERIFY_INT(b))
@@ -219,7 +219,7 @@ static inline int _ADD32(long long a, long long b, char *file, int line)
return res;
}
-static inline int SUB32(long long a, long long b)
+static inline int SUB32(long long a, long long b)
{
long long res;
if (!VERIFY_INT(a) || !VERIFY_INT(b))
@@ -236,7 +236,7 @@ static inline int SUB32(long long a, long long b)
#define ADD64(a,b) (MIPS_INC(a)+(b))
/* result fits in 16 bits */
-static inline short MULT16_16_16(int a, int b)
+static inline short MULT16_16_16(int a, int b)
{
int res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -250,8 +250,23 @@ static inline short MULT16_16_16(int a, int b)
return res;
}
+/* result fits in 32 bits */
+static inline int MULT16_32_32(int a, long long b)
+{
+ long long res;
+ if (!VERIFY_SHORT(a) || !VERIFY_INT(b))
+ {
+ fprintf (stderr, "MULT16_32_32: inputs are not short+int: %d %d\n", a, (int)b);
+ }
+ res = a*b;
+ if (!VERIFY_INT(res))
+ fprintf (stderr, "MULT16_32_32: output is not int: %d\n", (int)res);
+ spx_mips++;
+ return res;
+}
+
#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;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -279,8 +294,8 @@ static inline int _MULT16_32_QX(int a, long long b, int Q, char *file, int 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);
}
- if (ABS32(b)>=(EXTEND32(1)<<(15+Q)))
- fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line);
+ if (ABS(b)>>(16+Q))
+ fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line);
res = (((long long)a)*(long long)b) >> Q;
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);
@@ -295,8 +310,8 @@ static inline int MULT16_32_PX(int a, long long b, int Q)
{
fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d\n", Q, (int)a, (int)b);
}
- if (ABS32(b)>=(EXTEND32(1)<<(15+Q)))
- fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d\n", Q, (int)a, (int)b);
+ if (ABS(b)>>(16+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) + ((EXTEND32(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);
@@ -305,11 +320,6 @@ static inline int MULT16_32_PX(int a, long long b, int Q)
}
-#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) ADD32((c),MULT16_32_Q15((a),(b)))
@@ -323,7 +333,7 @@ static inline int SATURATE(int a, int b)
return a;
}
-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;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -337,7 +347,7 @@ static inline int MULT16_16_Q11_32(int a, int b)
spx_mips+=3;
return res;
}
-static inline short MULT16_16_Q13(int a, int b)
+static inline short MULT16_16_Q13(int a, int b)
{
long long res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -351,7 +361,7 @@ static inline short MULT16_16_Q13(int a, int b)
spx_mips+=3;
return res;
}
-static inline short MULT16_16_Q14(int a, int b)
+static inline short MULT16_16_Q14(int a, int b)
{
long long res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -365,7 +375,7 @@ static inline short MULT16_16_Q14(int a, int b)
spx_mips+=3;
return res;
}
-static inline short MULT16_16_Q15(int a, int b)
+static inline short MULT16_16_Q15(int a, int b)
{
long long res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -382,7 +392,7 @@ static inline short MULT16_16_Q15(int a, int b)
return res;
}
-static inline short MULT16_16_P13(int a, int b)
+static inline short MULT16_16_P13(int a, int b)
{
long long res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -399,7 +409,7 @@ static inline short MULT16_16_P13(int a, int b)
spx_mips+=4;
return res;
}
-static inline short MULT16_16_P14(int a, int b)
+static inline short MULT16_16_P14(int a, int b)
{
long long res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -416,7 +426,7 @@ static inline short MULT16_16_P14(int a, int b)
spx_mips+=4;
return res;
}
-static inline short MULT16_16_P15(int a, int b)
+static inline short MULT16_16_P15(int a, int b)
{
long long res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -436,7 +446,7 @@ static inline short MULT16_16_P15(int a, int b)
#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(long long a, long long b, char *file, int line)
{
long long res;
if (b==0)
@@ -462,7 +472,7 @@ static inline int _DIV32_16(long long a, long long b, char *file, int 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(long long a, long long b, char *file, int line)
{
long long res;
if (b==0)