annotate libao2/fir.h @ 3632:06911836febd

Adam Di Carlo changes. see debian/changelog
author eyck
date Thu, 20 Dec 2001 17:18:48 +0000
parents 5f5189ac6a41
children d6f8feeac656
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3631
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
1 /*=============================================================================
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
2 //
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
3 // This file is part of mplayer.
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
4 //
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
5 // mplayer is free software; you can redistribute it and/or modify
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
6 // it under the terms of the GNU General Public License as published by
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
7 // the Free Software Foundation; either version 2 of the License, or
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
8 // (at your option) any later version.
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
9 //
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
10 // mplayer is distributed in the hope that it will be useful,
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
13 // GNU General Public License for more details.
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
14 //
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
15 // You should have received a copy of the GNU General Public License
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
16 // along with mplayer; if not, write to the Free Software
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
18 //
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
19 // Copyright 2001 Anders Johansson ajh@atri.curtin.edu.au
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
20 //
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
21 //=============================================================================
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
22 */
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
23
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
24 #ifndef __FIR_H__
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
25 #define __FIR_H__
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
26
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
27 /* 4, 8 and 16 tap FIR filters implemented using SSE instructions
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
28 int16_t* x Input data
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
29 int16_t* y Output value
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
30 int16_t* w Filter weights
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
31
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
32 C function
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
33 for(int i = 0 ; i < L ; i++)
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
34 *y += w[i]*x[i];
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
35 */
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
36
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
37 #ifdef HAVE_SSE
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
38
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
39 // This block should be MMX only compatible, but it isn't...
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
40 #ifdef L4
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
41 #define LOAD_QUE(x) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
42 __asm __volatile("movq %0, %%mm2\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
43 : \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
44 :"m"((x)[0]) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
45 :"memory");
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
46 #define SAVE_QUE(x) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
47 __asm __volatile("movq %%mm2, %0\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
48 :"=m"(x[0]) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
49 : \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
50 :"memory");
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
51 #define UPDATE_QUE(in) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
52 __asm __volatile("psllq $16, %%mm2\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
53 "pinsrw $0, %0,%%mm2\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
54 : \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
55 :"m" ((in)[0]) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
56 :"memory");
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
57 #define FIR(x,w,y) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
58 __asm __volatile("movq %%mm2, %%mm0\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
59 "pmaddwd %1, %%mm0\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
60 "movq %%mm0, %%mm1\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
61 "psrlq $32, %%mm1\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
62 "paddd %%mm0, %%mm1\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
63 "movd %%mm1, %%esi\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
64 "shrl $16, %%esi\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
65 "movw %%si, %0\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
66 : "=m" ((y)[0]) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
67 : "m" ((w)[0]) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
68 : "memory", "%esi");
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
69 #endif /* L4 */
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
70
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
71 // It is possible to make the 8 bit filter a lot faster by using the
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
72 // 128 bit registers, feel free to optimize.
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
73 #ifdef L8
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
74 #define LOAD_QUE(x) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
75 __asm __volatile("movq %0, %%mm5\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
76 "movq %1, %%mm4\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
77 : \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
78 :"m"((x)[0]), \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
79 "m"((x)[4]) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
80 :"memory");
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
81 #define SAVE_QUE(x) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
82 __asm __volatile("movq %%mm5, %0\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
83 "movq %%mm4, %1\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
84 :"=m"((x)[0]), \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
85 "=m"((x)[4]) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
86 : \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
87 :"memory");
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
88
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
89 // Below operation could replace line 2 to 5 in macro below but can
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
90 // not cause of compiler bug ???
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
91 // "pextrw $3, %%mm5,%%eax\n\t"
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
92 #define UPDATE_QUE(in) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
93 __asm __volatile("psllq $16, %%mm4\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
94 "movq %%mm5, %%mm0\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
95 "psrlq $48, %%mm0\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
96 "movd %%mm0, %%eax\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
97 "pinsrw $0, %%eax,%%mm4\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
98 "psllq $16, %%mm5\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
99 "pinsrw $0, %0,%%mm5\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
100 : \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
101 :"m" ((in)[0]) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
102 :"memory", "%eax");
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
103 #define FIR(x,w,y) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
104 __asm __volatile("movq %%mm5, %%mm0\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
105 "pmaddwd %1, %%mm0\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
106 "movq %%mm4, %%mm1\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
107 "pmaddwd %2, %%mm1\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
108 "paddd %%mm1, %%mm0\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
109 "movq %%mm0, %%mm1\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
110 "psrlq $32, %%mm1\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
111 "paddd %%mm0, %%mm1\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
112 "movd %%mm1, %%esi\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
113 "shrl $16, %%esi\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
114 "movw %%si, %0\n\t" \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
115 : "=m" ((y)[0]) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
116 : "m" ((w)[0]), \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
117 "m" ((w)[4]) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
118 : "memory", "%esi");
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
119 #endif /* L8 */
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
120
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
121 #else /* HAVE_SSE */
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
122
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
123 #define LOAD_QUE(x)
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
124 #define SAVE_QUE(x)
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
125 #define UPDATE_QUE(inm) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
126 xi=(--xi)&(L-1); \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
127 x[xi]=x[xi+L]=*inm;
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
128
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
129 #ifdef L4
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
130 #define FIR(x,w,y) \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
131 y[0]=(w[0]*x[0]+w[1]*x[1]+w[2]*x[2]+w[3]*x[3]) >> 16;
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
132 #else
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
133 #define FIR(x,w,y){ \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
134 int16_t a = (w[0]*x[0]+w[1]*x[1]+w[2]*x[2]+w[3]*x[3]) >> 16; \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
135 int16_t b = (w[4]*x[4]+w[5]*x[5]+w[6]*x[6]+w[7]*x[7]) >> 16; \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
136 y[0] = a+b; \
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
137 }
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
138 #endif /* L4 */
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
139
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
140 #endif /* HAVE_SSE */
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
141
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
142 #endif /* __FIR_H__ */
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
143
5f5189ac6a41 Added plugin for fractional resampling (alpha code)
anders
parents:
diff changeset
144