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