|
@@ -7,18 +7,18 @@
|
|
Redistribution and use in source and binary forms, with or without
|
|
Redistribution and use in source and binary forms, with or without
|
|
modification, are permitted provided that the following conditions
|
|
modification, are permitted provided that the following conditions
|
|
are met:
|
|
are met:
|
|
-
|
|
|
|
|
|
+
|
|
- Redistributions of source code must retain the above copyright
|
|
- Redistributions of source code must retain the above copyright
|
|
notice, this list of conditions and the following disclaimer.
|
|
notice, this list of conditions and the following disclaimer.
|
|
-
|
|
|
|
|
|
+
|
|
- Redistributions in binary form must reproduce the above copyright
|
|
- Redistributions in binary form must reproduce the above copyright
|
|
notice, this list of conditions and the following disclaimer in the
|
|
notice, this list of conditions and the following disclaimer in the
|
|
documentation and/or other materials provided with the distribution.
|
|
documentation and/or other materials provided with the distribution.
|
|
-
|
|
|
|
|
|
+
|
|
- Neither the name of the Xiph.org Foundation nor the names of its
|
|
- Neither the name of the Xiph.org Foundation nor the names of its
|
|
contributors may be used to endorse or promote products derived from
|
|
contributors may be used to endorse or promote products derived from
|
|
this software without specific prior written permission.
|
|
this software without specific prior written permission.
|
|
-
|
|
|
|
|
|
+
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
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__)
|
|
#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;
|
|
int res;
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift))
|
|
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;
|
|
return res;
|
|
}
|
|
}
|
|
#define SHL16(a, shift) _SHL16(a, shift, __FILE__, __LINE__)
|
|
#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;
|
|
int res;
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift))
|
|
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;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
|
|
-static inline int SHR32(long long a, int shift)
|
|
|
|
|
|
+static inline int SHR32(long long a, int shift)
|
|
{
|
|
{
|
|
long long res;
|
|
long long res;
|
|
if (!VERIFY_INT(a) || !VERIFY_SHORT(shift))
|
|
if (!VERIFY_INT(a) || !VERIFY_SHORT(shift))
|
|
@@ -144,7 +144,7 @@ static inline int SHR32(long long a, int shift)
|
|
spx_mips++;
|
|
spx_mips++;
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
-static inline int SHL32(long long a, int shift)
|
|
|
|
|
|
+static inline int SHL32(long long a, int shift)
|
|
{
|
|
{
|
|
long long res;
|
|
long long res;
|
|
if (!VERIFY_INT(a) || !VERIFY_SHORT(shift))
|
|
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 SHL(a,shift) ((a) << (shift))
|
|
|
|
|
|
#define ADD16(a, b) _ADD16(a, b, __FILE__, __LINE__)
|
|
#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;
|
|
int res;
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
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__)
|
|
#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;
|
|
int res;
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
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__)
|
|
#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;
|
|
long long res;
|
|
if (!VERIFY_INT(a) || !VERIFY_INT(b))
|
|
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;
|
|
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;
|
|
long long res;
|
|
if (!VERIFY_INT(a) || !VERIFY_INT(b))
|
|
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))
|
|
#define ADD64(a,b) (MIPS_INC(a)+(b))
|
|
|
|
|
|
/* result fits in 16 bits */
|
|
/* 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;
|
|
int res;
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
@@ -251,7 +251,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;
|
|
long long res;
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
@@ -280,7 +280,7 @@ 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);
|
|
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)))
|
|
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);
|
|
|
|
|
|
+ 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;
|
|
res = (((long long)a)*(long long)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);
|
|
@@ -296,7 +296,7 @@ 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);
|
|
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)))
|
|
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);
|
|
|
|
|
|
+ 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;
|
|
res = ((((long long)a)*(long long)b) + ((EXTEND32(1)<<Q)>>1))>> Q;
|
|
if (!VERIFY_INT(res))
|
|
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);
|
|
fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d\n", Q, (int)a, (int)b,(int)res);
|
|
@@ -323,7 +323,7 @@ static inline int SATURATE(int a, int b)
|
|
return a;
|
|
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;
|
|
long long res;
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
@@ -337,7 +337,7 @@ static inline int MULT16_16_Q11_32(int a, int b)
|
|
spx_mips+=3;
|
|
spx_mips+=3;
|
|
return res;
|
|
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;
|
|
long long res;
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
@@ -351,7 +351,7 @@ static inline short MULT16_16_Q13(int a, int b)
|
|
spx_mips+=3;
|
|
spx_mips+=3;
|
|
return res;
|
|
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;
|
|
long long res;
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
@@ -365,7 +365,7 @@ static inline short MULT16_16_Q14(int a, int b)
|
|
spx_mips+=3;
|
|
spx_mips+=3;
|
|
return res;
|
|
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;
|
|
long long res;
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
@@ -382,7 +382,7 @@ static inline short MULT16_16_Q15(int a, int b)
|
|
return res;
|
|
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;
|
|
long long res;
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
@@ -399,7 +399,7 @@ static inline short MULT16_16_P13(int a, int b)
|
|
spx_mips+=4;
|
|
spx_mips+=4;
|
|
return res;
|
|
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;
|
|
long long res;
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
@@ -416,7 +416,7 @@ static inline short MULT16_16_P14(int a, int b)
|
|
spx_mips+=4;
|
|
spx_mips+=4;
|
|
return res;
|
|
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;
|
|
long long res;
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
|
@@ -436,7 +436,7 @@ 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(long long a, long long b, char *file, int line)
|
|
{
|
|
{
|
|
long long res;
|
|
long long res;
|
|
if (b==0)
|
|
if (b==0)
|
|
@@ -462,7 +462,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__)
|
|
#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;
|
|
long long res;
|
|
if (b==0)
|
|
if (b==0)
|