annotate postproc/swscale_template.c @ 3678:265680bbdcfd

mix3to2 in SSE
author michael
date Sun, 23 Dec 2001 17:32:34 +0000
parents 33c560ffd3dc
children 666a946a71b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
2 // Software scaling and colorspace conversion routines for MPlayer
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
3
2269
95c48204bcd9 (C) fixed
arpi
parents: 2267
diff changeset
4 // Orginal C implementation by A'rpi/ESP-team <arpi@thot.banki.hu>
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
5 // current version mostly by Michael Niedermayer (michaelni@gmx.at)
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
6 // the parts written by michael are under GNU GPL
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
7
2540
f2e70944d02a fixed a warning
michael
parents: 2534
diff changeset
8 #undef MOVNTQ
2680
e8a534509557 green line fix for dstw%8!=0
michael
parents: 2671
diff changeset
9 #undef PAVGB
3136
michael
parents: 3126
diff changeset
10 #undef PREFETCH
michael
parents: 3126
diff changeset
11 #undef PREFETCHW
michael
parents: 3126
diff changeset
12 #undef EMMS
michael
parents: 3126
diff changeset
13 #undef SFENCE
michael
parents: 3126
diff changeset
14
michael
parents: 3126
diff changeset
15 #ifdef HAVE_3DNOW
michael
parents: 3126
diff changeset
16 /* On K6 femms is faster of emms. On K7 femms is directly mapped on emms. */
michael
parents: 3126
diff changeset
17 #define EMMS "femms"
michael
parents: 3126
diff changeset
18 #else
michael
parents: 3126
diff changeset
19 #define EMMS "emms"
michael
parents: 3126
diff changeset
20 #endif
michael
parents: 3126
diff changeset
21
michael
parents: 3126
diff changeset
22 #ifdef HAVE_3DNOW
michael
parents: 3126
diff changeset
23 #define PREFETCH "prefetch"
michael
parents: 3126
diff changeset
24 #define PREFETCHW "prefetchw"
michael
parents: 3126
diff changeset
25 #elif defined ( HAVE_MMX2 )
michael
parents: 3126
diff changeset
26 #define PREFETCH "prefetchnta"
michael
parents: 3126
diff changeset
27 #define PREFETCHW "prefetcht0"
michael
parents: 3126
diff changeset
28 #else
michael
parents: 3126
diff changeset
29 #define PREFETCH "/nop"
michael
parents: 3126
diff changeset
30 #define PREFETCHW "/nop"
michael
parents: 3126
diff changeset
31 #endif
michael
parents: 3126
diff changeset
32
michael
parents: 3126
diff changeset
33 #ifdef HAVE_MMX2
michael
parents: 3126
diff changeset
34 #define SFENCE "sfence"
michael
parents: 3126
diff changeset
35 #else
michael
parents: 3126
diff changeset
36 #define SFENCE "/nop"
michael
parents: 3126
diff changeset
37 #endif
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
38
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
39 #ifdef HAVE_MMX2
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
40 #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
41 #elif defined (HAVE_3DNOW)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
42 #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
43 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
44
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
45 #ifdef HAVE_MMX2
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
46 #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
47 #else
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
48 #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
49 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
50
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
51
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
52 #define YSCALEYUV2YV12X(x) \
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
53 "xorl %%eax, %%eax \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
54 "pxor %%mm3, %%mm3 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
55 "pxor %%mm4, %%mm4 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
56 "movl %0, %%edx \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
57 ".balign 16 \n\t" /* FIXME Unroll? */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
58 "1: \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
59 "movl (%1, %%edx, 4), %%esi \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
60 "movq (%2, %%edx, 8), %%mm0 \n\t" /* filterCoeff */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
61 "movq " #x "(%%esi, %%eax, 2), %%mm2 \n\t" /* srcData */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
62 "movq 8+" #x "(%%esi, %%eax, 2), %%mm5 \n\t" /* srcData */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
63 "pmulhw %%mm0, %%mm2 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
64 "pmulhw %%mm0, %%mm5 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
65 "paddw %%mm2, %%mm3 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
66 "paddw %%mm5, %%mm4 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
67 "addl $1, %%edx \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
68 " jnz 1b \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
69 "psraw $3, %%mm3 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
70 "psraw $3, %%mm4 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
71 "packuswb %%mm4, %%mm3 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
72 MOVNTQ(%%mm3, (%3, %%eax))\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
73 "addl $8, %%eax \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
74 "cmpl %4, %%eax \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
75 "pxor %%mm3, %%mm3 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
76 "pxor %%mm4, %%mm4 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
77 "movl %0, %%edx \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
78 "jb 1b \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
79
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
80 #define YSCALEYUV2YV121 \
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
81 "movl %2, %%eax \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
82 ".balign 16 \n\t" /* FIXME Unroll? */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
83 "1: \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
84 "movq (%0, %%eax, 2), %%mm0 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
85 "movq 8(%0, %%eax, 2), %%mm1 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
86 "psraw $7, %%mm0 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
87 "psraw $7, %%mm1 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
88 "packuswb %%mm1, %%mm0 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
89 MOVNTQ(%%mm0, (%1, %%eax))\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
90 "addl $8, %%eax \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
91 "jnc 1b \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
92
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
93 /*
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
94 :: "m" (-lumFilterSize), "m" (-chrFilterSize),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
95 "m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
96 "r" (dest), "m" (dstW),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
97 "m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
98 : "%eax", "%ebx", "%ecx", "%edx", "%esi"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
99 */
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
100 #define YSCALEYUV2RGBX \
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
101 "xorl %%eax, %%eax \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
102 ".balign 16 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
103 "1: \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
104 "movl %1, %%edx \n\t" /* -chrFilterSize */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
105 "movl %3, %%ebx \n\t" /* chrMmxFilter+lumFilterSize */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
106 "movl %7, %%ecx \n\t" /* chrSrc+lumFilterSize */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
107 "pxor %%mm3, %%mm3 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
108 "pxor %%mm4, %%mm4 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
109 "2: \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
110 "movl (%%ecx, %%edx, 4), %%esi \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
111 "movq (%%ebx, %%edx, 8), %%mm0 \n\t" /* filterCoeff */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
112 "movq (%%esi, %%eax), %%mm2 \n\t" /* UsrcData */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
113 "movq 4096(%%esi, %%eax), %%mm5 \n\t" /* VsrcData */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
114 "pmulhw %%mm0, %%mm2 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
115 "pmulhw %%mm0, %%mm5 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
116 "paddw %%mm2, %%mm3 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
117 "paddw %%mm5, %%mm4 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
118 "addl $1, %%edx \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
119 " jnz 2b \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
120 \
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
121 "movl %0, %%edx \n\t" /* -lumFilterSize */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
122 "movl %2, %%ebx \n\t" /* lumMmxFilter+lumFilterSize */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
123 "movl %6, %%ecx \n\t" /* lumSrc+lumFilterSize */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
124 "pxor %%mm1, %%mm1 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
125 "pxor %%mm7, %%mm7 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
126 "2: \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
127 "movl (%%ecx, %%edx, 4), %%esi \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
128 "movq (%%ebx, %%edx, 8), %%mm0 \n\t" /* filterCoeff */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
129 "movq (%%esi, %%eax, 2), %%mm2 \n\t" /* Y1srcData */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
130 "movq 8(%%esi, %%eax, 2), %%mm5 \n\t" /* Y2srcData */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
131 "pmulhw %%mm0, %%mm2 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
132 "pmulhw %%mm0, %%mm5 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
133 "paddw %%mm2, %%mm1 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
134 "paddw %%mm5, %%mm7 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
135 "addl $1, %%edx \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
136 " jnz 2b \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
137 \
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
138 "psubw w400, %%mm3 \n\t" /* (U-128)8*/\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
139 "psubw w400, %%mm4 \n\t" /* (V-128)8*/\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
140 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
141 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
142 "pmulhw ugCoeff, %%mm3 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
143 "pmulhw vgCoeff, %%mm4 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
144 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
145 "pmulhw ubCoeff, %%mm2 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
146 "pmulhw vrCoeff, %%mm5 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
147 "psubw w80, %%mm1 \n\t" /* 8(Y-16)*/\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
148 "psubw w80, %%mm7 \n\t" /* 8(Y-16)*/\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
149 "pmulhw yCoeff, %%mm1 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
150 "pmulhw yCoeff, %%mm7 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
151 /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
152 "paddw %%mm3, %%mm4 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
153 "movq %%mm2, %%mm0 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
154 "movq %%mm5, %%mm6 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
155 "movq %%mm4, %%mm3 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
156 "punpcklwd %%mm2, %%mm2 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
157 "punpcklwd %%mm5, %%mm5 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
158 "punpcklwd %%mm4, %%mm4 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
159 "paddw %%mm1, %%mm2 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
160 "paddw %%mm1, %%mm5 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
161 "paddw %%mm1, %%mm4 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
162 "punpckhwd %%mm0, %%mm0 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
163 "punpckhwd %%mm6, %%mm6 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
164 "punpckhwd %%mm3, %%mm3 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
165 "paddw %%mm7, %%mm0 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
166 "paddw %%mm7, %%mm6 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
167 "paddw %%mm7, %%mm3 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
168 /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
169 "packuswb %%mm0, %%mm2 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
170 "packuswb %%mm6, %%mm5 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
171 "packuswb %%mm3, %%mm4 \n\t"\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
172 "pxor %%mm7, %%mm7 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
173
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
174 #define FULL_YSCALEYUV2RGB \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
175 "pxor %%mm7, %%mm7 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
176 "movd %6, %%mm6 \n\t" /*yalpha1*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
177 "punpcklwd %%mm6, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
178 "punpcklwd %%mm6, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
179 "movd %7, %%mm5 \n\t" /*uvalpha1*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
180 "punpcklwd %%mm5, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
181 "punpcklwd %%mm5, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
182 "xorl %%eax, %%eax \n\t"\
2800
7847d6b7ad3d .balign or we¡­ll align by 64kb on some architectures
michael
parents: 2799
diff changeset
183 ".balign 16 \n\t"\
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
184 "1: \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
185 "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
186 "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
187 "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
188 "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
189 "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
190 "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
191 "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
192 "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
193 "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
194 "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
195 "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
196 "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
197 "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
198 "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
199 "psubw %%mm0, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
200 "psubw w80, %%mm1 \n\t" /* 8(Y-16)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
201 "psubw w400, %%mm3 \n\t" /* 8(U-128)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
202 "pmulhw yCoeff, %%mm1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
203 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
204 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
205 "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
206 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
207 "pmulhw ubCoeff, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
208 "psraw $4, %%mm0 \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
209 "pmulhw ugCoeff, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
210 "paddw %%mm4, %%mm0 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
211 "psubw w400, %%mm0 \n\t" /* (V-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
212 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
213 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
214 "movq %%mm0, %%mm4 \n\t" /* (V-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
215 "pmulhw vrCoeff, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
216 "pmulhw vgCoeff, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
217 "paddw %%mm1, %%mm3 \n\t" /* B*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
218 "paddw %%mm1, %%mm0 \n\t" /* R*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
219 "packuswb %%mm3, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
220 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
221 "packuswb %%mm0, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
222 "paddw %%mm4, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
223 "paddw %%mm2, %%mm1 \n\t" /* G*/\
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 "packuswb %%mm1, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
226
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
227 #define YSCALEYUV2RGB \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
228 "movd %6, %%mm6 \n\t" /*yalpha1*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
229 "punpcklwd %%mm6, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
230 "punpcklwd %%mm6, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
231 "movq %%mm6, asm_yalpha1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
232 "movd %7, %%mm5 \n\t" /*uvalpha1*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
233 "punpcklwd %%mm5, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
234 "punpcklwd %%mm5, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
235 "movq %%mm5, asm_uvalpha1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
236 "xorl %%eax, %%eax \n\t"\
2800
7847d6b7ad3d .balign or we¡­ll align by 64kb on some architectures
michael
parents: 2799
diff changeset
237 ".balign 16 \n\t"\
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
238 "1: \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
239 "movq (%2, %%eax), %%mm2 \n\t" /* uvbuf0[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
240 "movq (%3, %%eax), %%mm3 \n\t" /* uvbuf1[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
241 "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
242 "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
243 "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
244 "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
245 "movq asm_uvalpha1, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
246 "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
247 "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
248 "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
249 "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
250 "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
251 "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
252 "psubw w400, %%mm3 \n\t" /* (U-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
253 "psubw w400, %%mm4 \n\t" /* (V-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
254 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
255 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
256 "pmulhw ugCoeff, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
257 "pmulhw vgCoeff, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
258 /* 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
259 "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
260 "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
261 "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
262 "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
263 "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
264 "psubw %%mm7, %%mm6 \n\t" /* buf0[eax] - buf1[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
265 "pmulhw asm_yalpha1, %%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
266 "pmulhw asm_yalpha1, %%mm6 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
267 "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
268 "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
269 "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
270 "paddw %%mm6, %%mm7 \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
271 "pmulhw ubCoeff, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
272 "pmulhw vrCoeff, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
273 "psubw w80, %%mm1 \n\t" /* 8(Y-16)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
274 "psubw w80, %%mm7 \n\t" /* 8(Y-16)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
275 "pmulhw yCoeff, %%mm1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
276 "pmulhw yCoeff, %%mm7 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
277 /* 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
278 "paddw %%mm3, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
279 "movq %%mm2, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
280 "movq %%mm5, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
281 "movq %%mm4, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
282 "punpcklwd %%mm2, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
283 "punpcklwd %%mm5, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
284 "punpcklwd %%mm4, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
285 "paddw %%mm1, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
286 "paddw %%mm1, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
287 "paddw %%mm1, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
288 "punpckhwd %%mm0, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
289 "punpckhwd %%mm6, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
290 "punpckhwd %%mm3, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
291 "paddw %%mm7, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
292 "paddw %%mm7, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
293 "paddw %%mm7, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
294 /* 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
295 "packuswb %%mm0, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
296 "packuswb %%mm6, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
297 "packuswb %%mm3, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
298 "pxor %%mm7, %%mm7 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
299
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
300 #define YSCALEYUV2RGB1 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
301 "xorl %%eax, %%eax \n\t"\
2800
7847d6b7ad3d .balign or we¡­ll align by 64kb on some architectures
michael
parents: 2799
diff changeset
302 ".balign 16 \n\t"\
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
303 "1: \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
304 "movq (%2, %%eax), %%mm3 \n\t" /* uvbuf0[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
305 "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
306 "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
307 "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
308 "psubw w400, %%mm3 \n\t" /* (U-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
309 "psubw w400, %%mm4 \n\t" /* (V-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
310 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
311 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
312 "pmulhw ugCoeff, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
313 "pmulhw vgCoeff, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
314 /* 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
315 "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
316 "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
317 "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
318 "psraw $4, %%mm7 \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
319 "pmulhw ubCoeff, %%mm2 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
320 "pmulhw vrCoeff, %%mm5 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
321 "psubw w80, %%mm1 \n\t" /* 8(Y-16)*/\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
322 "psubw w80, %%mm7 \n\t" /* 8(Y-16)*/\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
323 "pmulhw yCoeff, %%mm1 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
324 "pmulhw yCoeff, %%mm7 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
325 /* 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
326 "paddw %%mm3, %%mm4 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
327 "movq %%mm2, %%mm0 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
328 "movq %%mm5, %%mm6 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
329 "movq %%mm4, %%mm3 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
330 "punpcklwd %%mm2, %%mm2 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
331 "punpcklwd %%mm5, %%mm5 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
332 "punpcklwd %%mm4, %%mm4 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
333 "paddw %%mm1, %%mm2 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
334 "paddw %%mm1, %%mm5 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
335 "paddw %%mm1, %%mm4 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
336 "punpckhwd %%mm0, %%mm0 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
337 "punpckhwd %%mm6, %%mm6 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
338 "punpckhwd %%mm3, %%mm3 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
339 "paddw %%mm7, %%mm0 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
340 "paddw %%mm7, %%mm6 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
341 "paddw %%mm7, %%mm3 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
342 /* 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
343 "packuswb %%mm0, %%mm2 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
344 "packuswb %%mm6, %%mm5 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
345 "packuswb %%mm3, %%mm4 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
346 "pxor %%mm7, %%mm7 \n\t"
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
347
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
348 // do vertical chrominance interpolation
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
349 #define YSCALEYUV2RGB1b \
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
350 "xorl %%eax, %%eax \n\t"\
2800
7847d6b7ad3d .balign or we¡­ll align by 64kb on some architectures
michael
parents: 2799
diff changeset
351 ".balign 16 \n\t"\
2569
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
352 "1: \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
353 "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
354 "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
355 "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
356 "movq 4096(%3, %%eax), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
357 "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax] + uvbuf1[eax]*/\
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
358 "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048] + uvbuf1[eax+2048]*/\
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
359 "psrlw $5, %%mm3 \n\t" /*FIXME might overflow*/\
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
360 "psrlw $5, %%mm4 \n\t" /*FIXME might overflow*/\
2569
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
361 "psubw w400, %%mm3 \n\t" /* (U-128)8*/\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
362 "psubw w400, %%mm4 \n\t" /* (V-128)8*/\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
363 "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
364 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
365 "pmulhw ugCoeff, %%mm3 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
366 "pmulhw vgCoeff, %%mm4 \n\t"\
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
367 /* 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
368 "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
369 "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
370 "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
371 "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
372 "pmulhw ubCoeff, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
373 "pmulhw vrCoeff, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
374 "psubw w80, %%mm1 \n\t" /* 8(Y-16)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
375 "psubw w80, %%mm7 \n\t" /* 8(Y-16)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
376 "pmulhw yCoeff, %%mm1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
377 "pmulhw yCoeff, %%mm7 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
378 /* 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
379 "paddw %%mm3, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
380 "movq %%mm2, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
381 "movq %%mm5, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
382 "movq %%mm4, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
383 "punpcklwd %%mm2, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
384 "punpcklwd %%mm5, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
385 "punpcklwd %%mm4, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
386 "paddw %%mm1, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
387 "paddw %%mm1, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
388 "paddw %%mm1, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
389 "punpckhwd %%mm0, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
390 "punpckhwd %%mm6, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
391 "punpckhwd %%mm3, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
392 "paddw %%mm7, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
393 "paddw %%mm7, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
394 "paddw %%mm7, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
395 /* 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
396 "packuswb %%mm0, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
397 "packuswb %%mm6, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
398 "packuswb %%mm3, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
399 "pxor %%mm7, %%mm7 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
400
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
401 #define WRITEBGR32 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
402 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
403 "movq %%mm2, %%mm1 \n\t" /* B */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
404 "movq %%mm5, %%mm6 \n\t" /* R */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
405 "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
406 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
407 "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
408 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
409 "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
410 "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
411 "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
412 "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
413 "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
414 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
415 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
416 MOVNTQ(%%mm0, (%4, %%eax, 4))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
417 MOVNTQ(%%mm2, 8(%4, %%eax, 4))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
418 MOVNTQ(%%mm1, 16(%4, %%eax, 4))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
419 MOVNTQ(%%mm3, 24(%4, %%eax, 4))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
420 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
421 "addl $8, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
422 "cmpl %5, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
423 " jb 1b \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
424
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
425 #define WRITEBGR16 \
2669
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
426 "pand bF8, %%mm2 \n\t" /* B */\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
427 "pand bFC, %%mm4 \n\t" /* G */\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
428 "pand bF8, %%mm5 \n\t" /* R */\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
429 "psrlq $3, %%mm2 \n\t"\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
430 \
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
431 "movq %%mm2, %%mm1 \n\t"\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
432 "movq %%mm4, %%mm3 \n\t"\
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
433 \
2669
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
434 "punpcklbw %%mm7, %%mm3 \n\t"\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
435 "punpcklbw %%mm5, %%mm2 \n\t"\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
436 "punpckhbw %%mm7, %%mm4 \n\t"\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
437 "punpckhbw %%mm5, %%mm1 \n\t"\
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
438 \
2669
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
439 "psllq $3, %%mm3 \n\t"\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
440 "psllq $3, %%mm4 \n\t"\
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
441 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
442 "por %%mm3, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
443 "por %%mm4, %%mm1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
444 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
445 MOVNTQ(%%mm2, (%4, %%eax, 2))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
446 MOVNTQ(%%mm1, 8(%4, %%eax, 2))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
447 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
448 "addl $8, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
449 "cmpl %5, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
450 " jb 1b \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
451
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
452 #define WRITEBGR15 \
2669
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
453 "pand bF8, %%mm2 \n\t" /* B */\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
454 "pand bF8, %%mm4 \n\t" /* G */\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
455 "pand bF8, %%mm5 \n\t" /* R */\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
456 "psrlq $3, %%mm2 \n\t"\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
457 "psrlq $1, %%mm5 \n\t"\
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
458 \
2669
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
459 "movq %%mm2, %%mm1 \n\t"\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
460 "movq %%mm4, %%mm3 \n\t"\
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
461 \
2669
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
462 "punpcklbw %%mm7, %%mm3 \n\t"\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
463 "punpcklbw %%mm5, %%mm2 \n\t"\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
464 "punpckhbw %%mm7, %%mm4 \n\t"\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
465 "punpckhbw %%mm5, %%mm1 \n\t"\
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
466 \
2669
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
467 "psllq $2, %%mm3 \n\t"\
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
468 "psllq $2, %%mm4 \n\t"\
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
469 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
470 "por %%mm3, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
471 "por %%mm4, %%mm1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
472 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
473 MOVNTQ(%%mm2, (%4, %%eax, 2))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
474 MOVNTQ(%%mm1, 8(%4, %%eax, 2))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
475 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
476 "addl $8, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
477 "cmpl %5, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
478 " jb 1b \n\t"
2669
476b9b3b91be faster bgr15/16
michael
parents: 2638
diff changeset
479
2730
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
480 #define WRITEBGR24OLD \
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
481 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
482 "movq %%mm2, %%mm1 \n\t" /* B */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
483 "movq %%mm5, %%mm6 \n\t" /* R */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
484 "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
485 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
486 "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
487 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
488 "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
489 "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\
2326
7d3542955132 BGR24 bugfix
michael
parents: 2316
diff changeset
490 "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\
7d3542955132 BGR24 bugfix
michael
parents: 2316
diff changeset
491 "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\
7d3542955132 BGR24 bugfix
michael
parents: 2316
diff changeset
492 "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\
7d3542955132 BGR24 bugfix
michael
parents: 2316
diff changeset
493 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
494 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
495 "movq %%mm0, %%mm4 \n\t" /* 0RGB0RGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
496 "psrlq $8, %%mm0 \n\t" /* 00RGB0RG 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
497 "pand bm00000111, %%mm4 \n\t" /* 00000RGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
498 "pand bm11111000, %%mm0 \n\t" /* 00RGB000 0.5 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
499 "por %%mm4, %%mm0 \n\t" /* 00RGBRGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
500 "movq %%mm2, %%mm4 \n\t" /* 0RGB0RGB 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
501 "psllq $48, %%mm2 \n\t" /* GB000000 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
502 "por %%mm2, %%mm0 \n\t" /* GBRGBRGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
503 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
504 "movq %%mm4, %%mm2 \n\t" /* 0RGB0RGB 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
505 "psrld $16, %%mm4 \n\t" /* 000R000R 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
506 "psrlq $24, %%mm2 \n\t" /* 0000RGB0 1.5 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
507 "por %%mm4, %%mm2 \n\t" /* 000RRGBR 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
508 "pand bm00001111, %%mm2 \n\t" /* 0000RGBR 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
509 "movq %%mm1, %%mm4 \n\t" /* 0RGB0RGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
510 "psrlq $8, %%mm1 \n\t" /* 00RGB0RG 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
511 "pand bm00000111, %%mm4 \n\t" /* 00000RGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
512 "pand bm11111000, %%mm1 \n\t" /* 00RGB000 2.5 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
513 "por %%mm4, %%mm1 \n\t" /* 00RGBRGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
514 "movq %%mm1, %%mm4 \n\t" /* 00RGBRGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
515 "psllq $32, %%mm1 \n\t" /* BRGB0000 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
516 "por %%mm1, %%mm2 \n\t" /* BRGBRGBR 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
517 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
518 "psrlq $32, %%mm4 \n\t" /* 000000RG 2.5 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
519 "movq %%mm3, %%mm5 \n\t" /* 0RGB0RGB 3 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
520 "psrlq $8, %%mm3 \n\t" /* 00RGB0RG 3 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
521 "pand bm00000111, %%mm5 \n\t" /* 00000RGB 3 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
522 "pand bm11111000, %%mm3 \n\t" /* 00RGB000 3.5 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
523 "por %%mm5, %%mm3 \n\t" /* 00RGBRGB 3 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
524 "psllq $16, %%mm3 \n\t" /* RGBRGB00 3 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
525 "por %%mm4, %%mm3 \n\t" /* RGBRGBRG 2.5 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
526 \
2728
96c1d1e6cb9e only 6 registers used
michael
parents: 2680
diff changeset
527 MOVNTQ(%%mm0, (%%ebx))\
96c1d1e6cb9e only 6 registers used
michael
parents: 2680
diff changeset
528 MOVNTQ(%%mm2, 8(%%ebx))\
96c1d1e6cb9e only 6 registers used
michael
parents: 2680
diff changeset
529 MOVNTQ(%%mm3, 16(%%ebx))\
96c1d1e6cb9e only 6 registers used
michael
parents: 2680
diff changeset
530 "addl $24, %%ebx \n\t"\
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
531 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
532 "addl $8, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
533 "cmpl %5, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
534 " jb 1b \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
535
2730
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
536 #define WRITEBGR24MMX \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
537 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
538 "movq %%mm2, %%mm1 \n\t" /* B */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
539 "movq %%mm5, %%mm6 \n\t" /* R */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
540 "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
541 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
542 "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
543 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
544 "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
545 "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
546 "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
547 "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
548 "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
549 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
550 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
551 "movq %%mm0, %%mm4 \n\t" /* 0RGB0RGB 0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
552 "movq %%mm2, %%mm6 \n\t" /* 0RGB0RGB 1 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
553 "movq %%mm1, %%mm5 \n\t" /* 0RGB0RGB 2 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
554 "movq %%mm3, %%mm7 \n\t" /* 0RGB0RGB 3 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
555 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
556 "psllq $40, %%mm0 \n\t" /* RGB00000 0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
557 "psllq $40, %%mm2 \n\t" /* RGB00000 1 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
558 "psllq $40, %%mm1 \n\t" /* RGB00000 2 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
559 "psllq $40, %%mm3 \n\t" /* RGB00000 3 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
560 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
561 "punpckhdq %%mm4, %%mm0 \n\t" /* 0RGBRGB0 0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
562 "punpckhdq %%mm6, %%mm2 \n\t" /* 0RGBRGB0 1 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
563 "punpckhdq %%mm5, %%mm1 \n\t" /* 0RGBRGB0 2 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
564 "punpckhdq %%mm7, %%mm3 \n\t" /* 0RGBRGB0 3 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
565 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
566 "psrlq $8, %%mm0 \n\t" /* 00RGBRGB 0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
567 "movq %%mm2, %%mm6 \n\t" /* 0RGBRGB0 1 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
568 "psllq $40, %%mm2 \n\t" /* GB000000 1 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
569 "por %%mm2, %%mm0 \n\t" /* GBRGBRGB 0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
570 MOVNTQ(%%mm0, (%%ebx))\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
571 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
572 "psrlq $24, %%mm6 \n\t" /* 0000RGBR 1 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
573 "movq %%mm1, %%mm5 \n\t" /* 0RGBRGB0 2 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
574 "psllq $24, %%mm1 \n\t" /* BRGB0000 2 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
575 "por %%mm1, %%mm6 \n\t" /* BRGBRGBR 1 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
576 MOVNTQ(%%mm6, 8(%%ebx))\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
577 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
578 "psrlq $40, %%mm5 \n\t" /* 000000RG 2 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
579 "psllq $8, %%mm3 \n\t" /* RGBRGB00 3 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
580 "por %%mm3, %%mm5 \n\t" /* RGBRGBRG 2 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
581 MOVNTQ(%%mm5, 16(%%ebx))\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
582 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
583 "addl $24, %%ebx \n\t"\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
584 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
585 "addl $8, %%eax \n\t"\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
586 "cmpl %5, %%eax \n\t"\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
587 " jb 1b \n\t"
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
588
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
589 #define WRITEBGR24MMX2 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
590 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
591 "movq M24A, %%mm0 \n\t"\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
592 "movq M24C, %%mm7 \n\t"\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
593 "pshufw $0x50, %%mm2, %%mm1 \n\t" /* B3 B2 B3 B2 B1 B0 B1 B0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
594 "pshufw $0x50, %%mm4, %%mm3 \n\t" /* G3 G2 G3 G2 G1 G0 G1 G0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
595 "pshufw $0x00, %%mm5, %%mm6 \n\t" /* R1 R0 R1 R0 R1 R0 R1 R0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
596 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
597 "pand %%mm0, %%mm1 \n\t" /* B2 B1 B0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
598 "pand %%mm0, %%mm3 \n\t" /* G2 G1 G0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
599 "pand %%mm7, %%mm6 \n\t" /* R1 R0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
600 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
601 "psllq $8, %%mm3 \n\t" /* G2 G1 G0 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
602 "por %%mm1, %%mm6 \n\t"\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
603 "por %%mm3, %%mm6 \n\t"\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
604 MOVNTQ(%%mm6, (%%ebx))\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
605 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
606 "psrlq $8, %%mm4 \n\t" /* 00 G7 G6 G5 G4 G3 G2 G1 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
607 "pshufw $0xA5, %%mm2, %%mm1 \n\t" /* B5 B4 B5 B4 B3 B2 B3 B2 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
608 "pshufw $0x55, %%mm4, %%mm3 \n\t" /* G4 G3 G4 G3 G4 G3 G4 G3 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
609 "pshufw $0xA5, %%mm5, %%mm6 \n\t" /* R5 R4 R5 R4 R3 R2 R3 R2 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
610 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
611 "pand M24B, %%mm1 \n\t" /* B5 B4 B3 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
612 "pand %%mm7, %%mm3 \n\t" /* G4 G3 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
613 "pand %%mm0, %%mm6 \n\t" /* R4 R3 R2 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
614 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
615 "por %%mm1, %%mm3 \n\t" /* B5 G4 B4 G3 B3 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
616 "por %%mm3, %%mm6 \n\t"\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
617 MOVNTQ(%%mm6, 8(%%ebx))\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
618 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
619 "pshufw $0xFF, %%mm2, %%mm1 \n\t" /* B7 B6 B7 B6 B7 B6 B6 B7 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
620 "pshufw $0xFA, %%mm4, %%mm3 \n\t" /* 00 G7 00 G7 G6 G5 G6 G5 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
621 "pshufw $0xFA, %%mm5, %%mm6 \n\t" /* R7 R6 R7 R6 R5 R4 R5 R4 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
622 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
623 "pand %%mm7, %%mm1 \n\t" /* B7 B6 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
624 "pand %%mm0, %%mm3 \n\t" /* G7 G6 G5 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
625 "pand M24B, %%mm6 \n\t" /* R7 R6 R5 */\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
626 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
627 "por %%mm1, %%mm3 \n\t"\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
628 "por %%mm3, %%mm6 \n\t"\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
629 MOVNTQ(%%mm6, 16(%%ebx))\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
630 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
631 "addl $24, %%ebx \n\t"\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
632 \
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
633 "addl $8, %%eax \n\t"\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
634 "cmpl %5, %%eax \n\t"\
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
635 " jb 1b \n\t"
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
636
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
637 #ifdef HAVE_MMX2
3126
e71ae0213431 runtime cpu detection
michael
parents: 2800
diff changeset
638 #undef WRITEBGR24
2730
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
639 #define WRITEBGR24 WRITEBGR24MMX2
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
640 #else
3126
e71ae0213431 runtime cpu detection
michael
parents: 2800
diff changeset
641 #undef WRITEBGR24
2730
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
642 #define WRITEBGR24 WRITEBGR24MMX
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
643 #endif
c483fc9bf0c4 faster bgr24 output
michael
parents: 2728
diff changeset
644
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
645 static inline void RENAME(yuv2yuvX)(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
646 int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
647 uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
648 int16_t * lumMmxFilter, int16_t * chrMmxFilter)
2519
6f3fa9bc3b27 yv12 to yv12 scaler
michael
parents: 2503
diff changeset
649 {
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
650 #ifdef HAVE_MMX
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
651 if(uDest != NULL)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
652 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
653 asm volatile(
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
654 YSCALEYUV2YV12X(0)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
655 :: "m" (-chrFilterSize), "r" (chrSrc+chrFilterSize),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
656 "r" (chrMmxFilter+chrFilterSize*4), "r" (uDest), "m" (dstW>>1)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
657 : "%eax", "%edx", "%esi"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
658 );
2519
6f3fa9bc3b27 yv12 to yv12 scaler
michael
parents: 2503
diff changeset
659
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
660 asm volatile(
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
661 YSCALEYUV2YV12X(4096)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
662 :: "m" (-chrFilterSize), "r" (chrSrc+chrFilterSize),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
663 "r" (chrMmxFilter+chrFilterSize*4), "r" (vDest), "m" (dstW>>1)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
664 : "%eax", "%edx", "%esi"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
665 );
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
666 }
2521
b70a77066611 tell the c compiler that the memory changed
michael
parents: 2520
diff changeset
667
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
668 asm volatile(
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
669 YSCALEYUV2YV12X(0)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
670 :: "m" (-lumFilterSize), "r" (lumSrc+lumFilterSize),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
671 "r" (lumMmxFilter+lumFilterSize*4), "r" (dest), "m" (dstW)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
672 : "%eax", "%edx", "%esi"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
673 );
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
674 #else
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
675 yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize,
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
676 chrFilter, chrSrc, chrFilterSize,
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
677 dest, uDest, vDest, dstW);
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
678 #endif
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
679 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
680
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
681 static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
682 uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
683 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
684 #ifdef HAVE_MMX
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
685 if(uDest != NULL)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
686 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
687 asm volatile(
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
688 YSCALEYUV2YV121
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
689 :: "r" (chrSrc + (dstW>>1)), "r" (uDest + (dstW>>1)),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
690 "g" (-(dstW>>1))
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
691 : "%eax"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
692 );
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
693
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
694 asm volatile(
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
695 YSCALEYUV2YV121
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
696 :: "r" (chrSrc + 2048 + (dstW>>1)), "r" (vDest + (dstW>>1)),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
697 "g" (-(dstW>>1))
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
698 : "%eax"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
699 );
2519
6f3fa9bc3b27 yv12 to yv12 scaler
michael
parents: 2503
diff changeset
700 }
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
701
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
702 asm volatile(
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
703 YSCALEYUV2YV121
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
704 :: "r" (lumSrc + dstW), "r" (dest + dstW),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
705 "g" (-dstW)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
706 : "%eax"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
707 );
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
708 #else
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
709 //FIXME Optimize (just quickly writen not opti..)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
710 //FIXME replace MINMAX with LUTs
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
711 int i;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
712 for(i=0; i<dstW; i++)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
713 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
714 int val= lumSrc[i]>>7;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
715
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
716 dest[i]= MIN(MAX(val>>19, 0), 255);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
717 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
718
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
719 if(uDest != NULL)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
720 for(i=0; i<(dstW>>1); i++)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
721 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
722 int u=chrSrc[i]>>7;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
723 int v=chrSrc[i + 2048]>>7;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
724
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
725 uDest[i]= MIN(MAX(u>>19, 0), 255);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
726 vDest[i]= MIN(MAX(v>>19, 0), 255);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
727 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
728 #endif
2519
6f3fa9bc3b27 yv12 to yv12 scaler
michael
parents: 2503
diff changeset
729 }
6f3fa9bc3b27 yv12 to yv12 scaler
michael
parents: 2503
diff changeset
730
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
731
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
732 /**
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
733 * vertical scale YV12 to RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
734 */
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
735 static inline void RENAME(yuv2rgbX)(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
736 int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
737 uint8_t *dest, int dstW, int dstbpp, int16_t * lumMmxFilter, int16_t * chrMmxFilter)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
738 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
739 if(fullUVIpol)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
740 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
741 //FIXME
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
742 }//FULL_UV_IPOL
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
743 else
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
744 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
745 #ifdef HAVE_MMX
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
746 if(dstbpp == 32) //FIXME untested
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
747 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
748 asm volatile(
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
749 YSCALEYUV2RGBX
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
750 WRITEBGR32
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
751
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
752 :: "m" (-lumFilterSize), "m" (-chrFilterSize),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
753 "m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
754 "r" (dest), "m" (dstW),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
755 "m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
756 : "%eax", "%ebx", "%ecx", "%edx", "%esi"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
757 );
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
758 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
759 else if(dstbpp==24) //FIXME untested
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
760 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
761 asm volatile(
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
762 YSCALEYUV2RGBX
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
763 "leal (%%eax, %%eax, 2), %%ebx \n\t" //FIXME optimize
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
764 "addl %4, %%ebx \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
765 WRITEBGR24
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
766
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
767 :: "m" (-lumFilterSize), "m" (-chrFilterSize),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
768 "m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
769 "r" (dest), "m" (dstW),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
770 "m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
771 : "%eax", "%ebx", "%ecx", "%edx", "%esi"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
772 );
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
773 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
774 else if(dstbpp==15)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
775 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
776 asm volatile(
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
777 YSCALEYUV2RGBX
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
778 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
779 #ifdef DITHER1XBPP
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
780 "paddusb b5Dither, %%mm2 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
781 "paddusb g5Dither, %%mm4 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
782 "paddusb r5Dither, %%mm5 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
783 #endif
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
784
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
785 WRITEBGR15
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
786
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
787 :: "m" (-lumFilterSize), "m" (-chrFilterSize),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
788 "m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
789 "r" (dest), "m" (dstW),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
790 "m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
791 : "%eax", "%ebx", "%ecx", "%edx", "%esi"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
792 );
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
793 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
794 else if(dstbpp==16)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
795 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
796 asm volatile(
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
797 YSCALEYUV2RGBX
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
798 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
799 #ifdef DITHER1XBPP
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
800 "paddusb b5Dither, %%mm2 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
801 "paddusb g6Dither, %%mm4 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
802 "paddusb r5Dither, %%mm5 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
803 #endif
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
804
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
805 WRITEBGR16
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
806
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
807 :: "m" (-lumFilterSize), "m" (-chrFilterSize),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
808 "m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
809 "r" (dest), "m" (dstW),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
810 "m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
811 : "%eax", "%ebx", "%ecx", "%edx", "%esi"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
812 );
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
813 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
814 #else
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
815 yuv2rgbXinC(lumFilter, lumSrc, lumFilterSize,
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
816 chrFilter, chrSrc, chrFilterSize,
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
817 dest, dstW, dstbpp);
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
818
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
819 #endif
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
820 } //!FULL_UV_IPOL
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
821 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
822
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
823
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
824 /**
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
825 * vertical bilinear scale YV12 to RGB
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
826 */
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
827 static inline void RENAME(yuv2rgb2)(uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, uint16_t *uvbuf1,
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
828 uint8_t *dest, int dstW, int yalpha, int uvalpha, int dstbpp)
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
829 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
830 int yalpha1=yalpha^4095;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
831 int uvalpha1=uvalpha^4095;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
832
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
833 if(fullUVIpol)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
834 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
835
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
836 #ifdef HAVE_MMX
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
837 if(dstbpp == 32)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
838 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
839 asm volatile(
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
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
842 FULL_YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
843 "punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
844 "punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0
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 "movq %%mm3, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
847 "punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
848 "punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0
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 MOVNTQ(%%mm3, (%4, %%eax, 4))
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
851 MOVNTQ(%%mm1, 8(%4, %%eax, 4))
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 "addl $4, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
854 "cmpl %5, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
855 " jb 1b \n\t"
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
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
858 :: "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
859 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
860 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
861 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
862 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
863 else if(dstbpp==24)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
864 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
865 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
866
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
867 FULL_YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
868
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
869 // lsb ... msb
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
870 "punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
871 "punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0
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 "movq %%mm3, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
874 "punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
875 "punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
876
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
877 "movq %%mm3, %%mm2 \n\t" // BGR0BGR0
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
878 "psrlq $8, %%mm3 \n\t" // GR0BGR00
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
879 "pand bm00000111, %%mm2 \n\t" // BGR00000
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
880 "pand bm11111000, %%mm3 \n\t" // 000BGR00
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
881 "por %%mm2, %%mm3 \n\t" // BGRBGR00
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
882 "movq %%mm1, %%mm2 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
883 "psllq $48, %%mm1 \n\t" // 000000BG
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
884 "por %%mm1, %%mm3 \n\t" // BGRBGRBG
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
885
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
886 "movq %%mm2, %%mm1 \n\t" // BGR0BGR0
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
887 "psrld $16, %%mm2 \n\t" // R000R000
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
888 "psrlq $24, %%mm1 \n\t" // 0BGR0000
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
889 "por %%mm2, %%mm1 \n\t" // RBGRR000
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
890
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
891 "movl %4, %%ebx \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
892 "addl %%eax, %%ebx \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
893
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
894 #ifdef HAVE_MMX2
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
895 //FIXME Alignment
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
896 "movntq %%mm3, (%%ebx, %%eax, 2)\n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
897 "movntq %%mm1, 8(%%ebx, %%eax, 2)\n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
898 #else
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
899 "movd %%mm3, (%%ebx, %%eax, 2) \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
900 "psrlq $32, %%mm3 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
901 "movd %%mm3, 4(%%ebx, %%eax, 2) \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
902 "movd %%mm1, 8(%%ebx, %%eax, 2) \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
903 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
904 "addl $4, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
905 "cmpl %5, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
906 " jb 1b \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
907
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
908 :: "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
909 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
910 : "%eax", "%ebx"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
911 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
912 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
913 else if(dstbpp==15)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
914 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
915 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
916
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
917 FULL_YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
918 #ifdef DITHER1XBPP
2748
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
919 "paddusb g5Dither, %%mm1 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
920 "paddusb r5Dither, %%mm0 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
921 "paddusb b5Dither, %%mm3 \n\t"
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
922 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
923 "punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
924 "punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
925 "punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
926
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
927 "psrlw $3, %%mm3 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
928 "psllw $2, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
929 "psllw $7, %%mm0 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
930 "pand g15Mask, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
931 "pand r15Mask, %%mm0 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
932
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
933 "por %%mm3, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
934 "por %%mm1, %%mm0 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
935
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
936 MOVNTQ(%%mm0, (%4, %%eax, 2))
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 "addl $4, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
939 "cmpl %5, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
940 " jb 1b \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
941
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
942 :: "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
943 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
944 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
945 );
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 else if(dstbpp==16)
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 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
950
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
951 FULL_YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
952 #ifdef DITHER1XBPP
2748
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
953 "paddusb g6Dither, %%mm1 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
954 "paddusb r5Dither, %%mm0 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
955 "paddusb b5Dither, %%mm3 \n\t"
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
956 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
957 "punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
958 "punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
959 "punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
960
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
961 "psrlw $3, %%mm3 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
962 "psllw $3, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
963 "psllw $8, %%mm0 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
964 "pand g16Mask, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
965 "pand r16Mask, %%mm0 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
966
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
967 "por %%mm3, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
968 "por %%mm1, %%mm0 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
969
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
970 MOVNTQ(%%mm0, (%4, %%eax, 2))
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 "addl $4, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
973 "cmpl %5, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
974 " jb 1b \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
975
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
976 :: "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
977 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
978 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
979 );
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 #else
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
982 if(dstbpp==32 || dstbpp==24)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
983 {
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
984 int i;
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
985 for(i=0;i<dstW;i++){
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
986 // vertical linear interpolation && yuv2rgb in a single step:
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
987 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
988 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
989 int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
2503
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
990 dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
991 dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
992 dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
993 dest+=dstbpp>>3;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
994 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
995 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
996 else if(dstbpp==16)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
997 {
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
998 int i;
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
999 for(i=0;i<dstW;i++){
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1000 // vertical linear interpolation && yuv2rgb in a single step:
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1001 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
1002 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
1003 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
1004
2572
f2353173d52c c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents: 2569
diff changeset
1005 ((uint16_t*)dest)[i] =
2584
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1006 clip_table16b[(Y + yuvtab_40cf[U]) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1007 clip_table16g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1008 clip_table16r[(Y + yuvtab_3343[V]) >>13];
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1009 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1010 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1011 else if(dstbpp==15)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1012 {
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1013 int i;
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
1014 for(i=0;i<dstW;i++){
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1015 // vertical linear interpolation && yuv2rgb in a single step:
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1016 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
1017 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
1018 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
1019
2572
f2353173d52c c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents: 2569
diff changeset
1020 ((uint16_t*)dest)[i] =
2584
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1021 clip_table15b[(Y + yuvtab_40cf[U]) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1022 clip_table15g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1023 clip_table15r[(Y + yuvtab_3343[V]) >>13];
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1024 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1025 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1026 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1027 }//FULL_UV_IPOL
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1028 else
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1029 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1030 #ifdef HAVE_MMX
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1031 if(dstbpp == 32)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1032 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1033 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1034 YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1035 WRITEBGR32
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1036
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
1037 :: "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
1038 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1039 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1040 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1041 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1042 else if(dstbpp==24)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1043 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1044 asm volatile(
2728
96c1d1e6cb9e only 6 registers used
michael
parents: 2680
diff changeset
1045 "movl %4, %%ebx \n\t"
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1046 YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1047 WRITEBGR24
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1048
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
1049 :: "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
1050 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1051 : "%eax", "%ebx"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1052 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1053 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1054 else if(dstbpp==15)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1055 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1056 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1057 YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1058 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1059 #ifdef DITHER1XBPP
2748
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1060 "paddusb b5Dither, %%mm2 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1061 "paddusb g5Dither, %%mm4 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1062 "paddusb r5Dither, %%mm5 \n\t"
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1063 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1064
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1065 WRITEBGR15
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1066
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
1067 :: "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
1068 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1069 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1070 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1071 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1072 else if(dstbpp==16)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1073 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1074 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1075 YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1076 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1077 #ifdef DITHER1XBPP
2748
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1078 "paddusb b5Dither, %%mm2 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1079 "paddusb g6Dither, %%mm4 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1080 "paddusb r5Dither, %%mm5 \n\t"
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1081 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1082
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1083 WRITEBGR16
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1084
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
1085 :: "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
1086 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1087 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1088 );
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 #else
2575
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1091 if(dstbpp==32)
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1092 {
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1093 int i;
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
1094 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
1095 // vertical linear interpolation && yuv2rgb in a single step:
2575
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1096 int Y1=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1097 int Y2=yuvtab_2568[((buf0[i+1]*yalpha1+buf1[i+1]*yalpha)>>19)];
2585
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1098 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19);
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1099 int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19);
2575
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1100
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1101 int Cb= yuvtab_40cf[U];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1102 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1103 int Cr= yuvtab_3343[V];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1104
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1105 dest[4*i+0]=clip_table[((Y1 + Cb) >>13)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1106 dest[4*i+1]=clip_table[((Y1 + Cg) >>13)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1107 dest[4*i+2]=clip_table[((Y1 + Cr) >>13)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1108
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1109 dest[4*i+4]=clip_table[((Y2 + Cb) >>13)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1110 dest[4*i+5]=clip_table[((Y2 + Cg) >>13)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1111 dest[4*i+6]=clip_table[((Y2 + Cr) >>13)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1112 }
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1113 }
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1114 else if(dstbpp==24)
2575
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1115 {
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1116 int i;
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
1117 for(i=0; i<dstW-1; i+=2){
2575
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1118 // vertical linear interpolation && yuv2rgb in a single step:
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1119 int Y1=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1120 int Y2=yuvtab_2568[((buf0[i+1]*yalpha1+buf1[i+1]*yalpha)>>19)];
2585
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1121 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19);
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1122 int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19);
2575
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1123
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1124 int Cb= yuvtab_40cf[U];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1125 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1126 int Cr= yuvtab_3343[V];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1127
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1128 dest[0]=clip_table[((Y1 + Cb) >>13)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1129 dest[1]=clip_table[((Y1 + Cg) >>13)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1130 dest[2]=clip_table[((Y1 + Cr) >>13)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1131
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1132 dest[3]=clip_table[((Y2 + Cb) >>13)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1133 dest[4]=clip_table[((Y2 + Cg) >>13)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1134 dest[5]=clip_table[((Y2 + Cr) >>13)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1135 dest+=6;
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1136 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1137 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1138 else if(dstbpp==16)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1139 {
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1140 int i;
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
1141 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
1142 // vertical linear interpolation && yuv2rgb in a single step:
2575
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1143 int Y1=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1144 int Y2=yuvtab_2568[((buf0[i+1]*yalpha1+buf1[i+1]*yalpha)>>19)];
2585
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1145 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19);
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1146 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
1147
2575
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1148 int Cb= yuvtab_40cf[U];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1149 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1150 int Cr= yuvtab_3343[V];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1151
2572
f2353173d52c c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents: 2569
diff changeset
1152 ((uint16_t*)dest)[i] =
2584
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1153 clip_table16b[(Y1 + Cb) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1154 clip_table16g[(Y1 + Cg) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1155 clip_table16r[(Y1 + Cr) >>13];
2575
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1156
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1157 ((uint16_t*)dest)[i+1] =
2584
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1158 clip_table16b[(Y2 + Cb) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1159 clip_table16g[(Y2 + Cg) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1160 clip_table16r[(Y2 + Cr) >>13];
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 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1163 else if(dstbpp==15)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1164 {
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1165 int i;
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
1166 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
1167 // vertical linear interpolation && yuv2rgb in a single step:
2575
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1168 int Y1=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1169 int Y2=yuvtab_2568[((buf0[i+1]*yalpha1+buf1[i+1]*yalpha)>>19)];
2585
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1170 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19);
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1171 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
1172
2575
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1173 int Cb= yuvtab_40cf[U];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1174 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1175 int Cr= yuvtab_3343[V];
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1176
2572
f2353173d52c c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents: 2569
diff changeset
1177 ((uint16_t*)dest)[i] =
2584
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1178 clip_table15b[(Y1 + Cb) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1179 clip_table15g[(Y1 + Cg) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1180 clip_table15r[(Y1 + Cr) >>13];
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1181
2575
37da7219ebaf c optimizations
michael
parents: 2572
diff changeset
1182 ((uint16_t*)dest)[i+1] =
2584
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1183 clip_table15b[(Y2 + Cb) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1184 clip_table15g[(Y2 + Cg) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1185 clip_table15r[(Y2 + Cr) >>13];
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1186 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1187 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1188 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1189 } //!FULL_UV_IPOL
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1190 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1191
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1192 /**
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1193 * YV12 to RGB without scaling or interpolating
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1194 */
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1195 static inline void RENAME(yuv2rgb1)(uint16_t *buf0, uint16_t *uvbuf0, uint16_t *uvbuf1,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1196 uint8_t *dest, int dstW, int uvalpha, int dstbpp)
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1197 {
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1198 int uvalpha1=uvalpha^4095;
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1199 const int yalpha1=0;
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1200
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1201 if(fullUVIpol || allwaysIpol)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1202 {
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1203 RENAME(yuv2rgb2)(buf0, buf0, uvbuf0, uvbuf1, dest, dstW, 0, uvalpha, dstbpp);
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1204 return;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1205 }
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1206
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1207 #ifdef HAVE_MMX
2569
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1208 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
1209 {
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1210 if(dstbpp == 32)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1211 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1212 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1213 YSCALEYUV2RGB1
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1214 WRITEBGR32
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1215 :: "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
1216 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1217 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1218 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1219 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1220 else if(dstbpp==24)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1221 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1222 asm volatile(
2728
96c1d1e6cb9e only 6 registers used
michael
parents: 2680
diff changeset
1223 "movl %4, %%ebx \n\t"
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1224 YSCALEYUV2RGB1
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1225 WRITEBGR24
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1226 :: "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
1227 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1228 : "%eax", "%ebx"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1229 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1230 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1231 else if(dstbpp==15)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1232 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1233 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1234 YSCALEYUV2RGB1
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1235 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1236 #ifdef DITHER1XBPP
2748
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1237 "paddusb b5Dither, %%mm2 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1238 "paddusb g5Dither, %%mm4 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1239 "paddusb r5Dither, %%mm5 \n\t"
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1240 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1241 WRITEBGR15
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1242 :: "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
1243 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1244 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1245 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1246 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1247 else if(dstbpp==16)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1248 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1249 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1250 YSCALEYUV2RGB1
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1251 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1252 #ifdef DITHER1XBPP
2748
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1253 "paddusb b5Dither, %%mm2 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1254 "paddusb g6Dither, %%mm4 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1255 "paddusb r5Dither, %%mm5 \n\t"
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1256 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1257
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1258 WRITEBGR16
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1259 :: "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
1260 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1261 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1262 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1263 }
2569
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1264 }
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1265 else
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1266 {
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1267 if(dstbpp == 32)
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1268 {
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1269 asm volatile(
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1270 YSCALEYUV2RGB1b
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1271 WRITEBGR32
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1272 :: "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
1273 "m" (yalpha1), "m" (uvalpha1)
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1274 : "%eax"
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1275 );
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1276 }
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1277 else if(dstbpp==24)
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1278 {
2569
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1279 asm volatile(
2728
96c1d1e6cb9e only 6 registers used
michael
parents: 2680
diff changeset
1280 "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
1281 YSCALEYUV2RGB1b
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1282 WRITEBGR24
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1283 :: "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
1284 "m" (yalpha1), "m" (uvalpha1)
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1285 : "%eax", "%ebx"
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1286 );
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1287 }
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1288 else if(dstbpp==15)
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1289 {
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1290 asm volatile(
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1291 YSCALEYUV2RGB1b
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1292 /* 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
1293 #ifdef DITHER1XBPP
2748
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1294 "paddusb b5Dither, %%mm2 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1295 "paddusb g5Dither, %%mm4 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1296 "paddusb r5Dither, %%mm5 \n\t"
2569
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1297 #endif
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1298 WRITEBGR15
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1299 :: "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
1300 "m" (yalpha1), "m" (uvalpha1)
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1301 : "%eax"
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1302 );
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1303 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1304 else if(dstbpp==16)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1305 {
2569
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1306 asm volatile(
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1307 YSCALEYUV2RGB1b
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1308 /* 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
1309 #ifdef DITHER1XBPP
2748
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1310 "paddusb b5Dither, %%mm2 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1311 "paddusb g6Dither, %%mm4 \n\t"
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
1312 "paddusb r5Dither, %%mm5 \n\t"
2569
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1313 #endif
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1314
2569
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1315 WRITEBGR16
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1316 :: "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
1317 "m" (yalpha1), "m" (uvalpha1)
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1318 : "%eax"
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1319 );
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1320 }
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1321 }
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1322 #else
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1323 //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
1324
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1325 if(dstbpp==32)
2569
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1326 {
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1327 int i;
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
1328 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
1329 // vertical linear interpolation && yuv2rgb in a single step:
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1330 int Y1=yuvtab_2568[buf0[i]>>7];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1331 int Y2=yuvtab_2568[buf0[i+1]>>7];
2585
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1332 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19);
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1333 int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19);
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1334
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1335 int Cb= yuvtab_40cf[U];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1336 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1337 int Cr= yuvtab_3343[V];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1338
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1339 dest[4*i+0]=clip_table[((Y1 + Cb) >>13)];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1340 dest[4*i+1]=clip_table[((Y1 + Cg) >>13)];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1341 dest[4*i+2]=clip_table[((Y1 + Cr) >>13)];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1342
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1343 dest[4*i+4]=clip_table[((Y2 + Cb) >>13)];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1344 dest[4*i+5]=clip_table[((Y2 + Cg) >>13)];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1345 dest[4*i+6]=clip_table[((Y2 + Cr) >>13)];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1346 }
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1347 }
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1348 else if(dstbpp==24)
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1349 {
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1350 int i;
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
1351 for(i=0; i<dstW-1; i+=2){
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1352 // vertical linear interpolation && yuv2rgb in a single step:
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1353 int Y1=yuvtab_2568[buf0[i]>>7];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1354 int Y2=yuvtab_2568[buf0[i+1]>>7];
2585
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1355 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19);
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1356 int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19);
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1357
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1358 int Cb= yuvtab_40cf[U];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1359 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1360 int Cr= yuvtab_3343[V];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1361
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1362 dest[0]=clip_table[((Y1 + Cb) >>13)];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1363 dest[1]=clip_table[((Y1 + Cg) >>13)];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1364 dest[2]=clip_table[((Y1 + Cr) >>13)];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1365
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1366 dest[3]=clip_table[((Y2 + Cb) >>13)];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1367 dest[4]=clip_table[((Y2 + Cg) >>13)];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1368 dest[5]=clip_table[((Y2 + Cr) >>13)];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1369 dest+=6;
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1370 }
2569
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1371 }
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1372 else if(dstbpp==16)
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1373 {
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1374 int i;
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
1375 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
1376 // vertical linear interpolation && yuv2rgb in a single step:
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1377 int Y1=yuvtab_2568[buf0[i]>>7];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1378 int Y2=yuvtab_2568[buf0[i+1]>>7];
2585
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1379 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19);
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1380 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
1381
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1382 int Cb= yuvtab_40cf[U];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1383 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1384 int Cr= yuvtab_3343[V];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1385
2572
f2353173d52c c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents: 2569
diff changeset
1386 ((uint16_t*)dest)[i] =
2584
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1387 clip_table16b[(Y1 + Cb) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1388 clip_table16g[(Y1 + Cg) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1389 clip_table16r[(Y1 + Cr) >>13];
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1390
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1391 ((uint16_t*)dest)[i+1] =
2584
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1392 clip_table16b[(Y2 + Cb) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1393 clip_table16g[(Y2 + Cg) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1394 clip_table16r[(Y2 + Cr) >>13];
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1395 }
2569
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1396 }
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1397 else if(dstbpp==15)
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1398 {
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1399 int i;
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
1400 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
1401 // vertical linear interpolation && yuv2rgb in a single step:
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1402 int Y1=yuvtab_2568[buf0[i]>>7];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1403 int Y2=yuvtab_2568[buf0[i+1]>>7];
2585
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1404 int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19);
bd52b78f12dc c speedup
michael
parents: 2584
diff changeset
1405 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
1406
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1407 int Cb= yuvtab_40cf[U];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1408 int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1409 int Cr= yuvtab_3343[V];
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1410
2572
f2353173d52c c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents: 2569
diff changeset
1411 ((uint16_t*)dest)[i] =
2584
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1412 clip_table15b[(Y1 + Cb) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1413 clip_table15g[(Y1 + Cg) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1414 clip_table15r[(Y1 + Cr) >>13];
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1415
2576
437ed06579d8 c optimizations
michael
parents: 2575
diff changeset
1416 ((uint16_t*)dest)[i+1] =
2584
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1417 clip_table15b[(Y2 + Cb) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1418 clip_table15g[(Y2 + Cg) >>13] |
6d20d5d5829f 15/16bit in C speedup
michael
parents: 2576
diff changeset
1419 clip_table15r[(Y2 + Cr) >>13];
2569
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1420 }
30b736e7feef interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents: 2566
diff changeset
1421 }
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1422 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1423 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1424
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1425 // Bilinear / Bicubic scaling
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1426 static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc,
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1427 int16_t *filter, int16_t *filterPos, int filterSize)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1428 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1429 #ifdef HAVE_MMX
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1430 if(filterSize==4) // allways true for upscaling, sometimes for down too
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1431 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1432 int counter= -2*dstW;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1433 filter-= counter*2;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1434 filterPos-= counter/2;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1435 dst-= counter/2;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1436 asm volatile(
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1437 "pxor %%mm7, %%mm7 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1438 "movq w02, %%mm6 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1439 "pushl %%ebp \n\t" // we use 7 regs here ...
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1440 "movl %%eax, %%ebp \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1441 ".balign 16 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1442 "1: \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1443 "movzwl (%2, %%ebp), %%eax \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1444 "movzwl 2(%2, %%ebp), %%ebx \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1445 "movq (%1, %%ebp, 4), %%mm1 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1446 "movq 8(%1, %%ebp, 4), %%mm3 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1447 "movd (%3, %%eax), %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1448 "movd (%3, %%ebx), %%mm2 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1449 "punpcklbw %%mm7, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1450 "punpcklbw %%mm7, %%mm2 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1451 "pmaddwd %%mm1, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1452 "pmaddwd %%mm2, %%mm3 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1453 "psrad $8, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1454 "psrad $8, %%mm3 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1455 "packssdw %%mm3, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1456 "pmaddwd %%mm6, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1457 "packssdw %%mm0, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1458 "movd %%mm0, (%4, %%ebp) \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1459 "addl $4, %%ebp \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1460 " jnc 1b \n\t"
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1461
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1462 "popl %%ebp \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1463 : "+a" (counter)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1464 : "c" (filter), "d" (filterPos), "S" (src), "D" (dst)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1465 : "%ebx"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1466 );
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1467 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1468 else if(filterSize==8)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1469 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1470 int counter= -2*dstW;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1471 filter-= counter*4;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1472 filterPos-= counter/2;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1473 dst-= counter/2;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1474 asm volatile(
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1475 "pxor %%mm7, %%mm7 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1476 "movq w02, %%mm6 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1477 "pushl %%ebp \n\t" // we use 7 regs here ...
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1478 "movl %%eax, %%ebp \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1479 ".balign 16 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1480 "1: \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1481 "movzwl (%2, %%ebp), %%eax \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1482 "movzwl 2(%2, %%ebp), %%ebx \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1483 "movq (%1, %%ebp, 8), %%mm1 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1484 "movq 16(%1, %%ebp, 8), %%mm3 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1485 "movd (%3, %%eax), %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1486 "movd (%3, %%ebx), %%mm2 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1487 "punpcklbw %%mm7, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1488 "punpcklbw %%mm7, %%mm2 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1489 "pmaddwd %%mm1, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1490 "pmaddwd %%mm2, %%mm3 \n\t"
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1491
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1492 "movq 8(%1, %%ebp, 8), %%mm1 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1493 "movq 24(%1, %%ebp, 8), %%mm5 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1494 "movd 4(%3, %%eax), %%mm4 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1495 "movd 4(%3, %%ebx), %%mm2 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1496 "punpcklbw %%mm7, %%mm4 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1497 "punpcklbw %%mm7, %%mm2 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1498 "pmaddwd %%mm1, %%mm4 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1499 "pmaddwd %%mm2, %%mm5 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1500 "paddd %%mm4, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1501 "paddd %%mm5, %%mm3 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1502
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1503 "psrad $8, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1504 "psrad $8, %%mm3 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1505 "packssdw %%mm3, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1506 "pmaddwd %%mm6, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1507 "packssdw %%mm0, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1508 "movd %%mm0, (%4, %%ebp) \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1509 "addl $4, %%ebp \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1510 " jnc 1b \n\t"
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1511
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1512 "popl %%ebp \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1513 : "+a" (counter)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1514 : "c" (filter), "d" (filterPos), "S" (src), "D" (dst)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1515 : "%ebx"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1516 );
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1517 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1518 else
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1519 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1520 int counter= -2*dstW;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1521 // filter-= counter*filterSize/2;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1522 filterPos-= counter/2;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1523 dst-= counter/2;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1524 asm volatile(
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1525 "pxor %%mm7, %%mm7 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1526 "movq w02, %%mm6 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1527 ".balign 16 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1528 "1: \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1529 "movl %2, %%ecx \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1530 "movzwl (%%ecx, %0), %%eax \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1531 "movzwl 2(%%ecx, %0), %%ebx \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1532 "movl %5, %%ecx \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1533 "pxor %%mm4, %%mm4 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1534 "pxor %%mm5, %%mm5 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1535 "2: \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1536 "movq (%1), %%mm1 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1537 "movq (%1, %6), %%mm3 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1538 "movd (%%ecx, %%eax), %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1539 "movd (%%ecx, %%ebx), %%mm2 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1540 "punpcklbw %%mm7, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1541 "punpcklbw %%mm7, %%mm2 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1542 "pmaddwd %%mm1, %%mm0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1543 "pmaddwd %%mm2, %%mm3 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1544 "paddd %%mm3, %%mm5 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1545 "paddd %%mm0, %%mm4 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1546 "addl $8, %1 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1547 "addl $4, %%ecx \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1548 "cmpl %4, %%ecx \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1549 " jb 2b \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1550 "addl %6, %1 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1551 "psrad $8, %%mm4 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1552 "psrad $8, %%mm5 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1553 "packssdw %%mm5, %%mm4 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1554 "pmaddwd %%mm6, %%mm4 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1555 "packssdw %%mm4, %%mm4 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1556 "movl %3, %%eax \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1557 "movd %%mm4, (%%eax, %0) \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1558 "addl $4, %0 \n\t"
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1559 " jnc 1b \n\t"
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1560
3641
33c560ffd3dc minor bugfixes (noone noticed them)
michael
parents: 3352
diff changeset
1561 : "+r" (counter), "+r" (filter)
33c560ffd3dc minor bugfixes (noone noticed them)
michael
parents: 3352
diff changeset
1562 : "m" (filterPos), "m" (dst), "m"(src+filterSize),
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1563 "m" (src), "r" (filterSize*2)
3299
michael
parents: 3272
diff changeset
1564 : "%ebx", "%eax", "%ecx"
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1565 );
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1566 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1567 #else
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1568 int i;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1569 for(i=0; i<dstW; i++)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1570 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1571 int j;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1572 int srcPos= filterPos[i];
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1573 int val=0;
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1574 // printf("filterPos: %d\n", filterPos[i]);
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1575 for(j=0; j<filterSize; j++)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1576 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1577 // printf("filter: %d, src: %d\n", filter[i], src[srcPos + j]);
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1578 val += ((int)src[srcPos + j])*filter[filterSize*i + j];
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1579 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1580 // filter += hFilterSize;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1581 dst[i] = MIN(MAX(0, val>>7), (1<<15)-1); // the cubic equation does overflow ...
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1582 // dst[i] = val>>7;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1583 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1584 #endif
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1585 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1586 // *** horizontal scale Y line to temp buffer
3215
3083616ba4d6 sliced scaleing bugfix
michael
parents: 3209
diff changeset
1587 static inline void RENAME(hyscale)(uint16_t *dst, int dstWidth, uint8_t *src, int srcW, int xInc)
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1588 {
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1589 #ifdef HAVE_MMX
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1590 // use the new MMX scaler if th mmx2 cant be used (its faster than the x86asm one)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1591 if(sws_flags != SWS_FAST_BILINEAR || (!canMMX2BeUsed))
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1592 #else
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1593 if(sws_flags != SWS_FAST_BILINEAR)
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1594 #endif
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1595 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1596 RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1597 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1598 else // Fast Bilinear upscale / crap downscale
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1599 {
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1600 #ifdef ARCH_X86
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1601 #ifdef HAVE_MMX2
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1602 int i;
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1603 if(canMMX2BeUsed)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1604 {
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1605 asm volatile(
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1606 "pxor %%mm7, %%mm7 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1607 "pxor %%mm2, %%mm2 \n\t" // 2*xalpha
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1608 "movd %5, %%mm6 \n\t" // xInc&0xFFFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1609 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1610 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1611 "movq %%mm6, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1612 "psllq $16, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1613 "paddw %%mm6, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1614 "psllq $16, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1615 "paddw %%mm6, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1616 "psllq $16, %%mm2 \n\t" //0,t,2t,3t t=xInc&0xFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1617 "movq %%mm2, temp0 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1618 "movd %4, %%mm6 \n\t" //(xInc*4)&0xFFFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1619 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1620 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1621 "xorl %%eax, %%eax \n\t" // i
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1622 "movl %0, %%esi \n\t" // src
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1623 "movl %1, %%edi \n\t" // buf1
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1624 "movl %3, %%edx \n\t" // (xInc*4)>>16
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1625 "xorl %%ecx, %%ecx \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1626 "xorl %%ebx, %%ebx \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1627 "movw %4, %%bx \n\t" // (xInc*4)&0xFFFF
2520
b58c43aab619 3dnow prefetch & sfence
michael
parents: 2519
diff changeset
1628
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1629 #define FUNNY_Y_CODE \
2520
b58c43aab619 3dnow prefetch & sfence
michael
parents: 2519
diff changeset
1630 PREFETCH" 1024(%%esi) \n\t"\
b58c43aab619 3dnow prefetch & sfence
michael
parents: 2519
diff changeset
1631 PREFETCH" 1056(%%esi) \n\t"\
b58c43aab619 3dnow prefetch & sfence
michael
parents: 2519
diff changeset
1632 PREFETCH" 1088(%%esi) \n\t"\
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1633 "call funnyYCode \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1634 "movq temp0, %%mm2 \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1635 "xorl %%ecx, %%ecx \n\t"
2520
b58c43aab619 3dnow prefetch & sfence
michael
parents: 2519
diff changeset
1636
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1637 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1638 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1639 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1640 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1641 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1642 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1643 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1644 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1645
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1646 :: "m" (src), "m" (dst), "m" (dstWidth), "m" ((xInc*4)>>16),
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1647 "m" ((xInc*4)&0xFFFF), "m" (xInc&0xFFFF)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1648 : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1649 );
3215
3083616ba4d6 sliced scaleing bugfix
michael
parents: 3209
diff changeset
1650 for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128;
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1651 }
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1652 else
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1653 {
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1654 #endif
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1655 //NO MMX just normal asm ...
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1656 asm volatile(
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1657 "xorl %%eax, %%eax \n\t" // i
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1658 "xorl %%ebx, %%ebx \n\t" // xx
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1659 "xorl %%ecx, %%ecx \n\t" // 2*xalpha
2800
7847d6b7ad3d .balign or we¡­ll align by 64kb on some architectures
michael
parents: 2799
diff changeset
1660 ".balign 16 \n\t"
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1661 "1: \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1662 "movzbl (%0, %%ebx), %%edi \n\t" //src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1663 "movzbl 1(%0, %%ebx), %%esi \n\t" //src[xx+1]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1664 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1665 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1666 "shll $16, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1667 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1668 "movl %1, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1669 "shrl $9, %%esi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1670 "movw %%si, (%%edi, %%eax, 2) \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1671 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1672 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1673
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1674 "movzbl (%0, %%ebx), %%edi \n\t" //src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1675 "movzbl 1(%0, %%ebx), %%esi \n\t" //src[xx+1]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1676 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1677 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1678 "shll $16, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1679 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1680 "movl %1, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1681 "shrl $9, %%esi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1682 "movw %%si, 2(%%edi, %%eax, 2) \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1683 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1684 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1685
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1686
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1687 "addl $2, %%eax \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1688 "cmpl %2, %%eax \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1689 " jb 1b \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1690
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1691
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1692 :: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1693 : "%eax", "%ebx", "%ecx", "%edi", "%esi"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1694 );
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1695 #ifdef HAVE_MMX2
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1696 } //if MMX2 cant be used
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1697 #endif
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1698 #else
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1699 int i;
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1700 unsigned int xpos=0;
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1701 for(i=0;i<dstWidth;i++)
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1702 {
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1703 register unsigned int xx=xpos>>16;
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1704 register unsigned int xalpha=(xpos&0xFFFF)>>9;
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1705 dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1706 xpos+=xInc;
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1707 }
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1708 #endif
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1709 }
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1710 }
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1711
3126
e71ae0213431 runtime cpu detection
michael
parents: 2800
diff changeset
1712 inline static void RENAME(hcscale)(uint16_t *dst, int dstWidth,
3215
3083616ba4d6 sliced scaleing bugfix
michael
parents: 3209
diff changeset
1713 uint8_t *src1, uint8_t *src2, int srcW, int xInc)
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1714 {
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1715 #ifdef HAVE_MMX
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1716 // use the new MMX scaler if th mmx2 cant be used (its faster than the x86asm one)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1717 if(sws_flags != SWS_FAST_BILINEAR || (!canMMX2BeUsed))
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1718 #else
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1719 if(sws_flags != SWS_FAST_BILINEAR)
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1720 #endif
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1721 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1722 RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1723 RENAME(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1724 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1725 else // Fast Bilinear upscale / crap downscale
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1726 {
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1727 #ifdef ARCH_X86
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1728 #ifdef HAVE_MMX2
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1729 int i;
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1730 if(canMMX2BeUsed)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1731 {
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1732 asm volatile(
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1733 "pxor %%mm7, %%mm7 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1734 "pxor %%mm2, %%mm2 \n\t" // 2*xalpha
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1735 "movd %5, %%mm6 \n\t" // xInc&0xFFFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1736 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1737 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1738 "movq %%mm6, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1739 "psllq $16, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1740 "paddw %%mm6, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1741 "psllq $16, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1742 "paddw %%mm6, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1743 "psllq $16, %%mm2 \n\t" //0,t,2t,3t t=xInc&0xFFFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1744 "movq %%mm2, temp0 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1745 "movd %4, %%mm6 \n\t" //(xInc*4)&0xFFFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1746 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1747 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1748 "xorl %%eax, %%eax \n\t" // i
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1749 "movl %0, %%esi \n\t" // src
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1750 "movl %1, %%edi \n\t" // buf1
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1751 "movl %3, %%edx \n\t" // (xInc*4)>>16
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1752 "xorl %%ecx, %%ecx \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1753 "xorl %%ebx, %%ebx \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1754 "movw %4, %%bx \n\t" // (xInc*4)&0xFFFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1755
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1756 #define FUNNYUVCODE \
2520
b58c43aab619 3dnow prefetch & sfence
michael
parents: 2519
diff changeset
1757 PREFETCH" 1024(%%esi) \n\t"\
b58c43aab619 3dnow prefetch & sfence
michael
parents: 2519
diff changeset
1758 PREFETCH" 1056(%%esi) \n\t"\
b58c43aab619 3dnow prefetch & sfence
michael
parents: 2519
diff changeset
1759 PREFETCH" 1088(%%esi) \n\t"\
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1760 "call funnyUVCode \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1761 "movq temp0, %%mm2 \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1762 "xorl %%ecx, %%ecx \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1763
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1764 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1765 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1766 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1767 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1768
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1769 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1770 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1771 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1772 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1773 "xorl %%eax, %%eax \n\t" // i
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1774 "movl %6, %%esi \n\t" // src
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1775 "movl %1, %%edi \n\t" // buf1
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1776 "addl $4096, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1777
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1778 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1779 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1780 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1781 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1782
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1783 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1784 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1785 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1786 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1787
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1788 :: "m" (src1), "m" (dst), "m" (dstWidth), "m" ((xInc*4)>>16),
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1789 "m" ((xInc*4)&0xFFFF), "m" (xInc&0xFFFF), "m" (src2)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1790 : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1791 );
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1792 for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1793 {
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1794 // printf("%d %d %d\n", dstWidth, i, srcW);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1795 dst[i] = src1[srcW-1]*128;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1796 dst[i+2048] = src2[srcW-1]*128;
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1797 }
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1798 }
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1799 else
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1800 {
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1801 #endif
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1802 asm volatile(
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1803 "xorl %%eax, %%eax \n\t" // i
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1804 "xorl %%ebx, %%ebx \n\t" // xx
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1805 "xorl %%ecx, %%ecx \n\t" // 2*xalpha
2800
7847d6b7ad3d .balign or we¡­ll align by 64kb on some architectures
michael
parents: 2799
diff changeset
1806 ".balign 16 \n\t"
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1807 "1: \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1808 "movl %0, %%esi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1809 "movzbl (%%esi, %%ebx), %%edi \n\t" //src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1810 "movzbl 1(%%esi, %%ebx), %%esi \n\t" //src[xx+1]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1811 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1812 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1813 "shll $16, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1814 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1815 "movl %1, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1816 "shrl $9, %%esi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1817 "movw %%si, (%%edi, %%eax, 2) \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1818
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1819 "movzbl (%5, %%ebx), %%edi \n\t" //src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1820 "movzbl 1(%5, %%ebx), %%esi \n\t" //src[xx+1]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1821 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1822 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1823 "shll $16, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1824 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1825 "movl %1, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1826 "shrl $9, %%esi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1827 "movw %%si, 4096(%%edi, %%eax, 2)\n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1828
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1829 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1830 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1831 "addl $1, %%eax \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1832 "cmpl %2, %%eax \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1833 " jb 1b \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1834
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1835 :: "m" (src1), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF),
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1836 "r" (src2)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1837 : "%eax", "%ebx", "%ecx", "%edi", "%esi"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1838 );
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1839 #ifdef HAVE_MMX2
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1840 } //if MMX2 cant be used
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1841 #endif
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1842 #else
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1843 int i;
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1844 unsigned int xpos=0;
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1845 for(i=0;i<dstWidth;i++)
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1846 {
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1847 register unsigned int xx=xpos>>16;
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1848 register unsigned int xalpha=(xpos&0xFFFF)>>9;
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1849 dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1850 dst[i+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
2566
a350d8bed636 bugfixes
michael
parents: 2540
diff changeset
1851 /* slower
a350d8bed636 bugfixes
michael
parents: 2540
diff changeset
1852 dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha;
a350d8bed636 bugfixes
michael
parents: 2540
diff changeset
1853 dst[i+2048]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha;
a350d8bed636 bugfixes
michael
parents: 2540
diff changeset
1854 */
2671
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1855 xpos+=xInc;
555cb027c7a7 fixed warnings
michael
parents: 2669
diff changeset
1856 }
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1857 #endif
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1858 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1859 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1860
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1861 static inline void RENAME(initFilter)(int16_t *dstFilter, int16_t *filterPos, int *filterSize, int xInc,
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1862 int srcW, int dstW, int filterAlign, int one)
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1863 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1864 int i;
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1865 double filter[8000];
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1866 #ifdef HAVE_MMX
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1867 asm volatile("emms\n\t"::: "memory"); //FIXME this shouldnt be required but it IS (even for non mmx versions)
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1868 #endif
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1869
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1870 if(ABS(xInc - 0x10000) <10) // unscaled
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1871 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1872 int i;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1873 *filterSize= (1 +(filterAlign-1)) & (~(filterAlign-1)); // 1 or 4 normaly
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1874 for(i=0; i<dstW*(*filterSize); i++) filter[i]=0;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1875
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1876 for(i=0; i<dstW; i++)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1877 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1878 filter[i*(*filterSize)]=1;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1879 filterPos[i]=i;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1880 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1881
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1882 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1883 else if(xInc <= (1<<16) || sws_flags==SWS_FAST_BILINEAR) // upscale
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1884 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1885 int i;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1886 int xDstInSrc;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1887 if(sws_flags==SWS_BICUBIC) *filterSize= 4;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1888 else *filterSize= 2;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1889 // printf("%d %d %d\n", filterSize, srcW, dstW);
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1890 *filterSize= (*filterSize +(filterAlign-1)) & (~(filterAlign-1));
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1891
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1892 xDstInSrc= xInc - 0x8000;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1893 for(i=0; i<dstW; i++)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1894 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1895 int xx= (xDstInSrc>>16) - (*filterSize>>1) + 1;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1896 int j;
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1897
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1898 filterPos[i]= xx;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1899 if(sws_flags == SWS_BICUBIC)
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1900 {
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1901 double d= ABS(((xx+1)<<16) - xDstInSrc)/(double)(1<<16);
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1902 double y1,y2,y3,y4;
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1903 double A= -0.75;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1904 // Equation is from VirtualDub
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1905 y1 = ( + A*d - 2.0*A*d*d + A*d*d*d);
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1906 y2 = (+ 1.0 - (A+3.0)*d*d + (A+2.0)*d*d*d);
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1907 y3 = ( - A*d + (2.0*A+3.0)*d*d - (A+2.0)*d*d*d);
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1908 y4 = ( + A*d*d - A*d*d*d);
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1909
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1910 // printf("%d %d %d \n", coeff, (int)d, xDstInSrc);
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1911 filter[i*(*filterSize) + 0]= y1;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1912 filter[i*(*filterSize) + 1]= y2;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1913 filter[i*(*filterSize) + 2]= y3;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1914 filter[i*(*filterSize) + 3]= y4;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1915 // printf("%1.3f %d, %d, %d, %d\n",d , y1, y2, y3, y4);
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1916 }
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1917 else
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1918 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1919 for(j=0; j<*filterSize; j++)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1920 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1921 double d= ABS((xx<<16) - xDstInSrc)/(double)(1<<16);
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1922 double coeff= 1.0 - d;
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1923 if(coeff<0) coeff=0;
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1924 // printf("%d %d %d \n", coeff, (int)d, xDstInSrc);
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1925 filter[i*(*filterSize) + j]= coeff;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1926 xx++;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1927 }
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1928 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1929 xDstInSrc+= xInc;
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1930 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1931 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1932 else // downscale
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1933 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1934 int xDstInSrc;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1935 if(sws_flags==SWS_BICUBIC) *filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW);
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1936 else *filterSize= (int)ceil(1 + 2.0*srcW / (double)dstW);
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1937 // printf("%d %d %d\n", *filterSize, srcW, dstW);
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1938 *filterSize= (*filterSize +(filterAlign-1)) & (~(filterAlign-1));
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1939
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1940 xDstInSrc= xInc - 0x8000;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1941 for(i=0; i<dstW; i++)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1942 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1943 int xx= (int)((double)xDstInSrc/(double)(1<<16) - *filterSize*0.5 + 0.5);
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1944 int j;
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1945
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1946 filterPos[i]= xx;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1947 for(j=0; j<*filterSize; j++)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1948 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1949 double d= ABS((xx<<16) - xDstInSrc)/(double)xInc;
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1950 double coeff;
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1951 if(sws_flags == SWS_BICUBIC)
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1952 {
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1953 double A= -0.75;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1954 // d*=2;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1955 // Equation is from VirtualDub
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1956 if(d<1.0)
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1957 coeff = (1.0 - (A+3.0)*d*d + (A+2.0)*d*d*d);
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1958 else if(d<2.0)
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1959 coeff = (-4.0*A + 8.0*A*d - 5.0*A*d*d + A*d*d*d);
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1960 else
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1961 coeff=0.0;
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1962 }
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1963 else
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1964 {
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1965 coeff= 1.0 - d;
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1966 if(coeff<0) coeff=0;
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1967 }
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1968 // if(filterAlign==1) printf("%d %d %d \n", coeff, (int)d, xDstInSrc);
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1969 filter[i*(*filterSize) + j]= coeff;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1970 xx++;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1971 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1972 xDstInSrc+= xInc;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1973 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1974 }
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
1975
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1976 //fix borders
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1977 for(i=0; i<dstW; i++)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1978 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1979 int j;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1980 if(filterPos[i] < 0)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1981 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1982 // Move filter coeffs left to compensate for filterPos
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1983 for(j=1; j<*filterSize; j++)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1984 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1985 int left= MAX(j + filterPos[i], 0);
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1986 filter[i*(*filterSize) + left] += filter[i*(*filterSize) + j];
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1987 filter[i*(*filterSize) + j]=0;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1988 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1989 filterPos[i]= 0;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1990 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1991
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1992 if(filterPos[i] + (*filterSize) > srcW)
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1993 {
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1994 int shift= filterPos[i] + (*filterSize) - srcW;
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1995 // Move filter coeffs right to compensate for filterPos
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1996 for(j=(*filterSize)-2; j>=0; j--)
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1997 {
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
1998 int right= MIN(j + shift, (*filterSize)-1);
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
1999 filter[i*(*filterSize) +right] += filter[i*(*filterSize) +j];
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2000 filter[i*(*filterSize) +j]=0;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2001 }
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2002 filterPos[i]= srcW - (*filterSize);
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2003 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2004 }
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2005
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2006 //FIXME try to align filterpos if possible / try to shift filterpos to put zeros at the end
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2007 // and skip these than later
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2008
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2009 //Normalize
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2010 for(i=0; i<dstW; i++)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2011 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2012 int j;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2013 double sum=0;
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2014 double scale= one;
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2015 for(j=0; j<*filterSize; j++)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2016 {
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2017 sum+= filter[i*(*filterSize) + j];
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2018 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2019 scale/= sum;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2020 for(j=0; j<*filterSize; j++)
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2021 {
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2022 dstFilter[i*(*filterSize) + j]= (int)(filter[i*(*filterSize) + j]*scale);
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2023 }
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2024 }
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
2025 }
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
2026
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2027 #ifdef HAVE_MMX2
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2028 static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2029 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2030 uint8_t *fragment;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2031 int imm8OfPShufW1;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2032 int imm8OfPShufW2;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2033 int fragmentLength;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2034
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2035 int xpos, i;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2036
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2037 // create an optimized horizontal scaling routine
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2038
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2039 //code fragment
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2040
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2041 asm volatile(
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2042 "jmp 9f \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2043 // Begin
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2044 "0: \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2045 "movq (%%esi), %%mm0 \n\t" //FIXME Alignment
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2046 "movq %%mm0, %%mm1 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2047 "psrlq $8, %%mm0 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2048 "punpcklbw %%mm7, %%mm1 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2049 "movq %%mm2, %%mm3 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2050 "punpcklbw %%mm7, %%mm0 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2051 "addw %%bx, %%cx \n\t" //2*xalpha += (4*lumXInc)&0xFFFF
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2052 "pshufw $0xFF, %%mm1, %%mm1 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2053 "1: \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2054 "adcl %%edx, %%esi \n\t" //xx+= (4*lumXInc)>>16 + carry
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2055 "pshufw $0xFF, %%mm0, %%mm0 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2056 "2: \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2057 "psrlw $9, %%mm3 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2058 "psubw %%mm1, %%mm0 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2059 "pmullw %%mm3, %%mm0 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2060 "paddw %%mm6, %%mm2 \n\t" // 2*alpha += xpos&0xFFFF
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2061 "psllw $7, %%mm1 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2062 "paddw %%mm1, %%mm0 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2063
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2064 "movq %%mm0, (%%edi, %%eax) \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2065
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2066 "addl $8, %%eax \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2067 // End
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2068 "9: \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2069 // "int $3\n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2070 "leal 0b, %0 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2071 "leal 1b, %1 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2072 "leal 2b, %2 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2073 "decl %1 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2074 "decl %2 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2075 "subl %0, %1 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2076 "subl %0, %2 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2077 "leal 9b, %3 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2078 "subl %0, %3 \n\t"
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2079 :"=r" (fragment), "=r" (imm8OfPShufW1), "=r" (imm8OfPShufW2),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2080 "=r" (fragmentLength)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2081 );
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2082
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2083 xpos= 0; //lumXInc/2 - 0x8000; // difference between pixel centers
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2084
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2085 for(i=0; i<dstW/8; i++)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2086 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2087 int xx=xpos>>16;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2088
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2089 if((i&3) == 0)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2090 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2091 int a=0;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2092 int b=((xpos+xInc)>>16) - xx;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2093 int c=((xpos+xInc*2)>>16) - xx;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2094 int d=((xpos+xInc*3)>>16) - xx;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2095
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2096 memcpy(funnyCode + fragmentLength*i/4, fragment, fragmentLength);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2097
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2098 funnyCode[fragmentLength*i/4 + imm8OfPShufW1]=
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2099 funnyCode[fragmentLength*i/4 + imm8OfPShufW2]=
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2100 a | (b<<2) | (c<<4) | (d<<6);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2101
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2102 // if we dont need to read 8 bytes than dont :), reduces the chance of
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2103 // crossing a cache line
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2104 if(d<3) funnyCode[fragmentLength*i/4 + 1]= 0x6E;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2105
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2106 funnyCode[fragmentLength*(i+4)/4]= RET;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2107 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2108 xpos+=xInc;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2109 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2110 /*
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2111 xpos= 0; //chrXInc/2 - 0x10000; // difference between centers of chrom samples
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2112 for(i=0; i<dstUVw/8; i++)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2113 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2114 int xx=xpos>>16;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2115
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2116 if((i&3) == 0)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2117 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2118 int a=0;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2119 int b=((xpos+chrXInc)>>16) - xx;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2120 int c=((xpos+chrXInc*2)>>16) - xx;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2121 int d=((xpos+chrXInc*3)>>16) - xx;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2122
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2123 memcpy(funnyUVCode + fragmentLength*i/4, fragment, fragmentLength);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2124
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2125 funnyUVCode[fragmentLength*i/4 + imm8OfPShufW1]=
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2126 funnyUVCode[fragmentLength*i/4 + imm8OfPShufW2]=
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2127 a | (b<<2) | (c<<4) | (d<<6);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2128
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2129 // if we dont need to read 8 bytes than dont :), reduces the chance of
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2130 // crossing a cache line
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2131 if(d<3) funnyUVCode[fragmentLength*i/4 + 1]= 0x6E;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2132
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2133 funnyUVCode[fragmentLength*(i+4)/4]= RET;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2134 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2135 xpos+=chrXInc;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2136 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2137 */
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2138 // funnyCode[0]= RET;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2139 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2140 #endif // HAVE_MMX2
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2141
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
2142 static void RENAME(SwScale_YV12slice)(unsigned char* srcptr[],int stride[], int srcSliceY ,
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
2143 int srcSliceH, uint8_t* dstptr[], int dststride, int dstbpp,
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
2144 int srcW, int srcH, int dstW, int dstH){
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
2145
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
2146
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2147 unsigned int lumXInc= (srcW << 16) / dstW;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2148 unsigned int lumYInc= (srcH << 16) / dstH;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2149 unsigned int chrXInc;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2150 unsigned int chrYInc;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2151
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
2152 static int dstY;
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
2153
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2154 // used to detect a size change
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2155 static int oldDstW= -1;
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3215
diff changeset
2156 static int oldSrcW= -1;
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2157 static int oldDstH= -1;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2158 static int oldSrcH= -1;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2159 static int oldFlags=-1;
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
2160
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2161 static int lastInLumBuf;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2162 static int lastInChrBuf;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2163
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2164 int chrDstW, chrDstH;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2165
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2166 static int lumBufIndex=0;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2167 static int chrBufIndex=0;
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
2168
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2169 static int firstTime=1;
2680
e8a534509557 green line fix for dstw%8!=0
michael
parents: 2671
diff changeset
2170
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2171 const int widthAlign= dstbpp==12 ? 16 : 8;
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2172 const int bytespp= (dstbpp+1)/8; //(12->1, 15&16->2, 24->3, 32->4)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2173 const int over= dstbpp==12 ? (((dstW+15)&(~15))) - dststride
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2174 : (((dstW+7)&(~7)))*bytespp - dststride;
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2175 if(dststride%widthAlign !=0 )
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2176 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2177 if(firstTime)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2178 fprintf(stderr, "SwScaler: Warning: dstStride is not a multiple of %d!\n"
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2179 "SwScaler: ->cannot do aligned memory acesses anymore\n",
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2180 widthAlign);
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2181 }
2680
e8a534509557 green line fix for dstw%8!=0
michael
parents: 2671
diff changeset
2182
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2183 if(over>0)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2184 {
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2185 if(firstTime)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2186 fprintf(stderr, "SwScaler: Warning: output width is not a multiple of 8 (16 for YV12)\n"
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2187 "SwScaler: and dststride is not large enough to handle %d extra bytes\n"
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2188 "SwScaler: ->using unoptimized C version for last line(s)\n",
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2189 over);
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2190 }
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2191
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2192
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2193
3215
3083616ba4d6 sliced scaleing bugfix
michael
parents: 3209
diff changeset
2194 //printf("%d %d %d %d\n", srcW, srcH, dstW, dstH);
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2195 //printf("%d %d %d %d\n", lumXInc, lumYInc, srcSliceY, srcSliceH);
3215
3083616ba4d6 sliced scaleing bugfix
michael
parents: 3209
diff changeset
2196
2270
56ca174d8169 vertical lines bugfix
michael
parents: 2269
diff changeset
2197 #ifdef HAVE_MMX2
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2198 canMMX2BeUsed= (lumXInc <= 0x10000 && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2199 if(!canMMX2BeUsed && lumXInc <= 0x10000 && (srcW&15)==0 && sws_flags==SWS_FAST_BILINEAR)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2200 {
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2201 if(firstTime)
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2202 fprintf(stderr, "SwScaler: output Width is not a multiple of 32 -> no MMX2 scaler\n");
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2203 }
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2204 #else
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2205 canMMX2BeUsed=0; // should be 0 anyway but ...
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2206 #endif
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2207
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2208 if(firstTime)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2209 {
3345
20065c9b0f09 dithering info wasnt displayed
michael
parents: 3344
diff changeset
2210 #if defined (DITHER1XBPP) && defined (HAVE_MMX)
20065c9b0f09 dithering info wasnt displayed
michael
parents: 3344
diff changeset
2211 char *dither= " dithered";
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2212 #else
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2213 char *dither= "";
2270
56ca174d8169 vertical lines bugfix
michael
parents: 2269
diff changeset
2214 #endif
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2215 if(sws_flags==SWS_FAST_BILINEAR)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2216 fprintf(stderr, "SwScaler: FAST_BILINEAR scaler ");
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2217 else if(sws_flags==SWS_BILINEAR)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2218 fprintf(stderr, "SwScaler: BILINEAR scaler ");
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2219 else if(sws_flags==SWS_BICUBIC)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2220 fprintf(stderr, "SwScaler: BICUBIC scaler ");
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2221 else
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2222 fprintf(stderr, "SwScaler: ehh flags invalid?! ");
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2223
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2224 if(dstbpp==15)
3345
20065c9b0f09 dithering info wasnt displayed
michael
parents: 3344
diff changeset
2225 fprintf(stderr, "with%s BGR15 output ", dither);
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2226 else if(dstbpp==16)
3345
20065c9b0f09 dithering info wasnt displayed
michael
parents: 3344
diff changeset
2227 fprintf(stderr, "with%s BGR16 output ", dither);
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2228 else if(dstbpp==24)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2229 fprintf(stderr, "with BGR24 output ");
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2230 else if(dstbpp==32)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2231 fprintf(stderr, "with BGR32 output ");
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2232 else if(dstbpp==12)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2233 fprintf(stderr, "with YV12 output ");
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2234 else
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2235 fprintf(stderr, "without output ");
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2236
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2237 #ifdef HAVE_MMX2
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2238 fprintf(stderr, "using MMX2\n");
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2239 #elif defined (HAVE_3DNOW)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2240 fprintf(stderr, "using 3DNOW\n");
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2241 #elif defined (HAVE_MMX)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2242 fprintf(stderr, "using MMX\n");
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2243 #elif defined (ARCH_X86)
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2244 fprintf(stderr, "using X86 ASM\n");
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2245 #else
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2246 fprintf(stderr, "using C\n");
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2247 #endif
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2248 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2249
2270
56ca174d8169 vertical lines bugfix
michael
parents: 2269
diff changeset
2250
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
2251 // match pixel 0 of the src to pixel 0 of dst and match pixel n-2 of src to pixel n-2 of dst
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
2252 // n-2 is the last chrominance sample available
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2253 // this is not perfect, but noone shuld notice the difference, the more correct variant
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
2254 // would be like the vertical one, but that would require some special code for the
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
2255 // first and last pixel
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2256 if(sws_flags==SWS_FAST_BILINEAR)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2257 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2258 if(canMMX2BeUsed) lumXInc+= 20;
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2259 #ifndef HAVE_MMX //we dont use the x86asm scaler if mmx is available
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2260 else lumXInc = ((srcW-2)<<16)/(dstW-2) - 20;
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2261 #endif
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2262 }
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
2263
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2264 if(fullUVIpol && !(dstbpp==12)) chrXInc= lumXInc>>1, chrDstW= dstW;
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2265 else chrXInc= lumXInc, chrDstW= (dstW+1)>>1;
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2266
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2267 if(dstbpp==12) chrYInc= lumYInc, chrDstH= (dstH+1)>>1;
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2268 else chrYInc= lumYInc>>1, chrDstH= dstH;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2269
2271
a8d57bbc4413 horizontal lines bugfix
michael
parents: 2270
diff changeset
2270 // force calculation of the horizontal interpolation of the first line
a8d57bbc4413 horizontal lines bugfix
michael
parents: 2270
diff changeset
2271
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
2272 if(srcSliceY ==0){
3215
3083616ba4d6 sliced scaleing bugfix
michael
parents: 3209
diff changeset
2273 // printf("dstW %d, srcw %d, mmx2 %d\n", dstW, srcW, canMMX2BeUsed);
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2274 lumBufIndex=0;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2275 chrBufIndex=0;
3209
0b172eb639f1 swscaler cleanup
michael
parents: 3136
diff changeset
2276 dstY=0;
2638
d4211422b6cc right green line bugfix for width not %8==0 (untested -vo vesa doesnt work)
michael
parents: 2585
diff changeset
2277
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2278 //precalculate horizontal scaler filter coefficients
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2279 if(oldDstW!=dstW || oldSrcW!=srcW || oldFlags!=sws_flags)
2638
d4211422b6cc right green line bugfix for width not %8==0 (untested -vo vesa doesnt work)
michael
parents: 2585
diff changeset
2280 {
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2281 #ifdef HAVE_MMX
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2282 const int filterAlign=4;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2283 #else
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2284 const int filterAlign=1;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2285 #endif
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2286 oldDstW= dstW; oldSrcW= srcW; oldFlags= sws_flags;
2638
d4211422b6cc right green line bugfix for width not %8==0 (untested -vo vesa doesnt work)
michael
parents: 2585
diff changeset
2287
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2288 RENAME(initFilter)(hLumFilter, hLumFilterPos, &hLumFilterSize, lumXInc,
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2289 srcW , dstW , filterAlign, 1<<14);
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2290 RENAME(initFilter)(hChrFilter, hChrFilterPos, &hChrFilterSize, chrXInc,
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2291 (srcW+1)>>1, chrDstW, filterAlign, 1<<14);
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2292
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
2293 #ifdef HAVE_MMX2
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
2294 // cant downscale !!!
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2295 if(canMMX2BeUsed && sws_flags == SWS_FAST_BILINEAR)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2296 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2297 initMMX2HScaler(dstW , lumXInc, funnyYCode);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2298 initMMX2HScaler(chrDstW, chrXInc, funnyUVCode);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2299 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2300 #endif
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2301 } // Init Horizontal stuff
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2302
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2303 if(oldDstH!=dstH || oldSrcH!=srcH || oldFlags!=sws_flags)
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
2304 {
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2305 int i;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2306 oldDstH= dstH; oldSrcH= srcH; oldFlags= sws_flags; //FIXME swsflags conflict with x check
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
2307
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2308 // deallocate pixbufs
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2309 for(i=0; i<vLumBufSize; i++) free(lumPixBuf[i]);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2310 for(i=0; i<vChrBufSize; i++) free(chrPixBuf[i]);
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
2311
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2312 RENAME(initFilter)(vLumFilter, vLumFilterPos, &vLumFilterSize, lumYInc,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2313 srcH , dstH, 1, (1<<12)-4);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2314 RENAME(initFilter)(vChrFilter, vChrFilterPos, &vChrFilterSize, chrYInc,
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2315 (srcH+1)>>1, chrDstH, 1, (1<<12)-4);
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
2316
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2317 // Calculate Buffer Sizes so that they wont run out while handling these damn slices
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2318 vLumBufSize= vLumFilterSize; vChrBufSize= vChrFilterSize;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2319 for(i=0; i<dstH; i++)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2320 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2321 int chrI= i*chrDstH / dstH;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2322 int nextSlice= MAX(vLumFilterPos[i ] + vLumFilterSize - 1,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2323 ((vChrFilterPos[chrI] + vChrFilterSize - 1)<<1));
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2324 nextSlice&= ~1; // Slices start at even boundaries
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2325 if(vLumFilterPos[i ] + vLumBufSize < nextSlice)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2326 vLumBufSize= nextSlice - vLumFilterPos[i ];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2327 if(vChrFilterPos[chrI] + vChrBufSize < (nextSlice>>1))
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2328 vChrBufSize= (nextSlice>>1) - vChrFilterPos[chrI];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2329 }
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
2330
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2331 // allocate pixbufs (we use dynamic allocation because otherwise we would need to
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2332 // allocate several megabytes to handle all possible cases)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2333 for(i=0; i<vLumBufSize; i++)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2334 lumPixBuf[i]= lumPixBuf[i+vLumBufSize]= (uint16_t*)memalign(8, 4000);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2335 for(i=0; i<vChrBufSize; i++)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2336 chrPixBuf[i]= chrPixBuf[i+vChrBufSize]= (uint16_t*)memalign(8, 8000);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2337
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2338 //try to avoid drawing green stuff between the right end and the stride end
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2339 for(i=0; i<vLumBufSize; i++) memset(lumPixBuf[i], 0, 4000);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2340 for(i=0; i<vChrBufSize; i++) memset(chrPixBuf[i], 64, 8000);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2341
3641
33c560ffd3dc minor bugfixes (noone noticed them)
michael
parents: 3352
diff changeset
2342 ASSERT(chrDstH<=dstH)
33c560ffd3dc minor bugfixes (noone noticed them)
michael
parents: 3352
diff changeset
2343 ASSERT(vLumFilterSize*dstH*4<16000)
33c560ffd3dc minor bugfixes (noone noticed them)
michael
parents: 3352
diff changeset
2344 ASSERT(vChrFilterSize*chrDstH*4<16000)
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2345 #ifdef HAVE_MMX
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2346 // pack filter data for mmx code
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2347 for(i=0; i<vLumFilterSize*dstH; i++)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2348 lumMmxFilter[4*i]=lumMmxFilter[4*i+1]=lumMmxFilter[4*i+2]=lumMmxFilter[4*i+3]=
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2349 vLumFilter[i];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2350 for(i=0; i<vChrFilterSize*chrDstH; i++)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2351 chrMmxFilter[4*i]=chrMmxFilter[4*i+1]=chrMmxFilter[4*i+2]=chrMmxFilter[4*i+3]=
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2352 vChrFilter[i];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2353 #endif
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2354 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2355
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2356 if(firstTime && verbose)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2357 {
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2358 #ifdef HAVE_MMX2
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2359 int mmx2=1;
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2360 #else
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2361 int mmx2=0;
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2362 #endif
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2363 #ifdef HAVE_MMX
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2364 int mmx=1;
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2365 #else
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2366 int mmx=0;
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2367 #endif
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2368
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2369 #ifdef HAVE_MMX
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2370 if(canMMX2BeUsed && sws_flags==SWS_FAST_BILINEAR)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2371 printf("SwScaler: using FAST_BILINEAR MMX2 scaler for horizontal scaling\n");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2372 else
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2373 {
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2374 if(hLumFilterSize==4)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2375 printf("SwScaler: using 4-tap MMX scaler for horizontal luminance scaling\n");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2376 else if(hLumFilterSize==8)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2377 printf("SwScaler: using 8-tap MMX scaler for horizontal luminance scaling\n");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2378 else
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2379 printf("SwScaler: using n-tap MMX scaler for horizontal luminance scaling\n");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2380
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2381 if(hChrFilterSize==4)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2382 printf("SwScaler: using 4-tap MMX scaler for horizontal chrominance scaling\n");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2383 else if(hChrFilterSize==8)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2384 printf("SwScaler: using 8-tap MMX scaler for horizontal chrominance scaling\n");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2385 else
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2386 printf("SwScaler: using n-tap MMX scaler for horizontal chrominance scaling\n");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2387 }
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2388 #elif defined (ARCH_X86)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2389 printf("SwScaler: using X86-Asm scaler for horizontal scaling\n");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2390 #else
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2391 if(sws_flags==SWS_FAST_BILINEAR)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2392 printf("SwScaler: using FAST_BILINEAR C scaler for horizontal scaling\n");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2393 else
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2394 printf("SwScaler: using C scaler for horizontal scaling\n");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2395 #endif
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2396
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2397 if(dstbpp==12)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2398 {
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2399 if(vLumFilterSize==1)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2400 printf("SwScaler: using 1-tap %s \"scaler\" for vertical scaling (YV12)\n", mmx ? "MMX" : "C");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2401 else
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2402 printf("SwScaler: using n-tap %s scaler for vertical scaling (YV12)\n", mmx ? "MMX" : "C");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2403 }
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2404 else
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2405 {
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2406 if(vLumFilterSize==1 && vChrFilterSize==2)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2407 printf("SwScaler: using 1-tap %s \"scaler\" for vertical luminance scaling (BGR)\n"
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2408 "SwScaler: 2-tap scaler for vertical chrominance scaling (BGR)\n", mmx ? "MMX" : "C");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2409 else if(vLumFilterSize==2 && vChrFilterSize==2)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2410 printf("SwScaler: using 2-tap linear %s scaler for vertical scaling (BGR)\n", mmx ? "MMX" : "C");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2411 else
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2412 printf("SwScaler: using n-tap %s scaler for vertical scaling (BGR)\n", mmx ? "MMX" : "C");
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2413 }
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2414
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2415 if(dstbpp==24)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2416 printf("SwScaler: using %s YV12->BGR24 Converter\n",
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2417 mmx2 ? "MMX2" : (mmx ? "MMX" : "C"));
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2418 else
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2419 printf("SwScaler: using %s YV12->BGR%d Converter\n", mmx ? "MMX" : "C", dstbpp);
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2420
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2421 printf("SwScaler: %dx%d -> %dx%d\n", srcW, srcH, dstW, dstH);
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2422 }
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2423
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2424 lastInLumBuf= -1;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2425 lastInChrBuf= -1;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2426 } // if(firstLine)
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
2427
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2428 for(;dstY < dstH; dstY++){
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2429 unsigned char *dest =dstptr[0]+dststride*dstY;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2430 unsigned char *uDest=dstptr[1]+(dststride>>1)*(dstY>>1);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2431 unsigned char *vDest=dstptr[2]+(dststride>>1)*(dstY>>1);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2432 const int chrDstY= dstbpp==12 ? (dstY>>1) : dstY;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2433
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2434 const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2435 const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2436 const int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2437 const int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2438
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2439 if(sws_flags == SWS_FAST_BILINEAR)
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
2440 {
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2441 //handle holes
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2442 if(firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2443 if(firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
2444 }
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
2445
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2446 ASSERT(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2447 ASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1)
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
2448
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2449 // Do we have enough lines in this slice to output the dstY line
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2450 if(lastLumSrcY < srcSliceY + srcSliceH && lastChrSrcY < ((srcSliceY + srcSliceH)>>1))
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
2451 {
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2452 //Do horizontal scaling
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2453 while(lastInLumBuf < lastLumSrcY)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2454 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2455 uint8_t *src= srcptr[0]+(lastInLumBuf + 1 - srcSliceY)*stride[0];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2456 lumBufIndex++;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2457 ASSERT(lumBufIndex < 2*vLumBufSize)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2458 ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2459 ASSERT(lastInLumBuf + 1 - srcSliceY >= 0)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2460 // printf("%d %d\n", lumBufIndex, vLumBufSize);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2461 RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, src, srcW, lumXInc);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2462 lastInLumBuf++;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2463 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2464 while(lastInChrBuf < lastChrSrcY)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2465 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2466 uint8_t *src1= srcptr[1]+(lastInChrBuf + 1 - (srcSliceY>>1))*stride[1];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2467 uint8_t *src2= srcptr[2]+(lastInChrBuf + 1 - (srcSliceY>>1))*stride[2];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2468 chrBufIndex++;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2469 ASSERT(chrBufIndex < 2*vChrBufSize)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2470 ASSERT(lastInChrBuf + 1 - (srcSliceY>>1) < (srcSliceH>>1))
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2471 ASSERT(lastInChrBuf + 1 - (srcSliceY>>1) >= 0)
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2472 RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, (srcW+1)>>1, chrXInc);
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2473 lastInChrBuf++;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2474 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2475 //wrap buf index around to stay inside the ring buffer
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2476 if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2477 if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize;
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
2478 }
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2479 else // not enough lines left in this slice -> load the rest in the buffer
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
2480 {
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2481 /* printf("%d %d Last:%d %d LastInBuf:%d %d Index:%d %d Y:%d FSize: %d %d BSize: %d %d\n",
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2482 firstChrSrcY,firstLumSrcY,lastChrSrcY,lastLumSrcY,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2483 lastInChrBuf,lastInLumBuf,chrBufIndex,lumBufIndex,dstY,vChrFilterSize,vLumFilterSize,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2484 vChrBufSize, vLumBufSize);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2485 */
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2486 //Do horizontal scaling
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2487 while(lastInLumBuf+1 < srcSliceY + srcSliceH)
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
2488 {
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2489 uint8_t *src= srcptr[0]+(lastInLumBuf + 1 - srcSliceY)*stride[0];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2490 lumBufIndex++;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2491 ASSERT(lumBufIndex < 2*vLumBufSize)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2492 ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2493 ASSERT(lastInLumBuf + 1 - srcSliceY >= 0)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2494 RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, src, srcW, lumXInc);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2495 lastInLumBuf++;
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
2496 }
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2497 while(lastInChrBuf+1 < ((srcSliceY + srcSliceH)>>1))
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2498 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2499 uint8_t *src1= srcptr[1]+(lastInChrBuf + 1 - (srcSliceY>>1))*stride[1];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2500 uint8_t *src2= srcptr[2]+(lastInChrBuf + 1 - (srcSliceY>>1))*stride[2];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2501 chrBufIndex++;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2502 ASSERT(chrBufIndex < 2*vChrBufSize)
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2503 ASSERT(lastInChrBuf + 1 - (srcSliceY>>1) < (srcSliceH>>1))
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2504 ASSERT(lastInChrBuf + 1 - (srcSliceY>>1) >= 0)
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2505 RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, (srcW+1)>>1, chrXInc);
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2506 lastInChrBuf++;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2507 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2508 //wrap buf index around to stay inside the ring buffer
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2509 if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2510 if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2511 break; //we cant output a dstY line so lets try with the next slice
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
2512 }
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
2513
2748
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
2514 #ifdef HAVE_MMX
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2515 b5Dither= dither8[dstY&1];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2516 g6Dither= dither4[dstY&1];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2517 g5Dither= dither8[dstY&1];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2518 r5Dither= dither8[(dstY+1)&1];
2748
01dbf100b4f8 better dithering
michael
parents: 2730
diff changeset
2519 #endif
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2520 if(dstY < dstH-2 || over<=0)
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2521 {
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2522 if(dstbpp==12) //YV12
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2523 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2524 if(dstY&1) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2525 if(vLumFilterSize == 1 && vChrFilterSize == 1) // Unscaled YV12
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2526 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2527 int16_t *lumBuf = lumPixBuf[0];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2528 int16_t *chrBuf= chrPixBuf[0];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2529 RENAME(yuv2yuv1)(lumBuf, chrBuf, dest, uDest, vDest, dstW);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2530 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2531 else //General YV12
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2532 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2533 int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2534 int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2535 RENAME(yuv2yuvX)(
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2536 vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2537 vChrFilter+(dstY>>1)*vChrFilterSize, chrSrcPtr, vChrFilterSize,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2538 dest, uDest, vDest, dstW,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2539 lumMmxFilter+dstY*vLumFilterSize*4, chrMmxFilter+(dstY>>1)*vChrFilterSize*4);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2540 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2541 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2542 else
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2543 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2544 int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2545 int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2546
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2547 ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2548 ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2549 if(vLumFilterSize == 1 && vChrFilterSize == 2) //Unscaled RGB
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2550 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2551 int chrAlpha= vChrFilter[2*dstY+1];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2552
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2553 RENAME(yuv2rgb1)(*lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2554 dest, dstW, chrAlpha, dstbpp);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2555 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2556 else if(vLumFilterSize == 2 && vChrFilterSize == 2) //BiLinear Upscale RGB
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2557 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2558 int lumAlpha= vLumFilter[2*dstY+1];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2559 int chrAlpha= vChrFilter[2*dstY+1];
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2560
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2561 RENAME(yuv2rgb2)(*lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1),
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2562 dest, dstW, lumAlpha, chrAlpha, dstbpp);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2563 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2564 else //General RGB
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2565 {
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2566 RENAME(yuv2rgbX)(
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2567 vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2568 vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2569 dest, dstW, dstbpp,
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2570 lumMmxFilter+dstY*vLumFilterSize*4, chrMmxFilter+dstY*vChrFilterSize*4);
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2571 }
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2572 }
3352
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2573 }
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2574 else // hmm looks like we cant use MMX here without overwriting this arrays tail
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2575 {
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2576 int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2577 int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2578 if(dstbpp==12) //YV12
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2579 {
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2580 if(dstY&1) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2581 yuv2yuvXinC(
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2582 vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2583 vChrFilter+(dstY>>1)*vChrFilterSize, chrSrcPtr, vChrFilterSize,
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2584 dest, uDest, vDest, dstW);
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2585 }
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2586 else
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2587 {
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2588 ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2589 ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2);
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2590 yuv2rgbXinC(
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2591 vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2592 vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2593 dest, dstW, dstbpp);
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2594 }
64121e8a43f5 print more info if -v
michael
parents: 3345
diff changeset
2595 }
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2596 }
2534
cc9d3fd626f0 patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents: 2521
diff changeset
2597
cc9d3fd626f0 patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents: 2521
diff changeset
2598 #ifdef HAVE_MMX
cc9d3fd626f0 patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents: 2521
diff changeset
2599 __asm __volatile(SFENCE:::"memory");
2566
a350d8bed636 bugfixes
michael
parents: 2540
diff changeset
2600 __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
2601 #endif
3344
e87c59969d17 vertical cubic/linear scaling
michael
parents: 3299
diff changeset
2602 firstTime=0;
3641
33c560ffd3dc minor bugfixes (noone noticed them)
michael
parents: 3352
diff changeset
2603 }