1 /* Wrapper for the MMX version of peakval
2  * Copyright 2004 Phil Karn, KA9Q
3  */
4 
5 #include <stdlib.h>
6 
7 int peakval_mmx_assist(signed short *,int);
8 
peakval_mmx(signed short * b,int cnt)9 int peakval_mmx(signed short *b,int cnt){
10   int peak = 0;
11   int a;
12 
13   while(((int)b & 7) != 0 && cnt != 0){
14     a = abs(*b);
15     if(a > peak)
16       peak = a;
17     b++;
18     cnt--;
19   }
20   a = peakval_mmx_assist(b,cnt);
21   if(a > peak)
22     peak = a;
23   b += cnt & ~3;
24   cnt &= 3;
25 
26   while(cnt != 0){
27     a = abs(*b);
28     if(a > peak)
29       peak = a;
30     b++;
31     cnt--;
32   }
33   return peak;
34 }
35