aboutsummaryrefslogtreecommitdiffstats
path: root/peakval_sse.c
blob: 9868b7f080e5332887deabc9236d5c12767119ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* IA-32 SSE version of peakval
 * Copyright 2004 Phil Karn, KA9Q
 */

#include <stdlib.h>
#include "fec.h"

int peakval_sse_assist(signed short *,int);

int peakval_sse(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_sse_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;
}