Parent Directory | Revision Log
Revision 605 -
(view)
(download)
Original Path: trunk/xvidcore/src/image/x86_asm/interpolate8x8_mmx.asm
1 : | chl | 434 | ;/***************************************************************************** |
2 : | Isibaar | 262 | ; * |
3 : | chl | 434 | ; * XVID MPEG-4 VIDEO CODEC |
4 : | ; * mmx 8x8 block-based halfpel interpolation | ||
5 : | Isibaar | 262 | ; * |
6 : | chl | 434 | ; * Copyright(C) 2002 Peter Ross <pross@xvid.org> |
7 : | Isibaar | 262 | ; * |
8 : | chl | 434 | ; * This program is an implementation of a part of one or more MPEG-4 |
9 : | ; * Video tools as specified in ISO/IEC 14496-2 standard. Those intending | ||
10 : | ; * to use this software module in hardware or software products are | ||
11 : | ; * advised that its use may infringe existing patents or copyrights, and | ||
12 : | ; * any such use would be at such party's own risk. The original | ||
13 : | ; * developer of this software module and his/her company, and subsequent | ||
14 : | ; * editors and their companies, will have no liability for use of this | ||
15 : | ; * software or modifications or derivatives thereof. | ||
16 : | Isibaar | 262 | ; * |
17 : | chl | 434 | ; * This program is free software; you can redistribute it and/or modify |
18 : | ; * it under the terms of the GNU General Public License as published by | ||
19 : | ; * the Free Software Foundation; either version 2 of the License, or | ||
20 : | ; * (at your option) any later version. | ||
21 : | Isibaar | 262 | ; * |
22 : | chl | 434 | ; * This program is distributed in the hope that it will be useful, |
23 : | ; * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
24 : | ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
25 : | ; * GNU General Public License for more details. | ||
26 : | Isibaar | 262 | ; * |
27 : | chl | 434 | ; * You should have received a copy of the GNU General Public License |
28 : | ; * along with this program; if not, write to the Free Software | ||
29 : | ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
30 : | Isibaar | 262 | ; * |
31 : | chl | 434 | ; ****************************************************************************/ |
32 : | Isibaar | 262 | |
33 : | bits 32 | ||
34 : | |||
35 : | %macro cglobal 1 | ||
36 : | %ifdef PREFIX | ||
37 : | global _%1 | ||
38 : | %define %1 _%1 | ||
39 : | %else | ||
40 : | global %1 | ||
41 : | %endif | ||
42 : | %endmacro | ||
43 : | |||
44 : | section .data | ||
45 : | |||
46 : | align 16 | ||
47 : | |||
48 : | ;=========================================================================== | ||
49 : | ; (1 - r) rounding table | ||
50 : | ;=========================================================================== | ||
51 : | |||
52 : | rounding1_mmx | ||
53 : | times 4 dw 1 | ||
54 : | times 4 dw 0 | ||
55 : | |||
56 : | ;=========================================================================== | ||
57 : | ; (2 - r) rounding table | ||
58 : | ;=========================================================================== | ||
59 : | |||
60 : | rounding2_mmx | ||
61 : | times 4 dw 2 | ||
62 : | times 4 dw 1 | ||
63 : | |||
64 : | mmx_one | ||
65 : | times 8 db 1 | ||
66 : | |||
67 : | section .text | ||
68 : | |||
69 : | %macro CALC_AVG 6 | ||
70 : | punpcklbw %3, %6 | ||
71 : | punpckhbw %4, %6 | ||
72 : | |||
73 : | paddusw %1, %3 ; mm01 += mm23 | ||
74 : | paddusw %2, %4 | ||
75 : | paddusw %1, %5 ; mm01 += rounding | ||
76 : | paddusw %2, %5 | ||
77 : | |||
78 : | psrlw %1, 1 ; mm01 >>= 1 | ||
79 : | psrlw %2, 1 | ||
80 : | |||
81 : | %endmacro | ||
82 : | |||
83 : | |||
84 : | ;=========================================================================== | ||
85 : | ; | ||
86 : | ; void interpolate8x8_halfpel_h_mmx(uint8_t * const dst, | ||
87 : | ; const uint8_t * const src, | ||
88 : | ; const uint32_t stride, | ||
89 : | ; const uint32_t rounding); | ||
90 : | ; | ||
91 : | ;=========================================================================== | ||
92 : | |||
93 : | %macro COPY_H_MMX 0 | ||
94 : | movq mm0, [esi] | ||
95 : | movq mm2, [esi + 1] | ||
96 : | movq mm1, mm0 | ||
97 : | movq mm3, mm2 | ||
98 : | |||
99 : | punpcklbw mm0, mm6 ; mm01 = [src] | ||
100 : | punpckhbw mm1, mm6 ; mm23 = [src + 1] | ||
101 : | |||
102 : | CALC_AVG mm0, mm1, mm2, mm3, mm7, mm6 | ||
103 : | |||
104 : | packuswb mm0, mm1 | ||
105 : | movq [edi], mm0 ; [dst] = mm01 | ||
106 : | |||
107 : | add esi, edx ; src += stride | ||
108 : | add edi, edx ; dst += stride | ||
109 : | %endmacro | ||
110 : | |||
111 : | align 16 | ||
112 : | cglobal interpolate8x8_halfpel_h_mmx | ||
113 : | interpolate8x8_halfpel_h_mmx | ||
114 : | |||
115 : | push esi | ||
116 : | push edi | ||
117 : | |||
118 : | mov eax, [esp + 8 + 16] ; rounding | ||
119 : | |||
120 : | interpolate8x8_halfpel_h_mmx.start | ||
121 : | movq mm7, [rounding1_mmx + eax * 8] | ||
122 : | |||
123 : | mov edi, [esp + 8 + 4] ; dst | ||
124 : | mov esi, [esp + 8 + 8] ; src | ||
125 : | mov edx, [esp + 8 + 12] ; stride | ||
126 : | |||
127 : | pxor mm6, mm6 ; zero | ||
128 : | |||
129 : | COPY_H_MMX | ||
130 : | COPY_H_MMX | ||
131 : | COPY_H_MMX | ||
132 : | COPY_H_MMX | ||
133 : | COPY_H_MMX | ||
134 : | COPY_H_MMX | ||
135 : | COPY_H_MMX | ||
136 : | COPY_H_MMX | ||
137 : | |||
138 : | pop edi | ||
139 : | pop esi | ||
140 : | |||
141 : | ret | ||
142 : | |||
143 : | |||
144 : | ;=========================================================================== | ||
145 : | ; | ||
146 : | ; void interpolate8x8_halfpel_v_mmx(uint8_t * const dst, | ||
147 : | ; const uint8_t * const src, | ||
148 : | ; const uint32_t stride, | ||
149 : | ; const uint32_t rounding); | ||
150 : | ; | ||
151 : | ;=========================================================================== | ||
152 : | |||
153 : | %macro COPY_V_MMX 0 | ||
154 : | movq mm0, [esi] | ||
155 : | movq mm2, [esi + edx] | ||
156 : | movq mm1, mm0 | ||
157 : | movq mm3, mm2 | ||
158 : | |||
159 : | punpcklbw mm0, mm6 ; mm01 = [src] | ||
160 : | punpckhbw mm1, mm6 ; mm23 = [src + 1] | ||
161 : | |||
162 : | CALC_AVG mm0, mm1, mm2, mm3, mm7, mm6 | ||
163 : | |||
164 : | packuswb mm0, mm1 | ||
165 : | movq [edi], mm0 ; [dst] = mm01 | ||
166 : | |||
167 : | add esi, edx ; src += stride | ||
168 : | add edi, edx ; dst += stride | ||
169 : | %endmacro | ||
170 : | |||
171 : | align 16 | ||
172 : | cglobal interpolate8x8_halfpel_v_mmx | ||
173 : | interpolate8x8_halfpel_v_mmx | ||
174 : | |||
175 : | push esi | ||
176 : | push edi | ||
177 : | |||
178 : | mov eax, [esp + 8 + 16] ; rounding | ||
179 : | |||
180 : | interpolate8x8_halfpel_v_mmx.start | ||
181 : | movq mm7, [rounding1_mmx + eax * 8] | ||
182 : | |||
183 : | mov edi, [esp + 8 + 4] ; dst | ||
184 : | mov esi, [esp + 8 + 8] ; src | ||
185 : | mov edx, [esp + 8 + 12] ; stride | ||
186 : | |||
187 : | pxor mm6, mm6 ; zero | ||
188 : | |||
189 : | |||
190 : | COPY_V_MMX | ||
191 : | COPY_V_MMX | ||
192 : | COPY_V_MMX | ||
193 : | COPY_V_MMX | ||
194 : | COPY_V_MMX | ||
195 : | COPY_V_MMX | ||
196 : | COPY_V_MMX | ||
197 : | COPY_V_MMX | ||
198 : | |||
199 : | pop edi | ||
200 : | pop esi | ||
201 : | |||
202 : | ret | ||
203 : | |||
204 : | |||
205 : | ;=========================================================================== | ||
206 : | ; | ||
207 : | ; void interpolate8x8_halfpel_hv_mmx(uint8_t * const dst, | ||
208 : | ; const uint8_t * const src, | ||
209 : | ; const uint32_t stride, | ||
210 : | ; const uint32_t rounding); | ||
211 : | ; | ||
212 : | ; | ||
213 : | ;=========================================================================== | ||
214 : | |||
215 : | %macro COPY_HV_MMX 0 | ||
216 : | ; current row | ||
217 : | |||
218 : | movq mm0, [esi] | ||
219 : | movq mm2, [esi + 1] | ||
220 : | |||
221 : | movq mm1, mm0 | ||
222 : | movq mm3, mm2 | ||
223 : | |||
224 : | punpcklbw mm0, mm6 ; mm01 = [src] | ||
225 : | punpcklbw mm2, mm6 ; mm23 = [src + 1] | ||
226 : | punpckhbw mm1, mm6 | ||
227 : | punpckhbw mm3, mm6 | ||
228 : | |||
229 : | paddusw mm0, mm2 ; mm01 += mm23 | ||
230 : | paddusw mm1, mm3 | ||
231 : | |||
232 : | ; next row | ||
233 : | |||
234 : | movq mm4, [esi + edx] | ||
235 : | movq mm2, [esi + edx + 1] | ||
236 : | |||
237 : | movq mm5, mm4 | ||
238 : | movq mm3, mm2 | ||
239 : | |||
240 : | punpcklbw mm4, mm6 ; mm45 = [src + stride] | ||
241 : | punpcklbw mm2, mm6 ; mm23 = [src + stride + 1] | ||
242 : | punpckhbw mm5, mm6 | ||
243 : | punpckhbw mm3, mm6 | ||
244 : | |||
245 : | paddusw mm4, mm2 ; mm45 += mm23 | ||
246 : | paddusw mm5, mm3 | ||
247 : | |||
248 : | ; add current + next row | ||
249 : | |||
250 : | paddusw mm0, mm4 ; mm01 += mm45 | ||
251 : | paddusw mm1, mm5 | ||
252 : | paddusw mm0, mm7 ; mm01 += rounding2 | ||
253 : | paddusw mm1, mm7 | ||
254 : | |||
255 : | psrlw mm0, 2 ; mm01 >>= 2 | ||
256 : | psrlw mm1, 2 | ||
257 : | |||
258 : | packuswb mm0, mm1 | ||
259 : | movq [edi], mm0 ; [dst] = mm01 | ||
260 : | |||
261 : | add esi, edx ; src += stride | ||
262 : | add edi, edx ; dst += stride | ||
263 : | %endmacro | ||
264 : | |||
265 : | align 16 | ||
266 : | cglobal interpolate8x8_halfpel_hv_mmx | ||
267 : | interpolate8x8_halfpel_hv_mmx | ||
268 : | |||
269 : | push esi | ||
270 : | push edi | ||
271 : | |||
272 : | mov eax, [esp + 8 + 16] ; rounding | ||
273 : | interpolate8x8_halfpel_hv_mmx.start | ||
274 : | |||
275 : | movq mm7, [rounding2_mmx + eax * 8] | ||
276 : | |||
277 : | mov edi, [esp + 8 + 4] ; dst | ||
278 : | mov esi, [esp + 8 + 8] ; src | ||
279 : | |||
280 : | mov eax, 8 | ||
281 : | |||
282 : | pxor mm6, mm6 ; zero | ||
283 : | |||
284 : | mov edx, [esp + 8 + 12] ; stride | ||
285 : | |||
286 : | COPY_HV_MMX | ||
287 : | COPY_HV_MMX | ||
288 : | COPY_HV_MMX | ||
289 : | COPY_HV_MMX | ||
290 : | COPY_HV_MMX | ||
291 : | COPY_HV_MMX | ||
292 : | COPY_HV_MMX | ||
293 : | COPY_HV_MMX | ||
294 : | |||
295 : | pop edi | ||
296 : | pop esi | ||
297 : | |||
298 : | chl | 434 | ret |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |