[svn] / branches / dev-api-4 / xvidcore / src / utils / x86_asm / interlacing_mmx.asm Repository:
ViewVC logotype

Annotation of /branches/dev-api-4/xvidcore/src/utils/x86_asm/interlacing_mmx.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1192 - (view) (download)

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

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