aboutsummaryrefslogtreecommitdiffstats
path: root/peakval_mmx.c
diff options
context:
space:
mode:
Diffstat (limited to 'peakval_mmx.c')
-rw-r--r--peakval_mmx.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/peakval_mmx.c b/peakval_mmx.c
new file mode 100644
index 0000000..436fe88
--- /dev/null
+++ b/peakval_mmx.c
@@ -0,0 +1,34 @@
+/* Wrapper for the MMX version of peakval
+ * Copyright 2004 Phil Karn, KA9Q
+ */
+
+#include <stdlib.h>
+
+int peakval_mmx_assist(signed short *,int);
+
+int peakval_mmx(signed short *b,int cnt){
+ int peak = 0;
+ int a;
+
+ while(((int)b & 7) != 0 && cnt != 0){
+ a = abs(*b);
+ if(a > peak)
+ peak = a;
+ b++;
+ cnt--;
+ }
+ a = peakval_mmx_assist(b,cnt);
+ if(a > peak)
+ peak = a;
+ b += cnt & ~3;
+ cnt &= 3;
+
+ while(cnt != 0){
+ a = abs(*b);
+ if(a > peak)
+ peak = a;
+ b++;
+ cnt--;
+ }
+ return peak;
+}