annotate i386/dsputil_mmx_avg.h @ 157:bc12fd7e6153 libavcodec

temp denoiser changes: (a-b)^2 instead of |a-b| and MMX2/3DNOW version
author michael
date Wed, 14 Nov 2001 02:46:58 +0000
parents ae0516eadae2
children f49629bab18d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1 /*
986e461dc072 Initial revision
glantau
parents:
diff changeset
2 * DSP utils : average functions are compiled twice for 3dnow/mmx2
986e461dc072 Initial revision
glantau
parents:
diff changeset
3 * Copyright (c) 2000, 2001 Gerard Lantau.
986e461dc072 Initial revision
glantau
parents:
diff changeset
4 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
986e461dc072 Initial revision
glantau
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
986e461dc072 Initial revision
glantau
parents:
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
986e461dc072 Initial revision
glantau
parents:
diff changeset
8 * (at your option) any later version.
986e461dc072 Initial revision
glantau
parents:
diff changeset
9 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
986e461dc072 Initial revision
glantau
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
986e461dc072 Initial revision
glantau
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
986e461dc072 Initial revision
glantau
parents:
diff changeset
13 * GNU General Public License for more details.
986e461dc072 Initial revision
glantau
parents:
diff changeset
14 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
986e461dc072 Initial revision
glantau
parents:
diff changeset
16 * along with this program; if not, write to the Free Software
986e461dc072 Initial revision
glantau
parents:
diff changeset
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
986e461dc072 Initial revision
glantau
parents:
diff changeset
18 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
19 * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
986e461dc072 Initial revision
glantau
parents:
diff changeset
20 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
21
986e461dc072 Initial revision
glantau
parents:
diff changeset
22 static void DEF(put_pixels_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
986e461dc072 Initial revision
glantau
parents:
diff changeset
23 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
24 int dh, hh;
986e461dc072 Initial revision
glantau
parents:
diff changeset
25 UINT8 *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
26 const UINT8 *pix;
986e461dc072 Initial revision
glantau
parents:
diff changeset
27 p = block;
986e461dc072 Initial revision
glantau
parents:
diff changeset
28 pix = pixels;
986e461dc072 Initial revision
glantau
parents:
diff changeset
29 hh=h>>2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
30 dh=h&3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
31 while(hh--) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
32 __asm __volatile(
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
33 "movq (%1), %%mm0\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
34 "movq 1(%1), %%mm1\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
35 "movq (%1, %2), %%mm2\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
36 "movq 1(%1, %2), %%mm3\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
37 "movq (%1, %2, 2), %%mm4\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
38 "movq 1(%1, %2, 2), %%mm5\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
39 "movq (%1, %3), %%mm6\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
40 "movq 1(%1, %3), %%mm7\n\t"
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
41 PAVGB" %%mm1, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
42 PAVGB" %%mm3, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
43 PAVGB" %%mm5, %%mm4\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
44 PAVGB" %%mm7, %%mm6\n\t"
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
45 "movq %%mm0, (%0)\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
46 "movq %%mm2, (%0, %2)\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
47 "movq %%mm4, (%0, %2, 2)\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
48 "movq %%mm6, (%0, %3)\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
49 ::"r"(p), "r"(pix), "r" (line_size), "r" (line_size*3)
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
50 :"memory");
986e461dc072 Initial revision
glantau
parents:
diff changeset
51 pix += line_size*4; p += line_size*4;
986e461dc072 Initial revision
glantau
parents:
diff changeset
52 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
53 while(dh--) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
54 __asm __volatile(
986e461dc072 Initial revision
glantau
parents:
diff changeset
55 "movq %1, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
56 "movq 1%1, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
57 PAVGB" %%mm1, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
58 "movq %%mm0, %0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
59 :"=m"(*p)
986e461dc072 Initial revision
glantau
parents:
diff changeset
60 :"m"(*pix)
986e461dc072 Initial revision
glantau
parents:
diff changeset
61 :"memory");
986e461dc072 Initial revision
glantau
parents:
diff changeset
62 pix += line_size; p += line_size;
986e461dc072 Initial revision
glantau
parents:
diff changeset
63 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
64 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
65
986e461dc072 Initial revision
glantau
parents:
diff changeset
66 static void DEF(put_pixels_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
986e461dc072 Initial revision
glantau
parents:
diff changeset
67 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
68 int dh, hh;
986e461dc072 Initial revision
glantau
parents:
diff changeset
69 UINT8 *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
70 const UINT8 *pix;
986e461dc072 Initial revision
glantau
parents:
diff changeset
71 p = block;
986e461dc072 Initial revision
glantau
parents:
diff changeset
72 pix = pixels;
986e461dc072 Initial revision
glantau
parents:
diff changeset
73
986e461dc072 Initial revision
glantau
parents:
diff changeset
74 hh=h>>1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
75 dh=h&1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
76 while(hh--) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
77 __asm __volatile(
986e461dc072 Initial revision
glantau
parents:
diff changeset
78 "movq %2, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
79 "movq %3, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
80 "movq %4, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
81 PAVGB" %%mm1, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
82 PAVGB" %%mm2, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
83 "movq %%mm0, %0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
84 "movq %%mm1, %1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
85 :"=m"(*p), "=m"(*(p+line_size))
986e461dc072 Initial revision
glantau
parents:
diff changeset
86 :"m"(*pix), "m"(*(pix+line_size)),
986e461dc072 Initial revision
glantau
parents:
diff changeset
87 "m"(*(pix+line_size*2))
986e461dc072 Initial revision
glantau
parents:
diff changeset
88 :"memory");
986e461dc072 Initial revision
glantau
parents:
diff changeset
89 pix += line_size*2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
90 p += line_size*2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
91 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
92 if(dh) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
93 __asm __volatile(
986e461dc072 Initial revision
glantau
parents:
diff changeset
94 "movq %1, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
95 "movq %2, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
96 PAVGB" %%mm1, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
97 "movq %%mm0, %0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
98 :"=m"(*p)
986e461dc072 Initial revision
glantau
parents:
diff changeset
99 :"m"(*pix),
986e461dc072 Initial revision
glantau
parents:
diff changeset
100 "m"(*(pix+line_size))
986e461dc072 Initial revision
glantau
parents:
diff changeset
101 :"memory");
986e461dc072 Initial revision
glantau
parents:
diff changeset
102 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
103 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
104
986e461dc072 Initial revision
glantau
parents:
diff changeset
105 static void DEF(avg_pixels)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
986e461dc072 Initial revision
glantau
parents:
diff changeset
106 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
107 int dh, hh;
986e461dc072 Initial revision
glantau
parents:
diff changeset
108 UINT8 *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
109 const UINT8 *pix;
986e461dc072 Initial revision
glantau
parents:
diff changeset
110 p = block;
986e461dc072 Initial revision
glantau
parents:
diff changeset
111 pix = pixels;
986e461dc072 Initial revision
glantau
parents:
diff changeset
112 hh=h>>2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
113 dh=h&3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
114 while(hh--) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
115 __asm __volatile(
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
116 "movq (%0), %%mm0\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
117 "movq (%1), %%mm1\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
118 "movq (%0, %2), %%mm2\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
119 "movq (%1, %2), %%mm3\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
120 "movq (%0, %2, 2), %%mm4\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
121 "movq (%1, %2, 2), %%mm5\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
122 "movq (%0, %3), %%mm6\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
123 "movq (%1, %3), %%mm7\n\t"
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
124 PAVGB" %%mm1, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
125 PAVGB" %%mm3, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
126 PAVGB" %%mm5, %%mm4\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
127 PAVGB" %%mm7, %%mm6\n\t"
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
128 "movq %%mm0, (%0)\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
129 "movq %%mm2, (%0, %2)\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
130 "movq %%mm4, (%0, %2, 2)\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
131 "movq %%mm6, (%0, %3)\n\t"
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
132 ::"r"(p), "r"(pix), "r" (line_size), "r" (line_size*3)
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
133 :"memory");
986e461dc072 Initial revision
glantau
parents:
diff changeset
134 pix += line_size*4; p += line_size*4;
986e461dc072 Initial revision
glantau
parents:
diff changeset
135 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
136 while(dh--) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
137 __asm __volatile(
986e461dc072 Initial revision
glantau
parents:
diff changeset
138 "movq %0, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
139 "movq %1, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
140 PAVGB" %%mm1, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
141 "movq %%mm0, %0\n\t"
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
142 :"+m"(*p)
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
143 :"m"(*pix)
986e461dc072 Initial revision
glantau
parents:
diff changeset
144 :"memory");
986e461dc072 Initial revision
glantau
parents:
diff changeset
145 pix += line_size; p += line_size;
986e461dc072 Initial revision
glantau
parents:
diff changeset
146 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
147 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
148
986e461dc072 Initial revision
glantau
parents:
diff changeset
149 static void DEF(avg_pixels_x2)( UINT8 *block, const UINT8 *pixels, int line_size, int h)
986e461dc072 Initial revision
glantau
parents:
diff changeset
150 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
151 int dh, hh;
986e461dc072 Initial revision
glantau
parents:
diff changeset
152 UINT8 *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
153 const UINT8 *pix;
986e461dc072 Initial revision
glantau
parents:
diff changeset
154 p = block;
986e461dc072 Initial revision
glantau
parents:
diff changeset
155 pix = pixels;
986e461dc072 Initial revision
glantau
parents:
diff changeset
156 hh=h>>1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
157 dh=h&1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
158 while(hh--) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
159 __asm __volatile(
986e461dc072 Initial revision
glantau
parents:
diff changeset
160 "movq %2, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
161 "movq 1%2, %%mm3\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
162 "movq %3, %%mm4\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
163 "movq 1%3, %%mm5\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
164 "movq %0, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
165 "movq %1, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
166 PAVGB" %%mm3, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
167 PAVGB" %%mm2, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
168 PAVGB" %%mm5, %%mm4\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
169 PAVGB" %%mm4, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
170 "movq %%mm0, %0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
171 "movq %%mm1, %1\n\t"
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
172 :"+m"(*p), "+m"(*(p+line_size))
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
173 :"m"(*pix), "m"(*(pix+line_size))
986e461dc072 Initial revision
glantau
parents:
diff changeset
174 :"memory");
986e461dc072 Initial revision
glantau
parents:
diff changeset
175 pix += line_size*2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
176 p += line_size*2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
177 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
178 if(dh) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
179 __asm __volatile(
986e461dc072 Initial revision
glantau
parents:
diff changeset
180 "movq %1, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
181 "movq 1%1, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
182 "movq %0, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
183 PAVGB" %%mm2, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
184 PAVGB" %%mm1, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
185 "movq %%mm0, %0\n\t"
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
186 :"+m"(*p)
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
187 :"m"(*pix)
986e461dc072 Initial revision
glantau
parents:
diff changeset
188 :"memory");
986e461dc072 Initial revision
glantau
parents:
diff changeset
189 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
190 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
191
986e461dc072 Initial revision
glantau
parents:
diff changeset
192 static void DEF(avg_pixels_y2)( UINT8 *block, const UINT8 *pixels, int line_size, int h)
986e461dc072 Initial revision
glantau
parents:
diff changeset
193 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
194 int dh, hh;
986e461dc072 Initial revision
glantau
parents:
diff changeset
195 UINT8 *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
196 const UINT8 *pix;
986e461dc072 Initial revision
glantau
parents:
diff changeset
197 p = block;
986e461dc072 Initial revision
glantau
parents:
diff changeset
198 pix = pixels;
986e461dc072 Initial revision
glantau
parents:
diff changeset
199 hh=h>>1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
200 dh=h&1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
201 while(hh--) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
202 __asm __volatile(
986e461dc072 Initial revision
glantau
parents:
diff changeset
203 "movq %2, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
204 "movq %3, %%mm3\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
205 "movq %3, %%mm4\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
206 "movq %4, %%mm5\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
207 "movq %0, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
208 "movq %1, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
209 PAVGB" %%mm3, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
210 PAVGB" %%mm2, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
211 PAVGB" %%mm5, %%mm4\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
212 PAVGB" %%mm4, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
213 "movq %%mm0, %0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
214 "movq %%mm1, %1\n\t"
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
215 :"+m"(*p), "+m"(*(p+line_size))
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
216 :"m"(*pix), "m"(*(pix+line_size)), "m"(*(pix+line_size*2))
986e461dc072 Initial revision
glantau
parents:
diff changeset
217 :"memory");
986e461dc072 Initial revision
glantau
parents:
diff changeset
218 pix += line_size*2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
219 p += line_size*2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
220 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
221 if(dh) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
222 __asm __volatile(
986e461dc072 Initial revision
glantau
parents:
diff changeset
223 "movq %1, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
224 "movq %2, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
225 "movq %0, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
226 PAVGB" %%mm2, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
227 PAVGB" %%mm1, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
228 "movq %%mm0, %0\n\t"
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
229 :"+m"(*p)
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
230 :"m"(*pix), "m"(*(pix+line_size))
986e461dc072 Initial revision
glantau
parents:
diff changeset
231 :"memory");
986e461dc072 Initial revision
glantau
parents:
diff changeset
232 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
233 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
234
986e461dc072 Initial revision
glantau
parents:
diff changeset
235 static void DEF(avg_pixels_xy2)( UINT8 *block, const UINT8 *pixels, int line_size, int h)
986e461dc072 Initial revision
glantau
parents:
diff changeset
236 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
237 UINT8 *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
238 const UINT8 *pix;
986e461dc072 Initial revision
glantau
parents:
diff changeset
239 p = block;
986e461dc072 Initial revision
glantau
parents:
diff changeset
240 pix = pixels;
986e461dc072 Initial revision
glantau
parents:
diff changeset
241 __asm __volatile(
986e461dc072 Initial revision
glantau
parents:
diff changeset
242 "pxor %%mm7, %%mm7\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
243 "movq %0, %%mm6\n\t"
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
244 ::"m"(mm_wtwo));
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
245 do {
986e461dc072 Initial revision
glantau
parents:
diff changeset
246 __asm __volatile(
986e461dc072 Initial revision
glantau
parents:
diff changeset
247 "movq %1, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
248 "movq %2, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
249 "movq 1%1, %%mm4\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
250 "movq 1%2, %%mm5\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
251 "movq %%mm0, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
252 "movq %%mm1, %%mm3\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
253 "punpcklbw %%mm7, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
254 "punpcklbw %%mm7, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
255 "punpckhbw %%mm7, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
256 "punpckhbw %%mm7, %%mm3\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
257 "paddusw %%mm1, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
258 "paddusw %%mm3, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
259 "movq %%mm4, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
260 "movq %%mm5, %%mm3\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
261 "punpcklbw %%mm7, %%mm4\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
262 "punpcklbw %%mm7, %%mm5\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
263 "punpckhbw %%mm7, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
264 "punpckhbw %%mm7, %%mm3\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
265 "paddusw %%mm5, %%mm4\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
266 "paddusw %%mm3, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
267 "paddusw %%mm6, %%mm4\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
268 "paddusw %%mm6, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
269 "paddusw %%mm4, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
270 "paddusw %%mm1, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
271 "psrlw $2, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
272 "psrlw $2, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
273 "packuswb %%mm2, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
274 PAVGB" %0, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
275 "movq %%mm0, %0\n\t"
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
276 :"+m"(*p)
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
277 :"m"(*pix),
986e461dc072 Initial revision
glantau
parents:
diff changeset
278 "m"(*(pix+line_size))
986e461dc072 Initial revision
glantau
parents:
diff changeset
279 :"memory");
986e461dc072 Initial revision
glantau
parents:
diff changeset
280 pix += line_size;
986e461dc072 Initial revision
glantau
parents:
diff changeset
281 p += line_size ;
986e461dc072 Initial revision
glantau
parents:
diff changeset
282 } while(--h);
986e461dc072 Initial revision
glantau
parents:
diff changeset
283 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
284
986e461dc072 Initial revision
glantau
parents:
diff changeset
285 static void DEF(sub_pixels_x2)( DCTELEM *block, const UINT8 *pixels, int line_size, int h)
986e461dc072 Initial revision
glantau
parents:
diff changeset
286 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
287 DCTELEM *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
288 const UINT8 *pix;
986e461dc072 Initial revision
glantau
parents:
diff changeset
289 p = block;
986e461dc072 Initial revision
glantau
parents:
diff changeset
290 pix = pixels;
986e461dc072 Initial revision
glantau
parents:
diff changeset
291 __asm __volatile(
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
292 "pxor %%mm7, %%mm7":);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
293 do {
986e461dc072 Initial revision
glantau
parents:
diff changeset
294 __asm __volatile(
986e461dc072 Initial revision
glantau
parents:
diff changeset
295 "movq 1%1, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
296 "movq %0, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
297 PAVGB" %1, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
298 "movq 8%0, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
299 "movq %%mm2, %%mm3\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
300 "punpcklbw %%mm7, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
301 "punpckhbw %%mm7, %%mm3\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
302 "psubsw %%mm2, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
303 "psubsw %%mm3, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
304 "movq %%mm0, %0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
305 "movq %%mm1, 8%0\n\t"
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
306 :"+m"(*p)
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
307 :"m"(*pix)
986e461dc072 Initial revision
glantau
parents:
diff changeset
308 :"memory");
986e461dc072 Initial revision
glantau
parents:
diff changeset
309 pix += line_size;
986e461dc072 Initial revision
glantau
parents:
diff changeset
310 p += 8;
986e461dc072 Initial revision
glantau
parents:
diff changeset
311 } while (--h);
986e461dc072 Initial revision
glantau
parents:
diff changeset
312 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
313
986e461dc072 Initial revision
glantau
parents:
diff changeset
314 static void DEF(sub_pixels_y2)( DCTELEM *block, const UINT8 *pixels, int line_size, int h)
986e461dc072 Initial revision
glantau
parents:
diff changeset
315 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
316 DCTELEM *p;
986e461dc072 Initial revision
glantau
parents:
diff changeset
317 const UINT8 *pix;
986e461dc072 Initial revision
glantau
parents:
diff changeset
318 p = block;
986e461dc072 Initial revision
glantau
parents:
diff changeset
319 pix = pixels;
986e461dc072 Initial revision
glantau
parents:
diff changeset
320 __asm __volatile(
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
321 "pxor %%mm7, %%mm7":);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
322 do {
986e461dc072 Initial revision
glantau
parents:
diff changeset
323 __asm __volatile(
986e461dc072 Initial revision
glantau
parents:
diff changeset
324 "movq %2, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
325 "movq %0, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
326 PAVGB" %1, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
327 "movq 8%0, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
328 "movq %%mm2, %%mm3\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
329 "punpcklbw %%mm7, %%mm2\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
330 "punpckhbw %%mm7, %%mm3\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
331 "psubsw %%mm2, %%mm0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
332 "psubsw %%mm3, %%mm1\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
333 "movq %%mm0, %0\n\t"
986e461dc072 Initial revision
glantau
parents:
diff changeset
334 "movq %%mm1, 8%0\n\t"
151
ae0516eadae2 fixed gcc-3.0.x compilation (by Michael Niedermayer)
nickols_k
parents: 8
diff changeset
335 :"+m"(*p)
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
336 :"m"(*pix), "m"(*(pix+line_size))
986e461dc072 Initial revision
glantau
parents:
diff changeset
337 :"memory");
986e461dc072 Initial revision
glantau
parents:
diff changeset
338 pix += line_size;
986e461dc072 Initial revision
glantau
parents:
diff changeset
339 p += 8;
986e461dc072 Initial revision
glantau
parents:
diff changeset
340 } while (--h);
986e461dc072 Initial revision
glantau
parents:
diff changeset
341 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
342