1 |
;/************************************************************************** |
;/***************************************************************************** |
2 |
; * |
; * |
3 |
; * XVID MPEG-4 VIDEO CODEC |
; * XVID MPEG-4 VIDEO CODEC |
4 |
; * mmx 8x8 block-based halfpel interpolation |
; * - mmx 8x8 block-based halfpel interpolation - |
5 |
|
; * |
6 |
|
; * Copyright(C) 2001 Peter Ross <pross@xvid.org> |
7 |
|
; * 2002 Michael Militzer <isibaar@xvid.org> |
8 |
; * |
; * |
9 |
; * This program is free software; you can redistribute it and/or modify |
; * This program is free software; you can redistribute it and/or modify |
10 |
; * it under the terms of the GNU General Public License as published by |
; * it under the terms of the GNU General Public License as published by |
18 |
; * |
; * |
19 |
; * You should have received a copy of the GNU General Public License |
; * You should have received a copy of the GNU General Public License |
20 |
; * along with this program; if not, write to the Free Software |
; * along with this program; if not, write to the Free Software |
21 |
; * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
; * |
; * |
23 |
; *************************************************************************/ |
; ****************************************************************************/ |
24 |
|
|
25 |
;/************************************************************************** |
BITS 32 |
|
; * |
|
|
; * History: |
|
|
; * |
|
|
; * 05.10.2002 added some qpel mmx code - Isibaar |
|
|
; * 06.07.2002 mmx cleanup - Isibaar |
|
|
; * 22.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
|
|
; * |
|
|
; *************************************************************************/ |
|
|
|
|
|
|
|
|
bits 32 |
|
26 |
|
|
27 |
%macro cglobal 1 |
%macro cglobal 1 |
28 |
%ifdef PREFIX |
%ifdef PREFIX |
33 |
%endif |
%endif |
34 |
%endmacro |
%endmacro |
35 |
|
|
36 |
section .data |
;============================================================================= |
37 |
|
; Read only data |
38 |
|
;============================================================================= |
39 |
|
|
40 |
align 16 |
SECTION .rodata |
41 |
|
|
42 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
43 |
; (16 - r) rounding table |
; (16 - r) rounding table |
44 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
45 |
|
|
46 |
rounding_lowpass_mmx |
ALIGN 16 |
47 |
|
rounding_lowpass_mmx: |
48 |
times 4 dw 16 |
times 4 dw 16 |
49 |
times 4 dw 15 |
times 4 dw 15 |
50 |
|
|
51 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
52 |
; (1 - r) rounding table |
; (1 - r) rounding table |
53 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
54 |
|
|
55 |
rounding1_mmx |
rounding1_mmx: |
56 |
times 4 dw 1 |
times 4 dw 1 |
57 |
times 4 dw 0 |
times 4 dw 0 |
58 |
|
|
59 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
60 |
; (2 - r) rounding table |
; (2 - r) rounding table |
61 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
62 |
|
|
63 |
rounding2_mmx |
rounding2_mmx: |
64 |
times 4 dw 2 |
times 4 dw 2 |
65 |
times 4 dw 1 |
times 4 dw 1 |
66 |
|
|
67 |
mmx_one |
mmx_one: |
68 |
times 8 db 1 |
times 8 db 1 |
69 |
|
|
70 |
mmx_two |
mmx_two: |
71 |
times 8 db 2 |
times 8 db 2 |
72 |
|
|
73 |
mmx_three |
mmx_three: |
74 |
times 8 db 3 |
times 8 db 3 |
75 |
|
|
76 |
mmx_five |
mmx_five: |
77 |
times 4 dw 5 |
times 4 dw 5 |
78 |
|
|
79 |
mmx_mask |
mmx_mask: |
80 |
times 8 db 254 |
times 8 db 254 |
81 |
|
|
82 |
mmx_mask2 |
mmx_mask2: |
83 |
times 8 db 252 |
times 8 db 252 |
84 |
|
|
85 |
section .text |
;============================================================================= |
86 |
|
; Code |
87 |
|
;============================================================================= |
88 |
|
|
89 |
|
SECTION .text |
90 |
|
|
91 |
|
cglobal interpolate8x8_halfpel_h_mmx |
92 |
|
cglobal interpolate8x8_halfpel_v_mmx |
93 |
|
cglobal interpolate8x8_halfpel_hv_mmx |
94 |
|
cglobal interpolate8x8_avg4_mmx |
95 |
|
cglobal interpolate8x8_avg2_mmx |
96 |
|
cglobal interpolate8x8_6tap_lowpass_h_mmx |
97 |
|
cglobal interpolate8x8_6tap_lowpass_v_mmx |
98 |
|
|
99 |
%macro CALC_AVG 6 |
%macro CALC_AVG 6 |
100 |
punpcklbw %3, %6 |
punpcklbw %3, %6 |
107 |
|
|
108 |
psrlw %1, 1 ; mm01 >>= 1 |
psrlw %1, 1 ; mm01 >>= 1 |
109 |
psrlw %2, 1 |
psrlw %2, 1 |
|
|
|
110 |
%endmacro |
%endmacro |
111 |
|
|
112 |
|
|
113 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
114 |
; |
; |
115 |
; void interpolate8x8_halfpel_h_mmx(uint8_t * const dst, |
; void interpolate8x8_halfpel_h_mmx(uint8_t * const dst, |
116 |
; const uint8_t * const src, |
; const uint8_t * const src, |
117 |
; const uint32_t stride, |
; const uint32_t stride, |
118 |
; const uint32_t rounding); |
; const uint32_t rounding); |
119 |
; |
; |
120 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
121 |
|
|
122 |
%macro COPY_H_MMX 0 |
%macro COPY_H_MMX 0 |
123 |
movq mm0, [esi] |
movq mm0, [esi] |
137 |
add edi, edx ; dst += stride |
add edi, edx ; dst += stride |
138 |
%endmacro |
%endmacro |
139 |
|
|
140 |
align 16 |
ALIGN 16 |
141 |
cglobal interpolate8x8_halfpel_h_mmx |
interpolate8x8_halfpel_h_mmx: |
|
interpolate8x8_halfpel_h_mmx |
|
142 |
|
|
143 |
push esi |
push esi |
144 |
push edi |
push edi |
|
|
|
145 |
mov eax, [esp + 8 + 16] ; rounding |
mov eax, [esp + 8 + 16] ; rounding |
146 |
|
|
|
interpolate8x8_halfpel_h_mmx.start |
|
147 |
movq mm7, [rounding1_mmx + eax * 8] |
movq mm7, [rounding1_mmx + eax * 8] |
148 |
|
|
149 |
mov edi, [esp + 8 + 4] ; dst |
mov edi, [esp + 8 + 4] ; dst |
167 |
ret |
ret |
168 |
|
|
169 |
|
|
170 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
171 |
; |
; |
172 |
; void interpolate8x8_halfpel_v_mmx(uint8_t * const dst, |
; void interpolate8x8_halfpel_v_mmx(uint8_t * const dst, |
173 |
; const uint8_t * const src, |
; const uint8_t * const src, |
174 |
; const uint32_t stride, |
; const uint32_t stride, |
175 |
; const uint32_t rounding); |
; const uint32_t rounding); |
176 |
; |
; |
177 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
178 |
|
|
179 |
%macro COPY_V_MMX 0 |
%macro COPY_V_MMX 0 |
180 |
movq mm0, [esi] |
movq mm0, [esi] |
194 |
add edi, edx ; dst += stride |
add edi, edx ; dst += stride |
195 |
%endmacro |
%endmacro |
196 |
|
|
197 |
align 16 |
ALIGN 16 |
198 |
cglobal interpolate8x8_halfpel_v_mmx |
interpolate8x8_halfpel_v_mmx: |
|
interpolate8x8_halfpel_v_mmx |
|
199 |
|
|
200 |
push esi |
push esi |
201 |
push edi |
push edi |
202 |
|
|
203 |
mov eax, [esp + 8 + 16] ; rounding |
mov eax, [esp + 8 + 16] ; rounding |
204 |
|
|
|
interpolate8x8_halfpel_v_mmx.start |
|
205 |
movq mm7, [rounding1_mmx + eax * 8] |
movq mm7, [rounding1_mmx + eax * 8] |
206 |
|
|
207 |
mov edi, [esp + 8 + 4] ; dst |
mov edi, [esp + 8 + 4] ; dst |
226 |
ret |
ret |
227 |
|
|
228 |
|
|
229 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
230 |
; |
; |
231 |
; void interpolate8x8_halfpel_hv_mmx(uint8_t * const dst, |
; void interpolate8x8_halfpel_hv_mmx(uint8_t * const dst, |
232 |
; const uint8_t * const src, |
; const uint8_t * const src, |
234 |
; const uint32_t rounding); |
; const uint32_t rounding); |
235 |
; |
; |
236 |
; |
; |
237 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
238 |
|
|
239 |
%macro COPY_HV_MMX 0 |
%macro COPY_HV_MMX 0 |
240 |
; current row |
; current row |
|
|
|
241 |
movq mm0, [esi] |
movq mm0, [esi] |
242 |
movq mm2, [esi + 1] |
movq mm2, [esi + 1] |
243 |
|
|
253 |
paddusw mm1, mm3 |
paddusw mm1, mm3 |
254 |
|
|
255 |
; next row |
; next row |
|
|
|
256 |
movq mm4, [esi + edx] |
movq mm4, [esi + edx] |
257 |
movq mm2, [esi + edx + 1] |
movq mm2, [esi + edx + 1] |
258 |
|
|
268 |
paddusw mm5, mm3 |
paddusw mm5, mm3 |
269 |
|
|
270 |
; add current + next row |
; add current + next row |
|
|
|
271 |
paddusw mm0, mm4 ; mm01 += mm45 |
paddusw mm0, mm4 ; mm01 += mm45 |
272 |
paddusw mm1, mm5 |
paddusw mm1, mm5 |
273 |
paddusw mm0, mm7 ; mm01 += rounding2 |
paddusw mm0, mm7 ; mm01 += rounding2 |
283 |
add edi, edx ; dst += stride |
add edi, edx ; dst += stride |
284 |
%endmacro |
%endmacro |
285 |
|
|
286 |
align 16 |
ALIGN 16 |
287 |
cglobal interpolate8x8_halfpel_hv_mmx |
interpolate8x8_halfpel_hv_mmx: |
|
interpolate8x8_halfpel_hv_mmx |
|
288 |
|
|
289 |
push esi |
push esi |
290 |
push edi |
push edi |
291 |
|
|
292 |
mov eax, [esp + 8 + 16] ; rounding |
mov eax, [esp + 8 + 16] ; rounding |
|
interpolate8x8_halfpel_hv_mmx.start |
|
293 |
|
|
294 |
movq mm7, [rounding2_mmx + eax * 8] |
movq mm7, [rounding2_mmx + eax * 8] |
295 |
|
|
316 |
|
|
317 |
ret |
ret |
318 |
|
|
319 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
320 |
; |
; |
321 |
; void interpolate8x8_avg2_mmx(uint8_t const *dst, |
; void interpolate8x8_avg2_mmx(uint8_t const *dst, |
322 |
; const uint8_t * const src1, |
; const uint8_t * const src1, |
325 |
; const uint32_t rounding, |
; const uint32_t rounding, |
326 |
; const uint32_t height); |
; const uint32_t height); |
327 |
; |
; |
328 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
329 |
|
|
330 |
%macro AVG2_MMX_RND0 0 |
%macro AVG2_MMX_RND0 0 |
331 |
movq mm0, [eax] ; src1 -> mm0 |
movq mm0, [eax] ; src1 -> mm0 |
421 |
movq [ecx+edx], mm4 |
movq [ecx+edx], mm4 |
422 |
%endmacro |
%endmacro |
423 |
|
|
424 |
align 16 |
ALIGN 16 |
425 |
cglobal interpolate8x8_avg2_mmx |
interpolate8x8_avg2_mmx: |
|
interpolate8x8_avg2_mmx |
|
426 |
|
|
427 |
push ebx |
push ebx |
428 |
|
|
491 |
ret |
ret |
492 |
|
|
493 |
|
|
494 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
495 |
; |
; |
496 |
; void interpolate8x8_avg4_mmx(uint8_t const *dst, |
; void interpolate8x8_avg4_mmx(uint8_t const *dst, |
497 |
; const uint8_t * const src1, |
; const uint8_t * const src1, |
501 |
; const uint32_t stride, |
; const uint32_t stride, |
502 |
; const uint32_t rounding); |
; const uint32_t rounding); |
503 |
; |
; |
504 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
505 |
|
|
506 |
%macro AVG4_MMX_RND0 0 |
%macro AVG4_MMX_RND0 0 |
507 |
movq mm0, [eax] ; src1 -> mm0 |
movq mm0, [eax] ; src1 -> mm0 |
613 |
movq [ecx], mm0 ; (src1 + src2 + src3 + src4 + 2) / 4 -> dst |
movq [ecx], mm0 ; (src1 + src2 + src3 + src4 + 2) / 4 -> dst |
614 |
%endmacro |
%endmacro |
615 |
|
|
616 |
align 16 |
ALIGN 16 |
617 |
cglobal interpolate8x8_avg4_mmx |
interpolate8x8_avg4_mmx: |
|
interpolate8x8_avg4_mmx |
|
618 |
|
|
619 |
push ebx |
push ebx |
620 |
push edi |
push edi |
679 |
ret |
ret |
680 |
|
|
681 |
|
|
682 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
683 |
; |
; |
684 |
; void interpolate8x8_6tap_lowpass_h_mmx(uint8_t const *dst, |
; void interpolate8x8_6tap_lowpass_h_mmx(uint8_t const *dst, |
685 |
; const uint8_t * const src, |
; const uint8_t * const src, |
686 |
; const uint32_t stride, |
; const uint32_t stride, |
687 |
; const uint32_t rounding); |
; const uint32_t rounding); |
688 |
; |
; |
689 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
690 |
|
|
691 |
%macro LOWPASS_6TAP_H_MMX 0 |
%macro LOWPASS_6TAP_H_MMX 0 |
692 |
movq mm0, [eax] |
movq mm0, [eax] |
757 |
movq [ecx], mm0 |
movq [ecx], mm0 |
758 |
%endmacro |
%endmacro |
759 |
|
|
760 |
align 16 |
ALIGN 16 |
761 |
cglobal interpolate8x8_6tap_lowpass_h_mmx |
interpolate8x8_6tap_lowpass_h_mmx: |
|
interpolate8x8_6tap_lowpass_h_mmx |
|
762 |
|
|
763 |
mov eax, [esp + 16] ; rounding |
mov eax, [esp + 16] ; rounding |
764 |
|
|
788 |
|
|
789 |
ret |
ret |
790 |
|
|
791 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
792 |
; |
; |
793 |
; void interpolate8x8_6tap_lowpass_v_mmx(uint8_t const *dst, |
; void interpolate8x8_6tap_lowpass_v_mmx(uint8_t const *dst, |
794 |
; const uint8_t * const src, |
; const uint8_t * const src, |
795 |
; const uint32_t stride, |
; const uint32_t stride, |
796 |
; const uint32_t rounding); |
; const uint32_t rounding); |
797 |
; |
; |
798 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
799 |
|
|
800 |
%macro LOWPASS_6TAP_V_MMX 0 |
%macro LOWPASS_6TAP_V_MMX 0 |
801 |
movq mm0, [eax] |
movq mm0, [eax] |
867 |
movq [ecx], mm0 |
movq [ecx], mm0 |
868 |
%endmacro |
%endmacro |
869 |
|
|
870 |
align 16 |
ALIGN 16 |
871 |
cglobal interpolate8x8_6tap_lowpass_v_mmx |
interpolate8x8_6tap_lowpass_v_mmx: |
|
interpolate8x8_6tap_lowpass_v_mmx |
|
872 |
|
|
873 |
push ebx |
push ebx |
874 |
|
|