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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (view) (download)

1 : edgomez 1.3 ;/****************************************************************************
2 : edgomez 1.2 ; *
3 : edgomez 1.3 ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - Interlacing Field test -
5 : edgomez 1.2 ; *
6 : edgomez 1.3 ; * Copyright(C) 2002 Daniel Smith <danielsmith@astroboymail.com>
7 : edgomez 1.2 ; *
8 : edgomez 1.3 ; * 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 1.2 ; *
13 : edgomez 1.3 ; * 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 1.2 ; *
18 : edgomez 1.3 ; * 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 1.2 ; *
22 : Isibaar 1.8 ; * $Id: interlacing_mmx.asm,v 1.7 2008/08/19 09:06:48 Isibaar Exp $
23 : edgomez 1.2 ; *
24 : edgomez 1.3 ; ***************************************************************************/
25 : edgomez 1.2
26 : edgomez 1.3 BITS 32
27 : edgomez 1.2
28 : edgomez 1.3 %macro cglobal 1
29 : edgomez 1.2 %ifdef PREFIX
30 : edgomez 1.5 %ifdef MARK_FUNCS
31 : edgomez 1.6 global _%1:function %1.endfunc-%1
32 :     %define %1 _%1:function %1.endfunc-%1
33 : Isibaar 1.8 %define ENDFUNC .endfunc
34 : edgomez 1.5 %else
35 :     global _%1
36 :     %define %1 _%1
37 : Isibaar 1.8 %define ENDFUNC
38 : edgomez 1.5 %endif
39 : edgomez 1.2 %else
40 : edgomez 1.5 %ifdef MARK_FUNCS
41 : edgomez 1.6 global %1:function %1.endfunc-%1
42 : Isibaar 1.8 %define ENDFUNC .endfunc
43 : edgomez 1.5 %else
44 :     global %1
45 : Isibaar 1.8 %define ENDFUNC
46 : edgomez 1.5 %endif
47 : edgomez 1.2 %endif
48 :     %endmacro
49 :    
50 : edgomez 1.3 ;=============================================================================
51 :     ; Read only data
52 :     ;=============================================================================
53 :    
54 :     %ifdef FORMAT_COFF
55 : edgomez 1.4 SECTION .rodata
56 : edgomez 1.3 %else
57 : edgomez 1.4 SECTION .rodata align=16
58 : edgomez 1.3 %endif
59 :    
60 :     ; advances to next block on right
61 :     ALIGN 16
62 :     nexts:
63 :     dd 0, 0, 8, 120, 8
64 :    
65 :     ; multiply word sums into dwords
66 :     ALIGN 16
67 :     ones:
68 :     times 4 dw 1
69 :    
70 :     ;=============================================================================
71 :     ; Code
72 :     ;=============================================================================
73 : edgomez 1.2
74 : edgomez 1.3 SECTION .text
75 : edgomez 1.2
76 :     cglobal MBFieldTest_mmx
77 :    
78 :     ; neater
79 :     %define line0 esi
80 :     %define line1 esi+16
81 :     %define line2 esi+32
82 :     %define line3 esi+48
83 :     %define line4 esi+64
84 :     %define line5 esi+80
85 :     %define line6 esi+96
86 :     %define line7 esi+112
87 :     %define line8 edi
88 :     %define line9 edi+16
89 :     %define line10 edi+32
90 :     %define line11 edi+48
91 :     %define line12 edi+64
92 :     %define line13 edi+80
93 :     %define line14 edi+96
94 :     %define line15 edi+112
95 :    
96 :     ; keep from losing track which reg holds which line - these never overlap
97 :     %define m00 mm0
98 :     %define m01 mm1
99 :     %define m02 mm2
100 :     %define m03 mm0
101 :     %define m04 mm1
102 :     %define m05 mm2
103 :     %define m06 mm0
104 :     %define m07 mm1
105 :     %define m08 mm2
106 :     %define m09 mm0
107 :     %define m10 mm1
108 :     %define m11 mm2
109 :     %define m12 mm0
110 :     %define m13 mm1
111 :     %define m14 mm2
112 :     %define m15 mm0
113 :    
114 :     ; gets diff between three lines low(%2),mid(%3),hi(%4): frame = mid-low, field = hi-low
115 :     %macro ABS8 4
116 : edgomez 1.3 movq %4, [%1] ; m02 = hi
117 :     movq mm3, %2 ; mm3 = low copy
118 : edgomez 1.2
119 : edgomez 1.3 pxor mm4, mm4 ; mm4 = 0
120 :     pxor mm5, mm5 ; mm5 = 0
121 : edgomez 1.2
122 : edgomez 1.3 psubw %2, %3 ; diff(med,low) for frame
123 :     psubw mm3, %4 ; diff(hi,low) for field
124 : edgomez 1.2
125 : edgomez 1.3 pcmpgtw mm4, %2 ; if (diff<0), mm4 will be all 1's, else all 0's
126 :     pcmpgtw mm5, mm3
127 :     pxor %2, mm4 ; this will get abs(), but off by 1 if (diff<0)
128 :     pxor mm3, mm5
129 :     psubw %2, mm4 ; correct abs being off by 1 when (diff<0)
130 :     psubw mm3, mm5
131 : edgomez 1.2
132 : edgomez 1.3 paddw mm6, %2 ; add to totals
133 :     paddw mm7, mm3
134 : edgomez 1.2 %endmacro
135 :    
136 : edgomez 1.3 ;-----------------------------------------------------------------------------
137 : edgomez 1.2 ;
138 :     ; uint32_t MBFieldTest_mmx(int16_t * const data);
139 :     ;
140 : edgomez 1.3 ;-----------------------------------------------------------------------------
141 : edgomez 1.2
142 : edgomez 1.3 ALIGN 16
143 : edgomez 1.2 MBFieldTest_mmx:
144 :    
145 : edgomez 1.3 push esi
146 :     push edi
147 : edgomez 1.2
148 : edgomez 1.3 mov esi, [esp+8+4] ; esi = top left block
149 :     mov edi, esi
150 :     add edi, 256 ; edi = bottom left block
151 :    
152 :     pxor mm6, mm6 ; frame total
153 :     pxor mm7, mm7 ; field total
154 :    
155 :     mov eax, 4 ; we do left 8 bytes of data[0*64], then right 8 bytes
156 :     ; then left 8 bytes of data[1*64], then last 8 bytes
157 :     .loop:
158 :     movq m00, [line0] ; line0
159 :     movq m01, [line1] ; line1
160 :    
161 :     ABS8 line2, m00, m01, m02 ; frame += (line2-line1), field += (line2-line0)
162 :     ABS8 line3, m01, m02, m03
163 :     ABS8 line4, m02, m03, m04
164 :     ABS8 line5, m03, m04, m05
165 :     ABS8 line6, m04, m05, m06
166 :     ABS8 line7, m05, m06, m07
167 :     ABS8 line8, m06, m07, m08
168 :    
169 :     movq m09, [line9] ; line9-line7, no frame comp for line9-line8!
170 :     pxor mm4, mm4
171 :     psubw m07, m09
172 :     pcmpgtw mm4, mm1
173 :     pxor m07, mm4
174 :     psubw m07, mm4
175 :     paddw mm7, m07 ; add to field total
176 :    
177 :     ABS8 line10, m08, m09, m10 ; frame += (line10-line9), field += (line10-line8)
178 :     ABS8 line11, m09, m10, m11
179 :     ABS8 line12, m10, m11, m12
180 :     ABS8 line13, m11, m12, m13
181 :     ABS8 line14, m12, m13, m14
182 :     ABS8 line15, m13, m14, m15
183 :    
184 :     pxor mm4, mm4 ; line15-line14, we're done with field comps!
185 :     psubw m14, m15
186 :     pcmpgtw mm4, m14
187 :     pxor m14, mm4
188 :     psubw m14, mm4
189 :     paddw mm6, m14 ; add to frame total
190 :    
191 :     mov ecx, [nexts+eax*4] ; move esi/edi 8 pixels to the right
192 :     add esi, ecx
193 :     add edi, ecx
194 :    
195 :     dec eax
196 :     jnz near .loop
197 :    
198 :     .decide:
199 :     movq mm0, [ones] ; add packed words into single dwords
200 :     pmaddwd mm6, mm0
201 :     pmaddwd mm7, mm0
202 :    
203 :     movq mm0, mm6 ; ecx will be frame total, edx field
204 :     movq mm1, mm7
205 :     psrlq mm0, 32
206 :     psrlq mm1, 32
207 :     paddd mm0, mm6
208 :     paddd mm1, mm7
209 :     movd ecx, mm0
210 :     movd edx, mm1
211 :    
212 :     add edx, 350 ; add bias against field decision
213 :     cmp ecx, edx
214 :     jb .end ; if frame<field, don't use field dct
215 :     inc eax ; if frame>=field, use field dct (return 1)
216 :    
217 :     .end:
218 :     pop edi
219 :     pop esi
220 : edgomez 1.2
221 : edgomez 1.3 ret
222 : Isibaar 1.8 ENDFUNC
223 : edgomez 1.6
224 : Isibaar 1.7
225 :     %ifidn __OUTPUT_FORMAT__,elf
226 :     section ".note.GNU-stack" noalloc noexec nowrite progbits
227 :     %endif
228 :    

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