1*638691a0SAndroid Build Coastguard Worker /* 16-bit signed integer dot product
2*638691a0SAndroid Build Coastguard Worker * Switch to appropriate versions
3*638691a0SAndroid Build Coastguard Worker * Copyright 2004 Phil Karn
4*638691a0SAndroid Build Coastguard Worker * May be used under the terms of the GNU Lesser General Public License (LGPL)
5*638691a0SAndroid Build Coastguard Worker */
6*638691a0SAndroid Build Coastguard Worker #include <stdlib.h>
7*638691a0SAndroid Build Coastguard Worker #include "fec.h"
8*638691a0SAndroid Build Coastguard Worker
9*638691a0SAndroid Build Coastguard Worker void *initdp_port(signed short coeffs[],int len);
10*638691a0SAndroid Build Coastguard Worker long dotprod_port(void *p,signed short *b);
11*638691a0SAndroid Build Coastguard Worker void freedp_port(void *p);
12*638691a0SAndroid Build Coastguard Worker
13*638691a0SAndroid Build Coastguard Worker #ifdef __i386__
14*638691a0SAndroid Build Coastguard Worker void *initdp_mmx(signed short coeffs[],int len);
15*638691a0SAndroid Build Coastguard Worker void *initdp_sse2(signed short coeffs[],int len);
16*638691a0SAndroid Build Coastguard Worker long dotprod_mmx(void *p,signed short *b);
17*638691a0SAndroid Build Coastguard Worker long dotprod_sse2(void *p,signed short *b);
18*638691a0SAndroid Build Coastguard Worker void freedp_mmx(void *p);
19*638691a0SAndroid Build Coastguard Worker void freedp_sse2(void *p);
20*638691a0SAndroid Build Coastguard Worker #endif
21*638691a0SAndroid Build Coastguard Worker
22*638691a0SAndroid Build Coastguard Worker #ifdef __VEC__
23*638691a0SAndroid Build Coastguard Worker void *initdp_av(signed short coeffs[],int len);
24*638691a0SAndroid Build Coastguard Worker long dotprod_av(void *p,signed short *b);
25*638691a0SAndroid Build Coastguard Worker void freedp_av(void *p);
26*638691a0SAndroid Build Coastguard Worker #endif
27*638691a0SAndroid Build Coastguard Worker
28*638691a0SAndroid Build Coastguard Worker /* Create and return a descriptor for use with the dot product function */
initdp(signed short coeffs[],int len)29*638691a0SAndroid Build Coastguard Worker void *initdp(signed short coeffs[],int len){
30*638691a0SAndroid Build Coastguard Worker find_cpu_mode();
31*638691a0SAndroid Build Coastguard Worker
32*638691a0SAndroid Build Coastguard Worker switch(Cpu_mode){
33*638691a0SAndroid Build Coastguard Worker case PORT:
34*638691a0SAndroid Build Coastguard Worker default:
35*638691a0SAndroid Build Coastguard Worker return initdp_port(coeffs,len);
36*638691a0SAndroid Build Coastguard Worker #ifdef __i386__
37*638691a0SAndroid Build Coastguard Worker case MMX:
38*638691a0SAndroid Build Coastguard Worker case SSE:
39*638691a0SAndroid Build Coastguard Worker return initdp_mmx(coeffs,len);
40*638691a0SAndroid Build Coastguard Worker case SSE2:
41*638691a0SAndroid Build Coastguard Worker return initdp_sse2(coeffs,len);
42*638691a0SAndroid Build Coastguard Worker #endif
43*638691a0SAndroid Build Coastguard Worker
44*638691a0SAndroid Build Coastguard Worker #ifdef __VEC__
45*638691a0SAndroid Build Coastguard Worker case ALTIVEC:
46*638691a0SAndroid Build Coastguard Worker return initdp_av(coeffs,len);
47*638691a0SAndroid Build Coastguard Worker #endif
48*638691a0SAndroid Build Coastguard Worker }
49*638691a0SAndroid Build Coastguard Worker }
50*638691a0SAndroid Build Coastguard Worker
51*638691a0SAndroid Build Coastguard Worker
52*638691a0SAndroid Build Coastguard Worker /* Free a dot product descriptor created earlier */
freedp(void * p)53*638691a0SAndroid Build Coastguard Worker void freedp(void *p){
54*638691a0SAndroid Build Coastguard Worker switch(Cpu_mode){
55*638691a0SAndroid Build Coastguard Worker case PORT:
56*638691a0SAndroid Build Coastguard Worker default:
57*638691a0SAndroid Build Coastguard Worker #ifdef __i386__
58*638691a0SAndroid Build Coastguard Worker case MMX:
59*638691a0SAndroid Build Coastguard Worker case SSE:
60*638691a0SAndroid Build Coastguard Worker return freedp_mmx(p);
61*638691a0SAndroid Build Coastguard Worker case SSE2:
62*638691a0SAndroid Build Coastguard Worker return freedp_sse2(p);
63*638691a0SAndroid Build Coastguard Worker #endif
64*638691a0SAndroid Build Coastguard Worker #ifdef __VEC__
65*638691a0SAndroid Build Coastguard Worker case ALTIVEC:
66*638691a0SAndroid Build Coastguard Worker return freedp_av(p);
67*638691a0SAndroid Build Coastguard Worker #endif
68*638691a0SAndroid Build Coastguard Worker }
69*638691a0SAndroid Build Coastguard Worker }
70*638691a0SAndroid Build Coastguard Worker
71*638691a0SAndroid Build Coastguard Worker /* Compute a dot product given a descriptor and an input array
72*638691a0SAndroid Build Coastguard Worker * The length is taken from the descriptor
73*638691a0SAndroid Build Coastguard Worker */
dotprod(void * p,signed short a[])74*638691a0SAndroid Build Coastguard Worker long dotprod(void *p,signed short a[]){
75*638691a0SAndroid Build Coastguard Worker switch(Cpu_mode){
76*638691a0SAndroid Build Coastguard Worker case PORT:
77*638691a0SAndroid Build Coastguard Worker default:
78*638691a0SAndroid Build Coastguard Worker return dotprod_port(p,a);
79*638691a0SAndroid Build Coastguard Worker #ifdef __i386__
80*638691a0SAndroid Build Coastguard Worker case MMX:
81*638691a0SAndroid Build Coastguard Worker case SSE:
82*638691a0SAndroid Build Coastguard Worker return dotprod_mmx(p,a);
83*638691a0SAndroid Build Coastguard Worker case SSE2:
84*638691a0SAndroid Build Coastguard Worker return dotprod_sse2(p,a);
85*638691a0SAndroid Build Coastguard Worker #endif
86*638691a0SAndroid Build Coastguard Worker
87*638691a0SAndroid Build Coastguard Worker #ifdef __VEC__
88*638691a0SAndroid Build Coastguard Worker case ALTIVEC:
89*638691a0SAndroid Build Coastguard Worker return dotprod_av(p,a);
90*638691a0SAndroid Build Coastguard Worker #endif
91*638691a0SAndroid Build Coastguard Worker }
92*638691a0SAndroid Build Coastguard Worker }
93*638691a0SAndroid Build Coastguard Worker
94*638691a0SAndroid Build Coastguard Worker
95