35 unsigned char *
u,
unsigned char *
v,
int w,
int us,
int vs);
43 unsigned char *
u,
unsigned char *
v,
int w,
47 for (j = w/2; j; j--) {
56 unsigned char *
u,
unsigned char *
v,
int w,
int us,
int vs)
59 for (j = w/2; j; j--) {
61 *dst++ = (u[us+us] + 7*u[0])>>3;
63 *dst++ = (v[vs+vs] + 7*v[0])>>3;
69 unsigned char *
u,
unsigned char *
v,
int w,
int us,
int vs)
72 for (j = w/2; j; j--) {
74 *dst++ = (3*u[us+us] + 5*u[0])>>3;
76 *dst++ = (3*v[vs+vs] + 5*v[0])>>3;
83 unsigned char *
u,
unsigned char *
v,
int w,
89 "movq (%0), %%mm1 \n\t"
90 "movq (%0), %%mm2 \n\t"
91 "movq (%1), %%mm4 \n\t"
92 "movq (%2), %%mm6 \n\t"
93 "punpcklbw %%mm6, %%mm4 \n\t"
94 "punpcklbw %%mm4, %%mm1 \n\t"
95 "punpckhbw %%mm4, %%mm2 \n\t"
100 "movq %%mm1, (%3) \n\t"
101 "movq %%mm2, 8(%3) \n\t"
107 :
"r" (
y),
"r" (u),
"r" (
v),
"r" (dst),
"r" (w/8)
113 #if HAVE_EBX_AVAILABLE
114 static void pack_li_0_MMX(
unsigned char *
dst,
unsigned char *
y,
115 unsigned char *
u,
unsigned char *
v,
int w,
int us,
int vs)
118 "push %%"REG_BP
" \n\t"
120 "mov %6, %%"REG_BP
" \n\t"
122 "movl 4(%%"REG_d
"), %%"REG_BP
" \n\t"
123 "movl (%%"REG_d
"), %%"REG_d
" \n\t"
125 "pxor %%mm0, %%mm0 \n\t"
129 "movq (%%"REG_S
"), %%mm1 \n\t"
130 "movq (%%"REG_S
"), %%mm2 \n\t"
132 "movq (%%"REG_a
",%%"REG_d
",2), %%mm4 \n\t"
133 "movq (%%"REG_b
",%%"REG_BP
",2), %%mm6 \n\t"
134 "punpcklbw %%mm0, %%mm4 \n\t"
135 "punpcklbw %%mm0, %%mm6 \n\t"
136 "movq (%%"REG_a
"), %%mm3 \n\t"
137 "movq (%%"REG_b
"), %%mm5 \n\t"
138 "punpcklbw %%mm0, %%mm3 \n\t"
139 "punpcklbw %%mm0, %%mm5 \n\t"
140 "paddw %%mm3, %%mm4 \n\t"
141 "paddw %%mm5, %%mm6 \n\t"
142 "paddw %%mm3, %%mm4 \n\t"
143 "paddw %%mm5, %%mm6 \n\t"
144 "paddw %%mm3, %%mm4 \n\t"
145 "paddw %%mm5, %%mm6 \n\t"
146 "paddw %%mm3, %%mm4 \n\t"
147 "paddw %%mm5, %%mm6 \n\t"
148 "paddw %%mm3, %%mm4 \n\t"
149 "paddw %%mm5, %%mm6 \n\t"
150 "paddw %%mm3, %%mm4 \n\t"
151 "paddw %%mm5, %%mm6 \n\t"
152 "paddw %%mm3, %%mm4 \n\t"
153 "paddw %%mm5, %%mm6 \n\t"
154 "psrlw $3, %%mm4 \n\t"
155 "psrlw $3, %%mm6 \n\t"
156 "packuswb %%mm4, %%mm4 \n\t"
157 "packuswb %%mm6, %%mm6 \n\t"
158 "punpcklbw %%mm6, %%mm4 \n\t"
159 "punpcklbw %%mm4, %%mm1 \n\t"
160 "punpckhbw %%mm4, %%mm2 \n\t"
162 "movq %%mm1, (%%"REG_D
") \n\t"
163 "movq %%mm2, 8(%%"REG_D
") \n\t"
165 "movq 8(%%"REG_S
"), %%mm1 \n\t"
166 "movq 8(%%"REG_S
"), %%mm2 \n\t"
168 "movq (%%"REG_a
",%%"REG_d
",2), %%mm4 \n\t"
169 "movq (%%"REG_b
",%%"REG_BP
",2), %%mm6 \n\t"
170 "punpckhbw %%mm0, %%mm4 \n\t"
171 "punpckhbw %%mm0, %%mm6 \n\t"
172 "movq (%%"REG_a
"), %%mm3 \n\t"
173 "movq (%%"REG_b
"), %%mm5 \n\t"
174 "punpckhbw %%mm0, %%mm3 \n\t"
175 "punpckhbw %%mm0, %%mm5 \n\t"
176 "paddw %%mm3, %%mm4 \n\t"
177 "paddw %%mm5, %%mm6 \n\t"
178 "paddw %%mm3, %%mm4 \n\t"
179 "paddw %%mm5, %%mm6 \n\t"
180 "paddw %%mm3, %%mm4 \n\t"
181 "paddw %%mm5, %%mm6 \n\t"
182 "paddw %%mm3, %%mm4 \n\t"
183 "paddw %%mm5, %%mm6 \n\t"
184 "paddw %%mm3, %%mm4 \n\t"
185 "paddw %%mm5, %%mm6 \n\t"
186 "paddw %%mm3, %%mm4 \n\t"
187 "paddw %%mm5, %%mm6 \n\t"
188 "paddw %%mm3, %%mm4 \n\t"
189 "paddw %%mm5, %%mm6 \n\t"
190 "psrlw $3, %%mm4 \n\t"
191 "psrlw $3, %%mm6 \n\t"
192 "packuswb %%mm4, %%mm4 \n\t"
193 "packuswb %%mm6, %%mm6 \n\t"
194 "punpcklbw %%mm6, %%mm4 \n\t"
195 "punpcklbw %%mm4, %%mm1 \n\t"
196 "punpckhbw %%mm4, %%mm2 \n\t"
198 "add $16, %%"REG_S
" \n\t"
199 "add $8, %%"REG_a
" \n\t"
200 "add $8, %%"REG_b
" \n\t"
202 "movq %%mm1, 16(%%"REG_D
") \n\t"
203 "movq %%mm2, 24(%%"REG_D
") \n\t"
204 "add $32, %%"REG_D
" \n\t"
209 "pop %%"REG_BP
" \n\t"
211 :
"S" (
y),
"D" (dst),
"a" (
u),
"b" (v),
"c" (w/16),
222 static void pack_li_1_MMX(
unsigned char *dst,
unsigned char *y,
223 unsigned char *u,
unsigned char *v,
int w,
int us,
int vs)
226 "push %%"REG_BP
" \n\t"
228 "mov %6, %%"REG_BP
" \n\t"
230 "movl 4(%%"REG_d
"), %%"REG_BP
" \n\t"
231 "movl (%%"REG_d
"), %%"REG_d
" \n\t"
233 "pxor %%mm0, %%mm0 \n\t"
237 "movq (%%"REG_S
"), %%mm1 \n\t"
238 "movq (%%"REG_S
"), %%mm2 \n\t"
240 "movq (%%"REG_a
",%%"REG_d
",2), %%mm4 \n\t"
241 "movq (%%"REG_b
",%%"REG_BP
",2), %%mm6 \n\t"
242 "punpcklbw %%mm0, %%mm4 \n\t"
243 "punpcklbw %%mm0, %%mm6 \n\t"
244 "movq (%%"REG_a
"), %%mm3 \n\t"
245 "movq (%%"REG_b
"), %%mm5 \n\t"
246 "punpcklbw %%mm0, %%mm3 \n\t"
247 "punpcklbw %%mm0, %%mm5 \n\t"
248 "movq %%mm4, %%mm7 \n\t"
249 "paddw %%mm4, %%mm4 \n\t"
250 "paddw %%mm7, %%mm4 \n\t"
251 "movq %%mm6, %%mm7 \n\t"
252 "paddw %%mm6, %%mm6 \n\t"
253 "paddw %%mm7, %%mm6 \n\t"
254 "paddw %%mm3, %%mm4 \n\t"
255 "paddw %%mm5, %%mm6 \n\t"
256 "paddw %%mm3, %%mm4 \n\t"
257 "paddw %%mm5, %%mm6 \n\t"
258 "paddw %%mm3, %%mm4 \n\t"
259 "paddw %%mm5, %%mm6 \n\t"
260 "paddw %%mm3, %%mm4 \n\t"
261 "paddw %%mm5, %%mm6 \n\t"
262 "paddw %%mm3, %%mm4 \n\t"
263 "paddw %%mm5, %%mm6 \n\t"
264 "psrlw $3, %%mm4 \n\t"
265 "psrlw $3, %%mm6 \n\t"
266 "packuswb %%mm4, %%mm4 \n\t"
267 "packuswb %%mm6, %%mm6 \n\t"
268 "punpcklbw %%mm6, %%mm4 \n\t"
269 "punpcklbw %%mm4, %%mm1 \n\t"
270 "punpckhbw %%mm4, %%mm2 \n\t"
272 "movq %%mm1, (%%"REG_D
") \n\t"
273 "movq %%mm2, 8(%%"REG_D
") \n\t"
275 "movq 8(%%"REG_S
"), %%mm1 \n\t"
276 "movq 8(%%"REG_S
"), %%mm2 \n\t"
278 "movq (%%"REG_a
",%%"REG_d
",2), %%mm4 \n\t"
279 "movq (%%"REG_b
",%%"REG_BP
",2), %%mm6 \n\t"
280 "punpckhbw %%mm0, %%mm4 \n\t"
281 "punpckhbw %%mm0, %%mm6 \n\t"
282 "movq (%%"REG_a
"), %%mm3 \n\t"
283 "movq (%%"REG_b
"), %%mm5 \n\t"
284 "punpckhbw %%mm0, %%mm3 \n\t"
285 "punpckhbw %%mm0, %%mm5 \n\t"
286 "movq %%mm4, %%mm7 \n\t"
287 "paddw %%mm4, %%mm4 \n\t"
288 "paddw %%mm7, %%mm4 \n\t"
289 "movq %%mm6, %%mm7 \n\t"
290 "paddw %%mm6, %%mm6 \n\t"
291 "paddw %%mm7, %%mm6 \n\t"
292 "paddw %%mm3, %%mm4 \n\t"
293 "paddw %%mm5, %%mm6 \n\t"
294 "paddw %%mm3, %%mm4 \n\t"
295 "paddw %%mm5, %%mm6 \n\t"
296 "paddw %%mm3, %%mm4 \n\t"
297 "paddw %%mm5, %%mm6 \n\t"
298 "paddw %%mm3, %%mm4 \n\t"
299 "paddw %%mm5, %%mm6 \n\t"
300 "paddw %%mm3, %%mm4 \n\t"
301 "paddw %%mm5, %%mm6 \n\t"
302 "psrlw $3, %%mm4 \n\t"
303 "psrlw $3, %%mm6 \n\t"
304 "packuswb %%mm4, %%mm4 \n\t"
305 "packuswb %%mm6, %%mm6 \n\t"
306 "punpcklbw %%mm6, %%mm4 \n\t"
307 "punpcklbw %%mm4, %%mm1 \n\t"
308 "punpckhbw %%mm4, %%mm2 \n\t"
310 "add $16, %%"REG_S
" \n\t"
311 "add $8, %%"REG_a
" \n\t"
312 "add $8, %%"REG_b
" \n\t"
314 "movq %%mm1, 16(%%"REG_D
") \n\t"
315 "movq %%mm2, 24(%%"REG_D
") \n\t"
316 "add $32, %%"REG_D
" \n\t"
321 "pop %%"REG_BP
" \n\t"
323 :
"S" (
y),
"D" (dst),
"a" (
u),
"b" (v),
"c" (w/16),
340 static void ilpack(
unsigned char *dst,
unsigned char *src[3],
341 int dststride,
int srcstride[3],
int w,
int h,
pack_func_t *pack[2])
344 unsigned char *
y, *
u, *
v;
345 int ys = srcstride[0], us = srcstride[1], vs = srcstride[2];
352 pack_nn(dst, y, u, v, w, 0, 0);
353 y += ys; dst += dststride;
354 pack_nn(dst, y, u+us, v+vs, w, 0, 0);
355 y += ys; dst += dststride;
356 for (i=2; i<h-2; i++) {
358 b = (i&1) ^ ((i&2)>>1);
370 pack_nn(dst, y, u, v, w, 0, 0);
371 y += ys; dst += dststride; u += us; v += vs;
372 pack_nn(dst, y, u, v, w, 0, 0);
390 static int config(
struct vf_instance *vf,
392 unsigned int flags,
unsigned int outfmt)
418 if (args) sscanf(args,
"%d", &vf->
priv->
mode);
426 #if HAVE_EBX_AVAILABLE
427 pack_li_0 = pack_li_0_MMX;
428 pack_li_1 = pack_li_1_MMX;
439 "ilpack: unknown mode %d (fallback to linear)\n",
452 "4:2:0 planar -> 4:2:2 packed reinterlacer",