2 * scale_line_22_yuv_mmx.S -- scale line in YUY2 format
3 * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
4 * Author: Dan Dennedy <dan@dennedy.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 .file "scale_line_22_yuv_mmx.S"
27 MSG: .ascii "scale_line_22_yuv_mmx: %d %d\n"
32 #if !defined(__MINGW32__) && !defined(__CYGWIN__)
34 .globl pixops_scale_line_22_yuv_mmx
35 .type pixops_scale_line_22_yuv_mmx,@function
36 pixops_scale_line_22_yuv_mmx:
40 .globl _pixops_scale_line_22_yuv_mmx
41 _pixops_scale_line_22_yuv_mmx:
48 * p (dest): 12(%ebp) %esi
69 * int x_scaled -24(%ebp)
76 /* Initialize variables */
77 movl 36(%ebp),%eax # destx
79 movl 32(%ebp),%ebx # x
80 movl 12(%ebp),%esi # dest
82 cmpl 28(%ebp),%esi # dest == dest_end ?
85 /* For the body of this loop, %mm0, %mm1, %mm2, %mm3 hold the 4 adjoining
86 * points we are interpolating between, as:
93 * Load next component values into mm1 (src0) and mm3 (src1)
95 movl %ebx, %eax # x_scaled
97 andl $0xfffffffe, %eax
98 movl %eax, %edx # x_aligned
99 andl $0xfffffffc, %edx
101 movl 16(%ebp), %edi # get src0
102 movl (%edi,%eax), %ecx # get y
103 andl $0x00ff00ff, %ecx # mask off y
104 movl (%edi,%edx), %eax # get uv
105 andl $0xff00ff00, %eax # mask off uv
106 orl %eax, %ecx # composite y, uv
107 movd %ecx, %mm1 # move to mmx1
110 movl 20(%ebp), %edi # get src1
111 movl (%edi,%edx), %ecx # get y
112 andl $0x00ff00ff, %ecx # mask off y
113 movl (%edi,%edx), %eax # get uv
114 andl $0xff00ff00, %eax # mask off uv
115 orl %eax, %ecx # composite y, uv
116 movd %ecx, %mm3 # move to mmx3
124 /* short *pixel_weights = weights + ((x >> (SCALE_SHIFT - SUBSAMPLE_BITS)) & SUBSAMPLE_MASK) * n_x * n_y
127 movl 8(%ebp), %edi # get weights pointer
132 /* At this point, %edi holds weights. Load the 4 weights into
133 * %mm4,%mm5,%mm6,%mm7, multiply and accumulate.
135 movq (%edi,%eax), %mm4
137 movq 8(%edi,%eax), %mm5
139 movq 16(%edi,%eax), %mm6
141 movq 24(%edi,%eax), %mm7
148 /* %mm7 holds the accumulated sum. Compute (C + 0x80) / 256
151 movl $0x80808080, %eax
157 /* Pack into %eax and store result
162 movb %al, (%esi) # *dest = y
164 movl 36(%ebp), %ecx # get dest_x
165 andl $1, %ecx # select u or v
166 sall $1, %ecx # determine offset
167 addl $1, %ecx # relative to x_aligned
168 sall $3, %ecx # offset * 8 bits/byte
172 movb %al, 1(%esi) # *dest = uv
174 addl $2, %esi # dest += 2
175 cmpl %esi,28(%ebp) # if dest == dest_end
178 addl $1, 36(%ebp) # dest_x++
182 addl 24(%ebp), %ebx # x += x_step
184 * Load current component values into mm0 (src0) and mm2 (src1)
190 * Load next component values into mm1 (src0) and mm3 (src1)
192 movl %ebx, %eax # x_scaled
194 andl $0xfffffffe, %eax
195 movl %eax, %edx # x_aligned
196 andl $0xfffffffc, %edx
198 movl 16(%ebp), %edi # get src0
199 movl (%edi,%eax), %ecx # get y
200 andl $0x00ff00ff, %ecx # mask off y
201 movl (%edi,%edx), %eax # get uv
202 andl $0xff00ff00, %eax # mask off uv
203 orl %eax, %ecx # composite y, uv
204 movd %ecx, %mm1 # move to mmx1
207 movl 20(%ebp), %edi # get src1
208 movl (%edi,%edx), %ecx # get y
209 andl $0x00ff00ff, %ecx # mask off y
210 movl (%edi,%edx), %eax # get uv
211 andl $0xff00ff00, %eax # mask off uv
212 orl %eax, %ecx # composite y, uv
213 movd %ecx, %mm3 # move to mmx3