[svn] / trunk / xvidcore / src / utils / x86_asm / interlacing_mmx.asm Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/utils/x86_asm/interlacing_mmx.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1540 - (view) (download)

1 : edgomez 1382 ;/****************************************************************************
2 : edgomez 851 ; *
3 : edgomez 1382 ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - Interlacing Field test -
5 : edgomez 851 ; *
6 : edgomez 1382 ; * Copyright(C) 2002 Daniel Smith <danielsmith@astroboymail.com>
7 : edgomez 851 ; *
8 : edgomez 1382 ; * This program is free software ; you can redistribute it and/or modify
9 :     ; * it under the terms of the GNU General Public License as published by
10 :     ; * the Free Software Foundation ; either version 2 of the License, or
11 :     ; * (at your option) any later version.
12 : edgomez 851 ; *
13 : edgomez 1382 ; * This program is distributed in the hope that it will be useful,
14 :     ; * but WITHOUT ANY WARRANTY ; without even the implied warranty of
15 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 :     ; * GNU General Public License for more details.
17 : edgomez 851 ; *
18 : edgomez 1382 ; * You should have received a copy of the GNU General Public License
19 :     ; * along with this program ; if not, write to the Free Software
20 :     ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 : edgomez 851 ; *
22 : edgomez 1540 ; * $Id: interlacing_mmx.asm,v 1.6 2004-08-29 10:02:38 edgomez Exp $
23 : edgomez 851 ; *
24 : edgomez 1382 ; ***************************************************************************/
25 : edgomez 851
26 : edgomez 1382 BITS 32
27 : edgomez 851
28 : edgomez 1382 %macro cglobal 1
29 : edgomez 851 %ifdef PREFIX
30 : edgomez 1535 %ifdef MARK_FUNCS
31 : edgomez 1540 global _%1:function %1.endfunc-%1
32 :     %define %1 _%1:function %1.endfunc-%1
33 : edgomez 1535 %else
34 :     global _%1
35 :     %define %1 _%1
36 :     %endif
37 : edgomez 851 %else
38 : edgomez 1535 %ifdef MARK_FUNCS
39 : edgomez 1540 global %1:function %1.endfunc-%1
40 : edgomez 1535 %else
41 :     global %1
42 :     %endif
43 : edgomez 851 %endif
44 :     %endmacro
45 :    
46 : edgomez 1382 ;=============================================================================
47 :     ; Read only data
48 :     ;=============================================================================
49 : edgomez 851
50 : edgomez 1382 %ifdef FORMAT_COFF
51 : edgomez 1519 SECTION .rodata
52 : edgomez 1382 %else
53 : edgomez 1519 SECTION .rodata align=16
54 : edgomez 1382 %endif
55 : edgomez 851
56 : edgomez 1382 ; advances to next block on right
57 :     ALIGN 16
58 :     nexts:
59 :     dd 0, 0, 8, 120, 8
60 : edgomez 851
61 :     ; multiply word sums into dwords
62 : edgomez 1382 ALIGN 16
63 :     ones:
64 :     times 4 dw 1
65 : edgomez 851
66 : edgomez 1382 ;=============================================================================
67 :     ; Code
68 :     ;=============================================================================
69 :    
70 :     SECTION .text
71 :    
72 :     cglobal MBFieldTest_mmx
73 :    
74 : edgomez 851 ; neater
75 :     %define line0 esi
76 :     %define line1 esi+16
77 :     %define line2 esi+32
78 :     %define line3 esi+48
79 :     %define line4 esi+64
80 :     %define line5 esi+80
81 :     %define line6 esi+96
82 :     %define line7 esi+112
83 :     %define line8 edi
84 :     %define line9 edi+16
85 :     %define line10 edi+32
86 :     %define line11 edi+48
87 :     %define line12 edi+64
88 :     %define line13 edi+80
89 :     %define line14 edi+96
90 :     %define line15 edi+112
91 :    
92 :     ; keep from losing track which reg holds which line - these never overlap
93 :     %define m00 mm0
94 :     %define m01 mm1
95 :     %define m02 mm2
96 :     %define m03 mm0
97 :     %define m04 mm1
98 :     %define m05 mm2
99 :     %define m06 mm0
100 :     %define m07 mm1
101 :     %define m08 mm2
102 :     %define m09 mm0
103 :     %define m10 mm1
104 :     %define m11 mm2
105 :     %define m12 mm0
106 :     %define m13 mm1
107 :     %define m14 mm2
108 :     %define m15 mm0
109 :    
110 :     ; gets diff between three lines low(%2),mid(%3),hi(%4): frame = mid-low, field = hi-low
111 :     %macro ABS8 4
112 : edgomez 1382 movq %4, [%1] ; m02 = hi
113 :     movq mm3, %2 ; mm3 = low copy
114 : edgomez 851
115 : edgomez 1382 pxor mm4, mm4 ; mm4 = 0
116 :     pxor mm5, mm5 ; mm5 = 0
117 : edgomez 851
118 : edgomez 1382 psubw %2, %3 ; diff(med,low) for frame
119 :     psubw mm3, %4 ; diff(hi,low) for field
120 : edgomez 851
121 : edgomez 1382 pcmpgtw mm4, %2 ; if (diff<0), mm4 will be all 1's, else all 0's
122 :     pcmpgtw mm5, mm3
123 :     pxor %2, mm4 ; this will get abs(), but off by 1 if (diff<0)
124 :     pxor mm3, mm5
125 :     psubw %2, mm4 ; correct abs being off by 1 when (diff<0)
126 :     psubw mm3, mm5
127 : edgomez 851
128 : edgomez 1382 paddw mm6, %2 ; add to totals
129 :     paddw mm7, mm3
130 : edgomez 851 %endmacro
131 :    
132 : edgomez 1382 ;-----------------------------------------------------------------------------
133 : edgomez 851 ;
134 :     ; uint32_t MBFieldTest_mmx(int16_t * const data);
135 :     ;
136 : edgomez 1382 ;-----------------------------------------------------------------------------
137 : edgomez 851
138 : edgomez 1382 ALIGN 16
139 : edgomez 851 MBFieldTest_mmx:
140 :    
141 : edgomez 1382 push esi
142 :     push edi
143 : edgomez 851
144 : edgomez 1382 mov esi, [esp+8+4] ; esi = top left block
145 :     mov edi, esi
146 :     add edi, 256 ; edi = bottom left block
147 : edgomez 851
148 : edgomez 1382 pxor mm6, mm6 ; frame total
149 :     pxor mm7, mm7 ; field total
150 : edgomez 851
151 : edgomez 1382 mov eax, 4 ; we do left 8 bytes of data[0*64], then right 8 bytes
152 :     ; then left 8 bytes of data[1*64], then last 8 bytes
153 :     .loop:
154 :     movq m00, [line0] ; line0
155 :     movq m01, [line1] ; line1
156 : edgomez 851
157 : edgomez 1382 ABS8 line2, m00, m01, m02 ; frame += (line2-line1), field += (line2-line0)
158 :     ABS8 line3, m01, m02, m03
159 :     ABS8 line4, m02, m03, m04
160 :     ABS8 line5, m03, m04, m05
161 :     ABS8 line6, m04, m05, m06
162 :     ABS8 line7, m05, m06, m07
163 :     ABS8 line8, m06, m07, m08
164 : edgomez 851
165 : edgomez 1382 movq m09, [line9] ; line9-line7, no frame comp for line9-line8!
166 :     pxor mm4, mm4
167 :     psubw m07, m09
168 :     pcmpgtw mm4, mm1
169 :     pxor m07, mm4
170 :     psubw m07, mm4
171 :     paddw mm7, m07 ; add to field total
172 : edgomez 851
173 : edgomez 1382 ABS8 line10, m08, m09, m10 ; frame += (line10-line9), field += (line10-line8)
174 :     ABS8 line11, m09, m10, m11
175 :     ABS8 line12, m10, m11, m12
176 :     ABS8 line13, m11, m12, m13
177 :     ABS8 line14, m12, m13, m14
178 :     ABS8 line15, m13, m14, m15
179 : edgomez 851
180 : edgomez 1382 pxor mm4, mm4 ; line15-line14, we're done with field comps!
181 :     psubw m14, m15
182 :     pcmpgtw mm4, m14
183 :     pxor m14, mm4
184 :     psubw m14, mm4
185 :     paddw mm6, m14 ; add to frame total
186 : edgomez 851
187 : edgomez 1382 mov ecx, [nexts+eax*4] ; move esi/edi 8 pixels to the right
188 :     add esi, ecx
189 :     add edi, ecx
190 : edgomez 851
191 : edgomez 1382 dec eax
192 :     jnz near .loop
193 : edgomez 851
194 : edgomez 1382 .decide:
195 :     movq mm0, [ones] ; add packed words into single dwords
196 :     pmaddwd mm6, mm0
197 :     pmaddwd mm7, mm0
198 : edgomez 851
199 : edgomez 1382 movq mm0, mm6 ; ecx will be frame total, edx field
200 :     movq mm1, mm7
201 :     psrlq mm0, 32
202 :     psrlq mm1, 32
203 :     paddd mm0, mm6
204 :     paddd mm1, mm7
205 :     movd ecx, mm0
206 :     movd edx, mm1
207 : edgomez 851
208 : edgomez 1382 add edx, 350 ; add bias against field decision
209 :     cmp ecx, edx
210 :     jb .end ; if frame<field, don't use field dct
211 :     inc eax ; if frame>=field, use field dct (return 1)
212 : edgomez 851
213 : edgomez 1382 .end:
214 :     pop edi
215 :     pop esi
216 : edgomez 851
217 : edgomez 1382 ret
218 : edgomez 1540 .endfunc
219 :    

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4