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

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