Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/speexdsp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Tomlinson <karlt+@karlt.net>2020-09-01 02:53:25 +0300
committerRalph Giles <giles@thaumas.net>2020-10-02 19:23:27 +0300
commit06181733a6c304bd152caadfc5cd2aaf492016b2 (patch)
treee30de0efb10912fce47c585fe43a6913acc296ce
parent00d2e621c53bd5ca6dabd12f97d1224b3705645a (diff)
fixed-point: introduce MULT16_32_32 to handle unexpected types in MULT16_32_Q15
-rw-r--r--libspeexdsp/arch.h1
-rw-r--r--libspeexdsp/fixed_debug.h15
-rw-r--r--libspeexdsp/fixed_generic.h10
3 files changed, 22 insertions, 4 deletions
diff --git a/libspeexdsp/arch.h b/libspeexdsp/arch.h
index 0b2accb..4d953c6 100644
--- a/libspeexdsp/arch.h
+++ b/libspeexdsp/arch.h
@@ -177,6 +177,7 @@ typedef float spx_word32_t;
#define ADD32(a,b) ((a)+(b))
#define SUB32(a,b) ((a)-(b))
#define MULT16_16_16(a,b) ((a)*(b))
+#define MULT16_32_32(a,b) ((a)*(b))
#define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b))
#define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b))
diff --git a/libspeexdsp/fixed_debug.h b/libspeexdsp/fixed_debug.h
index 25d4ea7..dbf02f1 100644
--- a/libspeexdsp/fixed_debug.h
+++ b/libspeexdsp/fixed_debug.h
@@ -250,6 +250,21 @@ 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)
{
diff --git a/libspeexdsp/fixed_generic.h b/libspeexdsp/fixed_generic.h
index e5d1ce5..09366c3 100644
--- a/libspeexdsp/fixed_generic.h
+++ b/libspeexdsp/fixed_generic.h
@@ -69,16 +69,18 @@
/* result fits in 16 bits */
-#define MULT16_16_16(a,b) ((((spx_word16_t)(a))*((spx_word16_t)(b))))
+#define MULT16_16_16(a,b) (((spx_word16_t)(a))*((spx_word16_t)(b)))
+/* result fits in 32 bits */
+#define MULT16_32_32(a,b) (((spx_word16_t)(a))*((spx_word32_t)(b)))
/* (spx_word32_t)(spx_word16_t) gives TI compiler a hint that it's 16x16->32 multiply */
#define MULT16_16(a,b) (((spx_word32_t)(spx_word16_t)(a))*((spx_word32_t)(spx_word16_t)(b)))
#define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b))))
-#define MULT16_32_P15(a,b) ADD32((a)*SHR((b),15), PSHR(MULT16_16((a),((b)&0x00007fff)),15))
-#define MULT16_32_Q15(a,b) ADD32((a)*SHR((b),15), SHR(MULT16_16((a),((b)&0x00007fff)),15))
-#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32((a)*SHR((b),15), SHR(MULT16_16((a),((b)&0x00007fff)),15)))
+#define MULT16_32_P15(a,b) ADD32(MULT16_32_32(a,SHR((b),15)), PSHR(MULT16_16((a),((b)&0x00007fff)),15))
+#define MULT16_32_Q15(a,b) ADD32(MULT16_32_32(a,SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))
+#define MAC16_32_Q15(c,a,b) ADD32(c,MULT16_32_Q15(a,b))
#define MAC16_16_Q11(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),11)))