37 #if HAVE_6REGS && HAVE_INLINE_ASM && HAVE_MMX_EXTERNAL
39 void ff_vc1_put_ver_16b_shift2_mmx(int16_t *dst,
43 const int16_t *
src,
int rnd);
45 const int16_t *
src,
int rnd);
48 #define OP_AVG(S,D) "pavgb " #S ", " #D " \n\t"
51 #define NORMALIZE_MMX(SHIFT) \
52 "paddw %%mm7, %%mm3 \n\t" \
53 "paddw %%mm7, %%mm4 \n\t" \
54 "psraw "SHIFT", %%mm3 \n\t" \
55 "psraw "SHIFT", %%mm4 \n\t"
57 #define TRANSFER_DO_PACK(OP) \
58 "packuswb %%mm4, %%mm3 \n\t" \
60 "movq %%mm3, (%2) \n\t"
62 #define TRANSFER_DONT_PACK(OP) \
65 "movq %%mm3, 0(%2) \n\t" \
66 "movq %%mm4, 8(%2) \n\t"
69 #define DO_UNPACK(reg) "punpcklbw %%mm0, " reg "\n\t"
70 #define DONT_UNPACK(reg)
73 #define LOAD_ROUNDER_MMX(ROUND) \
74 "movd "ROUND", %%mm7 \n\t" \
75 "punpcklwd %%mm7, %%mm7 \n\t" \
76 "punpckldq %%mm7, %%mm7 \n\t"
82 #define VC1_SHIFT2(OP, OPNAME)\
83 static void OPNAME ## vc1_shift2_mmx(uint8_t *dst, const uint8_t *src,\
84 x86_reg stride, int rnd, x86_reg offset)\
88 "mov $8, %%"FF_REG_c" \n\t"\
89 LOAD_ROUNDER_MMX("%5")\
90 "movq "MANGLE(ff_pw_9)", %%mm6\n\t"\
92 "movd 0(%0 ), %%mm3 \n\t"\
93 "movd 4(%0 ), %%mm4 \n\t"\
94 "movd 0(%0,%2), %%mm1 \n\t"\
95 "movd 4(%0,%2), %%mm2 \n\t"\
97 "punpcklbw %%mm0, %%mm3 \n\t"\
98 "punpcklbw %%mm0, %%mm4 \n\t"\
99 "punpcklbw %%mm0, %%mm1 \n\t"\
100 "punpcklbw %%mm0, %%mm2 \n\t"\
101 "paddw %%mm1, %%mm3 \n\t"\
102 "paddw %%mm2, %%mm4 \n\t"\
103 "movd 0(%0,%3), %%mm1 \n\t"\
104 "movd 4(%0,%3), %%mm2 \n\t"\
105 "pmullw %%mm6, %%mm3 \n\t" \
106 "pmullw %%mm6, %%mm4 \n\t" \
107 "punpcklbw %%mm0, %%mm1 \n\t"\
108 "punpcklbw %%mm0, %%mm2 \n\t"\
109 "psubw %%mm1, %%mm3 \n\t" \
110 "psubw %%mm2, %%mm4 \n\t" \
111 "movd 0(%0,%2), %%mm1 \n\t"\
112 "movd 4(%0,%2), %%mm2 \n\t"\
113 "punpcklbw %%mm0, %%mm1 \n\t"\
114 "punpcklbw %%mm0, %%mm2 \n\t"\
115 "psubw %%mm1, %%mm3 \n\t" \
116 "psubw %%mm2, %%mm4 \n\t" \
118 "packuswb %%mm4, %%mm3 \n\t"\
120 "movq %%mm3, (%1) \n\t"\
123 "dec %%"FF_REG_c" \n\t"\
125 : "+r"(src), "+r"(dst)\
126 : "r"(offset), "r"(-2*offset), "g"(stride), "m"(rnd),\
128 NAMED_CONSTRAINTS_ADD(ff_pw_9)\
129 : "%"FF_REG_c, "memory"\
146 #define MSPEL_FILTER13_CORE(UNPACK, MOVQ, A1, A2, A3, A4) \
147 MOVQ "*0+"A1", %%mm1 \n\t" \
148 MOVQ "*4+"A1", %%mm2 \n\t" \
151 "pmullw "MANGLE(ff_pw_3)", %%mm1\n\t" \
152 "pmullw "MANGLE(ff_pw_3)", %%mm2\n\t" \
153 MOVQ "*0+"A2", %%mm3 \n\t" \
154 MOVQ "*4+"A2", %%mm4 \n\t" \
157 "pmullw %%mm6, %%mm3 \n\t" \
158 "pmullw %%mm6, %%mm4 \n\t" \
159 "psubw %%mm1, %%mm3 \n\t" \
160 "psubw %%mm2, %%mm4 \n\t" \
161 MOVQ "*0+"A4", %%mm1 \n\t" \
162 MOVQ "*4+"A4", %%mm2 \n\t" \
165 "psllw $2, %%mm1 \n\t" \
166 "psllw $2, %%mm2 \n\t" \
167 "psubw %%mm1, %%mm3 \n\t" \
168 "psubw %%mm2, %%mm4 \n\t" \
169 MOVQ "*0+"A3", %%mm1 \n\t" \
170 MOVQ "*4+"A3", %%mm2 \n\t" \
173 "pmullw %%mm5, %%mm1 \n\t" \
174 "pmullw %%mm5, %%mm2 \n\t" \
175 "paddw %%mm1, %%mm3 \n\t" \
176 "paddw %%mm2, %%mm4 \n\t"
186 #define MSPEL_FILTER13_VER_16B(NAME, A1, A2, A3, A4) \
188 vc1_put_ver_16b_ ## NAME ## _mmx(int16_t *dst, const uint8_t *src, \
189 x86_reg src_stride, \
190 int rnd, int64_t shift) \
195 LOAD_ROUNDER_MMX("%5") \
196 "movq "MANGLE(ff_pw_53)", %%mm5\n\t" \
197 "movq "MANGLE(ff_pw_18)", %%mm6\n\t" \
200 MSPEL_FILTER13_CORE(DO_UNPACK, "movd 1", A1, A2, A3, A4) \
201 NORMALIZE_MMX("%6") \
202 TRANSFER_DONT_PACK(OP_PUT) \
204 "movd 8+"A1", %%mm1 \n\t" \
206 "movq %%mm1, %%mm3 \n\t" \
207 "paddw %%mm1, %%mm1 \n\t" \
208 "paddw %%mm3, %%mm1 \n\t" \
209 "movd 8+"A2", %%mm3 \n\t" \
211 "pmullw %%mm6, %%mm3 \n\t" \
212 "psubw %%mm1, %%mm3 \n\t" \
213 "movd 8+"A3", %%mm1 \n\t" \
215 "pmullw %%mm5, %%mm1 \n\t" \
216 "paddw %%mm1, %%mm3 \n\t" \
217 "movd 8+"A4", %%mm1 \n\t" \
219 "psllw $2, %%mm1 \n\t" \
220 "psubw %%mm1, %%mm3 \n\t" \
221 "paddw %%mm7, %%mm3 \n\t" \
222 "psraw %6, %%mm3 \n\t" \
223 "movq %%mm3, 16(%2) \n\t" \
228 : "+r"(h), "+r" (src), "+r" (dst) \
229 : "r"(src_stride), "r"(3*src_stride), \
230 "m"(rnd), "m"(shift) \
231 NAMED_CONSTRAINTS_ADD(ff_pw_3,ff_pw_53,ff_pw_18) \
243 #define MSPEL_FILTER13_HOR_16B(NAME, A1, A2, A3, A4, OP, OPNAME) \
245 OPNAME ## vc1_hor_16b_ ## NAME ## _mmx(uint8_t *dst, x86_reg stride, \
246 const int16_t *src, int rnd) \
250 rnd -= (-4+58+13-3)*256; \
252 LOAD_ROUNDER_MMX("%4") \
253 "movq "MANGLE(ff_pw_18)", %%mm6 \n\t" \
254 "movq "MANGLE(ff_pw_53)", %%mm5 \n\t" \
257 MSPEL_FILTER13_CORE(DONT_UNPACK, "movq 2", A1, A2, A3, A4) \
258 NORMALIZE_MMX("$7") \
260 "paddw "MANGLE(ff_pw_128)", %%mm3 \n\t" \
261 "paddw "MANGLE(ff_pw_128)", %%mm4 \n\t" \
262 TRANSFER_DO_PACK(OP) \
267 : "+r"(h), "+r" (src), "+r" (dst) \
268 : "r"(stride), "m"(rnd) \
269 NAMED_CONSTRAINTS_ADD(ff_pw_3,ff_pw_18,ff_pw_53,ff_pw_128) \
282 #define MSPEL_FILTER13_8B(NAME, A1, A2, A3, A4, OP, OPNAME) \
284 OPNAME ## vc1_## NAME ## _mmx(uint8_t *dst, const uint8_t *src, \
285 x86_reg stride, int rnd, x86_reg offset) \
291 LOAD_ROUNDER_MMX("%6") \
292 "movq "MANGLE(ff_pw_53)", %%mm5 \n\t" \
293 "movq "MANGLE(ff_pw_18)", %%mm6 \n\t" \
296 MSPEL_FILTER13_CORE(DO_UNPACK, "movd 1", A1, A2, A3, A4) \
297 NORMALIZE_MMX("$6") \
298 TRANSFER_DO_PACK(OP) \
303 : "+r"(h), "+r" (src), "+r" (dst) \
304 : "r"(offset), "r"(3*offset), "g"(stride), "m"(rnd) \
305 NAMED_CONSTRAINTS_ADD(ff_pw_53,ff_pw_18,ff_pw_3) \
311 MSPEL_FILTER13_8B (
shift1,
"0(%1,%4 )",
"0(%1,%3,2)",
"0(%1,%3 )",
"0(%1 )",
OP_PUT, put_)
312 MSPEL_FILTER13_8B (
shift1,
"0(%1,%4 )",
"0(%1,%3,2)",
"0(%1,%3 )",
"0(%1 )",
OP_AVG, avg_)
318 MSPEL_FILTER13_8B (shift3, "0(%1 )", "0(%1,%3 )", "0(%1,%3,2)", "0(%1,%4 )",
OP_PUT, put_)
319 MSPEL_FILTER13_8B (shift3, "0(%1 )", "0(%1,%3 )", "0(%1,%3,2)", "0(%1,%4 )",
OP_AVG, avg_)
339 #define VC1_MSPEL_MC(OP, INSTR)\
340 static void OP ## vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride,\
341 int hmode, int vmode, int rnd)\
343 static const vc1_mspel_mc_filter_ver_16bits vc1_put_shift_ver_16bits[] =\
344 { NULL, vc1_put_ver_16b_shift1_mmx, ff_vc1_put_ver_16b_shift2_mmx, vc1_put_ver_16b_shift3_mmx };\
345 static const vc1_mspel_mc_filter_hor_16bits vc1_put_shift_hor_16bits[] =\
346 { NULL, OP ## vc1_hor_16b_shift1_mmx, ff_vc1_ ## OP ## hor_16b_shift2_ ## INSTR, OP ## vc1_hor_16b_shift3_mmx };\
347 static const vc1_mspel_mc_filter_8bits vc1_put_shift_8bits[] =\
348 { NULL, OP ## vc1_shift1_mmx, OP ## vc1_shift2_mmx, OP ## vc1_shift3_mmx };\
351 "pxor %%mm0, %%mm0 \n\t"\
357 static const int shift_value[] = { 0, 5, 1, 5 };\
358 int shift = (shift_value[hmode]+shift_value[vmode])>>1;\
360 LOCAL_ALIGNED(16, int16_t, tmp, [12*8]);\
362 r = (1<<(shift-1)) + rnd-1;\
363 vc1_put_shift_ver_16bits[vmode](tmp, src-1, stride, r, shift);\
365 vc1_put_shift_hor_16bits[hmode](dst, stride, tmp+1, 64-rnd);\
369 vc1_put_shift_8bits[vmode](dst, src, stride, 1-rnd, stride);\
375 vc1_put_shift_8bits[hmode](dst, src, stride, rnd, 1);\
377 static void OP ## vc1_mspel_mc_16(uint8_t *dst, const uint8_t *src, \
378 int stride, int hmode, int vmode, int rnd)\
380 OP ## vc1_mspel_mc(dst + 0, src + 0, stride, hmode, vmode, rnd); \
381 OP ## vc1_mspel_mc(dst + 8, src + 8, stride, hmode, vmode, rnd); \
382 dst += 8*stride; src += 8*stride; \
383 OP ## vc1_mspel_mc(dst + 0, src + 0, stride, hmode, vmode, rnd); \
384 OP ## vc1_mspel_mc(dst + 8, src + 8, stride, hmode, vmode, rnd); \
391 #define DECLARE_FUNCTION(a, b) \
392 static void put_vc1_mspel_mc ## a ## b ## _mmx(uint8_t *dst, \
393 const uint8_t *src, \
397 put_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
399 static void avg_vc1_mspel_mc ## a ## b ## _mmxext(uint8_t *dst, \
400 const uint8_t *src, \
404 avg_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
406 static void put_vc1_mspel_mc ## a ## b ## _16_mmx(uint8_t *dst, \
407 const uint8_t *src, \
411 put_vc1_mspel_mc_16(dst, src, stride, a, b, rnd); \
413 static void avg_vc1_mspel_mc ## a ## b ## _16_mmxext(uint8_t *dst, \
418 avg_vc1_mspel_mc_16(dst, src, stride, a, b, rnd); \
440 #define FN_ASSIGN(OP, X, Y, INSN) \
441 dsp->OP##vc1_mspel_pixels_tab[1][X+4*Y] = OP##vc1_mspel_mc##X##Y##INSN; \
442 dsp->OP##vc1_mspel_pixels_tab[0][X+4*Y] = OP##vc1_mspel_mc##X##Y##_16##INSN