Home | History | Annotate | Download | only in fec
      1 /* Portable C version of peakval
      2  * Copyright 2004 Phil Karn, KA9Q
      3  */
      4 #include <stdlib.h>
      5 #include "fec.h"
      6 
      7 int peakval_sse2_assist(signed short *,int);
      8 
      9 int peakval_sse2(signed short *b,int cnt){
     10   int peak = 0;
     11   int a;
     12 
     13   while(((int)b & 15) != 0 && cnt != 0){
     14     a = abs(*b);
     15     if(a > peak)
     16       peak = a;
     17     b++;
     18     cnt--;
     19   }
     20   a = peakval_sse2_assist(b,cnt);
     21   if(a > peak)
     22     peak = a;
     23   b += cnt & ~7;
     24   cnt &= 7;
     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