Mercurial > mplayer.hg
annotate postproc/swscale_template.c @ 9778:da63c272425e
AAC section added.
author | diego |
---|---|
date | Tue, 01 Apr 2003 00:33:16 +0000 |
parents | bc5b87370cd1 |
children | 61057de81510 |
rev | line source |
---|---|
4295 | 1 /* |
9476
eff727517e6b
yuv2rgb brightness/contrast/saturation/different colorspaces support finished
michael
parents:
9434
diff
changeset
|
2 Copyright (C) 2001-2003 Michael Niedermayer <michaelni@gmx.at> |
2216 | 3 |
4295 | 4 This program is free software; you can redistribute it and/or modify |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 2 of the License, or | |
7 (at your option) any later version. | |
2216 | 8 |
4295 | 9 This program is distributed in the hope that it will be useful, |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
15 along with this program; if not, write to the Free Software | |
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
17 */ | |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
18 |
2540 | 19 #undef MOVNTQ |
2680 | 20 #undef PAVGB |
3136 | 21 #undef PREFETCH |
22 #undef PREFETCHW | |
23 #undef EMMS | |
24 #undef SFENCE | |
25 | |
26 #ifdef HAVE_3DNOW | |
27 /* On K6 femms is faster of emms. On K7 femms is directly mapped on emms. */ | |
28 #define EMMS "femms" | |
29 #else | |
30 #define EMMS "emms" | |
31 #endif | |
32 | |
33 #ifdef HAVE_3DNOW | |
34 #define PREFETCH "prefetch" | |
35 #define PREFETCHW "prefetchw" | |
36 #elif defined ( HAVE_MMX2 ) | |
37 #define PREFETCH "prefetchnta" | |
38 #define PREFETCHW "prefetcht0" | |
39 #else | |
40 #define PREFETCH "/nop" | |
41 #define PREFETCHW "/nop" | |
42 #endif | |
43 | |
44 #ifdef HAVE_MMX2 | |
45 #define SFENCE "sfence" | |
46 #else | |
47 #define SFENCE "/nop" | |
48 #endif | |
2232
65996b3467d7
MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents:
2230
diff
changeset
|
49 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
50 #ifdef HAVE_MMX2 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
51 #define PAVGB(a,b) "pavgb " #a ", " #b " \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
52 #elif defined (HAVE_3DNOW) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
53 #define PAVGB(a,b) "pavgusb " #a ", " #b " \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
54 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
55 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
56 #ifdef HAVE_MMX2 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
57 #define MOVNTQ(a,b) "movntq " #a ", " #b " \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
58 #else |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
59 #define MOVNTQ(a,b) "movq " #a ", " #b " \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
60 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
61 |
9413 | 62 #define YSCALEYUV2YV12X(x, offset) \ |
3344 | 63 "xorl %%eax, %%eax \n\t"\ |
64 "pxor %%mm3, %%mm3 \n\t"\ | |
65 "pxor %%mm4, %%mm4 \n\t"\ | |
9413 | 66 "leal " offset "(%0), %%edx \n\t"\ |
67 "movl (%%edx), %%esi \n\t"\ | |
3344 | 68 ".balign 16 \n\t" /* FIXME Unroll? */\ |
69 "1: \n\t"\ | |
9413 | 70 "movq 8(%%edx), %%mm0 \n\t" /* filterCoeff */\ |
3344 | 71 "movq " #x "(%%esi, %%eax, 2), %%mm2 \n\t" /* srcData */\ |
72 "movq 8+" #x "(%%esi, %%eax, 2), %%mm5 \n\t" /* srcData */\ | |
9413 | 73 "addl $16, %%edx \n\t"\ |
74 "movl (%%edx), %%esi \n\t"\ | |
75 "testl %%esi, %%esi \n\t"\ | |
3344 | 76 "pmulhw %%mm0, %%mm2 \n\t"\ |
77 "pmulhw %%mm0, %%mm5 \n\t"\ | |
78 "paddw %%mm2, %%mm3 \n\t"\ | |
79 "paddw %%mm5, %%mm4 \n\t"\ | |
80 " jnz 1b \n\t"\ | |
81 "psraw $3, %%mm3 \n\t"\ | |
82 "psraw $3, %%mm4 \n\t"\ | |
83 "packuswb %%mm4, %%mm3 \n\t"\ | |
9413 | 84 MOVNTQ(%%mm3, (%1, %%eax))\ |
3344 | 85 "addl $8, %%eax \n\t"\ |
9413 | 86 "cmpl %2, %%eax \n\t"\ |
3344 | 87 "pxor %%mm3, %%mm3 \n\t"\ |
88 "pxor %%mm4, %%mm4 \n\t"\ | |
9413 | 89 "leal " offset "(%0), %%edx \n\t"\ |
90 "movl (%%edx), %%esi \n\t"\ | |
3344 | 91 "jb 1b \n\t" |
92 | |
93 #define YSCALEYUV2YV121 \ | |
94 "movl %2, %%eax \n\t"\ | |
95 ".balign 16 \n\t" /* FIXME Unroll? */\ | |
96 "1: \n\t"\ | |
97 "movq (%0, %%eax, 2), %%mm0 \n\t"\ | |
98 "movq 8(%0, %%eax, 2), %%mm1 \n\t"\ | |
99 "psraw $7, %%mm0 \n\t"\ | |
100 "psraw $7, %%mm1 \n\t"\ | |
101 "packuswb %%mm1, %%mm0 \n\t"\ | |
102 MOVNTQ(%%mm0, (%1, %%eax))\ | |
103 "addl $8, %%eax \n\t"\ | |
104 "jnc 1b \n\t" | |
105 | |
106 /* | |
107 :: "m" (-lumFilterSize), "m" (-chrFilterSize), | |
108 "m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4), | |
109 "r" (dest), "m" (dstW), | |
110 "m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize) | |
111 : "%eax", "%ebx", "%ecx", "%edx", "%esi" | |
112 */ | |
7723 | 113 #define YSCALEYUV2PACKEDX \ |
3344 | 114 "xorl %%eax, %%eax \n\t"\ |
115 ".balign 16 \n\t"\ | |
9413 | 116 "nop \n\t"\ |
3344 | 117 "1: \n\t"\ |
9413 | 118 "leal "CHR_MMX_FILTER_OFFSET"(%0), %%edx \n\t"\ |
119 "movl (%%edx), %%esi \n\t"\ | |
3344 | 120 "pxor %%mm3, %%mm3 \n\t"\ |
121 "pxor %%mm4, %%mm4 \n\t"\ | |
9413 | 122 ".balign 16 \n\t"\ |
3344 | 123 "2: \n\t"\ |
9413 | 124 "movq 8(%%edx), %%mm0 \n\t" /* filterCoeff */\ |
3344 | 125 "movq (%%esi, %%eax), %%mm2 \n\t" /* UsrcData */\ |
126 "movq 4096(%%esi, %%eax), %%mm5 \n\t" /* VsrcData */\ | |
9413 | 127 "addl $16, %%edx \n\t"\ |
128 "movl (%%edx), %%esi \n\t"\ | |
3344 | 129 "pmulhw %%mm0, %%mm2 \n\t"\ |
130 "pmulhw %%mm0, %%mm5 \n\t"\ | |
131 "paddw %%mm2, %%mm3 \n\t"\ | |
132 "paddw %%mm5, %%mm4 \n\t"\ | |
9413 | 133 "testl %%esi, %%esi \n\t"\ |
3344 | 134 " jnz 2b \n\t"\ |
135 \ | |
9413 | 136 "leal "LUM_MMX_FILTER_OFFSET"(%0), %%edx \n\t"\ |
137 "movl (%%edx), %%esi \n\t"\ | |
3344 | 138 "pxor %%mm1, %%mm1 \n\t"\ |
139 "pxor %%mm7, %%mm7 \n\t"\ | |
9413 | 140 ".balign 16 \n\t"\ |
3344 | 141 "2: \n\t"\ |
9413 | 142 "movq 8(%%edx), %%mm0 \n\t" /* filterCoeff */\ |
3344 | 143 "movq (%%esi, %%eax, 2), %%mm2 \n\t" /* Y1srcData */\ |
144 "movq 8(%%esi, %%eax, 2), %%mm5 \n\t" /* Y2srcData */\ | |
9413 | 145 "addl $16, %%edx \n\t"\ |
146 "movl (%%edx), %%esi \n\t"\ | |
3344 | 147 "pmulhw %%mm0, %%mm2 \n\t"\ |
148 "pmulhw %%mm0, %%mm5 \n\t"\ | |
149 "paddw %%mm2, %%mm1 \n\t"\ | |
150 "paddw %%mm5, %%mm7 \n\t"\ | |
9413 | 151 "testl %%esi, %%esi \n\t"\ |
3344 | 152 " jnz 2b \n\t"\ |
7723 | 153 |
154 | |
155 #define YSCALEYUV2RGBX \ | |
156 YSCALEYUV2PACKEDX\ | |
9413 | 157 "psubw "U_OFFSET"(%0), %%mm3 \n\t" /* (U-128)8*/\ |
158 "psubw "V_OFFSET"(%0), %%mm4 \n\t" /* (V-128)8*/\ | |
3344 | 159 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\ |
160 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\ | |
9413 | 161 "pmulhw "UG_COEFF"(%0), %%mm3 \n\t"\ |
162 "pmulhw "VG_COEFF"(%0), %%mm4 \n\t"\ | |
3344 | 163 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\ |
9413 | 164 "pmulhw "UB_COEFF"(%0), %%mm2 \n\t"\ |
165 "pmulhw "VR_COEFF"(%0), %%mm5 \n\t"\ | |
166 "psubw "Y_OFFSET"(%0), %%mm1 \n\t" /* 8(Y-16)*/\ | |
167 "psubw "Y_OFFSET"(%0), %%mm7 \n\t" /* 8(Y-16)*/\ | |
168 "pmulhw "Y_COEFF"(%0), %%mm1 \n\t"\ | |
169 "pmulhw "Y_COEFF"(%0), %%mm7 \n\t"\ | |
3344 | 170 /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\ |
171 "paddw %%mm3, %%mm4 \n\t"\ | |
172 "movq %%mm2, %%mm0 \n\t"\ | |
173 "movq %%mm5, %%mm6 \n\t"\ | |
174 "movq %%mm4, %%mm3 \n\t"\ | |
175 "punpcklwd %%mm2, %%mm2 \n\t"\ | |
176 "punpcklwd %%mm5, %%mm5 \n\t"\ | |
177 "punpcklwd %%mm4, %%mm4 \n\t"\ | |
178 "paddw %%mm1, %%mm2 \n\t"\ | |
179 "paddw %%mm1, %%mm5 \n\t"\ | |
180 "paddw %%mm1, %%mm4 \n\t"\ | |
181 "punpckhwd %%mm0, %%mm0 \n\t"\ | |
182 "punpckhwd %%mm6, %%mm6 \n\t"\ | |
183 "punpckhwd %%mm3, %%mm3 \n\t"\ | |
184 "paddw %%mm7, %%mm0 \n\t"\ | |
185 "paddw %%mm7, %%mm6 \n\t"\ | |
186 "paddw %%mm7, %%mm3 \n\t"\ | |
187 /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\ | |
188 "packuswb %%mm0, %%mm2 \n\t"\ | |
189 "packuswb %%mm6, %%mm5 \n\t"\ | |
190 "packuswb %%mm3, %%mm4 \n\t"\ | |
191 "pxor %%mm7, %%mm7 \n\t" | |
9413 | 192 #if 0 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
193 #define FULL_YSCALEYUV2RGB \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
194 "pxor %%mm7, %%mm7 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
195 "movd %6, %%mm6 \n\t" /*yalpha1*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
196 "punpcklwd %%mm6, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
197 "punpcklwd %%mm6, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
198 "movd %7, %%mm5 \n\t" /*uvalpha1*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
199 "punpcklwd %%mm5, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
200 "punpcklwd %%mm5, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
201 "xorl %%eax, %%eax \n\t"\ |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
202 ".balign 16 \n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
203 "1: \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
204 "movq (%0, %%eax, 2), %%mm0 \n\t" /*buf0[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
205 "movq (%1, %%eax, 2), %%mm1 \n\t" /*buf1[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
206 "movq (%2, %%eax,2), %%mm2 \n\t" /* uvbuf0[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
207 "movq (%3, %%eax,2), %%mm3 \n\t" /* uvbuf1[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
208 "psubw %%mm1, %%mm0 \n\t" /* buf0[eax] - buf1[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
209 "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
210 "pmulhw %%mm6, %%mm0 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
211 "pmulhw %%mm5, %%mm2 \n\t" /* (uvbuf0[eax] - uvbuf1[eax])uvalpha1>>16*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
212 "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
213 "movq 4096(%2, %%eax,2), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
214 "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
215 "paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
216 "movq 4096(%3, %%eax,2), %%mm0 \n\t" /* uvbuf1[eax+2048]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
217 "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax]uvalpha1 - uvbuf1[eax](1-uvalpha1)*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
218 "psubw %%mm0, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\ |
4248 | 219 "psubw "MANGLE(w80)", %%mm1 \n\t" /* 8(Y-16)*/\ |
220 "psubw "MANGLE(w400)", %%mm3 \n\t" /* 8(U-128)*/\ | |
221 "pmulhw "MANGLE(yCoeff)", %%mm1 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
222 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
223 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
224 "pmulhw %%mm5, %%mm4 \n\t" /* (uvbuf0[eax+2048] - uvbuf1[eax+2048])uvalpha1>>16*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
225 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\ |
4248 | 226 "pmulhw "MANGLE(ubCoeff)", %%mm3\n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
227 "psraw $4, %%mm0 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\ |
4248 | 228 "pmulhw "MANGLE(ugCoeff)", %%mm2\n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
229 "paddw %%mm4, %%mm0 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\ |
4248 | 230 "psubw "MANGLE(w400)", %%mm0 \n\t" /* (V-128)8*/\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
231 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
232 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
233 "movq %%mm0, %%mm4 \n\t" /* (V-128)8*/\ |
4248 | 234 "pmulhw "MANGLE(vrCoeff)", %%mm0\n\t"\ |
235 "pmulhw "MANGLE(vgCoeff)", %%mm4\n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
236 "paddw %%mm1, %%mm3 \n\t" /* B*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
237 "paddw %%mm1, %%mm0 \n\t" /* R*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
238 "packuswb %%mm3, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
239 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
240 "packuswb %%mm0, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
241 "paddw %%mm4, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
242 "paddw %%mm2, %%mm1 \n\t" /* G*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
243 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
244 "packuswb %%mm1, %%mm1 \n\t" |
9413 | 245 #endif |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
246 |
9414 | 247 #define YSCALEYUV2PACKED(index, c) \ |
248 "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0\n\t"\ | |
249 "movq "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm1\n\t"\ | |
250 "psraw $3, %%mm0 \n\t"\ | |
251 "psraw $3, %%mm1 \n\t"\ | |
252 "movq %%mm0, "CHR_MMX_FILTER_OFFSET"+8("#c")\n\t"\ | |
253 "movq %%mm1, "LUM_MMX_FILTER_OFFSET"+8("#c")\n\t"\ | |
254 "xorl "#index", "#index" \n\t"\ | |
7723 | 255 ".balign 16 \n\t"\ |
256 "1: \n\t"\ | |
9414 | 257 "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\ |
258 "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\ | |
259 "movq 4096(%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\ | |
260 "movq 4096(%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\ | |
7723 | 261 "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\ |
262 "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\ | |
9414 | 263 "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0\n\t"\ |
7723 | 264 "pmulhw %%mm0, %%mm2 \n\t" /* (uvbuf0[eax] - uvbuf1[eax])uvalpha1>>16*/\ |
265 "pmulhw %%mm0, %%mm5 \n\t" /* (uvbuf0[eax+2048] - uvbuf1[eax+2048])uvalpha1>>16*/\ | |
266 "psraw $7, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\ | |
267 "psraw $7, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\ | |
268 "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax]uvalpha1 - uvbuf1[eax](1-uvalpha1)*/\ | |
269 "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\ | |
9414 | 270 "movq (%0, "#index", 2), %%mm0 \n\t" /*buf0[eax]*/\ |
271 "movq (%1, "#index", 2), %%mm1 \n\t" /*buf1[eax]*/\ | |
272 "movq 8(%0, "#index", 2), %%mm6 \n\t" /*buf0[eax]*/\ | |
273 "movq 8(%1, "#index", 2), %%mm7 \n\t" /*buf1[eax]*/\ | |
7723 | 274 "psubw %%mm1, %%mm0 \n\t" /* buf0[eax] - buf1[eax]*/\ |
275 "psubw %%mm7, %%mm6 \n\t" /* buf0[eax] - buf1[eax]*/\ | |
9414 | 276 "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm0\n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\ |
277 "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm6\n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\ | |
7723 | 278 "psraw $7, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
279 "psraw $7, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ | |
280 "paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\ | |
281 "paddw %%mm6, %%mm7 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\ | |
282 | |
9414 | 283 #define YSCALEYUV2RGB(index, c) \ |
284 "xorl "#index", "#index" \n\t"\ | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
285 ".balign 16 \n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
286 "1: \n\t"\ |
9414 | 287 "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\ |
288 "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\ | |
289 "movq 4096(%2, "#index"), %%mm5\n\t" /* uvbuf0[eax+2048]*/\ | |
290 "movq 4096(%3, "#index"), %%mm4\n\t" /* uvbuf1[eax+2048]*/\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
291 "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
292 "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\ |
9414 | 293 "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0\n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
294 "pmulhw %%mm0, %%mm2 \n\t" /* (uvbuf0[eax] - uvbuf1[eax])uvalpha1>>16*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
295 "pmulhw %%mm0, %%mm5 \n\t" /* (uvbuf0[eax+2048] - uvbuf1[eax+2048])uvalpha1>>16*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
296 "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
297 "psraw $4, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
298 "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax]uvalpha1 - uvbuf1[eax](1-uvalpha1)*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
299 "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\ |
9414 | 300 "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\ |
301 "psubw "V_OFFSET"("#c"), %%mm4 \n\t" /* (V-128)8*/\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
302 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
303 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\ |
9414 | 304 "pmulhw "UG_COEFF"("#c"), %%mm3\n\t"\ |
305 "pmulhw "VG_COEFF"("#c"), %%mm4\n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
306 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\ |
9414 | 307 "movq (%0, "#index", 2), %%mm0 \n\t" /*buf0[eax]*/\ |
308 "movq (%1, "#index", 2), %%mm1 \n\t" /*buf1[eax]*/\ | |
309 "movq 8(%0, "#index", 2), %%mm6\n\t" /*buf0[eax]*/\ | |
310 "movq 8(%1, "#index", 2), %%mm7\n\t" /*buf1[eax]*/\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
311 "psubw %%mm1, %%mm0 \n\t" /* buf0[eax] - buf1[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
312 "psubw %%mm7, %%mm6 \n\t" /* buf0[eax] - buf1[eax]*/\ |
9414 | 313 "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm0\n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\ |
314 "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm6\n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
315 "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
316 "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
317 "paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
318 "paddw %%mm6, %%mm7 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\ |
9414 | 319 "pmulhw "UB_COEFF"("#c"), %%mm2\n\t"\ |
320 "pmulhw "VR_COEFF"("#c"), %%mm5\n\t"\ | |
321 "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\ | |
322 "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\ | |
323 "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\ | |
324 "pmulhw "Y_COEFF"("#c"), %%mm7 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
325 /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
326 "paddw %%mm3, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
327 "movq %%mm2, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
328 "movq %%mm5, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
329 "movq %%mm4, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
330 "punpcklwd %%mm2, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
331 "punpcklwd %%mm5, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
332 "punpcklwd %%mm4, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
333 "paddw %%mm1, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
334 "paddw %%mm1, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
335 "paddw %%mm1, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
336 "punpckhwd %%mm0, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
337 "punpckhwd %%mm6, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
338 "punpckhwd %%mm3, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
339 "paddw %%mm7, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
340 "paddw %%mm7, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
341 "paddw %%mm7, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
342 /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
343 "packuswb %%mm0, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
344 "packuswb %%mm6, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
345 "packuswb %%mm3, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
346 "pxor %%mm7, %%mm7 \n\t" |
7723 | 347 |
9417 | 348 #define YSCALEYUV2PACKED1(index, c) \ |
349 "xorl "#index", "#index" \n\t"\ | |
7723 | 350 ".balign 16 \n\t"\ |
351 "1: \n\t"\ | |
9417 | 352 "movq (%2, "#index"), %%mm3 \n\t" /* uvbuf0[eax]*/\ |
353 "movq 4096(%2, "#index"), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\ | |
7723 | 354 "psraw $7, %%mm3 \n\t" \ |
355 "psraw $7, %%mm4 \n\t" \ | |
9417 | 356 "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\ |
357 "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\ | |
7723 | 358 "psraw $7, %%mm1 \n\t" \ |
359 "psraw $7, %%mm7 \n\t" \ | |
360 | |
9417 | 361 #define YSCALEYUV2RGB1(index, c) \ |
362 "xorl "#index", "#index" \n\t"\ | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
363 ".balign 16 \n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
364 "1: \n\t"\ |
9417 | 365 "movq (%2, "#index"), %%mm3 \n\t" /* uvbuf0[eax]*/\ |
366 "movq 4096(%2, "#index"), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
367 "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
368 "psraw $4, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\ |
9417 | 369 "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\ |
370 "psubw "V_OFFSET"("#c"), %%mm4 \n\t" /* (V-128)8*/\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
371 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
372 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\ |
9417 | 373 "pmulhw "UG_COEFF"("#c"), %%mm3\n\t"\ |
374 "pmulhw "VG_COEFF"("#c"), %%mm4\n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
375 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\ |
9417 | 376 "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\ |
377 "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\ | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
378 "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
379 "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
9417 | 380 "pmulhw "UB_COEFF"("#c"), %%mm2\n\t"\ |
381 "pmulhw "VR_COEFF"("#c"), %%mm5\n\t"\ | |
382 "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\ | |
383 "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\ | |
384 "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\ | |
385 "pmulhw "Y_COEFF"("#c"), %%mm7 \n\t"\ | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
386 /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
387 "paddw %%mm3, %%mm4 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
388 "movq %%mm2, %%mm0 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
389 "movq %%mm5, %%mm6 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
390 "movq %%mm4, %%mm3 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
391 "punpcklwd %%mm2, %%mm2 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
392 "punpcklwd %%mm5, %%mm5 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
393 "punpcklwd %%mm4, %%mm4 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
394 "paddw %%mm1, %%mm2 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
395 "paddw %%mm1, %%mm5 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
396 "paddw %%mm1, %%mm4 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
397 "punpckhwd %%mm0, %%mm0 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
398 "punpckhwd %%mm6, %%mm6 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
399 "punpckhwd %%mm3, %%mm3 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
400 "paddw %%mm7, %%mm0 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
401 "paddw %%mm7, %%mm6 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
402 "paddw %%mm7, %%mm3 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
403 /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
404 "packuswb %%mm0, %%mm2 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
405 "packuswb %%mm6, %%mm5 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
406 "packuswb %%mm3, %%mm4 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
407 "pxor %%mm7, %%mm7 \n\t" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
408 |
9417 | 409 #define YSCALEYUV2PACKED1b(index, c) \ |
410 "xorl "#index", "#index" \n\t"\ | |
7723 | 411 ".balign 16 \n\t"\ |
412 "1: \n\t"\ | |
9417 | 413 "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\ |
414 "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\ | |
415 "movq 4096(%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\ | |
416 "movq 4096(%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\ | |
7723 | 417 "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax] + uvbuf1[eax]*/\ |
418 "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048] + uvbuf1[eax+2048]*/\ | |
419 "psrlw $8, %%mm3 \n\t" \ | |
420 "psrlw $8, %%mm4 \n\t" \ | |
9417 | 421 "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\ |
422 "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\ | |
7723 | 423 "psraw $7, %%mm1 \n\t" \ |
424 "psraw $7, %%mm7 \n\t" | |
425 | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
426 // do vertical chrominance interpolation |
9417 | 427 #define YSCALEYUV2RGB1b(index, c) \ |
428 "xorl "#index", "#index" \n\t"\ | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
429 ".balign 16 \n\t"\ |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
430 "1: \n\t"\ |
9417 | 431 "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\ |
432 "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\ | |
433 "movq 4096(%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\ | |
434 "movq 4096(%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\ | |
2576 | 435 "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax] + uvbuf1[eax]*/\ |
436 "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048] + uvbuf1[eax+2048]*/\ | |
3344 | 437 "psrlw $5, %%mm3 \n\t" /*FIXME might overflow*/\ |
438 "psrlw $5, %%mm4 \n\t" /*FIXME might overflow*/\ | |
9417 | 439 "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\ |
440 "psubw "V_OFFSET"("#c"), %%mm4 \n\t" /* (V-128)8*/\ | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
441 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
442 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\ |
9417 | 443 "pmulhw "UG_COEFF"("#c"), %%mm3\n\t"\ |
444 "pmulhw "VG_COEFF"("#c"), %%mm4\n\t"\ | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
445 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\ |
9417 | 446 "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\ |
447 "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
448 "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
449 "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
9417 | 450 "pmulhw "UB_COEFF"("#c"), %%mm2\n\t"\ |
451 "pmulhw "VR_COEFF"("#c"), %%mm5\n\t"\ | |
452 "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\ | |
453 "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\ | |
454 "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\ | |
455 "pmulhw "Y_COEFF"("#c"), %%mm7 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
456 /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
457 "paddw %%mm3, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
458 "movq %%mm2, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
459 "movq %%mm5, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
460 "movq %%mm4, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
461 "punpcklwd %%mm2, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
462 "punpcklwd %%mm5, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
463 "punpcklwd %%mm4, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
464 "paddw %%mm1, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
465 "paddw %%mm1, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
466 "paddw %%mm1, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
467 "punpckhwd %%mm0, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
468 "punpckhwd %%mm6, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
469 "punpckhwd %%mm3, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
470 "paddw %%mm7, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
471 "paddw %%mm7, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
472 "paddw %%mm7, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
473 /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
474 "packuswb %%mm0, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
475 "packuswb %%mm6, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
476 "packuswb %%mm3, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
477 "pxor %%mm7, %%mm7 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
478 |
9414 | 479 #define WRITEBGR32(dst, dstw, index) \ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
480 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
481 "movq %%mm2, %%mm1 \n\t" /* B */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
482 "movq %%mm5, %%mm6 \n\t" /* R */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
483 "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
484 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
485 "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
486 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
487 "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
488 "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
489 "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
490 "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
491 "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
492 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
493 \ |
9414 | 494 MOVNTQ(%%mm0, (dst, index, 4))\ |
495 MOVNTQ(%%mm2, 8(dst, index, 4))\ | |
496 MOVNTQ(%%mm1, 16(dst, index, 4))\ | |
497 MOVNTQ(%%mm3, 24(dst, index, 4))\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
498 \ |
9414 | 499 "addl $8, "#index" \n\t"\ |
500 "cmpl "#dstw", "#index" \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
501 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
502 |
9414 | 503 #define WRITEBGR16(dst, dstw, index) \ |
4248 | 504 "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\ |
505 "pand "MANGLE(bFC)", %%mm4 \n\t" /* G */\ | |
506 "pand "MANGLE(bF8)", %%mm5 \n\t" /* R */\ | |
2669 | 507 "psrlq $3, %%mm2 \n\t"\ |
508 \ | |
509 "movq %%mm2, %%mm1 \n\t"\ | |
510 "movq %%mm4, %%mm3 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
511 \ |
2669 | 512 "punpcklbw %%mm7, %%mm3 \n\t"\ |
513 "punpcklbw %%mm5, %%mm2 \n\t"\ | |
514 "punpckhbw %%mm7, %%mm4 \n\t"\ | |
515 "punpckhbw %%mm5, %%mm1 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
516 \ |
2669 | 517 "psllq $3, %%mm3 \n\t"\ |
518 "psllq $3, %%mm4 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
519 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
520 "por %%mm3, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
521 "por %%mm4, %%mm1 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
522 \ |
9414 | 523 MOVNTQ(%%mm2, (dst, index, 2))\ |
524 MOVNTQ(%%mm1, 8(dst, index, 2))\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
525 \ |
9414 | 526 "addl $8, "#index" \n\t"\ |
527 "cmpl "#dstw", "#index" \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
528 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
529 |
9414 | 530 #define WRITEBGR15(dst, dstw, index) \ |
4248 | 531 "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\ |
532 "pand "MANGLE(bF8)", %%mm4 \n\t" /* G */\ | |
533 "pand "MANGLE(bF8)", %%mm5 \n\t" /* R */\ | |
2669 | 534 "psrlq $3, %%mm2 \n\t"\ |
535 "psrlq $1, %%mm5 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
536 \ |
2669 | 537 "movq %%mm2, %%mm1 \n\t"\ |
538 "movq %%mm4, %%mm3 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
539 \ |
2669 | 540 "punpcklbw %%mm7, %%mm3 \n\t"\ |
541 "punpcklbw %%mm5, %%mm2 \n\t"\ | |
542 "punpckhbw %%mm7, %%mm4 \n\t"\ | |
543 "punpckhbw %%mm5, %%mm1 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
544 \ |
2669 | 545 "psllq $2, %%mm3 \n\t"\ |
546 "psllq $2, %%mm4 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
547 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
548 "por %%mm3, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
549 "por %%mm4, %%mm1 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
550 \ |
9414 | 551 MOVNTQ(%%mm2, (dst, index, 2))\ |
552 MOVNTQ(%%mm1, 8(dst, index, 2))\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
553 \ |
9414 | 554 "addl $8, "#index" \n\t"\ |
555 "cmpl "#dstw", "#index" \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
556 " jb 1b \n\t" |
2669 | 557 |
9414 | 558 #define WRITEBGR24OLD(dst, dstw, index) \ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
559 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
560 "movq %%mm2, %%mm1 \n\t" /* B */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
561 "movq %%mm5, %%mm6 \n\t" /* R */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
562 "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
563 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
564 "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
565 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
566 "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
567 "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\ |
2326 | 568 "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\ |
569 "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\ | |
570 "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\ | |
571 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
572 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
573 "movq %%mm0, %%mm4 \n\t" /* 0RGB0RGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
574 "psrlq $8, %%mm0 \n\t" /* 00RGB0RG 0 */\ |
4248 | 575 "pand "MANGLE(bm00000111)", %%mm4\n\t" /* 00000RGB 0 */\ |
576 "pand "MANGLE(bm11111000)", %%mm0\n\t" /* 00RGB000 0.5 */\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
577 "por %%mm4, %%mm0 \n\t" /* 00RGBRGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
578 "movq %%mm2, %%mm4 \n\t" /* 0RGB0RGB 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
579 "psllq $48, %%mm2 \n\t" /* GB000000 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
580 "por %%mm2, %%mm0 \n\t" /* GBRGBRGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
581 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
582 "movq %%mm4, %%mm2 \n\t" /* 0RGB0RGB 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
583 "psrld $16, %%mm4 \n\t" /* 000R000R 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
584 "psrlq $24, %%mm2 \n\t" /* 0000RGB0 1.5 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
585 "por %%mm4, %%mm2 \n\t" /* 000RRGBR 1 */\ |
4248 | 586 "pand "MANGLE(bm00001111)", %%mm2\n\t" /* 0000RGBR 1 */\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
587 "movq %%mm1, %%mm4 \n\t" /* 0RGB0RGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
588 "psrlq $8, %%mm1 \n\t" /* 00RGB0RG 2 */\ |
4248 | 589 "pand "MANGLE(bm00000111)", %%mm4\n\t" /* 00000RGB 2 */\ |
590 "pand "MANGLE(bm11111000)", %%mm1\n\t" /* 00RGB000 2.5 */\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
591 "por %%mm4, %%mm1 \n\t" /* 00RGBRGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
592 "movq %%mm1, %%mm4 \n\t" /* 00RGBRGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
593 "psllq $32, %%mm1 \n\t" /* BRGB0000 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
594 "por %%mm1, %%mm2 \n\t" /* BRGBRGBR 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
595 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
596 "psrlq $32, %%mm4 \n\t" /* 000000RG 2.5 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
597 "movq %%mm3, %%mm5 \n\t" /* 0RGB0RGB 3 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
598 "psrlq $8, %%mm3 \n\t" /* 00RGB0RG 3 */\ |
4248 | 599 "pand "MANGLE(bm00000111)", %%mm5\n\t" /* 00000RGB 3 */\ |
600 "pand "MANGLE(bm11111000)", %%mm3\n\t" /* 00RGB000 3.5 */\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
601 "por %%mm5, %%mm3 \n\t" /* 00RGBRGB 3 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
602 "psllq $16, %%mm3 \n\t" /* RGBRGB00 3 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
603 "por %%mm4, %%mm3 \n\t" /* RGBRGBRG 2.5 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
604 \ |
9414 | 605 MOVNTQ(%%mm0, (dst))\ |
606 MOVNTQ(%%mm2, 8(dst))\ | |
607 MOVNTQ(%%mm3, 16(dst))\ | |
608 "addl $24, "#dst" \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
609 \ |
9414 | 610 "addl $8, "#index" \n\t"\ |
611 "cmpl "#dstw", "#index" \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
612 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
613 |
9414 | 614 #define WRITEBGR24MMX(dst, dstw, index) \ |
2730 | 615 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\ |
616 "movq %%mm2, %%mm1 \n\t" /* B */\ | |
617 "movq %%mm5, %%mm6 \n\t" /* R */\ | |
618 "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\ | |
619 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\ | |
620 "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\ | |
621 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\ | |
622 "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\ | |
623 "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\ | |
624 "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\ | |
625 "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\ | |
626 "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\ | |
627 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\ | |
628 \ | |
629 "movq %%mm0, %%mm4 \n\t" /* 0RGB0RGB 0 */\ | |
630 "movq %%mm2, %%mm6 \n\t" /* 0RGB0RGB 1 */\ | |
631 "movq %%mm1, %%mm5 \n\t" /* 0RGB0RGB 2 */\ | |
632 "movq %%mm3, %%mm7 \n\t" /* 0RGB0RGB 3 */\ | |
633 \ | |
634 "psllq $40, %%mm0 \n\t" /* RGB00000 0 */\ | |
635 "psllq $40, %%mm2 \n\t" /* RGB00000 1 */\ | |
636 "psllq $40, %%mm1 \n\t" /* RGB00000 2 */\ | |
637 "psllq $40, %%mm3 \n\t" /* RGB00000 3 */\ | |
638 \ | |
639 "punpckhdq %%mm4, %%mm0 \n\t" /* 0RGBRGB0 0 */\ | |
640 "punpckhdq %%mm6, %%mm2 \n\t" /* 0RGBRGB0 1 */\ | |
641 "punpckhdq %%mm5, %%mm1 \n\t" /* 0RGBRGB0 2 */\ | |
642 "punpckhdq %%mm7, %%mm3 \n\t" /* 0RGBRGB0 3 */\ | |
643 \ | |
644 "psrlq $8, %%mm0 \n\t" /* 00RGBRGB 0 */\ | |
645 "movq %%mm2, %%mm6 \n\t" /* 0RGBRGB0 1 */\ | |
646 "psllq $40, %%mm2 \n\t" /* GB000000 1 */\ | |
647 "por %%mm2, %%mm0 \n\t" /* GBRGBRGB 0 */\ | |
9414 | 648 MOVNTQ(%%mm0, (dst))\ |
2730 | 649 \ |
650 "psrlq $24, %%mm6 \n\t" /* 0000RGBR 1 */\ | |
651 "movq %%mm1, %%mm5 \n\t" /* 0RGBRGB0 2 */\ | |
652 "psllq $24, %%mm1 \n\t" /* BRGB0000 2 */\ | |
653 "por %%mm1, %%mm6 \n\t" /* BRGBRGBR 1 */\ | |
9414 | 654 MOVNTQ(%%mm6, 8(dst))\ |
2730 | 655 \ |
656 "psrlq $40, %%mm5 \n\t" /* 000000RG 2 */\ | |
657 "psllq $8, %%mm3 \n\t" /* RGBRGB00 3 */\ | |
658 "por %%mm3, %%mm5 \n\t" /* RGBRGBRG 2 */\ | |
9414 | 659 MOVNTQ(%%mm5, 16(dst))\ |
2730 | 660 \ |
9414 | 661 "addl $24, "#dst" \n\t"\ |
2730 | 662 \ |
9414 | 663 "addl $8, "#index" \n\t"\ |
664 "cmpl "#dstw", "#index" \n\t"\ | |
2730 | 665 " jb 1b \n\t" |
666 | |
9414 | 667 #define WRITEBGR24MMX2(dst, dstw, index) \ |
2730 | 668 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\ |
4248 | 669 "movq "MANGLE(M24A)", %%mm0 \n\t"\ |
670 "movq "MANGLE(M24C)", %%mm7 \n\t"\ | |
2730 | 671 "pshufw $0x50, %%mm2, %%mm1 \n\t" /* B3 B2 B3 B2 B1 B0 B1 B0 */\ |
672 "pshufw $0x50, %%mm4, %%mm3 \n\t" /* G3 G2 G3 G2 G1 G0 G1 G0 */\ | |
673 "pshufw $0x00, %%mm5, %%mm6 \n\t" /* R1 R0 R1 R0 R1 R0 R1 R0 */\ | |
674 \ | |
675 "pand %%mm0, %%mm1 \n\t" /* B2 B1 B0 */\ | |
676 "pand %%mm0, %%mm3 \n\t" /* G2 G1 G0 */\ | |
677 "pand %%mm7, %%mm6 \n\t" /* R1 R0 */\ | |
678 \ | |
679 "psllq $8, %%mm3 \n\t" /* G2 G1 G0 */\ | |
680 "por %%mm1, %%mm6 \n\t"\ | |
681 "por %%mm3, %%mm6 \n\t"\ | |
9414 | 682 MOVNTQ(%%mm6, (dst))\ |
2730 | 683 \ |
684 "psrlq $8, %%mm4 \n\t" /* 00 G7 G6 G5 G4 G3 G2 G1 */\ | |
685 "pshufw $0xA5, %%mm2, %%mm1 \n\t" /* B5 B4 B5 B4 B3 B2 B3 B2 */\ | |
686 "pshufw $0x55, %%mm4, %%mm3 \n\t" /* G4 G3 G4 G3 G4 G3 G4 G3 */\ | |
687 "pshufw $0xA5, %%mm5, %%mm6 \n\t" /* R5 R4 R5 R4 R3 R2 R3 R2 */\ | |
688 \ | |
4248 | 689 "pand "MANGLE(M24B)", %%mm1 \n\t" /* B5 B4 B3 */\ |
2730 | 690 "pand %%mm7, %%mm3 \n\t" /* G4 G3 */\ |
691 "pand %%mm0, %%mm6 \n\t" /* R4 R3 R2 */\ | |
692 \ | |
693 "por %%mm1, %%mm3 \n\t" /* B5 G4 B4 G3 B3 */\ | |
694 "por %%mm3, %%mm6 \n\t"\ | |
9414 | 695 MOVNTQ(%%mm6, 8(dst))\ |
2730 | 696 \ |
697 "pshufw $0xFF, %%mm2, %%mm1 \n\t" /* B7 B6 B7 B6 B7 B6 B6 B7 */\ | |
698 "pshufw $0xFA, %%mm4, %%mm3 \n\t" /* 00 G7 00 G7 G6 G5 G6 G5 */\ | |
699 "pshufw $0xFA, %%mm5, %%mm6 \n\t" /* R7 R6 R7 R6 R5 R4 R5 R4 */\ | |
700 \ | |
701 "pand %%mm7, %%mm1 \n\t" /* B7 B6 */\ | |
702 "pand %%mm0, %%mm3 \n\t" /* G7 G6 G5 */\ | |
4248 | 703 "pand "MANGLE(M24B)", %%mm6 \n\t" /* R7 R6 R5 */\ |
2730 | 704 \ |
705 "por %%mm1, %%mm3 \n\t"\ | |
706 "por %%mm3, %%mm6 \n\t"\ | |
9414 | 707 MOVNTQ(%%mm6, 16(dst))\ |
2730 | 708 \ |
9414 | 709 "addl $24, "#dst" \n\t"\ |
2730 | 710 \ |
9414 | 711 "addl $8, "#index" \n\t"\ |
712 "cmpl "#dstw", "#index" \n\t"\ | |
2730 | 713 " jb 1b \n\t" |
714 | |
715 #ifdef HAVE_MMX2 | |
3126 | 716 #undef WRITEBGR24 |
2730 | 717 #define WRITEBGR24 WRITEBGR24MMX2 |
718 #else | |
3126 | 719 #undef WRITEBGR24 |
2730 | 720 #define WRITEBGR24 WRITEBGR24MMX |
721 #endif | |
722 | |
9414 | 723 #define WRITEYUY2(dst, dstw, index) \ |
7723 | 724 "packuswb %%mm3, %%mm3 \n\t"\ |
725 "packuswb %%mm4, %%mm4 \n\t"\ | |
726 "packuswb %%mm7, %%mm1 \n\t"\ | |
727 "punpcklbw %%mm4, %%mm3 \n\t"\ | |
728 "movq %%mm1, %%mm7 \n\t"\ | |
729 "punpcklbw %%mm3, %%mm1 \n\t"\ | |
730 "punpckhbw %%mm3, %%mm7 \n\t"\ | |
731 \ | |
9414 | 732 MOVNTQ(%%mm1, (dst, index, 2))\ |
733 MOVNTQ(%%mm7, 8(dst, index, 2))\ | |
7723 | 734 \ |
9414 | 735 "addl $8, "#index" \n\t"\ |
736 "cmpl "#dstw", "#index" \n\t"\ | |
7723 | 737 " jb 1b \n\t" |
738 | |
739 | |
9413 | 740 static inline void RENAME(yuv2yuvX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, |
3344 | 741 int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, |
9414 | 742 uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW) |
2519 | 743 { |
3344 | 744 #ifdef HAVE_MMX |
745 if(uDest != NULL) | |
746 { | |
747 asm volatile( | |
9413 | 748 YSCALEYUV2YV12X(0, CHR_MMX_FILTER_OFFSET) |
749 :: "r" (&c->redDither), | |
750 "r" (uDest), "m" (chrDstW) | |
3344 | 751 : "%eax", "%edx", "%esi" |
752 ); | |
2519 | 753 |
3344 | 754 asm volatile( |
9413 | 755 YSCALEYUV2YV12X(4096, CHR_MMX_FILTER_OFFSET) |
756 :: "r" (&c->redDither), | |
757 "r" (vDest), "m" (chrDstW) | |
3344 | 758 : "%eax", "%edx", "%esi" |
759 ); | |
760 } | |
2521 | 761 |
3344 | 762 asm volatile( |
9413 | 763 YSCALEYUV2YV12X(0, LUM_MMX_FILTER_OFFSET) |
764 :: "r" (&c->redDither), | |
765 "r" (dest), "m" (dstW) | |
3344 | 766 : "%eax", "%edx", "%esi" |
767 ); | |
768 #else | |
6540 | 769 yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize, |
3352 | 770 chrFilter, chrSrc, chrFilterSize, |
6540 | 771 dest, uDest, vDest, dstW, chrDstW); |
3344 | 772 #endif |
773 } | |
774 | |
775 static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc, | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
776 uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW) |
3344 | 777 { |
778 #ifdef HAVE_MMX | |
779 if(uDest != NULL) | |
780 { | |
781 asm volatile( | |
782 YSCALEYUV2YV121 | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
783 :: "r" (chrSrc + chrDstW), "r" (uDest + chrDstW), |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
784 "g" (-chrDstW) |
3344 | 785 : "%eax" |
786 ); | |
787 | |
788 asm volatile( | |
789 YSCALEYUV2YV121 | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
790 :: "r" (chrSrc + 2048 + chrDstW), "r" (vDest + chrDstW), |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
791 "g" (-chrDstW) |
3344 | 792 : "%eax" |
793 ); | |
2519 | 794 } |
3344 | 795 |
796 asm volatile( | |
797 YSCALEYUV2YV121 | |
798 :: "r" (lumSrc + dstW), "r" (dest + dstW), | |
799 "g" (-dstW) | |
800 : "%eax" | |
801 ); | |
802 #else | |
803 int i; | |
804 for(i=0; i<dstW; i++) | |
805 { | |
806 int val= lumSrc[i]>>7; | |
6503 | 807 |
808 if(val&256){ | |
809 if(val<0) val=0; | |
810 else val=255; | |
811 } | |
3344 | 812 |
6503 | 813 dest[i]= val; |
3344 | 814 } |
815 | |
816 if(uDest != NULL) | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
817 for(i=0; i<chrDstW; i++) |
3344 | 818 { |
819 int u=chrSrc[i]>>7; | |
820 int v=chrSrc[i + 2048]>>7; | |
821 | |
6503 | 822 if((u|v)&256){ |
823 if(u<0) u=0; | |
824 else if (u>255) u=255; | |
825 if(v<0) v=0; | |
826 else if (v>255) v=255; | |
827 } | |
828 | |
829 uDest[i]= u; | |
830 vDest[i]= v; | |
3344 | 831 } |
832 #endif | |
2519 | 833 } |
834 | |
3344 | 835 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
836 /** |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
837 * vertical scale YV12 to RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
838 */ |
7723 | 839 static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, |
3344 | 840 int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, |
9413 | 841 uint8_t *dest, int dstW, int dstY) |
3344 | 842 { |
9413 | 843 int dummy=0; |
6578 | 844 switch(c->dstFormat) |
3344 | 845 { |
846 #ifdef HAVE_MMX | |
6578 | 847 case IMGFMT_BGR32: |
3344 | 848 { |
849 asm volatile( | |
850 YSCALEYUV2RGBX | |
9414 | 851 WRITEBGR32(%4, %5, %%eax) |
3344 | 852 |
9413 | 853 :: "r" (&c->redDither), |
854 "m" (dummy), "m" (dummy), "m" (dummy), | |
855 "r" (dest), "m" (dstW) | |
856 : "%eax", "%edx", "%esi" | |
3344 | 857 ); |
858 } | |
6578 | 859 break; |
860 case IMGFMT_BGR24: | |
3344 | 861 { |
862 asm volatile( | |
863 YSCALEYUV2RGBX | |
864 "leal (%%eax, %%eax, 2), %%ebx \n\t" //FIXME optimize | |
865 "addl %4, %%ebx \n\t" | |
9414 | 866 WRITEBGR24(%%ebx, %5, %%eax) |
3344 | 867 |
9413 | 868 :: "r" (&c->redDither), |
869 "m" (dummy), "m" (dummy), "m" (dummy), | |
870 "r" (dest), "m" (dstW) | |
871 : "%eax", "%ebx", "%edx", "%esi" //FIXME ebx | |
3344 | 872 ); |
873 } | |
6578 | 874 break; |
875 case IMGFMT_BGR15: | |
3344 | 876 { |
877 asm volatile( | |
878 YSCALEYUV2RGBX | |
879 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ | |
880 #ifdef DITHER1XBPP | |
4248 | 881 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
882 "paddusb "MANGLE(g5Dither)", %%mm4\n\t" | |
883 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
3344 | 884 #endif |
885 | |
9414 | 886 WRITEBGR15(%4, %5, %%eax) |
3344 | 887 |
9413 | 888 :: "r" (&c->redDither), |
889 "m" (dummy), "m" (dummy), "m" (dummy), | |
890 "r" (dest), "m" (dstW) | |
891 : "%eax", "%edx", "%esi" | |
3344 | 892 ); |
893 } | |
6578 | 894 break; |
895 case IMGFMT_BGR16: | |
3344 | 896 { |
897 asm volatile( | |
898 YSCALEYUV2RGBX | |
899 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ | |
900 #ifdef DITHER1XBPP | |
4248 | 901 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
902 "paddusb "MANGLE(g6Dither)", %%mm4\n\t" | |
903 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
3344 | 904 #endif |
905 | |
9414 | 906 WRITEBGR16(%4, %5, %%eax) |
3344 | 907 |
9413 | 908 :: "r" (&c->redDither), |
909 "m" (dummy), "m" (dummy), "m" (dummy), | |
910 "r" (dest), "m" (dstW) | |
911 : "%eax", "%edx", "%esi" | |
3344 | 912 ); |
913 } | |
6578 | 914 break; |
7723 | 915 case IMGFMT_YUY2: |
916 { | |
917 asm volatile( | |
918 YSCALEYUV2PACKEDX | |
919 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ | |
920 | |
921 "psraw $3, %%mm3 \n\t" | |
922 "psraw $3, %%mm4 \n\t" | |
923 "psraw $3, %%mm1 \n\t" | |
924 "psraw $3, %%mm7 \n\t" | |
9414 | 925 WRITEYUY2(%4, %5, %%eax) |
7723 | 926 |
9413 | 927 :: "r" (&c->redDither), |
928 "m" (dummy), "m" (dummy), "m" (dummy), | |
929 "r" (dest), "m" (dstW) | |
930 : "%eax", "%edx", "%esi" | |
7723 | 931 ); |
932 } | |
933 break; | |
3344 | 934 #endif |
6578 | 935 default: |
7723 | 936 yuv2packedXinC(c, lumFilter, lumSrc, lumFilterSize, |
6578 | 937 chrFilter, chrSrc, chrFilterSize, |
938 dest, dstW, dstY); | |
939 break; | |
940 } | |
3344 | 941 } |
942 | |
943 /** | |
944 * vertical bilinear scale YV12 to RGB | |
945 */ | |
7723 | 946 static inline void RENAME(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, uint16_t *uvbuf1, |
6578 | 947 uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
948 { |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
949 int yalpha1=yalpha^4095; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
950 int uvalpha1=uvalpha^4095; |
6578 | 951 int i; |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
952 |
6578 | 953 #if 0 //isnt used |
4467 | 954 if(flags&SWS_FULL_CHR_H_INT) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
955 { |
6578 | 956 switch(dstFormat) |
957 { | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
958 #ifdef HAVE_MMX |
6578 | 959 case IMGFMT_BGR32: |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
960 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
961 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
962 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
963 FULL_YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
964 "punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
965 "punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
966 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
967 "movq %%mm3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
968 "punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
969 "punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
970 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
971 MOVNTQ(%%mm3, (%4, %%eax, 4)) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
972 MOVNTQ(%%mm1, 8(%4, %%eax, 4)) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
973 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
974 "addl $4, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
975 "cmpl %5, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
976 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
977 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
978 |
3209 | 979 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
980 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
981 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
982 ); |
6578 | 983 break; |
984 case IMGFMT_BGR24: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
985 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
986 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
987 FULL_YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
988 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
989 // lsb ... msb |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
990 "punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
991 "punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
992 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
993 "movq %%mm3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
994 "punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
995 "punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
996 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
997 "movq %%mm3, %%mm2 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
998 "psrlq $8, %%mm3 \n\t" // GR0BGR00 |
4248 | 999 "pand "MANGLE(bm00000111)", %%mm2\n\t" // BGR00000 |
1000 "pand "MANGLE(bm11111000)", %%mm3\n\t" // 000BGR00 | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1001 "por %%mm2, %%mm3 \n\t" // BGRBGR00 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1002 "movq %%mm1, %%mm2 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1003 "psllq $48, %%mm1 \n\t" // 000000BG |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1004 "por %%mm1, %%mm3 \n\t" // BGRBGRBG |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1005 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1006 "movq %%mm2, %%mm1 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1007 "psrld $16, %%mm2 \n\t" // R000R000 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1008 "psrlq $24, %%mm1 \n\t" // 0BGR0000 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1009 "por %%mm2, %%mm1 \n\t" // RBGRR000 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1010 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1011 "movl %4, %%ebx \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1012 "addl %%eax, %%ebx \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1013 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1014 #ifdef HAVE_MMX2 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1015 //FIXME Alignment |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1016 "movntq %%mm3, (%%ebx, %%eax, 2)\n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1017 "movntq %%mm1, 8(%%ebx, %%eax, 2)\n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1018 #else |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1019 "movd %%mm3, (%%ebx, %%eax, 2) \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1020 "psrlq $32, %%mm3 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1021 "movd %%mm3, 4(%%ebx, %%eax, 2) \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1022 "movd %%mm1, 8(%%ebx, %%eax, 2) \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1023 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1024 "addl $4, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1025 "cmpl %5, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1026 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1027 |
3209 | 1028 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), "m" (dstW), |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1029 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1030 : "%eax", "%ebx" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1031 ); |
6578 | 1032 break; |
1033 case IMGFMT_BGR15: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1034 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1035 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1036 FULL_YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1037 #ifdef DITHER1XBPP |
4248 | 1038 "paddusb "MANGLE(g5Dither)", %%mm1\n\t" |
1039 "paddusb "MANGLE(r5Dither)", %%mm0\n\t" | |
1040 "paddusb "MANGLE(b5Dither)", %%mm3\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1041 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1042 "punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1043 "punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1044 "punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1045 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1046 "psrlw $3, %%mm3 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1047 "psllw $2, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1048 "psllw $7, %%mm0 \n\t" |
4248 | 1049 "pand "MANGLE(g15Mask)", %%mm1 \n\t" |
1050 "pand "MANGLE(r15Mask)", %%mm0 \n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1051 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1052 "por %%mm3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1053 "por %%mm1, %%mm0 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1054 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1055 MOVNTQ(%%mm0, (%4, %%eax, 2)) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1056 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1057 "addl $4, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1058 "cmpl %5, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1059 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1060 |
3209 | 1061 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1062 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1063 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1064 ); |
6578 | 1065 break; |
1066 case IMGFMT_BGR16: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1067 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1068 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1069 FULL_YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1070 #ifdef DITHER1XBPP |
4248 | 1071 "paddusb "MANGLE(g6Dither)", %%mm1\n\t" |
1072 "paddusb "MANGLE(r5Dither)", %%mm0\n\t" | |
1073 "paddusb "MANGLE(b5Dither)", %%mm3\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1074 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1075 "punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1076 "punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1077 "punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1078 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1079 "psrlw $3, %%mm3 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1080 "psllw $3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1081 "psllw $8, %%mm0 \n\t" |
4248 | 1082 "pand "MANGLE(g16Mask)", %%mm1 \n\t" |
1083 "pand "MANGLE(r16Mask)", %%mm0 \n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1084 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1085 "por %%mm3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1086 "por %%mm1, %%mm0 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1087 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1088 MOVNTQ(%%mm0, (%4, %%eax, 2)) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1089 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1090 "addl $4, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1091 "cmpl %5, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1092 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1093 |
3209 | 1094 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1095 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1096 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1097 ); |
6578 | 1098 break; |
1099 #endif | |
1100 case IMGFMT_RGB32: | |
1101 #ifndef HAVE_MMX | |
1102 case IMGFMT_BGR32: | |
1103 #endif | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1104 if(dstFormat==IMGFMT_BGR32) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1105 { |
4794 | 1106 int i; |
4793 | 1107 #ifdef WORDS_BIGENDIAN |
1108 dest++; | |
1109 #endif | |
3209 | 1110 for(i=0;i<dstW;i++){ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1111 // vertical linear interpolation && yuv2rgb in a single step: |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1112 int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1113 int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1114 int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19); |
2503 | 1115 dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)]; |
1116 dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)]; | |
1117 dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)]; | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1118 dest+= 4; |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1119 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1120 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1121 else if(dstFormat==IMGFMT_BGR24) |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1122 { |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1123 int i; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1124 for(i=0;i<dstW;i++){ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1125 // vertical linear interpolation && yuv2rgb in a single step: |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1126 int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1127 int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19); |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1128 int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19); |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1129 dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)]; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1130 dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)]; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1131 dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)]; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1132 dest+= 3; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1133 } |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1134 } |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1135 else if(dstFormat==IMGFMT_BGR16) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1136 { |
2671 | 1137 int i; |
3209 | 1138 for(i=0;i<dstW;i++){ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1139 // vertical linear interpolation && yuv2rgb in a single step: |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1140 int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1141 int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1142 int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1143 |
2572
f2353173d52c
c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents:
2569
diff
changeset
|
1144 ((uint16_t*)dest)[i] = |
2584 | 1145 clip_table16b[(Y + yuvtab_40cf[U]) >>13] | |
1146 clip_table16g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] | | |
1147 clip_table16r[(Y + yuvtab_3343[V]) >>13]; | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1148 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1149 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1150 else if(dstFormat==IMGFMT_BGR15) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1151 { |
2671 | 1152 int i; |
3209 | 1153 for(i=0;i<dstW;i++){ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1154 // vertical linear interpolation && yuv2rgb in a single step: |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1155 int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1156 int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1157 int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1158 |
2572
f2353173d52c
c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents:
2569
diff
changeset
|
1159 ((uint16_t*)dest)[i] = |
2584 | 1160 clip_table15b[(Y + yuvtab_40cf[U]) >>13] | |
1161 clip_table15g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] | | |
1162 clip_table15r[(Y + yuvtab_3343[V]) >>13]; | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1163 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1164 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1165 }//FULL_UV_IPOL |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1166 else |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1167 { |
6578 | 1168 #endif // if 0 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1169 #ifdef HAVE_MMX |
6578 | 1170 switch(c->dstFormat) |
1171 { | |
9414 | 1172 //Note 8280 == DSTW_OFFSET but the preprocessor cant handle that there :( |
6578 | 1173 case IMGFMT_BGR32: |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1174 asm volatile( |
9414 | 1175 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1176 "movl %4, %%esp \n\t" | |
1177 YSCALEYUV2RGB(%%eax, %5) | |
1178 WRITEBGR32(%%esp, 8280(%5), %%eax) | |
1179 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1180 |
9414 | 1181 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), |
1182 "r" (&c->redDither) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1183 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1184 ); |
6578 | 1185 return; |
1186 case IMGFMT_BGR24: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1187 asm volatile( |
9414 | 1188 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1189 "movl %4, %%esp \n\t" | |
1190 YSCALEYUV2RGB(%%eax, %5) | |
1191 WRITEBGR24(%%esp, 8280(%5), %%eax) | |
1192 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1193 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1194 "r" (&c->redDither) | |
1195 : "%eax" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1196 ); |
6578 | 1197 return; |
1198 case IMGFMT_BGR15: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1199 asm volatile( |
9414 | 1200 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1201 "movl %4, %%esp \n\t" | |
1202 YSCALEYUV2RGB(%%eax, %5) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1203 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1204 #ifdef DITHER1XBPP |
4248 | 1205 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1206 "paddusb "MANGLE(g5Dither)", %%mm4\n\t" | |
1207 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1208 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1209 |
9414 | 1210 WRITEBGR15(%%esp, 8280(%5), %%eax) |
1211 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1212 |
9414 | 1213 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), |
1214 "r" (&c->redDither) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1215 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1216 ); |
6578 | 1217 return; |
1218 case IMGFMT_BGR16: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1219 asm volatile( |
9414 | 1220 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1221 "movl %4, %%esp \n\t" | |
1222 YSCALEYUV2RGB(%%eax, %5) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1223 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1224 #ifdef DITHER1XBPP |
4248 | 1225 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1226 "paddusb "MANGLE(g6Dither)", %%mm4\n\t" | |
1227 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1228 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1229 |
9414 | 1230 WRITEBGR16(%%esp, 8280(%5), %%eax) |
1231 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1232 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1233 "r" (&c->redDither) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1234 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1235 ); |
6578 | 1236 return; |
7723 | 1237 case IMGFMT_YUY2: |
1238 asm volatile( | |
9414 | 1239 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1240 "movl %4, %%esp \n\t" | |
1241 YSCALEYUV2PACKED(%%eax, %5) | |
1242 WRITEYUY2(%%esp, 8280(%5), %%eax) | |
1243 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1244 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1245 "r" (&c->redDither) | |
7723 | 1246 : "%eax" |
1247 ); | |
1248 return; | |
6578 | 1249 default: break; |
1250 } | |
1251 #endif //HAVE_MMX | |
7723 | 1252 YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1253 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1254 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1255 /** |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1256 * YV12 to RGB without scaling or interpolating |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1257 */ |
7723 | 1258 static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *uvbuf0, uint16_t *uvbuf1, |
6578 | 1259 uint8_t *dest, int dstW, int uvalpha, int dstFormat, int flags, int y) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1260 { |
3344 | 1261 const int yalpha1=0; |
6578 | 1262 int i; |
1263 | |
1264 uint16_t *buf1= buf0; //FIXME needed for the rgb1/bgr1 | |
1265 const int yalpha= 4096; //FIXME ... | |
2671 | 1266 |
4467 | 1267 if(flags&SWS_FULL_CHR_H_INT) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1268 { |
7723 | 1269 RENAME(yuv2packed2)(c, buf0, buf0, uvbuf0, uvbuf1, dest, dstW, 0, uvalpha, y); |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1270 return; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1271 } |
2576 | 1272 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1273 #ifdef HAVE_MMX |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1274 if( uvalpha < 2048 ) // note this is not correct (shifts chrominance by 0.5 pixels) but its a bit faster |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1275 { |
6578 | 1276 switch(dstFormat) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1277 { |
6578 | 1278 case IMGFMT_BGR32: |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1279 asm volatile( |
9417 | 1280 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1281 "movl %4, %%esp \n\t" | |
1282 YSCALEYUV2RGB1(%%eax, %5) | |
1283 WRITEBGR32(%%esp, 8280(%5), %%eax) | |
1284 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1285 | |
1286 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1287 "r" (&c->redDither) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1288 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1289 ); |
6578 | 1290 return; |
1291 case IMGFMT_BGR24: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1292 asm volatile( |
9417 | 1293 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1294 "movl %4, %%esp \n\t" | |
1295 YSCALEYUV2RGB1(%%eax, %5) | |
1296 WRITEBGR24(%%esp, 8280(%5), %%eax) | |
1297 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1298 | |
1299 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1300 "r" (&c->redDither) | |
1301 : "%eax" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1302 ); |
6578 | 1303 return; |
1304 case IMGFMT_BGR15: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1305 asm volatile( |
9417 | 1306 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1307 "movl %4, %%esp \n\t" | |
1308 YSCALEYUV2RGB1(%%eax, %5) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1309 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1310 #ifdef DITHER1XBPP |
4248 | 1311 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1312 "paddusb "MANGLE(g5Dither)", %%mm4\n\t" | |
1313 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1314 #endif |
9417 | 1315 WRITEBGR15(%%esp, 8280(%5), %%eax) |
1316 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1317 | |
1318 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1319 "r" (&c->redDither) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1320 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1321 ); |
6578 | 1322 return; |
1323 case IMGFMT_BGR16: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1324 asm volatile( |
9417 | 1325 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1326 "movl %4, %%esp \n\t" | |
1327 YSCALEYUV2RGB1(%%eax, %5) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1328 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1329 #ifdef DITHER1XBPP |
4248 | 1330 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1331 "paddusb "MANGLE(g6Dither)", %%mm4\n\t" | |
1332 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1333 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1334 |
9417 | 1335 WRITEBGR16(%%esp, 8280(%5), %%eax) |
1336 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1337 | |
1338 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1339 "r" (&c->redDither) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1340 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1341 ); |
6578 | 1342 return; |
7723 | 1343 case IMGFMT_YUY2: |
1344 asm volatile( | |
9417 | 1345 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1346 "movl %4, %%esp \n\t" | |
1347 YSCALEYUV2PACKED1(%%eax, %5) | |
1348 WRITEYUY2(%%esp, 8280(%5), %%eax) | |
1349 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1350 | |
1351 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1352 "r" (&c->redDither) | |
7723 | 1353 : "%eax" |
1354 ); | |
1355 return; | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1356 } |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1357 } |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1358 else |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1359 { |
6578 | 1360 switch(dstFormat) |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1361 { |
6578 | 1362 case IMGFMT_BGR32: |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1363 asm volatile( |
9417 | 1364 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1365 "movl %4, %%esp \n\t" | |
1366 YSCALEYUV2RGB1b(%%eax, %5) | |
1367 WRITEBGR32(%%esp, 8280(%5), %%eax) | |
1368 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1369 | |
1370 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1371 "r" (&c->redDither) | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1372 : "%eax" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1373 ); |
6578 | 1374 return; |
1375 case IMGFMT_BGR24: | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1376 asm volatile( |
9417 | 1377 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1378 "movl %4, %%esp \n\t" | |
1379 YSCALEYUV2RGB1b(%%eax, %5) | |
1380 WRITEBGR24(%%esp, 8280(%5), %%eax) | |
1381 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1382 | |
1383 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1384 "r" (&c->redDither) | |
1385 : "%eax" | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1386 ); |
6578 | 1387 return; |
1388 case IMGFMT_BGR15: | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1389 asm volatile( |
9417 | 1390 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1391 "movl %4, %%esp \n\t" | |
1392 YSCALEYUV2RGB1b(%%eax, %5) | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1393 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1394 #ifdef DITHER1XBPP |
4248 | 1395 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1396 "paddusb "MANGLE(g5Dither)", %%mm4\n\t" | |
1397 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1398 #endif |
9417 | 1399 WRITEBGR15(%%esp, 8280(%5), %%eax) |
1400 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1401 | |
1402 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1403 "r" (&c->redDither) | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1404 : "%eax" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1405 ); |
6578 | 1406 return; |
1407 case IMGFMT_BGR16: | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1408 asm volatile( |
9417 | 1409 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1410 "movl %4, %%esp \n\t" | |
1411 YSCALEYUV2RGB1b(%%eax, %5) | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1412 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1413 #ifdef DITHER1XBPP |
4248 | 1414 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1415 "paddusb "MANGLE(g6Dither)", %%mm4\n\t" | |
1416 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1417 #endif |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1418 |
9417 | 1419 WRITEBGR16(%%esp, 8280(%5), %%eax) |
1420 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1421 | |
1422 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1423 "r" (&c->redDither) | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1424 : "%eax" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1425 ); |
6578 | 1426 return; |
7723 | 1427 case IMGFMT_YUY2: |
1428 asm volatile( | |
9417 | 1429 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1430 "movl %4, %%esp \n\t" | |
1431 YSCALEYUV2PACKED1b(%%eax, %5) | |
1432 WRITEYUY2(%%esp, 8280(%5), %%eax) | |
1433 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1434 | |
1435 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1436 "r" (&c->redDither) | |
7723 | 1437 : "%eax" |
1438 ); | |
1439 return; | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1440 } |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1441 } |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1442 #endif |
6578 | 1443 if( uvalpha < 2048 ) |
1444 { | |
7723 | 1445 YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C, YSCALE_YUV_2_PACKED1_C) |
6578 | 1446 }else{ |
7723 | 1447 YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C, YSCALE_YUV_2_PACKED1B_C) |
6578 | 1448 } |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1449 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1450 |
4481 | 1451 //FIXME yuy2* can read upto 7 samples to much |
1452 | |
4467 | 1453 static inline void RENAME(yuy2ToY)(uint8_t *dst, uint8_t *src, int width) |
1454 { | |
4481 | 1455 #ifdef HAVE_MMX |
1456 asm volatile( | |
1457 "movq "MANGLE(bm01010101)", %%mm2\n\t" | |
1458 "movl %0, %%eax \n\t" | |
1459 "1: \n\t" | |
1460 "movq (%1, %%eax,2), %%mm0 \n\t" | |
1461 "movq 8(%1, %%eax,2), %%mm1 \n\t" | |
1462 "pand %%mm2, %%mm0 \n\t" | |
1463 "pand %%mm2, %%mm1 \n\t" | |
1464 "packuswb %%mm1, %%mm0 \n\t" | |
1465 "movq %%mm0, (%2, %%eax) \n\t" | |
1466 "addl $8, %%eax \n\t" | |
1467 " js 1b \n\t" | |
1468 : : "g" (-width), "r" (src+width*2), "r" (dst+width) | |
1469 : "%eax" | |
1470 ); | |
4467 | 1471 #else |
1472 int i; | |
1473 for(i=0; i<width; i++) | |
1474 dst[i]= src[2*i]; | |
1475 #endif | |
1476 } | |
1477 | |
1478 static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1479 { | |
4481 | 1480 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
1481 asm volatile( | |
1482 "movq "MANGLE(bm01010101)", %%mm4\n\t" | |
1483 "movl %0, %%eax \n\t" | |
1484 "1: \n\t" | |
1485 "movq (%1, %%eax,4), %%mm0 \n\t" | |
1486 "movq 8(%1, %%eax,4), %%mm1 \n\t" | |
1487 "movq (%2, %%eax,4), %%mm2 \n\t" | |
1488 "movq 8(%2, %%eax,4), %%mm3 \n\t" | |
1489 PAVGB(%%mm2, %%mm0) | |
1490 PAVGB(%%mm3, %%mm1) | |
1491 "psrlw $8, %%mm0 \n\t" | |
1492 "psrlw $8, %%mm1 \n\t" | |
1493 "packuswb %%mm1, %%mm0 \n\t" | |
1494 "movq %%mm0, %%mm1 \n\t" | |
1495 "psrlw $8, %%mm0 \n\t" | |
1496 "pand %%mm4, %%mm1 \n\t" | |
1497 "packuswb %%mm0, %%mm0 \n\t" | |
1498 "packuswb %%mm1, %%mm1 \n\t" | |
1499 "movd %%mm0, (%4, %%eax) \n\t" | |
1500 "movd %%mm1, (%3, %%eax) \n\t" | |
1501 "addl $4, %%eax \n\t" | |
1502 " js 1b \n\t" | |
1503 : : "g" (-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width) | |
1504 : "%eax" | |
1505 ); | |
4467 | 1506 #else |
1507 int i; | |
1508 for(i=0; i<width; i++) | |
1509 { | |
1510 dstU[i]= (src1[4*i + 1] + src2[4*i + 1])>>1; | |
1511 dstV[i]= (src1[4*i + 3] + src2[4*i + 3])>>1; | |
1512 } | |
1513 #endif | |
1514 } | |
1515 | |
9071 | 1516 //this is allmost identical to the previous, end exists only cuz yuy2ToY/UV)(dst, src+1, ...) would have 100% unaligned accesses |
1517 static inline void RENAME(uyvyToY)(uint8_t *dst, uint8_t *src, int width) | |
1518 { | |
1519 #ifdef HAVE_MMX | |
1520 asm volatile( | |
1521 "movl %0, %%eax \n\t" | |
1522 "1: \n\t" | |
1523 "movq (%1, %%eax,2), %%mm0 \n\t" | |
1524 "movq 8(%1, %%eax,2), %%mm1 \n\t" | |
1525 "psrlw $8, %%mm0 \n\t" | |
1526 "psrlw $8, %%mm1 \n\t" | |
1527 "packuswb %%mm1, %%mm0 \n\t" | |
1528 "movq %%mm0, (%2, %%eax) \n\t" | |
1529 "addl $8, %%eax \n\t" | |
1530 " js 1b \n\t" | |
1531 : : "g" (-width), "r" (src+width*2), "r" (dst+width) | |
1532 : "%eax" | |
1533 ); | |
1534 #else | |
1535 int i; | |
1536 for(i=0; i<width; i++) | |
1537 dst[i]= src[2*i+1]; | |
1538 #endif | |
1539 } | |
1540 | |
1541 static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1542 { | |
1543 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | |
1544 asm volatile( | |
1545 "movq "MANGLE(bm01010101)", %%mm4\n\t" | |
1546 "movl %0, %%eax \n\t" | |
1547 "1: \n\t" | |
1548 "movq (%1, %%eax,4), %%mm0 \n\t" | |
1549 "movq 8(%1, %%eax,4), %%mm1 \n\t" | |
1550 "movq (%2, %%eax,4), %%mm2 \n\t" | |
1551 "movq 8(%2, %%eax,4), %%mm3 \n\t" | |
1552 PAVGB(%%mm2, %%mm0) | |
1553 PAVGB(%%mm3, %%mm1) | |
1554 "pand %%mm4, %%mm0 \n\t" | |
1555 "pand %%mm4, %%mm1 \n\t" | |
1556 "packuswb %%mm1, %%mm0 \n\t" | |
1557 "movq %%mm0, %%mm1 \n\t" | |
1558 "psrlw $8, %%mm0 \n\t" | |
1559 "pand %%mm4, %%mm1 \n\t" | |
1560 "packuswb %%mm0, %%mm0 \n\t" | |
1561 "packuswb %%mm1, %%mm1 \n\t" | |
1562 "movd %%mm0, (%4, %%eax) \n\t" | |
1563 "movd %%mm1, (%3, %%eax) \n\t" | |
1564 "addl $4, %%eax \n\t" | |
1565 " js 1b \n\t" | |
1566 : : "g" (-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width) | |
1567 : "%eax" | |
1568 ); | |
1569 #else | |
1570 int i; | |
1571 for(i=0; i<width; i++) | |
1572 { | |
1573 dstU[i]= (src1[4*i + 0] + src2[4*i + 0])>>1; | |
1574 dstV[i]= (src1[4*i + 2] + src2[4*i + 2])>>1; | |
1575 } | |
1576 #endif | |
1577 } | |
1578 | |
4467 | 1579 static inline void RENAME(bgr32ToY)(uint8_t *dst, uint8_t *src, int width) |
1580 { | |
1581 #ifdef HAVE_MMXFIXME | |
1582 #else | |
1583 int i; | |
1584 for(i=0; i<width; i++) | |
1585 { | |
9433 | 1586 int b= ((uint32_t*)src)[i]&0xFF; |
1587 int g= (((uint32_t*)src)[i]>>8)&0xFF; | |
9499 | 1588 int r= (((uint32_t*)src)[i]>>16)&0xFF; |
4467 | 1589 |
9433 | 1590 dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); |
4467 | 1591 } |
1592 #endif | |
1593 } | |
1594 | |
1595 static inline void RENAME(bgr32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1596 { | |
1597 #ifdef HAVE_MMXFIXME | |
1598 #else | |
1599 int i; | |
1600 for(i=0; i<width; i++) | |
1601 { | |
9433 | 1602 const int a= ((uint32_t*)src1)[2*i+0]; |
1603 const int e= ((uint32_t*)src1)[2*i+1]; | |
1604 const int c= ((uint32_t*)src2)[2*i+0]; | |
1605 const int d= ((uint32_t*)src2)[2*i+1]; | |
1606 const int l= (a&0xFF00FF) + (e&0xFF00FF) + (c&0xFF00FF) + (d&0xFF00FF); | |
1607 const int h= (a&0x00FF00) + (e&0x00FF00) + (c&0x00FF00) + (d&0x00FF00); | |
1608 const int b= l&0x3FF; | |
1609 const int g= h>>8; | |
1610 const int r= l>>16; | |
4467 | 1611 |
1612 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1613 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1614 } | |
1615 #endif | |
1616 } | |
1617 | |
1618 static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, int width) | |
1619 { | |
4612 | 1620 #ifdef HAVE_MMX |
1621 asm volatile( | |
1622 "movl %2, %%eax \n\t" | |
4923 | 1623 "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t" |
1624 "movq "MANGLE(w1111)", %%mm5 \n\t" | |
4612 | 1625 "pxor %%mm7, %%mm7 \n\t" |
1626 "leal (%%eax, %%eax, 2), %%ebx \n\t" | |
1627 ".balign 16 \n\t" | |
1628 "1: \n\t" | |
1629 PREFETCH" 64(%0, %%ebx) \n\t" | |
1630 "movd (%0, %%ebx), %%mm0 \n\t" | |
1631 "movd 3(%0, %%ebx), %%mm1 \n\t" | |
1632 "punpcklbw %%mm7, %%mm0 \n\t" | |
1633 "punpcklbw %%mm7, %%mm1 \n\t" | |
1634 "movd 6(%0, %%ebx), %%mm2 \n\t" | |
1635 "movd 9(%0, %%ebx), %%mm3 \n\t" | |
1636 "punpcklbw %%mm7, %%mm2 \n\t" | |
1637 "punpcklbw %%mm7, %%mm3 \n\t" | |
1638 "pmaddwd %%mm6, %%mm0 \n\t" | |
1639 "pmaddwd %%mm6, %%mm1 \n\t" | |
1640 "pmaddwd %%mm6, %%mm2 \n\t" | |
1641 "pmaddwd %%mm6, %%mm3 \n\t" | |
1642 #ifndef FAST_BGR2YV12 | |
1643 "psrad $8, %%mm0 \n\t" | |
1644 "psrad $8, %%mm1 \n\t" | |
1645 "psrad $8, %%mm2 \n\t" | |
1646 "psrad $8, %%mm3 \n\t" | |
1647 #endif | |
1648 "packssdw %%mm1, %%mm0 \n\t" | |
1649 "packssdw %%mm3, %%mm2 \n\t" | |
1650 "pmaddwd %%mm5, %%mm0 \n\t" | |
1651 "pmaddwd %%mm5, %%mm2 \n\t" | |
1652 "packssdw %%mm2, %%mm0 \n\t" | |
1653 "psraw $7, %%mm0 \n\t" | |
1654 | |
1655 "movd 12(%0, %%ebx), %%mm4 \n\t" | |
1656 "movd 15(%0, %%ebx), %%mm1 \n\t" | |
1657 "punpcklbw %%mm7, %%mm4 \n\t" | |
1658 "punpcklbw %%mm7, %%mm1 \n\t" | |
1659 "movd 18(%0, %%ebx), %%mm2 \n\t" | |
1660 "movd 21(%0, %%ebx), %%mm3 \n\t" | |
1661 "punpcklbw %%mm7, %%mm2 \n\t" | |
1662 "punpcklbw %%mm7, %%mm3 \n\t" | |
1663 "pmaddwd %%mm6, %%mm4 \n\t" | |
1664 "pmaddwd %%mm6, %%mm1 \n\t" | |
1665 "pmaddwd %%mm6, %%mm2 \n\t" | |
1666 "pmaddwd %%mm6, %%mm3 \n\t" | |
1667 #ifndef FAST_BGR2YV12 | |
1668 "psrad $8, %%mm4 \n\t" | |
1669 "psrad $8, %%mm1 \n\t" | |
1670 "psrad $8, %%mm2 \n\t" | |
1671 "psrad $8, %%mm3 \n\t" | |
1672 #endif | |
1673 "packssdw %%mm1, %%mm4 \n\t" | |
1674 "packssdw %%mm3, %%mm2 \n\t" | |
1675 "pmaddwd %%mm5, %%mm4 \n\t" | |
1676 "pmaddwd %%mm5, %%mm2 \n\t" | |
1677 "addl $24, %%ebx \n\t" | |
1678 "packssdw %%mm2, %%mm4 \n\t" | |
1679 "psraw $7, %%mm4 \n\t" | |
1680 | |
1681 "packuswb %%mm4, %%mm0 \n\t" | |
4923 | 1682 "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t" |
4612 | 1683 |
4619 | 1684 "movq %%mm0, (%1, %%eax) \n\t" |
4612 | 1685 "addl $8, %%eax \n\t" |
1686 " js 1b \n\t" | |
1687 : : "r" (src+width*3), "r" (dst+width), "g" (-width) | |
1688 : "%eax", "%ebx" | |
1689 ); | |
4467 | 1690 #else |
1691 int i; | |
1692 for(i=0; i<width; i++) | |
1693 { | |
1694 int b= src[i*3+0]; | |
1695 int g= src[i*3+1]; | |
1696 int r= src[i*3+2]; | |
1697 | |
9434 | 1698 dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); |
4467 | 1699 } |
1700 #endif | |
1701 } | |
1702 | |
1703 static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1704 { | |
4619 | 1705 #ifdef HAVE_MMX |
1706 asm volatile( | |
1707 "movl %4, %%eax \n\t" | |
4923 | 1708 "movq "MANGLE(w1111)", %%mm5 \n\t" |
1709 "movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t" | |
4619 | 1710 "pxor %%mm7, %%mm7 \n\t" |
1711 "leal (%%eax, %%eax, 2), %%ebx \n\t" | |
1712 "addl %%ebx, %%ebx \n\t" | |
1713 ".balign 16 \n\t" | |
1714 "1: \n\t" | |
1715 PREFETCH" 64(%0, %%ebx) \n\t" | |
1716 PREFETCH" 64(%1, %%ebx) \n\t" | |
1717 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | |
1718 "movq (%0, %%ebx), %%mm0 \n\t" | |
1719 "movq (%1, %%ebx), %%mm1 \n\t" | |
1720 "movq 6(%0, %%ebx), %%mm2 \n\t" | |
1721 "movq 6(%1, %%ebx), %%mm3 \n\t" | |
1722 PAVGB(%%mm1, %%mm0) | |
1723 PAVGB(%%mm3, %%mm2) | |
1724 "movq %%mm0, %%mm1 \n\t" | |
1725 "movq %%mm2, %%mm3 \n\t" | |
1726 "psrlq $24, %%mm0 \n\t" | |
1727 "psrlq $24, %%mm2 \n\t" | |
1728 PAVGB(%%mm1, %%mm0) | |
1729 PAVGB(%%mm3, %%mm2) | |
1730 "punpcklbw %%mm7, %%mm0 \n\t" | |
1731 "punpcklbw %%mm7, %%mm2 \n\t" | |
1732 #else | |
1733 "movd (%0, %%ebx), %%mm0 \n\t" | |
1734 "movd (%1, %%ebx), %%mm1 \n\t" | |
1735 "movd 3(%0, %%ebx), %%mm2 \n\t" | |
1736 "movd 3(%1, %%ebx), %%mm3 \n\t" | |
1737 "punpcklbw %%mm7, %%mm0 \n\t" | |
1738 "punpcklbw %%mm7, %%mm1 \n\t" | |
1739 "punpcklbw %%mm7, %%mm2 \n\t" | |
1740 "punpcklbw %%mm7, %%mm3 \n\t" | |
1741 "paddw %%mm1, %%mm0 \n\t" | |
1742 "paddw %%mm3, %%mm2 \n\t" | |
1743 "paddw %%mm2, %%mm0 \n\t" | |
1744 "movd 6(%0, %%ebx), %%mm4 \n\t" | |
1745 "movd 6(%1, %%ebx), %%mm1 \n\t" | |
1746 "movd 9(%0, %%ebx), %%mm2 \n\t" | |
1747 "movd 9(%1, %%ebx), %%mm3 \n\t" | |
1748 "punpcklbw %%mm7, %%mm4 \n\t" | |
1749 "punpcklbw %%mm7, %%mm1 \n\t" | |
1750 "punpcklbw %%mm7, %%mm2 \n\t" | |
1751 "punpcklbw %%mm7, %%mm3 \n\t" | |
1752 "paddw %%mm1, %%mm4 \n\t" | |
1753 "paddw %%mm3, %%mm2 \n\t" | |
1754 "paddw %%mm4, %%mm2 \n\t" | |
1755 "psrlw $2, %%mm0 \n\t" | |
1756 "psrlw $2, %%mm2 \n\t" | |
1757 #endif | |
4923 | 1758 "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" |
1759 "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" | |
4619 | 1760 |
1761 "pmaddwd %%mm0, %%mm1 \n\t" | |
1762 "pmaddwd %%mm2, %%mm3 \n\t" | |
1763 "pmaddwd %%mm6, %%mm0 \n\t" | |
1764 "pmaddwd %%mm6, %%mm2 \n\t" | |
1765 #ifndef FAST_BGR2YV12 | |
1766 "psrad $8, %%mm0 \n\t" | |
1767 "psrad $8, %%mm1 \n\t" | |
1768 "psrad $8, %%mm2 \n\t" | |
1769 "psrad $8, %%mm3 \n\t" | |
1770 #endif | |
1771 "packssdw %%mm2, %%mm0 \n\t" | |
1772 "packssdw %%mm3, %%mm1 \n\t" | |
1773 "pmaddwd %%mm5, %%mm0 \n\t" | |
1774 "pmaddwd %%mm5, %%mm1 \n\t" | |
1775 "packssdw %%mm1, %%mm0 \n\t" // V1 V0 U1 U0 | |
1776 "psraw $7, %%mm0 \n\t" | |
1777 | |
1778 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | |
1779 "movq 12(%0, %%ebx), %%mm4 \n\t" | |
1780 "movq 12(%1, %%ebx), %%mm1 \n\t" | |
1781 "movq 18(%0, %%ebx), %%mm2 \n\t" | |
1782 "movq 18(%1, %%ebx), %%mm3 \n\t" | |
1783 PAVGB(%%mm1, %%mm4) | |
1784 PAVGB(%%mm3, %%mm2) | |
1785 "movq %%mm4, %%mm1 \n\t" | |
1786 "movq %%mm2, %%mm3 \n\t" | |
1787 "psrlq $24, %%mm4 \n\t" | |
1788 "psrlq $24, %%mm2 \n\t" | |
1789 PAVGB(%%mm1, %%mm4) | |
1790 PAVGB(%%mm3, %%mm2) | |
1791 "punpcklbw %%mm7, %%mm4 \n\t" | |
1792 "punpcklbw %%mm7, %%mm2 \n\t" | |
1793 #else | |
1794 "movd 12(%0, %%ebx), %%mm4 \n\t" | |
1795 "movd 12(%1, %%ebx), %%mm1 \n\t" | |
1796 "movd 15(%0, %%ebx), %%mm2 \n\t" | |
1797 "movd 15(%1, %%ebx), %%mm3 \n\t" | |
1798 "punpcklbw %%mm7, %%mm4 \n\t" | |
1799 "punpcklbw %%mm7, %%mm1 \n\t" | |
1800 "punpcklbw %%mm7, %%mm2 \n\t" | |
1801 "punpcklbw %%mm7, %%mm3 \n\t" | |
1802 "paddw %%mm1, %%mm4 \n\t" | |
1803 "paddw %%mm3, %%mm2 \n\t" | |
1804 "paddw %%mm2, %%mm4 \n\t" | |
1805 "movd 18(%0, %%ebx), %%mm5 \n\t" | |
1806 "movd 18(%1, %%ebx), %%mm1 \n\t" | |
1807 "movd 21(%0, %%ebx), %%mm2 \n\t" | |
1808 "movd 21(%1, %%ebx), %%mm3 \n\t" | |
1809 "punpcklbw %%mm7, %%mm5 \n\t" | |
1810 "punpcklbw %%mm7, %%mm1 \n\t" | |
1811 "punpcklbw %%mm7, %%mm2 \n\t" | |
1812 "punpcklbw %%mm7, %%mm3 \n\t" | |
1813 "paddw %%mm1, %%mm5 \n\t" | |
1814 "paddw %%mm3, %%mm2 \n\t" | |
1815 "paddw %%mm5, %%mm2 \n\t" | |
4923 | 1816 "movq "MANGLE(w1111)", %%mm5 \n\t" |
4619 | 1817 "psrlw $2, %%mm4 \n\t" |
1818 "psrlw $2, %%mm2 \n\t" | |
1819 #endif | |
4923 | 1820 "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" |
1821 "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" | |
4619 | 1822 |
1823 "pmaddwd %%mm4, %%mm1 \n\t" | |
1824 "pmaddwd %%mm2, %%mm3 \n\t" | |
1825 "pmaddwd %%mm6, %%mm4 \n\t" | |
1826 "pmaddwd %%mm6, %%mm2 \n\t" | |
1827 #ifndef FAST_BGR2YV12 | |
1828 "psrad $8, %%mm4 \n\t" | |
1829 "psrad $8, %%mm1 \n\t" | |
1830 "psrad $8, %%mm2 \n\t" | |
1831 "psrad $8, %%mm3 \n\t" | |
1832 #endif | |
1833 "packssdw %%mm2, %%mm4 \n\t" | |
1834 "packssdw %%mm3, %%mm1 \n\t" | |
1835 "pmaddwd %%mm5, %%mm4 \n\t" | |
1836 "pmaddwd %%mm5, %%mm1 \n\t" | |
1837 "addl $24, %%ebx \n\t" | |
1838 "packssdw %%mm1, %%mm4 \n\t" // V3 V2 U3 U2 | |
1839 "psraw $7, %%mm4 \n\t" | |
1840 | |
1841 "movq %%mm0, %%mm1 \n\t" | |
1842 "punpckldq %%mm4, %%mm0 \n\t" | |
1843 "punpckhdq %%mm4, %%mm1 \n\t" | |
1844 "packsswb %%mm1, %%mm0 \n\t" | |
4923 | 1845 "paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t" |
4619 | 1846 |
1847 "movd %%mm0, (%2, %%eax) \n\t" | |
1848 "punpckhdq %%mm0, %%mm0 \n\t" | |
1849 "movd %%mm0, (%3, %%eax) \n\t" | |
1850 "addl $4, %%eax \n\t" | |
1851 " js 1b \n\t" | |
1852 : : "r" (src1+width*6), "r" (src2+width*6), "r" (dstU+width), "r" (dstV+width), "g" (-width) | |
1853 : "%eax", "%ebx" | |
1854 ); | |
4467 | 1855 #else |
1856 int i; | |
1857 for(i=0; i<width; i++) | |
1858 { | |
1859 int b= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3]; | |
1860 int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4]; | |
1861 int r= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5]; | |
1862 | |
1863 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1864 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1865 } | |
1866 #endif | |
1867 } | |
1868 | |
4578 | 1869 static inline void RENAME(bgr16ToY)(uint8_t *dst, uint8_t *src, int width) |
1870 { | |
1871 int i; | |
1872 for(i=0; i<width; i++) | |
1873 { | |
9433 | 1874 int d= ((uint16_t*)src)[i]; |
4578 | 1875 int b= d&0x1F; |
1876 int g= (d>>5)&0x3F; | |
1877 int r= (d>>11)&0x1F; | |
1878 | |
1879 dst[i]= ((2*RY*r + GY*g + 2*BY*b)>>(RGB2YUV_SHIFT-2)) + 16; | |
1880 } | |
1881 } | |
1882 | |
1883 static inline void RENAME(bgr16ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1884 { | |
1885 int i; | |
1886 for(i=0; i<width; i++) | |
1887 { | |
9433 | 1888 int d0= ((uint32_t*)src1)[i]; |
1889 int d1= ((uint32_t*)src2)[i]; | |
4579 | 1890 |
1891 int dl= (d0&0x07E0F81F) + (d1&0x07E0F81F); | |
1892 int dh= ((d0>>5)&0x07C0F83F) + ((d1>>5)&0x07C0F83F); | |
1893 | |
1894 int dh2= (dh>>11) + (dh<<21); | |
1895 int d= dh2 + dl; | |
1896 | |
1897 int b= d&0x7F; | |
1898 int r= (d>>11)&0x7F; | |
1899 int g= d>>21; | |
4578 | 1900 dstU[i]= ((2*RU*r + GU*g + 2*BU*b)>>(RGB2YUV_SHIFT+2-2)) + 128; |
1901 dstV[i]= ((2*RV*r + GV*g + 2*BV*b)>>(RGB2YUV_SHIFT+2-2)) + 128; | |
1902 } | |
1903 } | |
1904 | |
4580 | 1905 static inline void RENAME(bgr15ToY)(uint8_t *dst, uint8_t *src, int width) |
1906 { | |
1907 int i; | |
1908 for(i=0; i<width; i++) | |
1909 { | |
9433 | 1910 int d= ((uint16_t*)src)[i]; |
4580 | 1911 int b= d&0x1F; |
1912 int g= (d>>5)&0x1F; | |
1913 int r= (d>>10)&0x1F; | |
1914 | |
1915 dst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16; | |
1916 } | |
1917 } | |
1918 | |
1919 static inline void RENAME(bgr15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1920 { | |
1921 int i; | |
1922 for(i=0; i<width; i++) | |
1923 { | |
9433 | 1924 int d0= ((uint32_t*)src1)[i]; |
1925 int d1= ((uint32_t*)src2)[i]; | |
4580 | 1926 |
1927 int dl= (d0&0x03E07C1F) + (d1&0x03E07C1F); | |
1928 int dh= ((d0>>5)&0x03E0F81F) + ((d1>>5)&0x03E0F81F); | |
1929 | |
1930 int dh2= (dh>>11) + (dh<<21); | |
1931 int d= dh2 + dl; | |
1932 | |
1933 int b= d&0x7F; | |
1934 int r= (d>>10)&0x7F; | |
1935 int g= d>>21; | |
1936 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2-3)) + 128; | |
1937 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2-3)) + 128; | |
1938 } | |
1939 } | |
1940 | |
1941 | |
4558 | 1942 static inline void RENAME(rgb32ToY)(uint8_t *dst, uint8_t *src, int width) |
1943 { | |
1944 int i; | |
1945 for(i=0; i<width; i++) | |
1946 { | |
9433 | 1947 int r= ((uint32_t*)src)[i]&0xFF; |
1948 int g= (((uint32_t*)src)[i]>>8)&0xFF; | |
9499 | 1949 int b= (((uint32_t*)src)[i]>>16)&0xFF; |
4558 | 1950 |
9433 | 1951 dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); |
4558 | 1952 } |
1953 } | |
1954 | |
1955 static inline void RENAME(rgb32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1956 { | |
1957 int i; | |
1958 for(i=0; i<width; i++) | |
1959 { | |
9433 | 1960 const int a= ((uint32_t*)src1)[2*i+0]; |
1961 const int e= ((uint32_t*)src1)[2*i+1]; | |
1962 const int c= ((uint32_t*)src2)[2*i+0]; | |
1963 const int d= ((uint32_t*)src2)[2*i+1]; | |
1964 const int l= (a&0xFF00FF) + (e&0xFF00FF) + (c&0xFF00FF) + (d&0xFF00FF); | |
1965 const int h= (a&0x00FF00) + (e&0x00FF00) + (c&0x00FF00) + (d&0x00FF00); | |
1966 const int r= l&0x3FF; | |
1967 const int g= h>>8; | |
1968 const int b= l>>16; | |
4558 | 1969 |
1970 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1971 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1972 } | |
1973 } | |
1974 | |
1975 static inline void RENAME(rgb24ToY)(uint8_t *dst, uint8_t *src, int width) | |
1976 { | |
1977 int i; | |
1978 for(i=0; i<width; i++) | |
1979 { | |
1980 int r= src[i*3+0]; | |
1981 int g= src[i*3+1]; | |
1982 int b= src[i*3+2]; | |
1983 | |
9433 | 1984 dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); |
4558 | 1985 } |
1986 } | |
1987 | |
1988 static inline void RENAME(rgb24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1989 { | |
1990 int i; | |
1991 for(i=0; i<width; i++) | |
1992 { | |
1993 int r= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3]; | |
1994 int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4]; | |
1995 int b= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5]; | |
1996 | |
1997 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1998 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1999 } | |
2000 } | |
2001 | |
4467 | 2002 |
3272 | 2003 // Bilinear / Bicubic scaling |
2004 static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc, | |
2005 int16_t *filter, int16_t *filterPos, int filterSize) | |
2006 { | |
2007 #ifdef HAVE_MMX | |
2008 if(filterSize==4) // allways true for upscaling, sometimes for down too | |
2009 { | |
2010 int counter= -2*dstW; | |
2011 filter-= counter*2; | |
2012 filterPos-= counter/2; | |
2013 dst-= counter/2; | |
2014 asm volatile( | |
2015 "pxor %%mm7, %%mm7 \n\t" | |
4248 | 2016 "movq "MANGLE(w02)", %%mm6 \n\t" |
3272 | 2017 "pushl %%ebp \n\t" // we use 7 regs here ... |
2018 "movl %%eax, %%ebp \n\t" | |
2019 ".balign 16 \n\t" | |
2020 "1: \n\t" | |
2021 "movzwl (%2, %%ebp), %%eax \n\t" | |
2022 "movzwl 2(%2, %%ebp), %%ebx \n\t" | |
2023 "movq (%1, %%ebp, 4), %%mm1 \n\t" | |
2024 "movq 8(%1, %%ebp, 4), %%mm3 \n\t" | |
2025 "movd (%3, %%eax), %%mm0 \n\t" | |
2026 "movd (%3, %%ebx), %%mm2 \n\t" | |
2027 "punpcklbw %%mm7, %%mm0 \n\t" | |
2028 "punpcklbw %%mm7, %%mm2 \n\t" | |
2029 "pmaddwd %%mm1, %%mm0 \n\t" | |
2030 "pmaddwd %%mm2, %%mm3 \n\t" | |
2031 "psrad $8, %%mm0 \n\t" | |
2032 "psrad $8, %%mm3 \n\t" | |
2033 "packssdw %%mm3, %%mm0 \n\t" | |
2034 "pmaddwd %%mm6, %%mm0 \n\t" | |
2035 "packssdw %%mm0, %%mm0 \n\t" | |
2036 "movd %%mm0, (%4, %%ebp) \n\t" | |
2037 "addl $4, %%ebp \n\t" | |
2038 " jnc 1b \n\t" | |
3352 | 2039 |
3272 | 2040 "popl %%ebp \n\t" |
2041 : "+a" (counter) | |
2042 : "c" (filter), "d" (filterPos), "S" (src), "D" (dst) | |
2043 : "%ebx" | |
2044 ); | |
2045 } | |
2046 else if(filterSize==8) | |
2047 { | |
2048 int counter= -2*dstW; | |
2049 filter-= counter*4; | |
2050 filterPos-= counter/2; | |
2051 dst-= counter/2; | |
2052 asm volatile( | |
2053 "pxor %%mm7, %%mm7 \n\t" | |
4248 | 2054 "movq "MANGLE(w02)", %%mm6 \n\t" |
3272 | 2055 "pushl %%ebp \n\t" // we use 7 regs here ... |
2056 "movl %%eax, %%ebp \n\t" | |
2057 ".balign 16 \n\t" | |
2058 "1: \n\t" | |
2059 "movzwl (%2, %%ebp), %%eax \n\t" | |
2060 "movzwl 2(%2, %%ebp), %%ebx \n\t" | |
2061 "movq (%1, %%ebp, 8), %%mm1 \n\t" | |
2062 "movq 16(%1, %%ebp, 8), %%mm3 \n\t" | |
2063 "movd (%3, %%eax), %%mm0 \n\t" | |
2064 "movd (%3, %%ebx), %%mm2 \n\t" | |
2065 "punpcklbw %%mm7, %%mm0 \n\t" | |
2066 "punpcklbw %%mm7, %%mm2 \n\t" | |
2067 "pmaddwd %%mm1, %%mm0 \n\t" | |
2068 "pmaddwd %%mm2, %%mm3 \n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
2069 |
3272 | 2070 "movq 8(%1, %%ebp, 8), %%mm1 \n\t" |
2071 "movq 24(%1, %%ebp, 8), %%mm5 \n\t" | |
2072 "movd 4(%3, %%eax), %%mm4 \n\t" | |
2073 "movd 4(%3, %%ebx), %%mm2 \n\t" | |
2074 "punpcklbw %%mm7, %%mm4 \n\t" | |
2075 "punpcklbw %%mm7, %%mm2 \n\t" | |
2076 "pmaddwd %%mm1, %%mm4 \n\t" | |
2077 "pmaddwd %%mm2, %%mm5 \n\t" | |
2078 "paddd %%mm4, %%mm0 \n\t" | |
2079 "paddd %%mm5, %%mm3 \n\t" | |
2080 | |
2081 "psrad $8, %%mm0 \n\t" | |
2082 "psrad $8, %%mm3 \n\t" | |
2083 "packssdw %%mm3, %%mm0 \n\t" | |
2084 "pmaddwd %%mm6, %%mm0 \n\t" | |
2085 "packssdw %%mm0, %%mm0 \n\t" | |
2086 "movd %%mm0, (%4, %%ebp) \n\t" | |
2087 "addl $4, %%ebp \n\t" | |
2088 " jnc 1b \n\t" | |
3344 | 2089 |
3272 | 2090 "popl %%ebp \n\t" |
2091 : "+a" (counter) | |
2092 : "c" (filter), "d" (filterPos), "S" (src), "D" (dst) | |
2093 : "%ebx" | |
2094 ); | |
2095 } | |
2096 else | |
2097 { | |
2098 int counter= -2*dstW; | |
2099 // filter-= counter*filterSize/2; | |
2100 filterPos-= counter/2; | |
2101 dst-= counter/2; | |
2102 asm volatile( | |
2103 "pxor %%mm7, %%mm7 \n\t" | |
4248 | 2104 "movq "MANGLE(w02)", %%mm6 \n\t" |
3272 | 2105 ".balign 16 \n\t" |
2106 "1: \n\t" | |
2107 "movl %2, %%ecx \n\t" | |
2108 "movzwl (%%ecx, %0), %%eax \n\t" | |
2109 "movzwl 2(%%ecx, %0), %%ebx \n\t" | |
2110 "movl %5, %%ecx \n\t" | |
2111 "pxor %%mm4, %%mm4 \n\t" | |
2112 "pxor %%mm5, %%mm5 \n\t" | |
2113 "2: \n\t" | |
2114 "movq (%1), %%mm1 \n\t" | |
2115 "movq (%1, %6), %%mm3 \n\t" | |
2116 "movd (%%ecx, %%eax), %%mm0 \n\t" | |
2117 "movd (%%ecx, %%ebx), %%mm2 \n\t" | |
2118 "punpcklbw %%mm7, %%mm0 \n\t" | |
2119 "punpcklbw %%mm7, %%mm2 \n\t" | |
2120 "pmaddwd %%mm1, %%mm0 \n\t" | |
2121 "pmaddwd %%mm2, %%mm3 \n\t" | |
2122 "paddd %%mm3, %%mm5 \n\t" | |
2123 "paddd %%mm0, %%mm4 \n\t" | |
2124 "addl $8, %1 \n\t" | |
2125 "addl $4, %%ecx \n\t" | |
2126 "cmpl %4, %%ecx \n\t" | |
2127 " jb 2b \n\t" | |
2128 "addl %6, %1 \n\t" | |
2129 "psrad $8, %%mm4 \n\t" | |
2130 "psrad $8, %%mm5 \n\t" | |
2131 "packssdw %%mm5, %%mm4 \n\t" | |
2132 "pmaddwd %%mm6, %%mm4 \n\t" | |
2133 "packssdw %%mm4, %%mm4 \n\t" | |
2134 "movl %3, %%eax \n\t" | |
2135 "movd %%mm4, (%%eax, %0) \n\t" | |
2136 "addl $4, %0 \n\t" | |
2137 " jnc 1b \n\t" | |
3344 | 2138 |
3641 | 2139 : "+r" (counter), "+r" (filter) |
2140 : "m" (filterPos), "m" (dst), "m"(src+filterSize), | |
3272 | 2141 "m" (src), "r" (filterSize*2) |
3299 | 2142 : "%ebx", "%eax", "%ecx" |
3272 | 2143 ); |
2144 } | |
2145 #else | |
2146 int i; | |
2147 for(i=0; i<dstW; i++) | |
2148 { | |
2149 int j; | |
2150 int srcPos= filterPos[i]; | |
2151 int val=0; | |
3344 | 2152 // printf("filterPos: %d\n", filterPos[i]); |
3272 | 2153 for(j=0; j<filterSize; j++) |
2154 { | |
2155 // printf("filter: %d, src: %d\n", filter[i], src[srcPos + j]); | |
2156 val += ((int)src[srcPos + j])*filter[filterSize*i + j]; | |
2157 } | |
2158 // filter += hFilterSize; | |
2159 dst[i] = MIN(MAX(0, val>>7), (1<<15)-1); // the cubic equation does overflow ... | |
2160 // dst[i] = val>>7; | |
2161 } | |
2162 #endif | |
2163 } | |
2164 // *** horizontal scale Y line to temp buffer | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2165 static inline void RENAME(hyscale)(uint16_t *dst, int dstWidth, uint8_t *src, int srcW, int xInc, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2166 int flags, int canMMX2BeUsed, int16_t *hLumFilter, |
4467 | 2167 int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode, |
5452 | 2168 int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter, |
2169 int32_t *mmx2FilterPos) | |
2469 | 2170 { |
4467 | 2171 if(srcFormat==IMGFMT_YUY2) |
2172 { | |
2173 RENAME(yuy2ToY)(formatConvBuffer, src, srcW); | |
2174 src= formatConvBuffer; | |
2175 } | |
9071 | 2176 else if(srcFormat==IMGFMT_UYVY) |
2177 { | |
2178 RENAME(uyvyToY)(formatConvBuffer, src, srcW); | |
2179 src= formatConvBuffer; | |
2180 } | |
4467 | 2181 else if(srcFormat==IMGFMT_BGR32) |
2182 { | |
2183 RENAME(bgr32ToY)(formatConvBuffer, src, srcW); | |
2184 src= formatConvBuffer; | |
2185 } | |
2186 else if(srcFormat==IMGFMT_BGR24) | |
2187 { | |
2188 RENAME(bgr24ToY)(formatConvBuffer, src, srcW); | |
2189 src= formatConvBuffer; | |
2190 } | |
4578 | 2191 else if(srcFormat==IMGFMT_BGR16) |
2192 { | |
2193 RENAME(bgr16ToY)(formatConvBuffer, src, srcW); | |
2194 src= formatConvBuffer; | |
2195 } | |
4580 | 2196 else if(srcFormat==IMGFMT_BGR15) |
2197 { | |
2198 RENAME(bgr15ToY)(formatConvBuffer, src, srcW); | |
2199 src= formatConvBuffer; | |
2200 } | |
4558 | 2201 else if(srcFormat==IMGFMT_RGB32) |
2202 { | |
2203 RENAME(rgb32ToY)(formatConvBuffer, src, srcW); | |
2204 src= formatConvBuffer; | |
2205 } | |
2206 else if(srcFormat==IMGFMT_RGB24) | |
2207 { | |
2208 RENAME(rgb24ToY)(formatConvBuffer, src, srcW); | |
2209 src= formatConvBuffer; | |
2210 } | |
4467 | 2211 |
3352 | 2212 #ifdef HAVE_MMX |
2213 // use the new MMX scaler if th mmx2 cant be used (its faster than the x86asm one) | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2214 if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) |
3352 | 2215 #else |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2216 if(!(flags&SWS_FAST_BILINEAR)) |
3352 | 2217 #endif |
3272 | 2218 { |
2219 RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize); | |
2220 } | |
2221 else // Fast Bilinear upscale / crap downscale | |
2222 { | |
2469 | 2223 #ifdef ARCH_X86 |
2224 #ifdef HAVE_MMX2 | |
2671 | 2225 int i; |
2469 | 2226 if(canMMX2BeUsed) |
2227 { | |
2228 asm volatile( | |
2229 "pxor %%mm7, %%mm7 \n\t" | |
5452 | 2230 "movl %0, %%ecx \n\t" |
2231 "movl %1, %%edi \n\t" | |
2232 "movl %2, %%edx \n\t" | |
2233 "movl %3, %%ebx \n\t" | |
2469 | 2234 "xorl %%eax, %%eax \n\t" // i |
5452 | 2235 PREFETCH" (%%ecx) \n\t" |
2236 PREFETCH" 32(%%ecx) \n\t" | |
2237 PREFETCH" 64(%%ecx) \n\t" | |
2520 | 2238 |
2469 | 2239 #define FUNNY_Y_CODE \ |
5452 | 2240 "movl (%%ebx), %%esi \n\t"\ |
2241 "call *%4 \n\t"\ | |
2242 "addl (%%ebx, %%eax), %%ecx \n\t"\ | |
2243 "addl %%eax, %%edi \n\t"\ | |
2244 "xorl %%eax, %%eax \n\t"\ | |
2520 | 2245 |
2469 | 2246 FUNNY_Y_CODE |
2247 FUNNY_Y_CODE | |
2248 FUNNY_Y_CODE | |
2249 FUNNY_Y_CODE | |
2250 FUNNY_Y_CODE | |
2251 FUNNY_Y_CODE | |
2252 FUNNY_Y_CODE | |
2253 FUNNY_Y_CODE | |
2254 | |
5452 | 2255 :: "m" (src), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos), |
2256 "m" (funnyYCode) | |
2469 | 2257 : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi" |
2258 ); | |
3215 | 2259 for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128; |
2469 | 2260 } |
2261 else | |
2262 { | |
2263 #endif | |
2264 //NO MMX just normal asm ... | |
2265 asm volatile( | |
2266 "xorl %%eax, %%eax \n\t" // i | |
2267 "xorl %%ebx, %%ebx \n\t" // xx | |
2268 "xorl %%ecx, %%ecx \n\t" // 2*xalpha | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
2269 ".balign 16 \n\t" |
2469 | 2270 "1: \n\t" |
2271 "movzbl (%0, %%ebx), %%edi \n\t" //src[xx] | |
2272 "movzbl 1(%0, %%ebx), %%esi \n\t" //src[xx+1] | |
2273 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
2274 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
2275 "shll $16, %%edi \n\t" | |
2276 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
2277 "movl %1, %%edi \n\t" | |
2278 "shrl $9, %%esi \n\t" | |
2279 "movw %%si, (%%edi, %%eax, 2) \n\t" | |
2280 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF | |
2281 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry | |
2282 | |
2283 "movzbl (%0, %%ebx), %%edi \n\t" //src[xx] | |
2284 "movzbl 1(%0, %%ebx), %%esi \n\t" //src[xx+1] | |
2285 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
2286 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
2287 "shll $16, %%edi \n\t" | |
2288 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
2289 "movl %1, %%edi \n\t" | |
2290 "shrl $9, %%esi \n\t" | |
2291 "movw %%si, 2(%%edi, %%eax, 2) \n\t" | |
2292 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF | |
2293 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry | |
2294 | |
2295 | |
2296 "addl $2, %%eax \n\t" | |
2297 "cmpl %2, %%eax \n\t" | |
2298 " jb 1b \n\t" | |
2299 | |
2300 | |
2301 :: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF) | |
2302 : "%eax", "%ebx", "%ecx", "%edi", "%esi" | |
2303 ); | |
2304 #ifdef HAVE_MMX2 | |
2305 } //if MMX2 cant be used | |
2306 #endif | |
2307 #else | |
2671 | 2308 int i; |
2309 unsigned int xpos=0; | |
2310 for(i=0;i<dstWidth;i++) | |
2311 { | |
2312 register unsigned int xx=xpos>>16; | |
2313 register unsigned int xalpha=(xpos&0xFFFF)>>9; | |
2314 dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha; | |
2315 xpos+=xInc; | |
2316 } | |
2469 | 2317 #endif |
3272 | 2318 } |
2469 | 2319 } |
2320 | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2321 inline static void RENAME(hcscale)(uint16_t *dst, int dstWidth, uint8_t *src1, uint8_t *src2, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2322 int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter, |
4467 | 2323 int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode, |
5452 | 2324 int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter, |
2325 int32_t *mmx2FilterPos) | |
2469 | 2326 { |
4467 | 2327 if(srcFormat==IMGFMT_YUY2) |
2328 { | |
2329 RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2330 src1= formatConvBuffer; | |
2331 src2= formatConvBuffer+2048; | |
2332 } | |
9071 | 2333 else if(srcFormat==IMGFMT_UYVY) |
2334 { | |
2335 RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2336 src1= formatConvBuffer; | |
2337 src2= formatConvBuffer+2048; | |
2338 } | |
4467 | 2339 else if(srcFormat==IMGFMT_BGR32) |
2340 { | |
2341 RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2342 src1= formatConvBuffer; | |
2343 src2= formatConvBuffer+2048; | |
2344 } | |
2345 else if(srcFormat==IMGFMT_BGR24) | |
2346 { | |
2347 RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2348 src1= formatConvBuffer; | |
2349 src2= formatConvBuffer+2048; | |
2350 } | |
4578 | 2351 else if(srcFormat==IMGFMT_BGR16) |
2352 { | |
2353 RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2354 src1= formatConvBuffer; | |
2355 src2= formatConvBuffer+2048; | |
2356 } | |
4580 | 2357 else if(srcFormat==IMGFMT_BGR15) |
2358 { | |
2359 RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2360 src1= formatConvBuffer; | |
2361 src2= formatConvBuffer+2048; | |
2362 } | |
4558 | 2363 else if(srcFormat==IMGFMT_RGB32) |
2364 { | |
2365 RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2366 src1= formatConvBuffer; | |
2367 src2= formatConvBuffer+2048; | |
2368 } | |
2369 else if(srcFormat==IMGFMT_RGB24) | |
2370 { | |
2371 RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2372 src1= formatConvBuffer; | |
2373 src2= formatConvBuffer+2048; | |
2374 } | |
4481 | 2375 else if(isGray(srcFormat)) |
2376 { | |
2377 return; | |
2378 } | |
4467 | 2379 |
3352 | 2380 #ifdef HAVE_MMX |
2381 // use the new MMX scaler if th mmx2 cant be used (its faster than the x86asm one) | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2382 if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) |
3352 | 2383 #else |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2384 if(!(flags&SWS_FAST_BILINEAR)) |
3352 | 2385 #endif |
3272 | 2386 { |
2387 RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); | |
2388 RENAME(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); | |
2389 } | |
2390 else // Fast Bilinear upscale / crap downscale | |
2391 { | |
2469 | 2392 #ifdef ARCH_X86 |
2393 #ifdef HAVE_MMX2 | |
2671 | 2394 int i; |
2469 | 2395 if(canMMX2BeUsed) |
2396 { | |
2397 asm volatile( | |
5452 | 2398 "pxor %%mm7, %%mm7 \n\t" |
2399 "movl %0, %%ecx \n\t" | |
2400 "movl %1, %%edi \n\t" | |
2401 "movl %2, %%edx \n\t" | |
2402 "movl %3, %%ebx \n\t" | |
2403 "xorl %%eax, %%eax \n\t" // i | |
2404 PREFETCH" (%%ecx) \n\t" | |
2405 PREFETCH" 32(%%ecx) \n\t" | |
2406 PREFETCH" 64(%%ecx) \n\t" | |
2407 | |
2408 #define FUNNY_UV_CODE \ | |
2409 "movl (%%ebx), %%esi \n\t"\ | |
2410 "call *%4 \n\t"\ | |
2411 "addl (%%ebx, %%eax), %%ecx \n\t"\ | |
2412 "addl %%eax, %%edi \n\t"\ | |
2413 "xorl %%eax, %%eax \n\t"\ | |
2469 | 2414 |
5452 | 2415 FUNNY_UV_CODE |
2416 FUNNY_UV_CODE | |
2417 FUNNY_UV_CODE | |
2418 FUNNY_UV_CODE | |
2419 "xorl %%eax, %%eax \n\t" // i | |
2420 "movl %5, %%ecx \n\t" // src | |
2421 "movl %1, %%edi \n\t" // buf1 | |
2422 "addl $4096, %%edi \n\t" | |
2423 PREFETCH" (%%ecx) \n\t" | |
2424 PREFETCH" 32(%%ecx) \n\t" | |
2425 PREFETCH" 64(%%ecx) \n\t" | |
2469 | 2426 |
5452 | 2427 FUNNY_UV_CODE |
2428 FUNNY_UV_CODE | |
2429 FUNNY_UV_CODE | |
2430 FUNNY_UV_CODE | |
2469 | 2431 |
5452 | 2432 :: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos), |
2433 "m" (funnyUVCode), "m" (src2) | |
2434 : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi" | |
2435 ); | |
3344 | 2436 for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) |
2469 | 2437 { |
3344 | 2438 // printf("%d %d %d\n", dstWidth, i, srcW); |
2439 dst[i] = src1[srcW-1]*128; | |
2440 dst[i+2048] = src2[srcW-1]*128; | |
2469 | 2441 } |
2442 } | |
2443 else | |
2444 { | |
2445 #endif | |
2446 asm volatile( | |
2447 "xorl %%eax, %%eax \n\t" // i | |
2448 "xorl %%ebx, %%ebx \n\t" // xx | |
2449 "xorl %%ecx, %%ecx \n\t" // 2*xalpha | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
2450 ".balign 16 \n\t" |
2469 | 2451 "1: \n\t" |
2452 "movl %0, %%esi \n\t" | |
2453 "movzbl (%%esi, %%ebx), %%edi \n\t" //src[xx] | |
2454 "movzbl 1(%%esi, %%ebx), %%esi \n\t" //src[xx+1] | |
2455 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
2456 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
2457 "shll $16, %%edi \n\t" | |
2458 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
2459 "movl %1, %%edi \n\t" | |
2460 "shrl $9, %%esi \n\t" | |
2461 "movw %%si, (%%edi, %%eax, 2) \n\t" | |
2462 | |
2463 "movzbl (%5, %%ebx), %%edi \n\t" //src[xx] | |
2464 "movzbl 1(%5, %%ebx), %%esi \n\t" //src[xx+1] | |
2465 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
2466 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
2467 "shll $16, %%edi \n\t" | |
2468 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
2469 "movl %1, %%edi \n\t" | |
2470 "shrl $9, %%esi \n\t" | |
2471 "movw %%si, 4096(%%edi, %%eax, 2)\n\t" | |
2472 | |
2473 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF | |
2474 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry | |
2475 "addl $1, %%eax \n\t" | |
2476 "cmpl %2, %%eax \n\t" | |
2477 " jb 1b \n\t" | |
2478 | |
2479 :: "m" (src1), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF), | |
2480 "r" (src2) | |
2481 : "%eax", "%ebx", "%ecx", "%edi", "%esi" | |
2482 ); | |
2483 #ifdef HAVE_MMX2 | |
2484 } //if MMX2 cant be used | |
2485 #endif | |
2486 #else | |
2671 | 2487 int i; |
2488 unsigned int xpos=0; | |
2489 for(i=0;i<dstWidth;i++) | |
2490 { | |
2491 register unsigned int xx=xpos>>16; | |
2492 register unsigned int xalpha=(xpos&0xFFFF)>>9; | |
2493 dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha); | |
2494 dst[i+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha); | |
2566 | 2495 /* slower |
2496 dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha; | |
2497 dst[i+2048]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha; | |
2498 */ | |
2671 | 2499 xpos+=xInc; |
2500 } | |
2469 | 2501 #endif |
3272 | 2502 } |
2503 } | |
2504 | |
9499 | 2505 static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, |
2506 int srcSliceH, uint8_t* dst[], int dstStride[]){ | |
3344 | 2507 |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2508 /* load a few things into local vars to make the code more readable? and faster */ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2509 const int srcW= c->srcW; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2510 const int dstW= c->dstW; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2511 const int dstH= c->dstH; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2512 const int chrDstW= c->chrDstW; |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2513 const int chrSrcW= c->chrSrcW; |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2514 const int lumXInc= c->lumXInc; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2515 const int chrXInc= c->chrXInc; |
4295 | 2516 const int dstFormat= c->dstFormat; |
6503 | 2517 const int srcFormat= c->srcFormat; |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2518 const int flags= c->flags; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2519 const int canMMX2BeUsed= c->canMMX2BeUsed; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2520 int16_t *vLumFilterPos= c->vLumFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2521 int16_t *vChrFilterPos= c->vChrFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2522 int16_t *hLumFilterPos= c->hLumFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2523 int16_t *hChrFilterPos= c->hChrFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2524 int16_t *vLumFilter= c->vLumFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2525 int16_t *vChrFilter= c->vChrFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2526 int16_t *hLumFilter= c->hLumFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2527 int16_t *hChrFilter= c->hChrFilter; |
9413 | 2528 int32_t *lumMmxFilter= c->lumMmxFilter; |
2529 int32_t *chrMmxFilter= c->chrMmxFilter; | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2530 const int vLumFilterSize= c->vLumFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2531 const int vChrFilterSize= c->vChrFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2532 const int hLumFilterSize= c->hLumFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2533 const int hChrFilterSize= c->hChrFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2534 int16_t **lumPixBuf= c->lumPixBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2535 int16_t **chrPixBuf= c->chrPixBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2536 const int vLumBufSize= c->vLumBufSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2537 const int vChrBufSize= c->vChrBufSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2538 uint8_t *funnyYCode= c->funnyYCode; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2539 uint8_t *funnyUVCode= c->funnyUVCode; |
4467 | 2540 uint8_t *formatConvBuffer= c->formatConvBuffer; |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2541 const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample; |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2542 const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample); |
9494
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9476
diff
changeset
|
2543 int lastDstY; |
3344 | 2544 |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2545 /* vars whch will change and which we need to storw back in the context */ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2546 int dstY= c->dstY; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2547 int lumBufIndex= c->lumBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2548 int chrBufIndex= c->chrBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2549 int lastInLumBuf= c->lastInLumBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2550 int lastInChrBuf= c->lastInChrBuf; |
6540 | 2551 |
2552 if(isPacked(c->srcFormat)){ | |
4467 | 2553 src[0]= |
2554 src[1]= | |
9499 | 2555 src[2]= src[0]; |
6540 | 2556 srcStride[0]= |
4467 | 2557 srcStride[1]= |
9499 | 2558 srcStride[2]= srcStride[0]; |
4467 | 2559 } |
6540 | 2560 srcStride[1]<<= c->vChrDrop; |
2561 srcStride[2]<<= c->vChrDrop; | |
4419 | 2562 |
6517 | 2563 // printf("swscale %X %X %X -> %X %X %X\n", (int)src[0], (int)src[1], (int)src[2], |
2564 // (int)dst[0], (int)dst[1], (int)dst[2]); | |
2565 | |
2566 #if 0 //self test FIXME move to a vfilter or something | |
2567 { | |
2568 static volatile int i=0; | |
2569 i++; | |
2570 if(srcFormat==IMGFMT_YV12 && i==1 && srcSliceH>= c->srcH) | |
2571 selfTest(src, srcStride, c->srcW, c->srcH); | |
2572 i--; | |
2573 } | |
2574 #endif | |
4554 | 2575 |
2576 //printf("sws Strides:%d %d %d -> %d %d %d\n", srcStride[0],srcStride[1],srcStride[2], | |
2577 //dstStride[0],dstStride[1],dstStride[2]); | |
4419 | 2578 |
2579 if(dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0) | |
2580 { | |
2581 static int firstTime=1; //FIXME move this into the context perhaps | |
2582 if(flags & SWS_PRINT_INFO && firstTime) | |
2583 { | |
5937 | 2584 mp_msg(MSGT_SWS,MSGL_WARN,"SwScaler: Warning: dstStride is not aligned!\n" |
4419 | 2585 "SwScaler: ->cannot do aligned memory acesses anymore\n"); |
2586 firstTime=0; | |
2587 } | |
2588 } | |
3344 | 2589 |
4467 | 2590 /* Note the user might start scaling the picture in the middle so this will not get executed |
2591 this is not really intended but works currently, so ppl might do it */ | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2592 if(srcSliceY ==0){ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2593 lumBufIndex=0; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2594 chrBufIndex=0; |
4467 | 2595 dstY=0; |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2596 lastInLumBuf= -1; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2597 lastInChrBuf= -1; |
3272 | 2598 } |
3344 | 2599 |
9494
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9476
diff
changeset
|
2600 lastDstY= dstY; |
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9476
diff
changeset
|
2601 |
3344 | 2602 for(;dstY < dstH; dstY++){ |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2603 unsigned char *dest =dst[0]+dstStride[0]*dstY; |
6520 | 2604 const int chrDstY= dstY>>c->chrDstVSubSample; |
2605 unsigned char *uDest=dst[1]+dstStride[1]*chrDstY; | |
2606 unsigned char *vDest=dst[2]+dstStride[2]*chrDstY; | |
3344 | 2607 |
2608 const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input | |
2609 const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input | |
2610 const int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input | |
2611 const int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input | |
2612 | |
4290
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2613 //handle holes (FAST_BILINEAR & weird filters) |
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2614 if(firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1; |
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2615 if(firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1; |
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2616 //printf("%d %d %d\n", firstChrSrcY, lastInChrBuf, vChrBufSize); |
3344 | 2617 ASSERT(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1) |
2618 ASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1) | |
2216 | 2619 |
3344 | 2620 // Do we have enough lines in this slice to output the dstY line |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2621 if(lastLumSrcY < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample)) |
2469 | 2622 { |
3344 | 2623 //Do horizontal scaling |
2624 while(lastInLumBuf < lastLumSrcY) | |
2625 { | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2626 uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0]; |
3344 | 2627 lumBufIndex++; |
4290
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2628 // printf("%d %d %d %d\n", lumBufIndex, vLumBufSize, lastInLumBuf, lastLumSrcY); |
3344 | 2629 ASSERT(lumBufIndex < 2*vLumBufSize) |
2630 ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH) | |
2631 ASSERT(lastInLumBuf + 1 - srcSliceY >= 0) | |
2632 // printf("%d %d\n", lumBufIndex, vLumBufSize); | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2633 RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2634 flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize, |
5452 | 2635 funnyYCode, c->srcFormat, formatConvBuffer, |
2636 c->lumMmx2Filter, c->lumMmx2FilterPos); | |
3344 | 2637 lastInLumBuf++; |
2638 } | |
2639 while(lastInChrBuf < lastChrSrcY) | |
2640 { | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2641 uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1]; |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2642 uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2]; |
3344 | 2643 chrBufIndex++; |
2644 ASSERT(chrBufIndex < 2*vChrBufSize) | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2645 ASSERT(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH)) |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2646 ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0) |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2647 //FIXME replace parameters through context struct (some at least) |
6503 | 2648 |
2649 if(!(isGray(srcFormat) || isGray(dstFormat))) | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2650 RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc, |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2651 flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize, |
5452 | 2652 funnyUVCode, c->srcFormat, formatConvBuffer, |
2653 c->chrMmx2Filter, c->chrMmx2FilterPos); | |
3344 | 2654 lastInChrBuf++; |
2655 } | |
2656 //wrap buf index around to stay inside the ring buffer | |
2657 if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize; | |
2658 if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize; | |
2469 | 2659 } |
3344 | 2660 else // not enough lines left in this slice -> load the rest in the buffer |
2469 | 2661 { |
3344 | 2662 /* printf("%d %d Last:%d %d LastInBuf:%d %d Index:%d %d Y:%d FSize: %d %d BSize: %d %d\n", |
2663 firstChrSrcY,firstLumSrcY,lastChrSrcY,lastLumSrcY, | |
2664 lastInChrBuf,lastInLumBuf,chrBufIndex,lumBufIndex,dstY,vChrFilterSize,vLumFilterSize, | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2665 vChrBufSize, vLumBufSize);*/ |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2666 |
3344 | 2667 //Do horizontal scaling |
2668 while(lastInLumBuf+1 < srcSliceY + srcSliceH) | |
2469 | 2669 { |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2670 uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0]; |
3344 | 2671 lumBufIndex++; |
2672 ASSERT(lumBufIndex < 2*vLumBufSize) | |
2673 ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH) | |
2674 ASSERT(lastInLumBuf + 1 - srcSliceY >= 0) | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2675 RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2676 flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize, |
5452 | 2677 funnyYCode, c->srcFormat, formatConvBuffer, |
2678 c->lumMmx2Filter, c->lumMmx2FilterPos); | |
3344 | 2679 lastInLumBuf++; |
2469 | 2680 } |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2681 while(lastInChrBuf+1 < (chrSrcSliceY + chrSrcSliceH)) |
3344 | 2682 { |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2683 uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1]; |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2684 uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2]; |
3344 | 2685 chrBufIndex++; |
2686 ASSERT(chrBufIndex < 2*vChrBufSize) | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2687 ASSERT(lastInChrBuf + 1 - chrSrcSliceY < chrSrcSliceH) |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2688 ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0) |
6503 | 2689 |
2690 if(!(isGray(srcFormat) || isGray(dstFormat))) | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2691 RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc, |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2692 flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize, |
5452 | 2693 funnyUVCode, c->srcFormat, formatConvBuffer, |
2694 c->chrMmx2Filter, c->chrMmx2FilterPos); | |
3344 | 2695 lastInChrBuf++; |
2696 } | |
2697 //wrap buf index around to stay inside the ring buffer | |
2698 if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize; | |
2699 if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize; | |
2700 break; //we cant output a dstY line so lets try with the next slice | |
2469 | 2701 } |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
2702 |
2748 | 2703 #ifdef HAVE_MMX |
3344 | 2704 b5Dither= dither8[dstY&1]; |
2705 g6Dither= dither4[dstY&1]; | |
2706 g5Dither= dither8[dstY&1]; | |
2707 r5Dither= dither8[(dstY+1)&1]; | |
2748 | 2708 #endif |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2709 if(dstY < dstH-2) |
3352 | 2710 { |
9414 | 2711 int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; |
2712 int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | |
2713 #ifdef HAVE_MMX | |
2714 int i; | |
2715 for(i=0; i<vLumFilterSize; i++) | |
2716 { | |
2717 lumMmxFilter[4*i+0]= (int32_t)lumSrcPtr[i]; | |
2718 lumMmxFilter[4*i+2]= | |
2719 lumMmxFilter[4*i+3]= | |
2720 ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001; | |
2721 } | |
2722 for(i=0; i<vChrFilterSize; i++) | |
2723 { | |
2724 chrMmxFilter[4*i+0]= (int32_t)chrSrcPtr[i]; | |
2725 chrMmxFilter[4*i+2]= | |
2726 chrMmxFilter[4*i+3]= | |
2727 ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001; | |
2728 } | |
2729 #endif | |
6503 | 2730 if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 like |
3344 | 2731 { |
7351 | 2732 const int chrSkipMask= (1<<c->chrDstVSubSample)-1; |
2733 if((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi | |
3344 | 2734 if(vLumFilterSize == 1 && vChrFilterSize == 1) // Unscaled YV12 |
2735 { | |
2736 int16_t *lumBuf = lumPixBuf[0]; | |
2737 int16_t *chrBuf= chrPixBuf[0]; | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2738 RENAME(yuv2yuv1)(lumBuf, chrBuf, dest, uDest, vDest, dstW, chrDstW); |
3344 | 2739 } |
2740 else //General YV12 | |
2741 { | |
9413 | 2742 RENAME(yuv2yuvX)(c, |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2743 vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2744 vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, |
9414 | 2745 dest, uDest, vDest, dstW, chrDstW); |
3344 | 2746 } |
2747 } | |
2748 else | |
2749 { | |
2750 ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); | |
2751 ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2); | |
2752 if(vLumFilterSize == 1 && vChrFilterSize == 2) //Unscaled RGB | |
2753 { | |
2754 int chrAlpha= vChrFilter[2*dstY+1]; | |
7723 | 2755 RENAME(yuv2packed1)(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1), |
6578 | 2756 dest, dstW, chrAlpha, dstFormat, flags, dstY); |
3344 | 2757 } |
2758 else if(vLumFilterSize == 2 && vChrFilterSize == 2) //BiLinear Upscale RGB | |
2759 { | |
2760 int lumAlpha= vLumFilter[2*dstY+1]; | |
2761 int chrAlpha= vChrFilter[2*dstY+1]; | |
7723 | 2762 RENAME(yuv2packed2)(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1), |
6578 | 2763 dest, dstW, lumAlpha, chrAlpha, dstY); |
3344 | 2764 } |
2765 else //General RGB | |
2766 { | |
7723 | 2767 RENAME(yuv2packedX)(c, |
3344 | 2768 vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, |
2769 vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, | |
9413 | 2770 dest, dstW, dstY); |
3344 | 2771 } |
2772 } | |
3352 | 2773 } |
2774 else // hmm looks like we cant use MMX here without overwriting this arrays tail | |
2775 { | |
2776 int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; | |
2777 int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | |
6615 | 2778 if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 |
3352 | 2779 { |
7351 | 2780 const int chrSkipMask= (1<<c->chrDstVSubSample)-1; |
2781 if((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi | |
6540 | 2782 yuv2yuvXinC( |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2783 vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2784 vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, |
6540 | 2785 dest, uDest, vDest, dstW, chrDstW); |
3352 | 2786 } |
2787 else | |
2788 { | |
2789 ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); | |
2790 ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2); | |
7723 | 2791 yuv2packedXinC(c, |
3352 | 2792 vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, |
2793 vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, | |
6578 | 2794 dest, dstW, dstY); |
3352 | 2795 } |
2796 } | |
3344 | 2797 } |
2534
cc9d3fd626f0
patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents:
2521
diff
changeset
|
2798 |
cc9d3fd626f0
patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents:
2521
diff
changeset
|
2799 #ifdef HAVE_MMX |
cc9d3fd626f0
patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents:
2521
diff
changeset
|
2800 __asm __volatile(SFENCE:::"memory"); |
2566 | 2801 __asm __volatile(EMMS:::"memory"); |
2534
cc9d3fd626f0
patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents:
2521
diff
changeset
|
2802 #endif |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2803 /* store changed local vars back in the context */ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2804 c->dstY= dstY; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2805 c->lumBufIndex= lumBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2806 c->chrBufIndex= chrBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2807 c->lastInLumBuf= lastInLumBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2808 c->lastInChrBuf= lastInChrBuf; |
9494
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9476
diff
changeset
|
2809 |
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9476
diff
changeset
|
2810 return dstY - lastDstY; |
3641 | 2811 } |