Mercurial > mplayer.hg
annotate postproc/swscale_template.c @ 4394:e8b73a96b736
show actual video:audio bitrates at status line
author | arpi |
---|---|
date | Sun, 27 Jan 2002 21:46:06 +0000 |
parents | 29fef3982238 |
children | f002407e298d |
rev | line source |
---|---|
4295 | 1 /* |
2 Copyright (C) 2001-2002 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 |
3344 | 62 |
63 #define YSCALEYUV2YV12X(x) \ | |
64 "xorl %%eax, %%eax \n\t"\ | |
65 "pxor %%mm3, %%mm3 \n\t"\ | |
66 "pxor %%mm4, %%mm4 \n\t"\ | |
67 "movl %0, %%edx \n\t"\ | |
68 ".balign 16 \n\t" /* FIXME Unroll? */\ | |
69 "1: \n\t"\ | |
70 "movl (%1, %%edx, 4), %%esi \n\t"\ | |
71 "movq (%2, %%edx, 8), %%mm0 \n\t" /* filterCoeff */\ | |
72 "movq " #x "(%%esi, %%eax, 2), %%mm2 \n\t" /* srcData */\ | |
73 "movq 8+" #x "(%%esi, %%eax, 2), %%mm5 \n\t" /* srcData */\ | |
74 "pmulhw %%mm0, %%mm2 \n\t"\ | |
75 "pmulhw %%mm0, %%mm5 \n\t"\ | |
76 "paddw %%mm2, %%mm3 \n\t"\ | |
77 "paddw %%mm5, %%mm4 \n\t"\ | |
78 "addl $1, %%edx \n\t"\ | |
79 " jnz 1b \n\t"\ | |
80 "psraw $3, %%mm3 \n\t"\ | |
81 "psraw $3, %%mm4 \n\t"\ | |
82 "packuswb %%mm4, %%mm3 \n\t"\ | |
83 MOVNTQ(%%mm3, (%3, %%eax))\ | |
84 "addl $8, %%eax \n\t"\ | |
85 "cmpl %4, %%eax \n\t"\ | |
86 "pxor %%mm3, %%mm3 \n\t"\ | |
87 "pxor %%mm4, %%mm4 \n\t"\ | |
88 "movl %0, %%edx \n\t"\ | |
89 "jb 1b \n\t" | |
90 | |
91 #define YSCALEYUV2YV121 \ | |
92 "movl %2, %%eax \n\t"\ | |
93 ".balign 16 \n\t" /* FIXME Unroll? */\ | |
94 "1: \n\t"\ | |
95 "movq (%0, %%eax, 2), %%mm0 \n\t"\ | |
96 "movq 8(%0, %%eax, 2), %%mm1 \n\t"\ | |
97 "psraw $7, %%mm0 \n\t"\ | |
98 "psraw $7, %%mm1 \n\t"\ | |
99 "packuswb %%mm1, %%mm0 \n\t"\ | |
100 MOVNTQ(%%mm0, (%1, %%eax))\ | |
101 "addl $8, %%eax \n\t"\ | |
102 "jnc 1b \n\t" | |
103 | |
104 /* | |
105 :: "m" (-lumFilterSize), "m" (-chrFilterSize), | |
106 "m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4), | |
107 "r" (dest), "m" (dstW), | |
108 "m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize) | |
109 : "%eax", "%ebx", "%ecx", "%edx", "%esi" | |
110 */ | |
111 #define YSCALEYUV2RGBX \ | |
112 "xorl %%eax, %%eax \n\t"\ | |
113 ".balign 16 \n\t"\ | |
114 "1: \n\t"\ | |
115 "movl %1, %%edx \n\t" /* -chrFilterSize */\ | |
116 "movl %3, %%ebx \n\t" /* chrMmxFilter+lumFilterSize */\ | |
117 "movl %7, %%ecx \n\t" /* chrSrc+lumFilterSize */\ | |
118 "pxor %%mm3, %%mm3 \n\t"\ | |
119 "pxor %%mm4, %%mm4 \n\t"\ | |
120 "2: \n\t"\ | |
121 "movl (%%ecx, %%edx, 4), %%esi \n\t"\ | |
122 "movq (%%ebx, %%edx, 8), %%mm0 \n\t" /* filterCoeff */\ | |
123 "movq (%%esi, %%eax), %%mm2 \n\t" /* UsrcData */\ | |
124 "movq 4096(%%esi, %%eax), %%mm5 \n\t" /* VsrcData */\ | |
125 "pmulhw %%mm0, %%mm2 \n\t"\ | |
126 "pmulhw %%mm0, %%mm5 \n\t"\ | |
127 "paddw %%mm2, %%mm3 \n\t"\ | |
128 "paddw %%mm5, %%mm4 \n\t"\ | |
129 "addl $1, %%edx \n\t"\ | |
130 " jnz 2b \n\t"\ | |
131 \ | |
132 "movl %0, %%edx \n\t" /* -lumFilterSize */\ | |
133 "movl %2, %%ebx \n\t" /* lumMmxFilter+lumFilterSize */\ | |
134 "movl %6, %%ecx \n\t" /* lumSrc+lumFilterSize */\ | |
135 "pxor %%mm1, %%mm1 \n\t"\ | |
136 "pxor %%mm7, %%mm7 \n\t"\ | |
137 "2: \n\t"\ | |
138 "movl (%%ecx, %%edx, 4), %%esi \n\t"\ | |
139 "movq (%%ebx, %%edx, 8), %%mm0 \n\t" /* filterCoeff */\ | |
140 "movq (%%esi, %%eax, 2), %%mm2 \n\t" /* Y1srcData */\ | |
141 "movq 8(%%esi, %%eax, 2), %%mm5 \n\t" /* Y2srcData */\ | |
142 "pmulhw %%mm0, %%mm2 \n\t"\ | |
143 "pmulhw %%mm0, %%mm5 \n\t"\ | |
144 "paddw %%mm2, %%mm1 \n\t"\ | |
145 "paddw %%mm5, %%mm7 \n\t"\ | |
146 "addl $1, %%edx \n\t"\ | |
147 " jnz 2b \n\t"\ | |
148 \ | |
4248 | 149 "psubw "MANGLE(w400)", %%mm3 \n\t" /* (U-128)8*/\ |
150 "psubw "MANGLE(w400)", %%mm4 \n\t" /* (V-128)8*/\ | |
3344 | 151 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\ |
152 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\ | |
4248 | 153 "pmulhw "MANGLE(ugCoeff)", %%mm3\n\t"\ |
154 "pmulhw "MANGLE(vgCoeff)", %%mm4\n\t"\ | |
3344 | 155 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\ |
4248 | 156 "pmulhw "MANGLE(ubCoeff)", %%mm2\n\t"\ |
157 "pmulhw "MANGLE(vrCoeff)", %%mm5\n\t"\ | |
158 "psubw "MANGLE(w80)", %%mm1 \n\t" /* 8(Y-16)*/\ | |
159 "psubw "MANGLE(w80)", %%mm7 \n\t" /* 8(Y-16)*/\ | |
160 "pmulhw "MANGLE(yCoeff)", %%mm1 \n\t"\ | |
161 "pmulhw "MANGLE(yCoeff)", %%mm7 \n\t"\ | |
3344 | 162 /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\ |
163 "paddw %%mm3, %%mm4 \n\t"\ | |
164 "movq %%mm2, %%mm0 \n\t"\ | |
165 "movq %%mm5, %%mm6 \n\t"\ | |
166 "movq %%mm4, %%mm3 \n\t"\ | |
167 "punpcklwd %%mm2, %%mm2 \n\t"\ | |
168 "punpcklwd %%mm5, %%mm5 \n\t"\ | |
169 "punpcklwd %%mm4, %%mm4 \n\t"\ | |
170 "paddw %%mm1, %%mm2 \n\t"\ | |
171 "paddw %%mm1, %%mm5 \n\t"\ | |
172 "paddw %%mm1, %%mm4 \n\t"\ | |
173 "punpckhwd %%mm0, %%mm0 \n\t"\ | |
174 "punpckhwd %%mm6, %%mm6 \n\t"\ | |
175 "punpckhwd %%mm3, %%mm3 \n\t"\ | |
176 "paddw %%mm7, %%mm0 \n\t"\ | |
177 "paddw %%mm7, %%mm6 \n\t"\ | |
178 "paddw %%mm7, %%mm3 \n\t"\ | |
179 /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\ | |
180 "packuswb %%mm0, %%mm2 \n\t"\ | |
181 "packuswb %%mm6, %%mm5 \n\t"\ | |
182 "packuswb %%mm3, %%mm4 \n\t"\ | |
183 "pxor %%mm7, %%mm7 \n\t" | |
184 | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
185 #define FULL_YSCALEYUV2RGB \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
186 "pxor %%mm7, %%mm7 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
187 "movd %6, %%mm6 \n\t" /*yalpha1*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
188 "punpcklwd %%mm6, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
189 "punpcklwd %%mm6, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
190 "movd %7, %%mm5 \n\t" /*uvalpha1*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
191 "punpcklwd %%mm5, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
192 "punpcklwd %%mm5, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
193 "xorl %%eax, %%eax \n\t"\ |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
194 ".balign 16 \n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
195 "1: \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
196 "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
|
197 "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
|
198 "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
|
199 "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
|
200 "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
|
201 "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
|
202 "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
|
203 "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
|
204 "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
|
205 "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
|
206 "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
|
207 "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
|
208 "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
|
209 "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
|
210 "psubw %%mm0, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\ |
4248 | 211 "psubw "MANGLE(w80)", %%mm1 \n\t" /* 8(Y-16)*/\ |
212 "psubw "MANGLE(w400)", %%mm3 \n\t" /* 8(U-128)*/\ | |
213 "pmulhw "MANGLE(yCoeff)", %%mm1 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
214 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
215 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
216 "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
|
217 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\ |
4248 | 218 "pmulhw "MANGLE(ubCoeff)", %%mm3\n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
219 "psraw $4, %%mm0 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\ |
4248 | 220 "pmulhw "MANGLE(ugCoeff)", %%mm2\n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
221 "paddw %%mm4, %%mm0 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\ |
4248 | 222 "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
|
223 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
224 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
225 "movq %%mm0, %%mm4 \n\t" /* (V-128)8*/\ |
4248 | 226 "pmulhw "MANGLE(vrCoeff)", %%mm0\n\t"\ |
227 "pmulhw "MANGLE(vgCoeff)", %%mm4\n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
228 "paddw %%mm1, %%mm3 \n\t" /* B*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
229 "paddw %%mm1, %%mm0 \n\t" /* R*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
230 "packuswb %%mm3, %%mm3 \n\t"\ |
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 "packuswb %%mm0, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
233 "paddw %%mm4, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
234 "paddw %%mm2, %%mm1 \n\t" /* G*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
235 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
236 "packuswb %%mm1, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
237 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
238 #define YSCALEYUV2RGB \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
239 "movd %6, %%mm6 \n\t" /*yalpha1*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
240 "punpcklwd %%mm6, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
241 "punpcklwd %%mm6, %%mm6 \n\t"\ |
4248 | 242 "movq %%mm6, "MANGLE(asm_yalpha1)"\n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
243 "movd %7, %%mm5 \n\t" /*uvalpha1*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
244 "punpcklwd %%mm5, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
245 "punpcklwd %%mm5, %%mm5 \n\t"\ |
4248 | 246 "movq %%mm5, "MANGLE(asm_uvalpha1)"\n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
247 "xorl %%eax, %%eax \n\t"\ |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
248 ".balign 16 \n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
249 "1: \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
250 "movq (%2, %%eax), %%mm2 \n\t" /* uvbuf0[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
251 "movq (%3, %%eax), %%mm3 \n\t" /* uvbuf1[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
252 "movq 4096(%2, %%eax), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
253 "movq 4096(%3, %%eax), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
254 "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
|
255 "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\ |
4248 | 256 "movq "MANGLE(asm_uvalpha1)", %%mm0\n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
257 "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
|
258 "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
|
259 "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
|
260 "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
|
261 "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
|
262 "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\ |
4248 | 263 "psubw "MANGLE(w400)", %%mm3 \n\t" /* (U-128)8*/\ |
264 "psubw "MANGLE(w400)", %%mm4 \n\t" /* (V-128)8*/\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
265 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
266 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\ |
4248 | 267 "pmulhw "MANGLE(ugCoeff)", %%mm3\n\t"\ |
268 "pmulhw "MANGLE(vgCoeff)", %%mm4\n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
269 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
270 "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
|
271 "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
|
272 "movq 8(%0, %%eax, 2), %%mm6 \n\t" /*buf0[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
273 "movq 8(%1, %%eax, 2), %%mm7 \n\t" /*buf1[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
274 "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
|
275 "psubw %%mm7, %%mm6 \n\t" /* buf0[eax] - buf1[eax]*/\ |
4248 | 276 "pmulhw "MANGLE(asm_yalpha1)", %%mm0\n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\ |
277 "pmulhw "MANGLE(asm_yalpha1)", %%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
|
278 "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
|
279 "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
|
280 "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
|
281 "paddw %%mm6, %%mm7 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\ |
4248 | 282 "pmulhw "MANGLE(ubCoeff)", %%mm2\n\t"\ |
283 "pmulhw "MANGLE(vrCoeff)", %%mm5\n\t"\ | |
284 "psubw "MANGLE(w80)", %%mm1 \n\t" /* 8(Y-16)*/\ | |
285 "psubw "MANGLE(w80)", %%mm7 \n\t" /* 8(Y-16)*/\ | |
286 "pmulhw "MANGLE(yCoeff)", %%mm1 \n\t"\ | |
287 "pmulhw "MANGLE(yCoeff)", %%mm7 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
288 /* 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
|
289 "paddw %%mm3, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
290 "movq %%mm2, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
291 "movq %%mm5, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
292 "movq %%mm4, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
293 "punpcklwd %%mm2, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
294 "punpcklwd %%mm5, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
295 "punpcklwd %%mm4, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
296 "paddw %%mm1, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
297 "paddw %%mm1, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
298 "paddw %%mm1, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
299 "punpckhwd %%mm0, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
300 "punpckhwd %%mm6, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
301 "punpckhwd %%mm3, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
302 "paddw %%mm7, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
303 "paddw %%mm7, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
304 "paddw %%mm7, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
305 /* 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
|
306 "packuswb %%mm0, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
307 "packuswb %%mm6, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
308 "packuswb %%mm3, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
309 "pxor %%mm7, %%mm7 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
310 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
311 #define YSCALEYUV2RGB1 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
312 "xorl %%eax, %%eax \n\t"\ |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
313 ".balign 16 \n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
314 "1: \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
315 "movq (%2, %%eax), %%mm3 \n\t" /* uvbuf0[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
316 "movq 4096(%2, %%eax), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
317 "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
|
318 "psraw $4, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\ |
4248 | 319 "psubw "MANGLE(w400)", %%mm3 \n\t" /* (U-128)8*/\ |
320 "psubw "MANGLE(w400)", %%mm4 \n\t" /* (V-128)8*/\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
321 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
322 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\ |
4248 | 323 "pmulhw "MANGLE(ugCoeff)", %%mm3\n\t"\ |
324 "pmulhw "MANGLE(vgCoeff)", %%mm4\n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
325 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\ |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
326 "movq (%0, %%eax, 2), %%mm1 \n\t" /*buf0[eax]*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
327 "movq 8(%0, %%eax, 2), %%mm7 \n\t" /*buf0[eax]*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
328 "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
|
329 "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
4248 | 330 "pmulhw "MANGLE(ubCoeff)", %%mm2\n\t"\ |
331 "pmulhw "MANGLE(vrCoeff)", %%mm5\n\t"\ | |
332 "psubw "MANGLE(w80)", %%mm1 \n\t" /* 8(Y-16)*/\ | |
333 "psubw "MANGLE(w80)", %%mm7 \n\t" /* 8(Y-16)*/\ | |
334 "pmulhw "MANGLE(yCoeff)", %%mm1 \n\t"\ | |
335 "pmulhw "MANGLE(yCoeff)", %%mm7 \n\t"\ | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
336 /* 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
|
337 "paddw %%mm3, %%mm4 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
338 "movq %%mm2, %%mm0 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
339 "movq %%mm5, %%mm6 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
340 "movq %%mm4, %%mm3 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
341 "punpcklwd %%mm2, %%mm2 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
342 "punpcklwd %%mm5, %%mm5 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
343 "punpcklwd %%mm4, %%mm4 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
344 "paddw %%mm1, %%mm2 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
345 "paddw %%mm1, %%mm5 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
346 "paddw %%mm1, %%mm4 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
347 "punpckhwd %%mm0, %%mm0 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
348 "punpckhwd %%mm6, %%mm6 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
349 "punpckhwd %%mm3, %%mm3 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
350 "paddw %%mm7, %%mm0 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
351 "paddw %%mm7, %%mm6 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
352 "paddw %%mm7, %%mm3 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
353 /* 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
|
354 "packuswb %%mm0, %%mm2 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
355 "packuswb %%mm6, %%mm5 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
356 "packuswb %%mm3, %%mm4 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
357 "pxor %%mm7, %%mm7 \n\t" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
358 |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
359 // do vertical chrominance interpolation |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
360 #define YSCALEYUV2RGB1b \ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
361 "xorl %%eax, %%eax \n\t"\ |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
362 ".balign 16 \n\t"\ |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
363 "1: \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
364 "movq (%2, %%eax), %%mm2 \n\t" /* uvbuf0[eax]*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
365 "movq (%3, %%eax), %%mm3 \n\t" /* uvbuf1[eax]*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
366 "movq 4096(%2, %%eax), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
367 "movq 4096(%3, %%eax), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\ |
2576 | 368 "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax] + uvbuf1[eax]*/\ |
369 "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048] + uvbuf1[eax+2048]*/\ | |
3344 | 370 "psrlw $5, %%mm3 \n\t" /*FIXME might overflow*/\ |
371 "psrlw $5, %%mm4 \n\t" /*FIXME might overflow*/\ | |
4248 | 372 "psubw "MANGLE(w400)", %%mm3 \n\t" /* (U-128)8*/\ |
373 "psubw "MANGLE(w400)", %%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
|
374 "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
|
375 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\ |
4248 | 376 "pmulhw "MANGLE(ugCoeff)", %%mm3\n\t"\ |
377 "pmulhw "MANGLE(vgCoeff)", %%mm4\n\t"\ | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
378 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
379 "movq (%0, %%eax, 2), %%mm1 \n\t" /*buf0[eax]*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
380 "movq 8(%0, %%eax, 2), %%mm7 \n\t" /*buf0[eax]*/\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
381 "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
|
382 "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
4248 | 383 "pmulhw "MANGLE(ubCoeff)", %%mm2\n\t"\ |
384 "pmulhw "MANGLE(vrCoeff)", %%mm5\n\t"\ | |
385 "psubw "MANGLE(w80)", %%mm1 \n\t" /* 8(Y-16)*/\ | |
386 "psubw "MANGLE(w80)", %%mm7 \n\t" /* 8(Y-16)*/\ | |
387 "pmulhw "MANGLE(yCoeff)", %%mm1 \n\t"\ | |
388 "pmulhw "MANGLE(yCoeff)", %%mm7 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
389 /* 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
|
390 "paddw %%mm3, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
391 "movq %%mm2, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
392 "movq %%mm5, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
393 "movq %%mm4, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
394 "punpcklwd %%mm2, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
395 "punpcklwd %%mm5, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
396 "punpcklwd %%mm4, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
397 "paddw %%mm1, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
398 "paddw %%mm1, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
399 "paddw %%mm1, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
400 "punpckhwd %%mm0, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
401 "punpckhwd %%mm6, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
402 "punpckhwd %%mm3, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
403 "paddw %%mm7, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
404 "paddw %%mm7, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
405 "paddw %%mm7, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
406 /* 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
|
407 "packuswb %%mm0, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
408 "packuswb %%mm6, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
409 "packuswb %%mm3, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
410 "pxor %%mm7, %%mm7 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
411 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
412 #define WRITEBGR32 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
413 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
414 "movq %%mm2, %%mm1 \n\t" /* B */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
415 "movq %%mm5, %%mm6 \n\t" /* R */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
416 "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
417 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
418 "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
419 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
420 "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
421 "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
422 "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
423 "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
424 "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
425 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
426 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
427 MOVNTQ(%%mm0, (%4, %%eax, 4))\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
428 MOVNTQ(%%mm2, 8(%4, %%eax, 4))\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
429 MOVNTQ(%%mm1, 16(%4, %%eax, 4))\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
430 MOVNTQ(%%mm3, 24(%4, %%eax, 4))\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
431 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
432 "addl $8, %%eax \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
433 "cmpl %5, %%eax \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
434 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
435 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
436 #define WRITEBGR16 \ |
4248 | 437 "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\ |
438 "pand "MANGLE(bFC)", %%mm4 \n\t" /* G */\ | |
439 "pand "MANGLE(bF8)", %%mm5 \n\t" /* R */\ | |
2669 | 440 "psrlq $3, %%mm2 \n\t"\ |
441 \ | |
442 "movq %%mm2, %%mm1 \n\t"\ | |
443 "movq %%mm4, %%mm3 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
444 \ |
2669 | 445 "punpcklbw %%mm7, %%mm3 \n\t"\ |
446 "punpcklbw %%mm5, %%mm2 \n\t"\ | |
447 "punpckhbw %%mm7, %%mm4 \n\t"\ | |
448 "punpckhbw %%mm5, %%mm1 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
449 \ |
2669 | 450 "psllq $3, %%mm3 \n\t"\ |
451 "psllq $3, %%mm4 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
452 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
453 "por %%mm3, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
454 "por %%mm4, %%mm1 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
455 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
456 MOVNTQ(%%mm2, (%4, %%eax, 2))\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
457 MOVNTQ(%%mm1, 8(%4, %%eax, 2))\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
458 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
459 "addl $8, %%eax \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
460 "cmpl %5, %%eax \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
461 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
462 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
463 #define WRITEBGR15 \ |
4248 | 464 "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\ |
465 "pand "MANGLE(bF8)", %%mm4 \n\t" /* G */\ | |
466 "pand "MANGLE(bF8)", %%mm5 \n\t" /* R */\ | |
2669 | 467 "psrlq $3, %%mm2 \n\t"\ |
468 "psrlq $1, %%mm5 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
469 \ |
2669 | 470 "movq %%mm2, %%mm1 \n\t"\ |
471 "movq %%mm4, %%mm3 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
472 \ |
2669 | 473 "punpcklbw %%mm7, %%mm3 \n\t"\ |
474 "punpcklbw %%mm5, %%mm2 \n\t"\ | |
475 "punpckhbw %%mm7, %%mm4 \n\t"\ | |
476 "punpckhbw %%mm5, %%mm1 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
477 \ |
2669 | 478 "psllq $2, %%mm3 \n\t"\ |
479 "psllq $2, %%mm4 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
480 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
481 "por %%mm3, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
482 "por %%mm4, %%mm1 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
483 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
484 MOVNTQ(%%mm2, (%4, %%eax, 2))\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
485 MOVNTQ(%%mm1, 8(%4, %%eax, 2))\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
486 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
487 "addl $8, %%eax \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
488 "cmpl %5, %%eax \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
489 " jb 1b \n\t" |
2669 | 490 |
2730 | 491 #define WRITEBGR24OLD \ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
492 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
493 "movq %%mm2, %%mm1 \n\t" /* B */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
494 "movq %%mm5, %%mm6 \n\t" /* R */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
495 "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
496 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
497 "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
498 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
499 "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
500 "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\ |
2326 | 501 "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\ |
502 "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\ | |
503 "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\ | |
504 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
505 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
506 "movq %%mm0, %%mm4 \n\t" /* 0RGB0RGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
507 "psrlq $8, %%mm0 \n\t" /* 00RGB0RG 0 */\ |
4248 | 508 "pand "MANGLE(bm00000111)", %%mm4\n\t" /* 00000RGB 0 */\ |
509 "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
|
510 "por %%mm4, %%mm0 \n\t" /* 00RGBRGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
511 "movq %%mm2, %%mm4 \n\t" /* 0RGB0RGB 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
512 "psllq $48, %%mm2 \n\t" /* GB000000 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
513 "por %%mm2, %%mm0 \n\t" /* GBRGBRGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
514 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
515 "movq %%mm4, %%mm2 \n\t" /* 0RGB0RGB 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
516 "psrld $16, %%mm4 \n\t" /* 000R000R 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
517 "psrlq $24, %%mm2 \n\t" /* 0000RGB0 1.5 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
518 "por %%mm4, %%mm2 \n\t" /* 000RRGBR 1 */\ |
4248 | 519 "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
|
520 "movq %%mm1, %%mm4 \n\t" /* 0RGB0RGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
521 "psrlq $8, %%mm1 \n\t" /* 00RGB0RG 2 */\ |
4248 | 522 "pand "MANGLE(bm00000111)", %%mm4\n\t" /* 00000RGB 2 */\ |
523 "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
|
524 "por %%mm4, %%mm1 \n\t" /* 00RGBRGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
525 "movq %%mm1, %%mm4 \n\t" /* 00RGBRGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
526 "psllq $32, %%mm1 \n\t" /* BRGB0000 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
527 "por %%mm1, %%mm2 \n\t" /* BRGBRGBR 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
528 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
529 "psrlq $32, %%mm4 \n\t" /* 000000RG 2.5 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
530 "movq %%mm3, %%mm5 \n\t" /* 0RGB0RGB 3 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
531 "psrlq $8, %%mm3 \n\t" /* 00RGB0RG 3 */\ |
4248 | 532 "pand "MANGLE(bm00000111)", %%mm5\n\t" /* 00000RGB 3 */\ |
533 "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
|
534 "por %%mm5, %%mm3 \n\t" /* 00RGBRGB 3 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
535 "psllq $16, %%mm3 \n\t" /* RGBRGB00 3 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
536 "por %%mm4, %%mm3 \n\t" /* RGBRGBRG 2.5 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
537 \ |
2728 | 538 MOVNTQ(%%mm0, (%%ebx))\ |
539 MOVNTQ(%%mm2, 8(%%ebx))\ | |
540 MOVNTQ(%%mm3, 16(%%ebx))\ | |
541 "addl $24, %%ebx \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
542 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
543 "addl $8, %%eax \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
544 "cmpl %5, %%eax \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
545 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
546 |
2730 | 547 #define WRITEBGR24MMX \ |
548 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\ | |
549 "movq %%mm2, %%mm1 \n\t" /* B */\ | |
550 "movq %%mm5, %%mm6 \n\t" /* R */\ | |
551 "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\ | |
552 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\ | |
553 "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\ | |
554 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\ | |
555 "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\ | |
556 "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\ | |
557 "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\ | |
558 "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\ | |
559 "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\ | |
560 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\ | |
561 \ | |
562 "movq %%mm0, %%mm4 \n\t" /* 0RGB0RGB 0 */\ | |
563 "movq %%mm2, %%mm6 \n\t" /* 0RGB0RGB 1 */\ | |
564 "movq %%mm1, %%mm5 \n\t" /* 0RGB0RGB 2 */\ | |
565 "movq %%mm3, %%mm7 \n\t" /* 0RGB0RGB 3 */\ | |
566 \ | |
567 "psllq $40, %%mm0 \n\t" /* RGB00000 0 */\ | |
568 "psllq $40, %%mm2 \n\t" /* RGB00000 1 */\ | |
569 "psllq $40, %%mm1 \n\t" /* RGB00000 2 */\ | |
570 "psllq $40, %%mm3 \n\t" /* RGB00000 3 */\ | |
571 \ | |
572 "punpckhdq %%mm4, %%mm0 \n\t" /* 0RGBRGB0 0 */\ | |
573 "punpckhdq %%mm6, %%mm2 \n\t" /* 0RGBRGB0 1 */\ | |
574 "punpckhdq %%mm5, %%mm1 \n\t" /* 0RGBRGB0 2 */\ | |
575 "punpckhdq %%mm7, %%mm3 \n\t" /* 0RGBRGB0 3 */\ | |
576 \ | |
577 "psrlq $8, %%mm0 \n\t" /* 00RGBRGB 0 */\ | |
578 "movq %%mm2, %%mm6 \n\t" /* 0RGBRGB0 1 */\ | |
579 "psllq $40, %%mm2 \n\t" /* GB000000 1 */\ | |
580 "por %%mm2, %%mm0 \n\t" /* GBRGBRGB 0 */\ | |
581 MOVNTQ(%%mm0, (%%ebx))\ | |
582 \ | |
583 "psrlq $24, %%mm6 \n\t" /* 0000RGBR 1 */\ | |
584 "movq %%mm1, %%mm5 \n\t" /* 0RGBRGB0 2 */\ | |
585 "psllq $24, %%mm1 \n\t" /* BRGB0000 2 */\ | |
586 "por %%mm1, %%mm6 \n\t" /* BRGBRGBR 1 */\ | |
587 MOVNTQ(%%mm6, 8(%%ebx))\ | |
588 \ | |
589 "psrlq $40, %%mm5 \n\t" /* 000000RG 2 */\ | |
590 "psllq $8, %%mm3 \n\t" /* RGBRGB00 3 */\ | |
591 "por %%mm3, %%mm5 \n\t" /* RGBRGBRG 2 */\ | |
592 MOVNTQ(%%mm5, 16(%%ebx))\ | |
593 \ | |
594 "addl $24, %%ebx \n\t"\ | |
595 \ | |
596 "addl $8, %%eax \n\t"\ | |
597 "cmpl %5, %%eax \n\t"\ | |
598 " jb 1b \n\t" | |
599 | |
600 #define WRITEBGR24MMX2 \ | |
601 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\ | |
4248 | 602 "movq "MANGLE(M24A)", %%mm0 \n\t"\ |
603 "movq "MANGLE(M24C)", %%mm7 \n\t"\ | |
2730 | 604 "pshufw $0x50, %%mm2, %%mm1 \n\t" /* B3 B2 B3 B2 B1 B0 B1 B0 */\ |
605 "pshufw $0x50, %%mm4, %%mm3 \n\t" /* G3 G2 G3 G2 G1 G0 G1 G0 */\ | |
606 "pshufw $0x00, %%mm5, %%mm6 \n\t" /* R1 R0 R1 R0 R1 R0 R1 R0 */\ | |
607 \ | |
608 "pand %%mm0, %%mm1 \n\t" /* B2 B1 B0 */\ | |
609 "pand %%mm0, %%mm3 \n\t" /* G2 G1 G0 */\ | |
610 "pand %%mm7, %%mm6 \n\t" /* R1 R0 */\ | |
611 \ | |
612 "psllq $8, %%mm3 \n\t" /* G2 G1 G0 */\ | |
613 "por %%mm1, %%mm6 \n\t"\ | |
614 "por %%mm3, %%mm6 \n\t"\ | |
615 MOVNTQ(%%mm6, (%%ebx))\ | |
616 \ | |
617 "psrlq $8, %%mm4 \n\t" /* 00 G7 G6 G5 G4 G3 G2 G1 */\ | |
618 "pshufw $0xA5, %%mm2, %%mm1 \n\t" /* B5 B4 B5 B4 B3 B2 B3 B2 */\ | |
619 "pshufw $0x55, %%mm4, %%mm3 \n\t" /* G4 G3 G4 G3 G4 G3 G4 G3 */\ | |
620 "pshufw $0xA5, %%mm5, %%mm6 \n\t" /* R5 R4 R5 R4 R3 R2 R3 R2 */\ | |
621 \ | |
4248 | 622 "pand "MANGLE(M24B)", %%mm1 \n\t" /* B5 B4 B3 */\ |
2730 | 623 "pand %%mm7, %%mm3 \n\t" /* G4 G3 */\ |
624 "pand %%mm0, %%mm6 \n\t" /* R4 R3 R2 */\ | |
625 \ | |
626 "por %%mm1, %%mm3 \n\t" /* B5 G4 B4 G3 B3 */\ | |
627 "por %%mm3, %%mm6 \n\t"\ | |
628 MOVNTQ(%%mm6, 8(%%ebx))\ | |
629 \ | |
630 "pshufw $0xFF, %%mm2, %%mm1 \n\t" /* B7 B6 B7 B6 B7 B6 B6 B7 */\ | |
631 "pshufw $0xFA, %%mm4, %%mm3 \n\t" /* 00 G7 00 G7 G6 G5 G6 G5 */\ | |
632 "pshufw $0xFA, %%mm5, %%mm6 \n\t" /* R7 R6 R7 R6 R5 R4 R5 R4 */\ | |
633 \ | |
634 "pand %%mm7, %%mm1 \n\t" /* B7 B6 */\ | |
635 "pand %%mm0, %%mm3 \n\t" /* G7 G6 G5 */\ | |
4248 | 636 "pand "MANGLE(M24B)", %%mm6 \n\t" /* R7 R6 R5 */\ |
2730 | 637 \ |
638 "por %%mm1, %%mm3 \n\t"\ | |
639 "por %%mm3, %%mm6 \n\t"\ | |
640 MOVNTQ(%%mm6, 16(%%ebx))\ | |
641 \ | |
642 "addl $24, %%ebx \n\t"\ | |
643 \ | |
644 "addl $8, %%eax \n\t"\ | |
645 "cmpl %5, %%eax \n\t"\ | |
646 " jb 1b \n\t" | |
647 | |
648 #ifdef HAVE_MMX2 | |
3126 | 649 #undef WRITEBGR24 |
2730 | 650 #define WRITEBGR24 WRITEBGR24MMX2 |
651 #else | |
3126 | 652 #undef WRITEBGR24 |
2730 | 653 #define WRITEBGR24 WRITEBGR24MMX |
654 #endif | |
655 | |
3344 | 656 static inline void RENAME(yuv2yuvX)(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, |
657 int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, | |
658 uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, | |
659 int16_t * lumMmxFilter, int16_t * chrMmxFilter) | |
2519 | 660 { |
3344 | 661 #ifdef HAVE_MMX |
662 if(uDest != NULL) | |
663 { | |
664 asm volatile( | |
665 YSCALEYUV2YV12X(0) | |
666 :: "m" (-chrFilterSize), "r" (chrSrc+chrFilterSize), | |
667 "r" (chrMmxFilter+chrFilterSize*4), "r" (uDest), "m" (dstW>>1) | |
668 : "%eax", "%edx", "%esi" | |
669 ); | |
2519 | 670 |
3344 | 671 asm volatile( |
672 YSCALEYUV2YV12X(4096) | |
673 :: "m" (-chrFilterSize), "r" (chrSrc+chrFilterSize), | |
674 "r" (chrMmxFilter+chrFilterSize*4), "r" (vDest), "m" (dstW>>1) | |
675 : "%eax", "%edx", "%esi" | |
676 ); | |
677 } | |
2521 | 678 |
3344 | 679 asm volatile( |
680 YSCALEYUV2YV12X(0) | |
681 :: "m" (-lumFilterSize), "r" (lumSrc+lumFilterSize), | |
682 "r" (lumMmxFilter+lumFilterSize*4), "r" (dest), "m" (dstW) | |
683 : "%eax", "%edx", "%esi" | |
684 ); | |
685 #else | |
3352 | 686 yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize, |
687 chrFilter, chrSrc, chrFilterSize, | |
688 dest, uDest, vDest, dstW); | |
3344 | 689 #endif |
690 } | |
691 | |
692 static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc, | |
693 uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW) | |
694 { | |
695 #ifdef HAVE_MMX | |
696 if(uDest != NULL) | |
697 { | |
698 asm volatile( | |
699 YSCALEYUV2YV121 | |
700 :: "r" (chrSrc + (dstW>>1)), "r" (uDest + (dstW>>1)), | |
701 "g" (-(dstW>>1)) | |
702 : "%eax" | |
703 ); | |
704 | |
705 asm volatile( | |
706 YSCALEYUV2YV121 | |
707 :: "r" (chrSrc + 2048 + (dstW>>1)), "r" (vDest + (dstW>>1)), | |
708 "g" (-(dstW>>1)) | |
709 : "%eax" | |
710 ); | |
2519 | 711 } |
3344 | 712 |
713 asm volatile( | |
714 YSCALEYUV2YV121 | |
715 :: "r" (lumSrc + dstW), "r" (dest + dstW), | |
716 "g" (-dstW) | |
717 : "%eax" | |
718 ); | |
719 #else | |
720 //FIXME Optimize (just quickly writen not opti..) | |
721 //FIXME replace MINMAX with LUTs | |
722 int i; | |
723 for(i=0; i<dstW; i++) | |
724 { | |
725 int val= lumSrc[i]>>7; | |
726 | |
727 dest[i]= MIN(MAX(val>>19, 0), 255); | |
728 } | |
729 | |
730 if(uDest != NULL) | |
731 for(i=0; i<(dstW>>1); i++) | |
732 { | |
733 int u=chrSrc[i]>>7; | |
734 int v=chrSrc[i + 2048]>>7; | |
735 | |
736 uDest[i]= MIN(MAX(u>>19, 0), 255); | |
737 vDest[i]= MIN(MAX(v>>19, 0), 255); | |
738 } | |
739 #endif | |
2519 | 740 } |
741 | |
3344 | 742 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
743 /** |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
744 * vertical scale YV12 to RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
745 */ |
3344 | 746 static inline void RENAME(yuv2rgbX)(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, |
747 int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
748 uint8_t *dest, int dstW, int dstFormat, int16_t * lumMmxFilter, int16_t * chrMmxFilter) |
3344 | 749 { |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
750 /* if(flags&SWS_FULL_UV_IPOL) |
3344 | 751 { |
752 //FIXME | |
753 }//FULL_UV_IPOL | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
754 else*/ |
3344 | 755 { |
756 #ifdef HAVE_MMX | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
757 if(dstFormat == IMGFMT_BGR32) //FIXME untested |
3344 | 758 { |
759 asm volatile( | |
760 YSCALEYUV2RGBX | |
761 WRITEBGR32 | |
762 | |
763 :: "m" (-lumFilterSize), "m" (-chrFilterSize), | |
764 "m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4), | |
765 "r" (dest), "m" (dstW), | |
766 "m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize) | |
767 : "%eax", "%ebx", "%ecx", "%edx", "%esi" | |
768 ); | |
769 } | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
770 else if(dstFormat == IMGFMT_BGR24) //FIXME untested |
3344 | 771 { |
772 asm volatile( | |
773 YSCALEYUV2RGBX | |
774 "leal (%%eax, %%eax, 2), %%ebx \n\t" //FIXME optimize | |
775 "addl %4, %%ebx \n\t" | |
776 WRITEBGR24 | |
777 | |
778 :: "m" (-lumFilterSize), "m" (-chrFilterSize), | |
779 "m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4), | |
780 "r" (dest), "m" (dstW), | |
781 "m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize) | |
782 : "%eax", "%ebx", "%ecx", "%edx", "%esi" | |
783 ); | |
784 } | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
785 else if(dstFormat==IMGFMT_BGR15) |
3344 | 786 { |
787 asm volatile( | |
788 YSCALEYUV2RGBX | |
789 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ | |
790 #ifdef DITHER1XBPP | |
4248 | 791 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
792 "paddusb "MANGLE(g5Dither)", %%mm4\n\t" | |
793 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
3344 | 794 #endif |
795 | |
796 WRITEBGR15 | |
797 | |
798 :: "m" (-lumFilterSize), "m" (-chrFilterSize), | |
799 "m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4), | |
800 "r" (dest), "m" (dstW), | |
801 "m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize) | |
802 : "%eax", "%ebx", "%ecx", "%edx", "%esi" | |
803 ); | |
804 } | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
805 else if(dstFormat==IMGFMT_BGR16) |
3344 | 806 { |
807 asm volatile( | |
808 YSCALEYUV2RGBX | |
809 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ | |
810 #ifdef DITHER1XBPP | |
4248 | 811 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
812 "paddusb "MANGLE(g6Dither)", %%mm4\n\t" | |
813 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
3344 | 814 #endif |
815 | |
816 WRITEBGR16 | |
817 | |
818 :: "m" (-lumFilterSize), "m" (-chrFilterSize), | |
819 "m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4), | |
820 "r" (dest), "m" (dstW), | |
821 "m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize) | |
822 : "%eax", "%ebx", "%ecx", "%edx", "%esi" | |
823 ); | |
824 } | |
825 #else | |
3352 | 826 yuv2rgbXinC(lumFilter, lumSrc, lumFilterSize, |
827 chrFilter, chrSrc, chrFilterSize, | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
828 dest, dstW, dstFormat); |
3344 | 829 |
830 #endif | |
831 } //!FULL_UV_IPOL | |
832 } | |
833 | |
834 | |
835 /** | |
836 * vertical bilinear scale YV12 to RGB | |
837 */ | |
838 static inline void RENAME(yuv2rgb2)(uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, uint16_t *uvbuf1, | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
839 uint8_t *dest, int dstW, int yalpha, int uvalpha, int dstFormat, int flags) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
840 { |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
841 int yalpha1=yalpha^4095; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
842 int uvalpha1=uvalpha^4095; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
843 |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
844 if(flags&SWS_FULL_UV_IPOL) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
845 { |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
846 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
847 #ifdef HAVE_MMX |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
848 if(dstFormat==IMGFMT_BGR32) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
849 { |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
850 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
851 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
852 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
853 FULL_YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
854 "punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
855 "punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
856 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
857 "movq %%mm3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
858 "punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
859 "punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
860 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
861 MOVNTQ(%%mm3, (%4, %%eax, 4)) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
862 MOVNTQ(%%mm1, 8(%4, %%eax, 4)) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
863 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
864 "addl $4, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
865 "cmpl %5, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
866 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
867 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
868 |
3209 | 869 :: "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
|
870 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
871 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
872 ); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
873 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
874 else if(dstFormat==IMGFMT_BGR24) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
875 { |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
876 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
877 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
878 FULL_YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
879 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
880 // lsb ... msb |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
881 "punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
882 "punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
883 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
884 "movq %%mm3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
885 "punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
886 "punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
887 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
888 "movq %%mm3, %%mm2 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
889 "psrlq $8, %%mm3 \n\t" // GR0BGR00 |
4248 | 890 "pand "MANGLE(bm00000111)", %%mm2\n\t" // BGR00000 |
891 "pand "MANGLE(bm11111000)", %%mm3\n\t" // 000BGR00 | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
892 "por %%mm2, %%mm3 \n\t" // BGRBGR00 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
893 "movq %%mm1, %%mm2 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
894 "psllq $48, %%mm1 \n\t" // 000000BG |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
895 "por %%mm1, %%mm3 \n\t" // BGRBGRBG |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
896 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
897 "movq %%mm2, %%mm1 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
898 "psrld $16, %%mm2 \n\t" // R000R000 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
899 "psrlq $24, %%mm1 \n\t" // 0BGR0000 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
900 "por %%mm2, %%mm1 \n\t" // RBGRR000 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
901 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
902 "movl %4, %%ebx \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
903 "addl %%eax, %%ebx \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
904 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
905 #ifdef HAVE_MMX2 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
906 //FIXME Alignment |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
907 "movntq %%mm3, (%%ebx, %%eax, 2)\n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
908 "movntq %%mm1, 8(%%ebx, %%eax, 2)\n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
909 #else |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
910 "movd %%mm3, (%%ebx, %%eax, 2) \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
911 "psrlq $32, %%mm3 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
912 "movd %%mm3, 4(%%ebx, %%eax, 2) \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
913 "movd %%mm1, 8(%%ebx, %%eax, 2) \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
914 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
915 "addl $4, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
916 "cmpl %5, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
917 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
918 |
3209 | 919 :: "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
|
920 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
921 : "%eax", "%ebx" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
922 ); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
923 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
924 else if(dstFormat==IMGFMT_BGR15) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
925 { |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
926 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
927 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
928 FULL_YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
929 #ifdef DITHER1XBPP |
4248 | 930 "paddusb "MANGLE(g5Dither)", %%mm1\n\t" |
931 "paddusb "MANGLE(r5Dither)", %%mm0\n\t" | |
932 "paddusb "MANGLE(b5Dither)", %%mm3\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
933 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
934 "punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
935 "punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
936 "punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
937 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
938 "psrlw $3, %%mm3 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
939 "psllw $2, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
940 "psllw $7, %%mm0 \n\t" |
4248 | 941 "pand "MANGLE(g15Mask)", %%mm1 \n\t" |
942 "pand "MANGLE(r15Mask)", %%mm0 \n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
943 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
944 "por %%mm3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
945 "por %%mm1, %%mm0 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
946 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
947 MOVNTQ(%%mm0, (%4, %%eax, 2)) |
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 "addl $4, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
950 "cmpl %5, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
951 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
952 |
3209 | 953 :: "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
|
954 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
955 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
956 ); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
957 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
958 else if(dstFormat==IMGFMT_BGR16) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
959 { |
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 FULL_YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
963 #ifdef DITHER1XBPP |
4248 | 964 "paddusb "MANGLE(g6Dither)", %%mm1\n\t" |
965 "paddusb "MANGLE(r5Dither)", %%mm0\n\t" | |
966 "paddusb "MANGLE(b5Dither)", %%mm3\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
967 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
968 "punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
969 "punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
970 "punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
971 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
972 "psrlw $3, %%mm3 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
973 "psllw $3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
974 "psllw $8, %%mm0 \n\t" |
4248 | 975 "pand "MANGLE(g16Mask)", %%mm1 \n\t" |
976 "pand "MANGLE(r16Mask)", %%mm0 \n\t" | |
2316
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 "por %%mm3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
979 "por %%mm1, %%mm0 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
980 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
981 MOVNTQ(%%mm0, (%4, %%eax, 2)) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
982 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
983 "addl $4, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
984 "cmpl %5, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
985 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
986 |
3209 | 987 :: "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
|
988 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
989 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
990 ); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
991 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
992 #else |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
993 if(dstFormat==IMGFMT_BGR32) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
994 { |
2671 | 995 int i; |
3209 | 996 for(i=0;i<dstW;i++){ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
997 // vertical linear interpolation && yuv2rgb in a single step: |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
998 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
|
999 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
|
1000 int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19); |
2503 | 1001 dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)]; |
1002 dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)]; | |
1003 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
|
1004 dest+= 4; |
2316
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 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1007 else if(dstFormat==IMGFMT_BGR24) |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1008 { |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1009 int i; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1010 for(i=0;i<dstW;i++){ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1011 // vertical linear interpolation && yuv2rgb in a single step: |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1012 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
|
1013 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
|
1014 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
|
1015 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
|
1016 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
|
1017 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
|
1018 dest+= 3; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1019 } |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1020 } |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1021 else if(dstFormat==IMGFMT_BGR16) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1022 { |
2671 | 1023 int i; |
3209 | 1024 for(i=0;i<dstW;i++){ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1025 // vertical linear interpolation && yuv2rgb in a single step: |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1026 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
|
1027 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
|
1028 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
|
1029 |
2572
f2353173d52c
c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents:
2569
diff
changeset
|
1030 ((uint16_t*)dest)[i] = |
2584 | 1031 clip_table16b[(Y + yuvtab_40cf[U]) >>13] | |
1032 clip_table16g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] | | |
1033 clip_table16r[(Y + yuvtab_3343[V]) >>13]; | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1034 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1035 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1036 else if(dstFormat==IMGFMT_BGR15) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1037 { |
2671 | 1038 int i; |
3209 | 1039 for(i=0;i<dstW;i++){ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1040 // vertical linear interpolation && yuv2rgb in a single step: |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1041 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
|
1042 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
|
1043 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
|
1044 |
2572
f2353173d52c
c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents:
2569
diff
changeset
|
1045 ((uint16_t*)dest)[i] = |
2584 | 1046 clip_table15b[(Y + yuvtab_40cf[U]) >>13] | |
1047 clip_table15g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] | | |
1048 clip_table15r[(Y + yuvtab_3343[V]) >>13]; | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1049 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1050 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1051 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1052 }//FULL_UV_IPOL |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1053 else |
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 #ifdef HAVE_MMX |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1056 if(dstFormat==IMGFMT_BGR32) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1057 { |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1058 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1059 YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1060 WRITEBGR32 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1061 |
3209 | 1062 :: "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
|
1063 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1064 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1065 ); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1066 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1067 else if(dstFormat==IMGFMT_BGR24) |
2316
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 asm volatile( |
2728 | 1070 "movl %4, %%ebx \n\t" |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1071 YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1072 WRITEBGR24 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1073 |
3209 | 1074 :: "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
|
1075 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1076 : "%eax", "%ebx" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1077 ); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1078 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1079 else if(dstFormat==IMGFMT_BGR15) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1080 { |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1081 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1082 YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1083 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1084 #ifdef DITHER1XBPP |
4248 | 1085 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1086 "paddusb "MANGLE(g5Dither)", %%mm4\n\t" | |
1087 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1088 #endif |
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 WRITEBGR15 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1091 |
3209 | 1092 :: "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
|
1093 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1094 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1095 ); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1096 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1097 else if(dstFormat==IMGFMT_BGR16) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1098 { |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1099 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1100 YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1101 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1102 #ifdef DITHER1XBPP |
4248 | 1103 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1104 "paddusb "MANGLE(g6Dither)", %%mm4\n\t" | |
1105 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1106 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1107 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1108 WRITEBGR16 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1109 |
3209 | 1110 :: "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
|
1111 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1112 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1113 ); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1114 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1115 #else |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1116 if(dstFormat==IMGFMT_BGR32) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1117 { |
2671 | 1118 int i; |
3209 | 1119 for(i=0; i<dstW-1; i+=2){ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1120 // vertical linear interpolation && yuv2rgb in a single step: |
2575 | 1121 int Y1=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; |
1122 int Y2=yuvtab_2568[((buf0[i+1]*yalpha1+buf1[i+1]*yalpha)>>19)]; | |
2585 | 1123 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); |
1124 int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19); | |
2575 | 1125 |
1126 int Cb= yuvtab_40cf[U]; | |
1127 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; | |
1128 int Cr= yuvtab_3343[V]; | |
1129 | |
1130 dest[4*i+0]=clip_table[((Y1 + Cb) >>13)]; | |
1131 dest[4*i+1]=clip_table[((Y1 + Cg) >>13)]; | |
1132 dest[4*i+2]=clip_table[((Y1 + Cr) >>13)]; | |
1133 | |
1134 dest[4*i+4]=clip_table[((Y2 + Cb) >>13)]; | |
1135 dest[4*i+5]=clip_table[((Y2 + Cg) >>13)]; | |
1136 dest[4*i+6]=clip_table[((Y2 + Cr) >>13)]; | |
1137 } | |
1138 } | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1139 else if(dstFormat==IMGFMT_BGR24) |
2575 | 1140 { |
2671 | 1141 int i; |
3209 | 1142 for(i=0; i<dstW-1; i+=2){ |
2575 | 1143 // vertical linear interpolation && yuv2rgb in a single step: |
1144 int Y1=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; | |
1145 int Y2=yuvtab_2568[((buf0[i+1]*yalpha1+buf1[i+1]*yalpha)>>19)]; | |
2585 | 1146 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); |
1147 int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19); | |
2575 | 1148 |
1149 int Cb= yuvtab_40cf[U]; | |
1150 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; | |
1151 int Cr= yuvtab_3343[V]; | |
1152 | |
1153 dest[0]=clip_table[((Y1 + Cb) >>13)]; | |
1154 dest[1]=clip_table[((Y1 + Cg) >>13)]; | |
1155 dest[2]=clip_table[((Y1 + Cr) >>13)]; | |
1156 | |
1157 dest[3]=clip_table[((Y2 + Cb) >>13)]; | |
1158 dest[4]=clip_table[((Y2 + Cg) >>13)]; | |
1159 dest[5]=clip_table[((Y2 + Cr) >>13)]; | |
1160 dest+=6; | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1161 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1162 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1163 else if(dstFormat==IMGFMT_BGR16) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1164 { |
2671 | 1165 int i; |
4297
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1166 #ifdef DITHER1XBPP |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1167 static int ditherb1=1<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1168 static int ditherg1=1<<13; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1169 static int ditherr1=2<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1170 static int ditherb2=3<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1171 static int ditherg2=3<<13; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1172 static int ditherr2=0<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1173 |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1174 ditherb1 ^= (1^2)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1175 ditherg1 ^= (1^2)<<13; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1176 ditherr1 ^= (1^2)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1177 ditherb2 ^= (3^0)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1178 ditherg2 ^= (3^0)<<13; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1179 ditherr2 ^= (3^0)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1180 #else |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1181 const int ditherb1=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1182 const int ditherg1=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1183 const int ditherr1=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1184 const int ditherb2=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1185 const int ditherg2=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1186 const int ditherr2=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1187 #endif |
3209 | 1188 for(i=0; i<dstW-1; i+=2){ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1189 // vertical linear interpolation && yuv2rgb in a single step: |
2575 | 1190 int Y1=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; |
1191 int Y2=yuvtab_2568[((buf0[i+1]*yalpha1+buf1[i+1]*yalpha)>>19)]; | |
2585 | 1192 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); |
1193 int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19); | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1194 |
2575 | 1195 int Cb= yuvtab_40cf[U]; |
1196 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; | |
1197 int Cr= yuvtab_3343[V]; | |
1198 | |
2572
f2353173d52c
c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents:
2569
diff
changeset
|
1199 ((uint16_t*)dest)[i] = |
4297
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1200 clip_table16b[(Y1 + Cb + ditherb1) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1201 clip_table16g[(Y1 + Cg + ditherg1) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1202 clip_table16r[(Y1 + Cr + ditherr1) >>13]; |
2575 | 1203 |
1204 ((uint16_t*)dest)[i+1] = | |
4297
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1205 clip_table16b[(Y2 + Cb + ditherb2) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1206 clip_table16g[(Y2 + Cg + ditherg2) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1207 clip_table16r[(Y2 + Cr + ditherr2) >>13]; |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1208 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1209 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1210 else if(dstFormat==IMGFMT_BGR15) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1211 { |
2671 | 1212 int i; |
4297
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1213 #ifdef DITHER1XBPP |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1214 static int ditherb1=1<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1215 static int ditherg1=1<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1216 static int ditherr1=2<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1217 static int ditherb2=3<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1218 static int ditherg2=3<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1219 static int ditherr2=0<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1220 |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1221 ditherb1 ^= (1^2)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1222 ditherg1 ^= (1^2)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1223 ditherr1 ^= (1^2)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1224 ditherb2 ^= (3^0)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1225 ditherg2 ^= (3^0)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1226 ditherr2 ^= (3^0)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1227 #else |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1228 const int ditherb1=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1229 const int ditherg1=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1230 const int ditherr1=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1231 const int ditherb2=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1232 const int ditherg2=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1233 const int ditherr2=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1234 #endif |
3209 | 1235 for(i=0; i<dstW-1; i+=2){ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1236 // vertical linear interpolation && yuv2rgb in a single step: |
2575 | 1237 int Y1=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; |
1238 int Y2=yuvtab_2568[((buf0[i+1]*yalpha1+buf1[i+1]*yalpha)>>19)]; | |
2585 | 1239 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); |
1240 int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19); | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1241 |
2575 | 1242 int Cb= yuvtab_40cf[U]; |
1243 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; | |
1244 int Cr= yuvtab_3343[V]; | |
1245 | |
2572
f2353173d52c
c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents:
2569
diff
changeset
|
1246 ((uint16_t*)dest)[i] = |
4297
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1247 clip_table15b[(Y1 + Cb + ditherb1) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1248 clip_table15g[(Y1 + Cg + ditherg1) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1249 clip_table15r[(Y1 + Cr + ditherr1) >>13]; |
2584 | 1250 |
2575 | 1251 ((uint16_t*)dest)[i+1] = |
4297
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1252 clip_table15b[(Y2 + Cb + ditherb2) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1253 clip_table15g[(Y2 + Cg + ditherg2) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1254 clip_table15r[(Y2 + Cr + ditherr2) >>13]; |
2316
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 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1257 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1258 } //!FULL_UV_IPOL |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1259 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1260 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1261 /** |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1262 * YV12 to RGB without scaling or interpolating |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1263 */ |
3344 | 1264 static inline void RENAME(yuv2rgb1)(uint16_t *buf0, uint16_t *uvbuf0, uint16_t *uvbuf1, |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1265 uint8_t *dest, int dstW, int uvalpha, int dstFormat, int flags) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1266 { |
2671 | 1267 int uvalpha1=uvalpha^4095; |
3344 | 1268 const int yalpha1=0; |
2671 | 1269 |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1270 if(flags&SWS_FULL_UV_IPOL) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1271 { |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1272 RENAME(yuv2rgb2)(buf0, buf0, uvbuf0, uvbuf1, dest, dstW, 0, uvalpha, dstFormat, flags); |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1273 return; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1274 } |
2576 | 1275 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1276 #ifdef HAVE_MMX |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1277 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
|
1278 { |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1279 if(dstFormat==IMGFMT_BGR32) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1280 { |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1281 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1282 YSCALEYUV2RGB1 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1283 WRITEBGR32 |
3344 | 1284 :: "r" (buf0), "r" (buf0), "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
|
1285 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1286 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1287 ); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1288 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1289 else if(dstFormat==IMGFMT_BGR24) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1290 { |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1291 asm volatile( |
2728 | 1292 "movl %4, %%ebx \n\t" |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1293 YSCALEYUV2RGB1 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1294 WRITEBGR24 |
3344 | 1295 :: "r" (buf0), "r" (buf0), "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
|
1296 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1297 : "%eax", "%ebx" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1298 ); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1299 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1300 else if(dstFormat==IMGFMT_BGR15) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1301 { |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1302 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1303 YSCALEYUV2RGB1 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1304 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1305 #ifdef DITHER1XBPP |
4248 | 1306 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1307 "paddusb "MANGLE(g5Dither)", %%mm4\n\t" | |
1308 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1309 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1310 WRITEBGR15 |
3344 | 1311 :: "r" (buf0), "r" (buf0), "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
|
1312 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1313 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1314 ); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1315 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1316 else if(dstFormat==IMGFMT_BGR16) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1317 { |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1318 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1319 YSCALEYUV2RGB1 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1320 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1321 #ifdef DITHER1XBPP |
4248 | 1322 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1323 "paddusb "MANGLE(g6Dither)", %%mm4\n\t" | |
1324 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1325 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1326 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1327 WRITEBGR16 |
3344 | 1328 :: "r" (buf0), "r" (buf0), "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
|
1329 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1330 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1331 ); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1332 } |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1333 } |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1334 else |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1335 { |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1336 if(dstFormat==IMGFMT_BGR32) |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1337 { |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1338 asm volatile( |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1339 YSCALEYUV2RGB1b |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1340 WRITEBGR32 |
3344 | 1341 :: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1342 "m" (yalpha1), "m" (uvalpha1) |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1343 : "%eax" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1344 ); |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1345 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1346 else if(dstFormat==IMGFMT_BGR24) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1347 { |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1348 asm volatile( |
2728 | 1349 "movl %4, %%ebx \n\t" |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1350 YSCALEYUV2RGB1b |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1351 WRITEBGR24 |
3344 | 1352 :: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), "m" (dstW), |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1353 "m" (yalpha1), "m" (uvalpha1) |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1354 : "%eax", "%ebx" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1355 ); |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1356 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1357 else if(dstFormat==IMGFMT_BGR15) |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1358 { |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1359 asm volatile( |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1360 YSCALEYUV2RGB1b |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1361 /* 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
|
1362 #ifdef DITHER1XBPP |
4248 | 1363 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1364 "paddusb "MANGLE(g5Dither)", %%mm4\n\t" | |
1365 "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
|
1366 #endif |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1367 WRITEBGR15 |
3344 | 1368 :: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1369 "m" (yalpha1), "m" (uvalpha1) |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1370 : "%eax" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1371 ); |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1372 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1373 else if(dstFormat==IMGFMT_BGR16) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1374 { |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1375 asm volatile( |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1376 YSCALEYUV2RGB1b |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1377 /* 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
|
1378 #ifdef DITHER1XBPP |
4248 | 1379 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1380 "paddusb "MANGLE(g6Dither)", %%mm4\n\t" | |
1381 "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
|
1382 #endif |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1383 |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1384 WRITEBGR16 |
3344 | 1385 :: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1386 "m" (yalpha1), "m" (uvalpha1) |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1387 : "%eax" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1388 ); |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1389 } |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1390 } |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1391 #else |
2576 | 1392 //FIXME write 2 versions (for even & odd lines) |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1393 |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1394 if(dstFormat==IMGFMT_BGR32) |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1395 { |
2671 | 1396 int i; |
3209 | 1397 for(i=0; i<dstW-1; i+=2){ |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1398 // vertical linear interpolation && yuv2rgb in a single step: |
2576 | 1399 int Y1=yuvtab_2568[buf0[i]>>7]; |
1400 int Y2=yuvtab_2568[buf0[i+1]>>7]; | |
2585 | 1401 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); |
1402 int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19); | |
2576 | 1403 |
1404 int Cb= yuvtab_40cf[U]; | |
1405 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; | |
1406 int Cr= yuvtab_3343[V]; | |
1407 | |
1408 dest[4*i+0]=clip_table[((Y1 + Cb) >>13)]; | |
1409 dest[4*i+1]=clip_table[((Y1 + Cg) >>13)]; | |
1410 dest[4*i+2]=clip_table[((Y1 + Cr) >>13)]; | |
1411 | |
1412 dest[4*i+4]=clip_table[((Y2 + Cb) >>13)]; | |
1413 dest[4*i+5]=clip_table[((Y2 + Cg) >>13)]; | |
1414 dest[4*i+6]=clip_table[((Y2 + Cr) >>13)]; | |
1415 } | |
1416 } | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1417 else if(dstFormat==IMGFMT_BGR24) |
2576 | 1418 { |
2671 | 1419 int i; |
3209 | 1420 for(i=0; i<dstW-1; i+=2){ |
2576 | 1421 // vertical linear interpolation && yuv2rgb in a single step: |
1422 int Y1=yuvtab_2568[buf0[i]>>7]; | |
1423 int Y2=yuvtab_2568[buf0[i+1]>>7]; | |
2585 | 1424 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); |
1425 int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19); | |
2576 | 1426 |
1427 int Cb= yuvtab_40cf[U]; | |
1428 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; | |
1429 int Cr= yuvtab_3343[V]; | |
1430 | |
1431 dest[0]=clip_table[((Y1 + Cb) >>13)]; | |
1432 dest[1]=clip_table[((Y1 + Cg) >>13)]; | |
1433 dest[2]=clip_table[((Y1 + Cr) >>13)]; | |
1434 | |
1435 dest[3]=clip_table[((Y2 + Cb) >>13)]; | |
1436 dest[4]=clip_table[((Y2 + Cg) >>13)]; | |
1437 dest[5]=clip_table[((Y2 + Cr) >>13)]; | |
1438 dest+=6; | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1439 } |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1440 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1441 else if(dstFormat==IMGFMT_BGR16) |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1442 { |
2671 | 1443 int i; |
4297
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1444 #ifdef DITHER1XBPP |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1445 static int ditherb1=1<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1446 static int ditherg1=1<<13; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1447 static int ditherr1=2<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1448 static int ditherb2=3<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1449 static int ditherg2=3<<13; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1450 static int ditherr2=0<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1451 |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1452 ditherb1 ^= (1^2)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1453 ditherg1 ^= (1^2)<<13; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1454 ditherr1 ^= (1^2)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1455 ditherb2 ^= (3^0)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1456 ditherg2 ^= (3^0)<<13; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1457 ditherr2 ^= (3^0)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1458 #else |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1459 const int ditherb1=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1460 const int ditherg1=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1461 const int ditherr1=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1462 const int ditherb2=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1463 const int ditherg2=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1464 const int ditherr2=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1465 #endif |
3209 | 1466 for(i=0; i<dstW-1; i+=2){ |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1467 // vertical linear interpolation && yuv2rgb in a single step: |
2576 | 1468 int Y1=yuvtab_2568[buf0[i]>>7]; |
1469 int Y2=yuvtab_2568[buf0[i+1]>>7]; | |
2585 | 1470 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); |
1471 int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19); | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1472 |
2576 | 1473 int Cb= yuvtab_40cf[U]; |
1474 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; | |
1475 int Cr= yuvtab_3343[V]; | |
1476 | |
2572
f2353173d52c
c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents:
2569
diff
changeset
|
1477 ((uint16_t*)dest)[i] = |
4297
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1478 clip_table16b[(Y1 + Cb + ditherb1) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1479 clip_table16g[(Y1 + Cg + ditherg1) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1480 clip_table16r[(Y1 + Cr + ditherr1) >>13]; |
2576 | 1481 |
1482 ((uint16_t*)dest)[i+1] = | |
4297
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1483 clip_table16b[(Y2 + Cb + ditherb2) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1484 clip_table16g[(Y2 + Cg + ditherg2) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1485 clip_table16r[(Y2 + Cr + ditherr2) >>13]; |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1486 } |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1487 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1488 else if(dstFormat==IMGFMT_BGR15) |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1489 { |
2671 | 1490 int i; |
4297
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1491 #ifdef DITHER1XBPP |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1492 static int ditherb1=1<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1493 static int ditherg1=1<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1494 static int ditherr1=2<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1495 static int ditherb2=3<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1496 static int ditherg2=3<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1497 static int ditherr2=0<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1498 |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1499 ditherb1 ^= (1^2)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1500 ditherg1 ^= (1^2)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1501 ditherr1 ^= (1^2)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1502 ditherb2 ^= (3^0)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1503 ditherg2 ^= (3^0)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1504 ditherr2 ^= (3^0)<<14; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1505 #else |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1506 const int ditherb1=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1507 const int ditherg1=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1508 const int ditherr1=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1509 const int ditherb2=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1510 const int ditherg2=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1511 const int ditherr2=0; |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1512 #endif |
3209 | 1513 for(i=0; i<dstW-1; i+=2){ |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1514 // vertical linear interpolation && yuv2rgb in a single step: |
2576 | 1515 int Y1=yuvtab_2568[buf0[i]>>7]; |
1516 int Y2=yuvtab_2568[buf0[i+1]>>7]; | |
2585 | 1517 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19); |
1518 int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19); | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1519 |
2576 | 1520 int Cb= yuvtab_40cf[U]; |
1521 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U]; | |
1522 int Cr= yuvtab_3343[V]; | |
1523 | |
2572
f2353173d52c
c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents:
2569
diff
changeset
|
1524 ((uint16_t*)dest)[i] = |
4297
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1525 clip_table15b[(Y1 + Cb + ditherb1) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1526 clip_table15g[(Y1 + Cg + ditherg1) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1527 clip_table15r[(Y1 + Cr + ditherr1) >>13]; |
2584 | 1528 |
2576 | 1529 ((uint16_t*)dest)[i+1] = |
4297
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1530 clip_table15b[(Y2 + Cb + ditherb2) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1531 clip_table15g[(Y2 + Cg + ditherg2) >>13] | |
29fef3982238
15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents:
4295
diff
changeset
|
1532 clip_table15r[(Y2 + Cr + ditherr2) >>13]; |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1533 } |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1534 } |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1535 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1536 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1537 |
3272 | 1538 // Bilinear / Bicubic scaling |
1539 static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc, | |
1540 int16_t *filter, int16_t *filterPos, int filterSize) | |
1541 { | |
1542 #ifdef HAVE_MMX | |
1543 if(filterSize==4) // allways true for upscaling, sometimes for down too | |
1544 { | |
1545 int counter= -2*dstW; | |
1546 filter-= counter*2; | |
1547 filterPos-= counter/2; | |
1548 dst-= counter/2; | |
1549 asm volatile( | |
1550 "pxor %%mm7, %%mm7 \n\t" | |
4248 | 1551 "movq "MANGLE(w02)", %%mm6 \n\t" |
3272 | 1552 "pushl %%ebp \n\t" // we use 7 regs here ... |
1553 "movl %%eax, %%ebp \n\t" | |
1554 ".balign 16 \n\t" | |
1555 "1: \n\t" | |
1556 "movzwl (%2, %%ebp), %%eax \n\t" | |
1557 "movzwl 2(%2, %%ebp), %%ebx \n\t" | |
1558 "movq (%1, %%ebp, 4), %%mm1 \n\t" | |
1559 "movq 8(%1, %%ebp, 4), %%mm3 \n\t" | |
1560 "movd (%3, %%eax), %%mm0 \n\t" | |
1561 "movd (%3, %%ebx), %%mm2 \n\t" | |
1562 "punpcklbw %%mm7, %%mm0 \n\t" | |
1563 "punpcklbw %%mm7, %%mm2 \n\t" | |
1564 "pmaddwd %%mm1, %%mm0 \n\t" | |
1565 "pmaddwd %%mm2, %%mm3 \n\t" | |
1566 "psrad $8, %%mm0 \n\t" | |
1567 "psrad $8, %%mm3 \n\t" | |
1568 "packssdw %%mm3, %%mm0 \n\t" | |
1569 "pmaddwd %%mm6, %%mm0 \n\t" | |
1570 "packssdw %%mm0, %%mm0 \n\t" | |
1571 "movd %%mm0, (%4, %%ebp) \n\t" | |
1572 "addl $4, %%ebp \n\t" | |
1573 " jnc 1b \n\t" | |
3352 | 1574 |
3272 | 1575 "popl %%ebp \n\t" |
1576 : "+a" (counter) | |
1577 : "c" (filter), "d" (filterPos), "S" (src), "D" (dst) | |
1578 : "%ebx" | |
1579 ); | |
1580 } | |
1581 else if(filterSize==8) | |
1582 { | |
1583 int counter= -2*dstW; | |
1584 filter-= counter*4; | |
1585 filterPos-= counter/2; | |
1586 dst-= counter/2; | |
1587 asm volatile( | |
1588 "pxor %%mm7, %%mm7 \n\t" | |
4248 | 1589 "movq "MANGLE(w02)", %%mm6 \n\t" |
3272 | 1590 "pushl %%ebp \n\t" // we use 7 regs here ... |
1591 "movl %%eax, %%ebp \n\t" | |
1592 ".balign 16 \n\t" | |
1593 "1: \n\t" | |
1594 "movzwl (%2, %%ebp), %%eax \n\t" | |
1595 "movzwl 2(%2, %%ebp), %%ebx \n\t" | |
1596 "movq (%1, %%ebp, 8), %%mm1 \n\t" | |
1597 "movq 16(%1, %%ebp, 8), %%mm3 \n\t" | |
1598 "movd (%3, %%eax), %%mm0 \n\t" | |
1599 "movd (%3, %%ebx), %%mm2 \n\t" | |
1600 "punpcklbw %%mm7, %%mm0 \n\t" | |
1601 "punpcklbw %%mm7, %%mm2 \n\t" | |
1602 "pmaddwd %%mm1, %%mm0 \n\t" | |
1603 "pmaddwd %%mm2, %%mm3 \n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1604 |
3272 | 1605 "movq 8(%1, %%ebp, 8), %%mm1 \n\t" |
1606 "movq 24(%1, %%ebp, 8), %%mm5 \n\t" | |
1607 "movd 4(%3, %%eax), %%mm4 \n\t" | |
1608 "movd 4(%3, %%ebx), %%mm2 \n\t" | |
1609 "punpcklbw %%mm7, %%mm4 \n\t" | |
1610 "punpcklbw %%mm7, %%mm2 \n\t" | |
1611 "pmaddwd %%mm1, %%mm4 \n\t" | |
1612 "pmaddwd %%mm2, %%mm5 \n\t" | |
1613 "paddd %%mm4, %%mm0 \n\t" | |
1614 "paddd %%mm5, %%mm3 \n\t" | |
1615 | |
1616 "psrad $8, %%mm0 \n\t" | |
1617 "psrad $8, %%mm3 \n\t" | |
1618 "packssdw %%mm3, %%mm0 \n\t" | |
1619 "pmaddwd %%mm6, %%mm0 \n\t" | |
1620 "packssdw %%mm0, %%mm0 \n\t" | |
1621 "movd %%mm0, (%4, %%ebp) \n\t" | |
1622 "addl $4, %%ebp \n\t" | |
1623 " jnc 1b \n\t" | |
3344 | 1624 |
3272 | 1625 "popl %%ebp \n\t" |
1626 : "+a" (counter) | |
1627 : "c" (filter), "d" (filterPos), "S" (src), "D" (dst) | |
1628 : "%ebx" | |
1629 ); | |
1630 } | |
1631 else | |
1632 { | |
1633 int counter= -2*dstW; | |
1634 // filter-= counter*filterSize/2; | |
1635 filterPos-= counter/2; | |
1636 dst-= counter/2; | |
1637 asm volatile( | |
1638 "pxor %%mm7, %%mm7 \n\t" | |
4248 | 1639 "movq "MANGLE(w02)", %%mm6 \n\t" |
3272 | 1640 ".balign 16 \n\t" |
1641 "1: \n\t" | |
1642 "movl %2, %%ecx \n\t" | |
1643 "movzwl (%%ecx, %0), %%eax \n\t" | |
1644 "movzwl 2(%%ecx, %0), %%ebx \n\t" | |
1645 "movl %5, %%ecx \n\t" | |
1646 "pxor %%mm4, %%mm4 \n\t" | |
1647 "pxor %%mm5, %%mm5 \n\t" | |
1648 "2: \n\t" | |
1649 "movq (%1), %%mm1 \n\t" | |
1650 "movq (%1, %6), %%mm3 \n\t" | |
1651 "movd (%%ecx, %%eax), %%mm0 \n\t" | |
1652 "movd (%%ecx, %%ebx), %%mm2 \n\t" | |
1653 "punpcklbw %%mm7, %%mm0 \n\t" | |
1654 "punpcklbw %%mm7, %%mm2 \n\t" | |
1655 "pmaddwd %%mm1, %%mm0 \n\t" | |
1656 "pmaddwd %%mm2, %%mm3 \n\t" | |
1657 "paddd %%mm3, %%mm5 \n\t" | |
1658 "paddd %%mm0, %%mm4 \n\t" | |
1659 "addl $8, %1 \n\t" | |
1660 "addl $4, %%ecx \n\t" | |
1661 "cmpl %4, %%ecx \n\t" | |
1662 " jb 2b \n\t" | |
1663 "addl %6, %1 \n\t" | |
1664 "psrad $8, %%mm4 \n\t" | |
1665 "psrad $8, %%mm5 \n\t" | |
1666 "packssdw %%mm5, %%mm4 \n\t" | |
1667 "pmaddwd %%mm6, %%mm4 \n\t" | |
1668 "packssdw %%mm4, %%mm4 \n\t" | |
1669 "movl %3, %%eax \n\t" | |
1670 "movd %%mm4, (%%eax, %0) \n\t" | |
1671 "addl $4, %0 \n\t" | |
1672 " jnc 1b \n\t" | |
3344 | 1673 |
3641 | 1674 : "+r" (counter), "+r" (filter) |
1675 : "m" (filterPos), "m" (dst), "m"(src+filterSize), | |
3272 | 1676 "m" (src), "r" (filterSize*2) |
3299 | 1677 : "%ebx", "%eax", "%ecx" |
3272 | 1678 ); |
1679 } | |
1680 #else | |
1681 int i; | |
1682 for(i=0; i<dstW; i++) | |
1683 { | |
1684 int j; | |
1685 int srcPos= filterPos[i]; | |
1686 int val=0; | |
3344 | 1687 // printf("filterPos: %d\n", filterPos[i]); |
3272 | 1688 for(j=0; j<filterSize; j++) |
1689 { | |
1690 // printf("filter: %d, src: %d\n", filter[i], src[srcPos + j]); | |
1691 val += ((int)src[srcPos + j])*filter[filterSize*i + j]; | |
1692 } | |
1693 // filter += hFilterSize; | |
1694 dst[i] = MIN(MAX(0, val>>7), (1<<15)-1); // the cubic equation does overflow ... | |
1695 // dst[i] = val>>7; | |
1696 } | |
1697 #endif | |
1698 } | |
1699 // *** horizontal scale Y line to temp buffer | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1700 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
|
1701 int flags, int canMMX2BeUsed, int16_t *hLumFilter, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1702 int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode) |
2469 | 1703 { |
3352 | 1704 #ifdef HAVE_MMX |
1705 // 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
|
1706 if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) |
3352 | 1707 #else |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1708 if(!(flags&SWS_FAST_BILINEAR)) |
3352 | 1709 #endif |
3272 | 1710 { |
1711 RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize); | |
1712 } | |
1713 else // Fast Bilinear upscale / crap downscale | |
1714 { | |
2469 | 1715 #ifdef ARCH_X86 |
1716 #ifdef HAVE_MMX2 | |
2671 | 1717 int i; |
2469 | 1718 if(canMMX2BeUsed) |
1719 { | |
1720 asm volatile( | |
1721 "pxor %%mm7, %%mm7 \n\t" | |
1722 "pxor %%mm2, %%mm2 \n\t" // 2*xalpha | |
1723 "movd %5, %%mm6 \n\t" // xInc&0xFFFF | |
1724 "punpcklwd %%mm6, %%mm6 \n\t" | |
1725 "punpcklwd %%mm6, %%mm6 \n\t" | |
1726 "movq %%mm6, %%mm2 \n\t" | |
1727 "psllq $16, %%mm2 \n\t" | |
1728 "paddw %%mm6, %%mm2 \n\t" | |
1729 "psllq $16, %%mm2 \n\t" | |
1730 "paddw %%mm6, %%mm2 \n\t" | |
1731 "psllq $16, %%mm2 \n\t" //0,t,2t,3t t=xInc&0xFF | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1732 "movq %%mm2, %%mm4 \n\t" |
2469 | 1733 "movd %4, %%mm6 \n\t" //(xInc*4)&0xFFFF |
1734 "punpcklwd %%mm6, %%mm6 \n\t" | |
1735 "punpcklwd %%mm6, %%mm6 \n\t" | |
1736 "xorl %%eax, %%eax \n\t" // i | |
1737 "movl %0, %%esi \n\t" // src | |
1738 "movl %1, %%edi \n\t" // buf1 | |
1739 "movl %3, %%edx \n\t" // (xInc*4)>>16 | |
1740 "xorl %%ecx, %%ecx \n\t" | |
1741 "xorl %%ebx, %%ebx \n\t" | |
1742 "movw %4, %%bx \n\t" // (xInc*4)&0xFFFF | |
2520 | 1743 |
2469 | 1744 #define FUNNY_Y_CODE \ |
2520 | 1745 PREFETCH" 1024(%%esi) \n\t"\ |
1746 PREFETCH" 1056(%%esi) \n\t"\ | |
1747 PREFETCH" 1088(%%esi) \n\t"\ | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1748 "call *%6 \n\t"\ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1749 "movq %%mm4, %%mm2 \n\t"\ |
2469 | 1750 "xorl %%ecx, %%ecx \n\t" |
2520 | 1751 |
2469 | 1752 FUNNY_Y_CODE |
1753 FUNNY_Y_CODE | |
1754 FUNNY_Y_CODE | |
1755 FUNNY_Y_CODE | |
1756 FUNNY_Y_CODE | |
1757 FUNNY_Y_CODE | |
1758 FUNNY_Y_CODE | |
1759 FUNNY_Y_CODE | |
1760 | |
1761 :: "m" (src), "m" (dst), "m" (dstWidth), "m" ((xInc*4)>>16), | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1762 "m" ((xInc*4)&0xFFFF), "m" (xInc&0xFFFF), "m" (funnyYCode) |
2469 | 1763 : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi" |
1764 ); | |
3215 | 1765 for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128; |
2469 | 1766 } |
1767 else | |
1768 { | |
1769 #endif | |
1770 //NO MMX just normal asm ... | |
1771 asm volatile( | |
1772 "xorl %%eax, %%eax \n\t" // i | |
1773 "xorl %%ebx, %%ebx \n\t" // xx | |
1774 "xorl %%ecx, %%ecx \n\t" // 2*xalpha | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
1775 ".balign 16 \n\t" |
2469 | 1776 "1: \n\t" |
1777 "movzbl (%0, %%ebx), %%edi \n\t" //src[xx] | |
1778 "movzbl 1(%0, %%ebx), %%esi \n\t" //src[xx+1] | |
1779 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
1780 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
1781 "shll $16, %%edi \n\t" | |
1782 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
1783 "movl %1, %%edi \n\t" | |
1784 "shrl $9, %%esi \n\t" | |
1785 "movw %%si, (%%edi, %%eax, 2) \n\t" | |
1786 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF | |
1787 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry | |
1788 | |
1789 "movzbl (%0, %%ebx), %%edi \n\t" //src[xx] | |
1790 "movzbl 1(%0, %%ebx), %%esi \n\t" //src[xx+1] | |
1791 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
1792 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
1793 "shll $16, %%edi \n\t" | |
1794 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
1795 "movl %1, %%edi \n\t" | |
1796 "shrl $9, %%esi \n\t" | |
1797 "movw %%si, 2(%%edi, %%eax, 2) \n\t" | |
1798 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF | |
1799 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry | |
1800 | |
1801 | |
1802 "addl $2, %%eax \n\t" | |
1803 "cmpl %2, %%eax \n\t" | |
1804 " jb 1b \n\t" | |
1805 | |
1806 | |
1807 :: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF) | |
1808 : "%eax", "%ebx", "%ecx", "%edi", "%esi" | |
1809 ); | |
1810 #ifdef HAVE_MMX2 | |
1811 } //if MMX2 cant be used | |
1812 #endif | |
1813 #else | |
2671 | 1814 int i; |
1815 unsigned int xpos=0; | |
1816 for(i=0;i<dstWidth;i++) | |
1817 { | |
1818 register unsigned int xx=xpos>>16; | |
1819 register unsigned int xalpha=(xpos&0xFFFF)>>9; | |
1820 dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha; | |
1821 xpos+=xInc; | |
1822 } | |
2469 | 1823 #endif |
3272 | 1824 } |
2469 | 1825 } |
1826 | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1827 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
|
1828 int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1829 int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode) |
2469 | 1830 { |
3352 | 1831 #ifdef HAVE_MMX |
1832 // 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
|
1833 if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) |
3352 | 1834 #else |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1835 if(!(flags&SWS_FAST_BILINEAR)) |
3352 | 1836 #endif |
3272 | 1837 { |
1838 RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); | |
1839 RENAME(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); | |
1840 } | |
1841 else // Fast Bilinear upscale / crap downscale | |
1842 { | |
2469 | 1843 #ifdef ARCH_X86 |
1844 #ifdef HAVE_MMX2 | |
2671 | 1845 int i; |
2469 | 1846 if(canMMX2BeUsed) |
1847 { | |
1848 asm volatile( | |
1849 "pxor %%mm7, %%mm7 \n\t" | |
1850 "pxor %%mm2, %%mm2 \n\t" // 2*xalpha | |
1851 "movd %5, %%mm6 \n\t" // xInc&0xFFFF | |
1852 "punpcklwd %%mm6, %%mm6 \n\t" | |
1853 "punpcklwd %%mm6, %%mm6 \n\t" | |
1854 "movq %%mm6, %%mm2 \n\t" | |
1855 "psllq $16, %%mm2 \n\t" | |
1856 "paddw %%mm6, %%mm2 \n\t" | |
1857 "psllq $16, %%mm2 \n\t" | |
1858 "paddw %%mm6, %%mm2 \n\t" | |
1859 "psllq $16, %%mm2 \n\t" //0,t,2t,3t t=xInc&0xFFFF | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1860 "movq %%mm2, %%mm4 \n\t" |
2469 | 1861 "movd %4, %%mm6 \n\t" //(xInc*4)&0xFFFF |
1862 "punpcklwd %%mm6, %%mm6 \n\t" | |
1863 "punpcklwd %%mm6, %%mm6 \n\t" | |
1864 "xorl %%eax, %%eax \n\t" // i | |
1865 "movl %0, %%esi \n\t" // src | |
1866 "movl %1, %%edi \n\t" // buf1 | |
1867 "movl %3, %%edx \n\t" // (xInc*4)>>16 | |
1868 "xorl %%ecx, %%ecx \n\t" | |
1869 "xorl %%ebx, %%ebx \n\t" | |
1870 "movw %4, %%bx \n\t" // (xInc*4)&0xFFFF | |
1871 | |
1872 #define FUNNYUVCODE \ | |
2520 | 1873 PREFETCH" 1024(%%esi) \n\t"\ |
1874 PREFETCH" 1056(%%esi) \n\t"\ | |
1875 PREFETCH" 1088(%%esi) \n\t"\ | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1876 "call *%7 \n\t"\ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1877 "movq %%mm4, %%mm2 \n\t"\ |
2469 | 1878 "xorl %%ecx, %%ecx \n\t" |
1879 | |
1880 FUNNYUVCODE | |
1881 FUNNYUVCODE | |
1882 FUNNYUVCODE | |
1883 FUNNYUVCODE | |
1884 | |
1885 FUNNYUVCODE | |
1886 FUNNYUVCODE | |
1887 FUNNYUVCODE | |
1888 FUNNYUVCODE | |
1889 "xorl %%eax, %%eax \n\t" // i | |
1890 "movl %6, %%esi \n\t" // src | |
1891 "movl %1, %%edi \n\t" // buf1 | |
1892 "addl $4096, %%edi \n\t" | |
1893 | |
1894 FUNNYUVCODE | |
1895 FUNNYUVCODE | |
1896 FUNNYUVCODE | |
1897 FUNNYUVCODE | |
1898 | |
1899 FUNNYUVCODE | |
1900 FUNNYUVCODE | |
1901 FUNNYUVCODE | |
1902 FUNNYUVCODE | |
1903 | |
1904 :: "m" (src1), "m" (dst), "m" (dstWidth), "m" ((xInc*4)>>16), | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1905 "m" ((xInc*4)&0xFFFF), "m" (xInc&0xFFFF), "m" (src2), "m" (funnyUVCode) |
2469 | 1906 : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi" |
1907 ); | |
3344 | 1908 for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) |
2469 | 1909 { |
3344 | 1910 // printf("%d %d %d\n", dstWidth, i, srcW); |
1911 dst[i] = src1[srcW-1]*128; | |
1912 dst[i+2048] = src2[srcW-1]*128; | |
2469 | 1913 } |
1914 } | |
1915 else | |
1916 { | |
1917 #endif | |
1918 asm volatile( | |
1919 "xorl %%eax, %%eax \n\t" // i | |
1920 "xorl %%ebx, %%ebx \n\t" // xx | |
1921 "xorl %%ecx, %%ecx \n\t" // 2*xalpha | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
1922 ".balign 16 \n\t" |
2469 | 1923 "1: \n\t" |
1924 "movl %0, %%esi \n\t" | |
1925 "movzbl (%%esi, %%ebx), %%edi \n\t" //src[xx] | |
1926 "movzbl 1(%%esi, %%ebx), %%esi \n\t" //src[xx+1] | |
1927 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
1928 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
1929 "shll $16, %%edi \n\t" | |
1930 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
1931 "movl %1, %%edi \n\t" | |
1932 "shrl $9, %%esi \n\t" | |
1933 "movw %%si, (%%edi, %%eax, 2) \n\t" | |
1934 | |
1935 "movzbl (%5, %%ebx), %%edi \n\t" //src[xx] | |
1936 "movzbl 1(%5, %%ebx), %%esi \n\t" //src[xx+1] | |
1937 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
1938 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
1939 "shll $16, %%edi \n\t" | |
1940 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
1941 "movl %1, %%edi \n\t" | |
1942 "shrl $9, %%esi \n\t" | |
1943 "movw %%si, 4096(%%edi, %%eax, 2)\n\t" | |
1944 | |
1945 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF | |
1946 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry | |
1947 "addl $1, %%eax \n\t" | |
1948 "cmpl %2, %%eax \n\t" | |
1949 " jb 1b \n\t" | |
1950 | |
1951 :: "m" (src1), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF), | |
1952 "r" (src2) | |
1953 : "%eax", "%ebx", "%ecx", "%edi", "%esi" | |
1954 ); | |
1955 #ifdef HAVE_MMX2 | |
1956 } //if MMX2 cant be used | |
1957 #endif | |
1958 #else | |
2671 | 1959 int i; |
1960 unsigned int xpos=0; | |
1961 for(i=0;i<dstWidth;i++) | |
1962 { | |
1963 register unsigned int xx=xpos>>16; | |
1964 register unsigned int xalpha=(xpos&0xFFFF)>>9; | |
1965 dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha); | |
1966 dst[i+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha); | |
2566 | 1967 /* slower |
1968 dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha; | |
1969 dst[i+2048]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha; | |
1970 */ | |
2671 | 1971 xpos+=xInc; |
1972 } | |
2469 | 1973 #endif |
3272 | 1974 } |
1975 } | |
1976 | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1977 static void RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1978 int srcSliceH, uint8_t* dst[], int dstStride[]){ |
3344 | 1979 |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1980 /* 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
|
1981 const int srcW= c->srcW; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1982 const int dstW= c->dstW; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1983 const int dstH= c->dstH; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1984 const int chrDstW= c->chrDstW; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1985 const int lumXInc= c->lumXInc; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1986 const int chrXInc= c->chrXInc; |
4295 | 1987 const int dstFormat= c->dstFormat; |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1988 const int flags= c->flags; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1989 const int canMMX2BeUsed= c->canMMX2BeUsed; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1990 int16_t *vLumFilterPos= c->vLumFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1991 int16_t *vChrFilterPos= c->vChrFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1992 int16_t *hLumFilterPos= c->hLumFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1993 int16_t *hChrFilterPos= c->hChrFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1994 int16_t *vLumFilter= c->vLumFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1995 int16_t *vChrFilter= c->vChrFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1996 int16_t *hLumFilter= c->hLumFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1997 int16_t *hChrFilter= c->hChrFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1998 int16_t *lumMmxFilter= c->lumMmxFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1999 int16_t *chrMmxFilter= c->chrMmxFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2000 const int vLumFilterSize= c->vLumFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2001 const int vChrFilterSize= c->vChrFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2002 const int hLumFilterSize= c->hLumFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2003 const int hChrFilterSize= c->hChrFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2004 int16_t **lumPixBuf= c->lumPixBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2005 int16_t **chrPixBuf= c->chrPixBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2006 const int vLumBufSize= c->vLumBufSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2007 const int vChrBufSize= c->vChrBufSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2008 uint8_t *funnyYCode= c->funnyYCode; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2009 uint8_t *funnyUVCode= c->funnyUVCode; |
3344 | 2010 |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2011 /* 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
|
2012 int dstY= c->dstY; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2013 int lumBufIndex= c->lumBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2014 int chrBufIndex= c->chrBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2015 int lastInLumBuf= c->lastInLumBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2016 int lastInChrBuf= c->lastInChrBuf; |
3344 | 2017 |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2018 if(srcSliceY ==0){ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2019 lumBufIndex=0; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2020 chrBufIndex=0; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2021 dstY=0; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2022 lastInLumBuf= -1; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2023 lastInChrBuf= -1; |
3272 | 2024 } |
3344 | 2025 |
2026 for(;dstY < dstH; dstY++){ | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2027 unsigned char *dest =dst[0]+dstStride[0]*dstY; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2028 unsigned char *uDest=dst[1]+dstStride[1]*(dstY>>1); |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2029 unsigned char *vDest=dst[2]+dstStride[2]*(dstY>>1); |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2030 const int chrDstY= dstFormat==IMGFMT_YV12 ? (dstY>>1) : dstY; |
3344 | 2031 |
2032 const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input | |
2033 const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input | |
2034 const int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input | |
2035 const int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input | |
2036 | |
4290
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2037 //handle holes (FAST_BILINEAR & weird filters) |
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2038 if(firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1; |
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2039 if(firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1; |
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2040 //printf("%d %d %d\n", firstChrSrcY, lastInChrBuf, vChrBufSize); |
3344 | 2041 ASSERT(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1) |
2042 ASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1) | |
2216 | 2043 |
3344 | 2044 // Do we have enough lines in this slice to output the dstY line |
2045 if(lastLumSrcY < srcSliceY + srcSliceH && lastChrSrcY < ((srcSliceY + srcSliceH)>>1)) | |
2469 | 2046 { |
3344 | 2047 //Do horizontal scaling |
2048 while(lastInLumBuf < lastLumSrcY) | |
2049 { | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2050 uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0]; |
3344 | 2051 lumBufIndex++; |
4290
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2052 // printf("%d %d %d %d\n", lumBufIndex, vLumBufSize, lastInLumBuf, lastLumSrcY); |
3344 | 2053 ASSERT(lumBufIndex < 2*vLumBufSize) |
2054 ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH) | |
2055 ASSERT(lastInLumBuf + 1 - srcSliceY >= 0) | |
2056 // printf("%d %d\n", lumBufIndex, vLumBufSize); | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2057 RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2058 flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2059 funnyYCode); |
3344 | 2060 lastInLumBuf++; |
2061 } | |
2062 while(lastInChrBuf < lastChrSrcY) | |
2063 { | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2064 uint8_t *src1= src[1]+(lastInChrBuf + 1 - (srcSliceY>>1))*srcStride[1]; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2065 uint8_t *src2= src[2]+(lastInChrBuf + 1 - (srcSliceY>>1))*srcStride[2]; |
3344 | 2066 chrBufIndex++; |
2067 ASSERT(chrBufIndex < 2*vChrBufSize) | |
2068 ASSERT(lastInChrBuf + 1 - (srcSliceY>>1) < (srcSliceH>>1)) | |
2069 ASSERT(lastInChrBuf + 1 - (srcSliceY>>1) >= 0) | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2070 //FIXME replace parameters through context struct (some at least) |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2071 RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, (srcW+1)>>1, chrXInc, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2072 flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2073 funnyUVCode); |
3344 | 2074 lastInChrBuf++; |
2075 } | |
2076 //wrap buf index around to stay inside the ring buffer | |
2077 if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize; | |
2078 if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize; | |
2469 | 2079 } |
3344 | 2080 else // not enough lines left in this slice -> load the rest in the buffer |
2469 | 2081 { |
3344 | 2082 /* printf("%d %d Last:%d %d LastInBuf:%d %d Index:%d %d Y:%d FSize: %d %d BSize: %d %d\n", |
2083 firstChrSrcY,firstLumSrcY,lastChrSrcY,lastLumSrcY, | |
2084 lastInChrBuf,lastInLumBuf,chrBufIndex,lumBufIndex,dstY,vChrFilterSize,vLumFilterSize, | |
2085 vChrBufSize, vLumBufSize); | |
2086 */ | |
2087 //Do horizontal scaling | |
2088 while(lastInLumBuf+1 < srcSliceY + srcSliceH) | |
2469 | 2089 { |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2090 uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0]; |
3344 | 2091 lumBufIndex++; |
2092 ASSERT(lumBufIndex < 2*vLumBufSize) | |
2093 ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH) | |
2094 ASSERT(lastInLumBuf + 1 - srcSliceY >= 0) | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2095 RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2096 flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2097 funnyYCode); |
3344 | 2098 lastInLumBuf++; |
2469 | 2099 } |
3344 | 2100 while(lastInChrBuf+1 < ((srcSliceY + srcSliceH)>>1)) |
2101 { | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2102 uint8_t *src1= src[1]+(lastInChrBuf + 1 - (srcSliceY>>1))*srcStride[1]; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2103 uint8_t *src2= src[2]+(lastInChrBuf + 1 - (srcSliceY>>1))*srcStride[2]; |
3344 | 2104 chrBufIndex++; |
2105 ASSERT(chrBufIndex < 2*vChrBufSize) | |
2106 ASSERT(lastInChrBuf + 1 - (srcSliceY>>1) < (srcSliceH>>1)) | |
2107 ASSERT(lastInChrBuf + 1 - (srcSliceY>>1) >= 0) | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2108 RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, (srcW+1)>>1, chrXInc, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2109 flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2110 funnyUVCode); |
3344 | 2111 lastInChrBuf++; |
2112 } | |
2113 //wrap buf index around to stay inside the ring buffer | |
2114 if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize; | |
2115 if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize; | |
2116 break; //we cant output a dstY line so lets try with the next slice | |
2469 | 2117 } |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
2118 |
2748 | 2119 #ifdef HAVE_MMX |
3344 | 2120 b5Dither= dither8[dstY&1]; |
2121 g6Dither= dither4[dstY&1]; | |
2122 g5Dither= dither8[dstY&1]; | |
2123 r5Dither= dither8[(dstY+1)&1]; | |
2748 | 2124 #endif |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2125 if(dstY < dstH-2) |
3352 | 2126 { |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2127 if(dstFormat==IMGFMT_YV12) //YV12 |
3344 | 2128 { |
2129 if(dstY&1) uDest=vDest= NULL; //FIXME split functions in lumi / chromi | |
2130 if(vLumFilterSize == 1 && vChrFilterSize == 1) // Unscaled YV12 | |
2131 { | |
2132 int16_t *lumBuf = lumPixBuf[0]; | |
2133 int16_t *chrBuf= chrPixBuf[0]; | |
2134 RENAME(yuv2yuv1)(lumBuf, chrBuf, dest, uDest, vDest, dstW); | |
2135 } | |
2136 else //General YV12 | |
2137 { | |
2138 int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; | |
2139 int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | |
2140 RENAME(yuv2yuvX)( | |
2141 vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, | |
2142 vChrFilter+(dstY>>1)*vChrFilterSize, chrSrcPtr, vChrFilterSize, | |
2143 dest, uDest, vDest, dstW, | |
2144 lumMmxFilter+dstY*vLumFilterSize*4, chrMmxFilter+(dstY>>1)*vChrFilterSize*4); | |
2145 } | |
2146 } | |
2147 else | |
2148 { | |
2149 int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; | |
2150 int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | |
2151 | |
2152 ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); | |
2153 ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2); | |
2154 if(vLumFilterSize == 1 && vChrFilterSize == 2) //Unscaled RGB | |
2155 { | |
2156 int chrAlpha= vChrFilter[2*dstY+1]; | |
2157 | |
2158 RENAME(yuv2rgb1)(*lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1), | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2159 dest, dstW, chrAlpha, dstFormat, flags); |
3344 | 2160 } |
2161 else if(vLumFilterSize == 2 && vChrFilterSize == 2) //BiLinear Upscale RGB | |
2162 { | |
2163 int lumAlpha= vLumFilter[2*dstY+1]; | |
2164 int chrAlpha= vChrFilter[2*dstY+1]; | |
2165 | |
2166 RENAME(yuv2rgb2)(*lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1), | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2167 dest, dstW, lumAlpha, chrAlpha, dstFormat, flags); |
3344 | 2168 } |
2169 else //General RGB | |
2170 { | |
2171 RENAME(yuv2rgbX)( | |
2172 vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | |
2173 vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2174 dest, dstW, dstFormat, |
3344 | 2175 lumMmxFilter+dstY*vLumFilterSize*4, chrMmxFilter+dstY*vChrFilterSize*4); |
2176 } | |
2177 } | |
3352 | 2178 } |
2179 else // hmm looks like we cant use MMX here without overwriting this arrays tail | |
2180 { | |
2181 int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; | |
2182 int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2183 if(dstFormat==IMGFMT_YV12) //YV12 |
3352 | 2184 { |
2185 if(dstY&1) uDest=vDest= NULL; //FIXME split functions in lumi / chromi | |
2186 yuv2yuvXinC( | |
2187 vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, | |
2188 vChrFilter+(dstY>>1)*vChrFilterSize, chrSrcPtr, vChrFilterSize, | |
2189 dest, uDest, vDest, dstW); | |
2190 } | |
2191 else | |
2192 { | |
2193 ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); | |
2194 ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2); | |
2195 yuv2rgbXinC( | |
2196 vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | |
2197 vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2198 dest, dstW, dstFormat); |
3352 | 2199 } |
2200 } | |
3344 | 2201 } |
2534
cc9d3fd626f0
patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents:
2521
diff
changeset
|
2202 |
cc9d3fd626f0
patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents:
2521
diff
changeset
|
2203 #ifdef HAVE_MMX |
cc9d3fd626f0
patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents:
2521
diff
changeset
|
2204 __asm __volatile(SFENCE:::"memory"); |
2566 | 2205 __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
|
2206 #endif |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2207 /* store changed local vars back in the context */ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2208 c->dstY= dstY; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2209 c->lumBufIndex= lumBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2210 c->chrBufIndex= chrBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2211 c->lastInLumBuf= lastInLumBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2212 c->lastInChrBuf= lastInChrBuf; |
3641 | 2213 } |