]> git.sesse.net Git - mlt/blob - src/modules/core/composite_line_yuv_mmx.S
Remove unused string.h include
[mlt] / src / modules / core / composite_line_yuv_mmx.S
1         .file "composite_line_yuv_mmx"
2         .version "01.01"
3         
4 gcc2_compiled.:
5 .data
6
7 .text
8         .align 16
9
10 #if !defined(__MINGW32__) && !defined(__CYGWIN__)
11 .globl composite_line_yuv_mmx
12         .type    composite_line_yuv_mmx,@function
13 composite_line_yuv_mmx:
14 #else
15 .globl _composite_line_yuv_mmx
16 _composite_line_yuv_mmx:
17 #endif
18
19 /*
20  * Arguments
21  *              
22  * dest:             8(%ebp)            %esi
23  * src:         12(%ebp)
24  * width_src:   16(%ebp)        
25  * alpha:       20(%ebp)        
26  * weight:      24(%ebp)        
27  * luma:        28(%ebp)
28  * softness:    32(%ebp)
29  */
30
31 /*
32  * Function call entry
33  */
34         pushl %ebp
35         movl %esp,%ebp
36         subl $28,%esp
37         pushl %edi
38         pushl %esi
39         pushl %ebx
40
41 /* Initialise */
42         movl 8(%ebp), %esi            # get dest
43         movl $0, %edx                     # j = 0
44         
45 .loop:
46
47         movl $0xffff, %ecx           # a = 255
48         cmpl $0, 20(%ebp)         # if alpha == NULL
49         je .noalpha
50         movl 20(%ebp), %edi       # a = alpha[ j ]
51         movb (%edi,%edx), %cl
52 .noalpha:
53         movl %ecx, -24(%ebp)      # save ecx
54
55         movl 24(%ebp), %eax       # mix = weight
56         cmpl $0, 28(%ebp)         # if luma == NULL
57         je .noluma
58         movl 28(%ebp), %edi       # mix = ...
59         movl %edx, %ebx
60         sall $1, %ebx
61         movw (%edi,%ebx), %bx # luma[ j*2 ]
62         cmpl %ebx, %eax
63         jl .luma0
64         movl %ebx, %ecx
65         addl 32(%ebp), %ecx       # + softness
66         cmpl %ecx, %eax
67         jge .luma1
68         /* TODO: linear interpolate between edges */
69         subw %bx, %ax
70         sall $8, %eax
71         subw %bx, %cx
72         movl %edx, %ebx
73         divw %cx
74         movl %ebx, %edx
75         jmp .noluma
76 .luma0:
77         movl $0, %eax
78         jmp .noluma
79 .luma1:
80         movl $0xffff, %eax
81 .noluma:
82         shrl $8, %eax
83
84         movl %edx, %ebx           # edx will be destroyed by mulw
85         movl -24(%ebp), %ecx      # restore ecx
86         mull %ecx                  # mix = mix * a...
87         movl %ebx, %edx           # restore edx
88         shrl $8, %eax             # >>8
89         andl $0xff, %eax
90         
91 /* put alpha and (1-alpha) into mm0 */
92 /* 0 aa 0 1-a 0 aa 0 1-a */
93
94         /* duplicate word */
95         movl %eax, %ecx
96         shll $16, %ecx
97         orl %eax, %ecx
98         
99         movd %ecx, %mm1
100         
101         /* (1 << 16) - mix */
102         movl $0x000000ff, %ecx
103         subl %eax, %ecx
104         andl $0xff, %ecx
105         
106         /* duplicate word */
107         movl %ecx, %eax
108         shll $16, %eax
109         orl %eax, %ecx
110         
111         movd %ecx, %mm0
112         
113         /* unpack words into double words */
114         punpcklwd %mm1, %mm0
115         
116 /* put src yuv and dest yuv into mm1 */
117 /* 0 UVs 0 UVd 0 Ys 0 Yd */
118
119         movl 12(%ebp), %edi       # get src
120         movb (%edi), %cl
121         shll $8, %ecx
122         movb 1(%edi), %al
123         shll $24, %eax
124         orl %eax, %ecx
125         
126         movb (%esi), %al         # get dest
127         orl %eax, %ecx
128         movb 1(%esi), %al
129         shll $16, %eax
130         orl %eax, %ecx
131         
132         movd %ecx, %mm1
133         punpcklbw %mm4, %mm1
134         
135 /* alpha composite */
136         pmaddwd %mm1, %mm0
137         psrld $8, %mm0
138
139 /* store result */
140         movd %mm0, %eax
141         movb %al, (%esi)
142         pextrw $2, %mm0, %eax
143                 movl $128, %eax
144         movb %al, 1(%esi)
145
146 /* for..next */
147         addl $1, %edx             # j++
148         cmpl 16(%ebp), %edx       # if ( j == width_src )
149         jge .out
150         
151         addl $2, %esi
152         addl $2, 12(%ebp)
153         
154         jmp .loop
155
156 .out:
157         emms
158         leal -40(%ebp),%esp
159         popl %ebx
160         popl %esi
161         popl %edi
162         movl %ebp,%esp
163         popl %ebp
164         ret
165
166
167 /********************************************/
168
169 .align 8
170 #if !defined(__MINGW32__) && !defined(__CYGWIN__)       
171 .globl composite_have_mmx
172         .type    composite_have_mmx,@function
173 composite_have_mmx:
174 #else
175 .globl _composite_have_mmx
176 _composite_have_mmx:
177 #endif
178         
179         push    %ebx
180
181 # Check if bit 21 in flags word is writeable
182
183         pushfl  
184         popl    %eax
185         movl    %eax,%ebx
186         xorl    $0x00200000, %eax
187         pushl   %eax
188         popfl
189         pushfl
190         popl    %eax
191
192         cmpl    %eax, %ebx
193
194         je .notfound
195
196 # OK, we have CPUID
197
198         movl    $1, %eax
199         cpuid
200         
201         test    $0x00800000, %edx
202         jz      .notfound
203
204         movl    $1, %eax
205         jmp     .out2
206
207 .notfound:
208         movl    $0, %eax
209 .out2:  
210         popl    %ebx
211         ret