38 # define RENAME(a) a ## _C
40 # define TEMPLATE_PP_C 0
43 #ifdef TEMPLATE_PP_ALTIVEC
44 # define RENAME(a) a ## _altivec
46 # define TEMPLATE_PP_ALTIVEC 0
49 #ifdef TEMPLATE_PP_MMX
50 # define RENAME(a) a ## _MMX
52 # define TEMPLATE_PP_MMX 0
55 #ifdef TEMPLATE_PP_MMXEXT
56 # undef TEMPLATE_PP_MMX
57 # define TEMPLATE_PP_MMX 1
58 # define RENAME(a) a ## _MMX2
60 # define TEMPLATE_PP_MMXEXT 0
63 #ifdef TEMPLATE_PP_SSE2
64 # undef TEMPLATE_PP_MMX
65 # define TEMPLATE_PP_MMX 1
66 # undef TEMPLATE_PP_MMXEXT
67 # define TEMPLATE_PP_MMXEXT 1
68 # define RENAME(a) a ## _SSE2
70 # define TEMPLATE_PP_SSE2 0
78 #if TEMPLATE_PP_MMXEXT
79 #define REAL_PAVGB(a,b) "pavgb " #a ", " #b " \n\t"
81 #define PAVGB(a,b) REAL_PAVGB(a,b)
83 #if TEMPLATE_PP_MMXEXT
84 #define PMINUB(a,b,t) "pminub " #a ", " #b " \n\t"
87 #if TEMPLATE_PP_MMXEXT
88 #define PMAXUB(a,b) "pmaxub " #a ", " #b " \n\t"
92 #if TEMPLATE_PP_MMXEXT
100 "movq %0, %%mm7 \n\t"
101 "movq %1, %%mm6 \n\t"
102 : :
"m" (
c->mmxDcOffset[
c->nonBQP]),
"m" (
c->mmxDcThreshold[
c->nonBQP])
106 "lea (%2, %3), %%"FF_REG_a
" \n\t"
110 "movq (%2), %%mm0 \n\t"
111 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
112 "movq %%mm0, %%mm3 \n\t"
113 "movq %%mm0, %%mm4 \n\t"
115 PMINUB(%%mm1, %%mm3, %%mm5)
116 "psubb %%mm1, %%mm0 \n\t"
117 "paddb %%mm7, %%mm0 \n\t"
118 "pcmpgtb %%mm6, %%mm0 \n\t"
120 "movq (%%"FF_REG_a
",%3), %%mm2 \n\t"
122 PMINUB(%%mm2, %%mm3, %%mm5)
123 "psubb %%mm2, %%mm1 \n\t"
124 "paddb %%mm7, %%mm1 \n\t"
125 "pcmpgtb %%mm6, %%mm1 \n\t"
126 "paddb %%mm1, %%mm0 \n\t"
128 "movq (%%"FF_REG_a
", %3, 2), %%mm1 \n\t"
130 PMINUB(%%mm1, %%mm3, %%mm5)
131 "psubb %%mm1, %%mm2 \n\t"
132 "paddb %%mm7, %%mm2 \n\t"
133 "pcmpgtb %%mm6, %%mm2 \n\t"
134 "paddb %%mm2, %%mm0 \n\t"
136 "lea (%%"FF_REG_a
", %3, 4), %%"FF_REG_a
"\n\t"
138 "movq (%2, %3, 4), %%mm2 \n\t"
140 PMINUB(%%mm2, %%mm3, %%mm5)
141 "psubb %%mm2, %%mm1 \n\t"
142 "paddb %%mm7, %%mm1 \n\t"
143 "pcmpgtb %%mm6, %%mm1 \n\t"
144 "paddb %%mm1, %%mm0 \n\t"
146 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
148 PMINUB(%%mm1, %%mm3, %%mm5)
149 "psubb %%mm1, %%mm2 \n\t"
150 "paddb %%mm7, %%mm2 \n\t"
151 "pcmpgtb %%mm6, %%mm2 \n\t"
152 "paddb %%mm2, %%mm0 \n\t"
154 "movq (%%"FF_REG_a
", %3), %%mm2 \n\t"
156 PMINUB(%%mm2, %%mm3, %%mm5)
157 "psubb %%mm2, %%mm1 \n\t"
158 "paddb %%mm7, %%mm1 \n\t"
159 "pcmpgtb %%mm6, %%mm1 \n\t"
160 "paddb %%mm1, %%mm0 \n\t"
162 "movq (%%"FF_REG_a
", %3, 2), %%mm1 \n\t"
164 PMINUB(%%mm1, %%mm3, %%mm5)
165 "psubb %%mm1, %%mm2 \n\t"
166 "paddb %%mm7, %%mm2 \n\t"
167 "pcmpgtb %%mm6, %%mm2 \n\t"
168 "paddb %%mm2, %%mm0 \n\t"
169 "psubusb %%mm3, %%mm4 \n\t"
172 "pxor %%mm7, %%mm7 \n\t"
173 "psadbw %%mm7, %%mm0 \n\t"
174 "movq %4, %%mm7 \n\t"
175 "paddusb %%mm7, %%mm7 \n\t"
176 "psubusb %%mm7, %%mm4 \n\t"
177 "packssdw %%mm4, %%mm4 \n\t"
178 "movd %%mm0, %0 \n\t"
179 "movd %%mm4, %1 \n\t"
181 :
"=r" (numEq),
"=r" (dcOk)
186 numEq= (-numEq) &0xFF;
187 if(numEq >
c->ppMode.flatnessThreshold){
194 #endif //TEMPLATE_PP_MMXEXT
200 #if !TEMPLATE_PP_ALTIVEC
203 #if TEMPLATE_PP_MMXEXT
206 "movq %2, %%mm0 \n\t"
207 "pxor %%mm4, %%mm4 \n\t"
209 "movq (%0), %%mm6 \n\t"
210 "movq (%0, %1), %%mm5 \n\t"
211 "movq %%mm5, %%mm1 \n\t"
212 "movq %%mm6, %%mm2 \n\t"
213 "psubusb %%mm6, %%mm5 \n\t"
214 "psubusb %%mm1, %%mm2 \n\t"
215 "por %%mm5, %%mm2 \n\t"
216 "psubusb %%mm0, %%mm2 \n\t"
217 "pcmpeqb %%mm4, %%mm2 \n\t"
219 "pand %%mm2, %%mm6 \n\t"
220 "pandn %%mm1, %%mm2 \n\t"
221 "por %%mm2, %%mm6 \n\t"
223 "movq (%0, %1, 8), %%mm5 \n\t"
224 "lea (%0, %1, 4), %%"FF_REG_a
" \n\t"
225 "lea (%0, %1, 8), %%"FF_REG_c
" \n\t"
226 "sub %1, %%"FF_REG_c
" \n\t"
228 "movq (%0, %1, 8), %%mm7 \n\t"
229 "movq %%mm5, %%mm1 \n\t"
230 "movq %%mm7, %%mm2 \n\t"
231 "psubusb %%mm7, %%mm5 \n\t"
232 "psubusb %%mm1, %%mm2 \n\t"
233 "por %%mm5, %%mm2 \n\t"
234 "psubusb %%mm0, %%mm2 \n\t"
235 "pcmpeqb %%mm4, %%mm2 \n\t"
237 "pand %%mm2, %%mm7 \n\t"
238 "pandn %%mm1, %%mm2 \n\t"
239 "por %%mm2, %%mm7 \n\t"
248 "movq (%0, %1), %%mm0 \n\t"
249 "movq %%mm0, %%mm1 \n\t"
253 "movq (%0, %1, 4), %%mm2 \n\t"
254 "movq %%mm2, %%mm5 \n\t"
255 PAVGB((%%FF_REGa), %%mm2)
256 PAVGB((%0, %1, 2), %%mm2)
257 "movq %%mm2, %%mm3 \n\t"
258 "movq (%0), %%mm4 \n\t"
261 "movq %%mm3, (%0) \n\t"
263 "movq %%mm1, %%mm0 \n\t"
265 "movq %%mm4, %%mm3 \n\t"
266 PAVGB((%0,%1,2), %%mm3)
267 PAVGB((%%FF_REGa,%1,2), %%mm5)
268 PAVGB((%%FF_REGa), %%mm5)
271 "movq %%mm3, (%0,%1) \n\t"
274 "movq (%%"FF_REG_c
"), %%mm0 \n\t"
275 PAVGB((%%FF_REGa, %1, 2), %%mm0)
276 "movq %%mm0, %%mm3 \n\t"
280 "movq (%0, %1, 2), %%mm2 \n\t"
281 "movq %%mm0, (%0, %1, 2) \n\t"
283 "movq (%%"FF_REG_a
", %1, 4), %%mm0 \n\t"
284 PAVGB((%%FF_REGc), %%mm0)
290 "movq (%%"FF_REG_a
"), %%mm5 \n\t"
291 "movq %%mm6, (%%"FF_REG_a
") \n\t"
293 "movq (%%"FF_REG_a
", %1, 4), %%mm6 \n\t"
298 "movq (%0, %1, 4), %%mm4 \n\t"
301 "movq %%mm6, (%0, %1, 4) \n\t"
306 "movq (%%"FF_REG_a
", %1, 2), %%mm6 \n\t"
309 "movq %%mm1, (%%"FF_REG_a
", %1, 2) \n\t"
311 PAVGB((%%FF_REGc), %%mm2)
312 "movq (%%"FF_REG_a
", %1, 4), %%mm0 \n\t"
316 "movq %%mm6, (%%"FF_REG_c
") \n\t"
323 "movq %%mm5, (%%"FF_REG_a
", %1, 4) \n\t"
328 :
"%"FF_REG_a,
"%"FF_REG_c
330 #else //TEMPLATE_PP_MMXEXT
332 const int l2=
stride + l1;
333 const int l3=
stride + l2;
334 const int l4=
stride + l3;
335 const int l5=
stride + l4;
336 const int l6=
stride + l5;
337 const int l7=
stride + l6;
338 const int l8=
stride + l7;
339 const int l9=
stride + l8;
348 sums[1] = sums[0] -
first +
src[l4];
349 sums[2] = sums[1] -
first +
src[l5];
350 sums[3] = sums[2] -
first +
src[l6];
351 sums[4] = sums[3] -
first +
src[l7];
352 sums[5] = sums[4] -
src[l1] +
src[l8];
353 sums[6] = sums[5] -
src[l2] + last;
354 sums[7] = sums[6] -
src[l3] + last;
355 sums[8] = sums[7] -
src[l4] + last;
356 sums[9] = sums[8] -
src[l5] + last;
358 src[l1]= (sums[0] + sums[2] + 2*
src[l1])>>4;
359 src[l2]= (sums[1] + sums[3] + 2*
src[l2])>>4;
360 src[l3]= (sums[2] + sums[4] + 2*
src[l3])>>4;
361 src[l4]= (sums[3] + sums[5] + 2*
src[l4])>>4;
362 src[l5]= (sums[4] + sums[6] + 2*
src[l5])>>4;
363 src[l6]= (sums[5] + sums[7] + 2*
src[l6])>>4;
364 src[l7]= (sums[6] + sums[8] + 2*
src[l7])>>4;
365 src[l8]= (sums[7] + sums[9] + 2*
src[l8])>>4;
369 #endif //TEMPLATE_PP_MMXEXT
371 #endif //TEMPLATE_PP_ALTIVEC
382 #if TEMPLATE_PP_MMXEXT
386 "pxor %%mm7, %%mm7 \n\t"
387 "lea (%0, %1), %%"FF_REG_a
" \n\t"
388 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_c
"\n\t"
391 "movq (%%"FF_REG_a
", %1, 2), %%mm0 \n\t"
392 "movq (%0, %1, 4), %%mm1 \n\t"
393 "movq %%mm1, %%mm2 \n\t"
394 "psubusb %%mm0, %%mm1 \n\t"
395 "psubusb %%mm2, %%mm0 \n\t"
396 "por %%mm1, %%mm0 \n\t"
397 "movq (%%"FF_REG_c
"), %%mm3 \n\t"
398 "movq (%%"FF_REG_c
", %1), %%mm4 \n\t"
399 "movq %%mm3, %%mm5 \n\t"
400 "psubusb %%mm4, %%mm3 \n\t"
401 "psubusb %%mm5, %%mm4 \n\t"
402 "por %%mm4, %%mm3 \n\t"
404 "movq %%mm2, %%mm1 \n\t"
405 "psubusb %%mm5, %%mm2 \n\t"
406 "movq %%mm2, %%mm4 \n\t"
407 "pcmpeqb %%mm7, %%mm2 \n\t"
408 "psubusb %%mm1, %%mm5 \n\t"
409 "por %%mm5, %%mm4 \n\t"
410 "psubusb %%mm0, %%mm4 \n\t"
411 "movq %%mm4, %%mm3 \n\t"
412 "movq %2, %%mm0 \n\t"
413 "paddusb %%mm0, %%mm0 \n\t"
414 "psubusb %%mm0, %%mm4 \n\t"
415 "pcmpeqb %%mm7, %%mm4 \n\t"
416 "psubusb "MANGLE(b01)
", %%mm3 \n\t"
417 "pand %%mm4, %%mm3 \n\t"
420 "movq %%mm3, %%mm1 \n\t"
424 "movq (%0, %1, 4), %%mm0 \n\t"
425 "pxor %%mm2, %%mm0 \n\t"
426 "psubusb %%mm3, %%mm0 \n\t"
427 "pxor %%mm2, %%mm0 \n\t"
428 "movq %%mm0, (%0, %1, 4) \n\t"
430 "movq (%%"FF_REG_c
"), %%mm0 \n\t"
431 "pxor %%mm2, %%mm0 \n\t"
432 "paddusb %%mm3, %%mm0 \n\t"
433 "pxor %%mm2, %%mm0 \n\t"
434 "movq %%mm0, (%%"FF_REG_c
") \n\t"
438 "movq (%%"FF_REG_a
", %1, 2), %%mm0 \n\t"
439 "pxor %%mm2, %%mm0 \n\t"
440 "psubusb %%mm1, %%mm0 \n\t"
441 "pxor %%mm2, %%mm0 \n\t"
442 "movq %%mm0, (%%"FF_REG_a
", %1, 2) \n\t"
444 "movq (%%"FF_REG_c
", %1), %%mm0 \n\t"
445 "pxor %%mm2, %%mm0 \n\t"
446 "paddusb %%mm1, %%mm0 \n\t"
447 "pxor %%mm2, %%mm0 \n\t"
448 "movq %%mm0, (%%"FF_REG_c
", %1) \n\t"
452 "movq (%%"FF_REG_a
", %1), %%mm0 \n\t"
453 "pxor %%mm2, %%mm0 \n\t"
454 "psubusb %%mm1, %%mm0 \n\t"
455 "pxor %%mm2, %%mm0 \n\t"
456 "movq %%mm0, (%%"FF_REG_a
", %1) \n\t"
458 "movq (%%"FF_REG_c
", %1, 2), %%mm0 \n\t"
459 "pxor %%mm2, %%mm0 \n\t"
460 "paddusb %%mm1, %%mm0 \n\t"
461 "pxor %%mm2, %%mm0 \n\t"
462 "movq %%mm0, (%%"FF_REG_c
", %1, 2) \n\t"
467 :
"%"FF_REG_a,
"%"FF_REG_c
469 #else //TEMPLATE_PP_MMXEXT
472 const int l2=
stride + l1;
473 const int l3=
stride + l2;
474 const int l4=
stride + l3;
475 const int l5=
stride + l4;
476 const int l6=
stride + l5;
477 const int l7=
stride + l6;
503 #endif //TEMPLATE_PP_MMXEXT
506 #if !TEMPLATE_PP_ALTIVEC
509 #if TEMPLATE_PP_MMXEXT
527 #if 0 //slightly more accurate and slightly slower
528 "pxor %%mm7, %%mm7 \n\t"
529 "lea (%0, %1), %%"FF_REG_a
" \n\t"
530 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_c
"\n\t"
536 "movq (%0, %1, 2), %%mm0 \n\t"
537 "movq (%0), %%mm1 \n\t"
538 "movq %%mm0, %%mm2 \n\t"
543 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
544 "movq (%%"FF_REG_a
", %1, 2), %%mm3 \n\t"
545 "movq %%mm1, %%mm4 \n\t"
550 "movq %%mm0, %%mm4 \n\t"
551 "psubusb %%mm1, %%mm0 \n\t"
552 "psubusb %%mm4, %%mm1 \n\t"
553 "por %%mm0, %%mm1 \n\t"
556 "movq (%0, %1, 4), %%mm0 \n\t"
557 "movq %%mm0, %%mm4 \n\t"
562 "movq (%%"FF_REG_c
"), %%mm2 \n\t"
563 "movq %%mm3, %%mm5 \n\t"
568 "movq %%mm0, %%mm6 \n\t"
569 "psubusb %%mm3, %%mm0 \n\t"
570 "psubusb %%mm6, %%mm3 \n\t"
571 "por %%mm0, %%mm3 \n\t"
572 "pcmpeqb %%mm7, %%mm0 \n\t"
575 "movq (%%"FF_REG_c
", %1), %%mm6 \n\t"
576 "movq %%mm6, %%mm5 \n\t"
581 "movq (%%"FF_REG_c
", %1, 2), %%mm5 \n\t"
582 "movq %%mm2, %%mm4 \n\t"
587 "movq %%mm6, %%mm4 \n\t"
588 "psubusb %%mm2, %%mm6 \n\t"
589 "psubusb %%mm4, %%mm2 \n\t"
590 "por %%mm6, %%mm2 \n\t"
594 PMINUB(%%mm2, %%mm1, %%mm4)
595 "movq %2, %%mm4 \n\t"
596 "paddusb "MANGLE(b01)
", %%mm4 \n\t"
597 "pcmpgtb %%mm3, %%mm4 \n\t"
598 "psubusb %%mm1, %%mm3 \n\t"
599 "pand %%mm4, %%mm3 \n\t"
601 "movq %%mm3, %%mm1 \n\t"
605 "paddusb %%mm1, %%mm3 \n\t"
608 "movq (%%"FF_REG_a
", %1, 2), %%mm6 \n\t"
609 "movq (%0, %1, 4), %%mm5 \n\t"
610 "movq (%0, %1, 4), %%mm4 \n\t"
611 "psubusb %%mm6, %%mm5 \n\t"
612 "psubusb %%mm4, %%mm6 \n\t"
613 "por %%mm6, %%mm5 \n\t"
614 "pcmpeqb %%mm7, %%mm6 \n\t"
615 "pxor %%mm6, %%mm0 \n\t"
616 "pand %%mm0, %%mm3 \n\t"
617 PMINUB(%%mm5, %%mm3, %%mm0)
619 "psubusb "MANGLE(b01)
", %%mm3 \n\t"
622 "movq (%%"FF_REG_a
", %1, 2), %%mm0 \n\t"
623 "movq (%0, %1, 4), %%mm2 \n\t"
624 "pxor %%mm6, %%mm0 \n\t"
625 "pxor %%mm6, %%mm2 \n\t"
626 "psubb %%mm3, %%mm0 \n\t"
627 "paddb %%mm3, %%mm2 \n\t"
628 "pxor %%mm6, %%mm0 \n\t"
629 "pxor %%mm6, %%mm2 \n\t"
630 "movq %%mm0, (%%"FF_REG_a
", %1, 2) \n\t"
631 "movq %%mm2, (%0, %1, 4) \n\t"
634 "lea (%0, %1), %%"FF_REG_a
" \n\t"
635 "pcmpeqb %%mm6, %%mm6 \n\t"
641 "movq (%%"FF_REG_a
", %1, 2), %%mm1 \n\t"
642 "movq (%0, %1, 4), %%mm0 \n\t"
643 "pxor %%mm6, %%mm1 \n\t"
647 "movq (%%"FF_REG_a
", %1, 4), %%mm2 \n\t"
648 "movq (%%"FF_REG_a
", %1), %%mm3 \n\t"
649 "pxor %%mm6, %%mm2 \n\t"
650 "movq %%mm2, %%mm5 \n\t"
651 "movq "MANGLE(b80)
", %%mm4 \n\t"
652 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_c
"\n\t"
659 "movq (%%"FF_REG_a
"), %%mm2 \n\t"
660 "pxor %%mm6, %%mm2 \n\t"
663 "movq "MANGLE(b80)
", %%mm3 \n\t"
669 PAVGB((%%FF_REGc, %1), %%mm5)
670 "movq (%%"FF_REG_c
", %1, 2), %%mm1 \n\t"
671 "pxor %%mm6, %%mm1 \n\t"
672 PAVGB((%0, %1, 4), %%mm1)
673 "movq "MANGLE(b80)
", %%mm2 \n\t"
679 "movq "MANGLE(b00)
", %%mm1 \n\t"
680 "movq "MANGLE(b00)
", %%mm5 \n\t"
681 "psubb %%mm2, %%mm1 \n\t"
682 "psubb %%mm3, %%mm5 \n\t"
685 PMINUB(%%mm2, %%mm3, %%mm1)
689 "movq "MANGLE(b00)
", %%mm7 \n\t"
690 "movq %2, %%mm2 \n\t"
692 "psubb %%mm6, %%mm2 \n\t"
694 "movq %%mm4, %%mm1 \n\t"
695 "pcmpgtb %%mm7, %%mm1 \n\t"
696 "pxor %%mm1, %%mm4 \n\t"
697 "psubb %%mm1, %%mm4 \n\t"
698 "pcmpgtb %%mm4, %%mm2 \n\t"
699 "psubusb %%mm3, %%mm4 \n\t"
702 "movq %%mm4, %%mm3 \n\t"
703 "psubusb "MANGLE(b01)
", %%mm4 \n\t"
706 "paddb %%mm3, %%mm4 \n\t"
707 "pand %%mm2, %%mm4 \n\t"
709 "movq "MANGLE(b80)
", %%mm5 \n\t"
710 "psubb %%mm0, %%mm5 \n\t"
711 "paddsb %%mm6, %%mm5 \n\t"
712 "pcmpgtb %%mm5, %%mm7 \n\t"
713 "pxor %%mm7, %%mm5 \n\t"
715 PMINUB(%%mm5, %%mm4, %%mm3)
716 "pxor %%mm1, %%mm7 \n\t"
718 "pand %%mm7, %%mm4 \n\t"
719 "movq (%%"FF_REG_a
", %1, 2), %%mm0 \n\t"
720 "movq (%0, %1, 4), %%mm2 \n\t"
721 "pxor %%mm1, %%mm0 \n\t"
722 "pxor %%mm1, %%mm2 \n\t"
723 "paddb %%mm4, %%mm0 \n\t"
724 "psubb %%mm4, %%mm2 \n\t"
725 "pxor %%mm1, %%mm0 \n\t"
726 "pxor %%mm1, %%mm2 \n\t"
727 "movq %%mm0, (%%"FF_REG_a
", %1, 2) \n\t"
728 "movq %%mm2, (%0, %1, 4) \n\t"
733 :
"%"FF_REG_a,
"%"FF_REG_c
791 #else //TEMPLATE_PP_MMXEXT
793 const int l2=
stride + l1;
794 const int l3=
stride + l2;
795 const int l4=
stride + l3;
796 const int l5=
stride + l4;
797 const int l6=
stride + l5;
798 const int l7=
stride + l6;
799 const int l8=
stride + l7;
804 const int middleEnergy= 5*(
src[l5] -
src[l4]) + 2*(
src[l3] -
src[l6]);
805 if(
FFABS(middleEnergy) < 8*
c->QP){
806 const int q=(
src[l4] -
src[l5])/2;
807 const int leftEnergy= 5*(
src[l3] -
src[l2]) + 2*(
src[l1] -
src[l4]);
808 const int rightEnergy= 5*(
src[l7] -
src[l6]) + 2*(
src[l5] -
src[l8]);
814 d*=
FFSIGN(-middleEnergy);
829 #endif //TEMPLATE_PP_MMXEXT
831 #endif //TEMPLATE_PP_ALTIVEC
833 #if !TEMPLATE_PP_ALTIVEC
836 #if TEMPLATE_PP_MMXEXT && HAVE_7REGS
839 "pxor %%mm6, %%mm6 \n\t"
840 "pcmpeqb %%mm7, %%mm7 \n\t"
841 "movq %2, %%mm0 \n\t"
842 "punpcklbw %%mm6, %%mm0 \n\t"
843 "psrlw $1, %%mm0 \n\t"
844 "psubw %%mm7, %%mm0 \n\t"
845 "packuswb %%mm0, %%mm0 \n\t"
846 "movq %%mm0, %3 \n\t"
848 "lea (%0, %1), %%"FF_REG_a
" \n\t"
849 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_d
"\n\t"
854 #undef REAL_FIND_MIN_MAX
856 #define REAL_FIND_MIN_MAX(addr)\
857 "movq " #addr ", %%mm0 \n\t"\
858 "pminub %%mm0, %%mm7 \n\t"\
859 "pmaxub %%mm0, %%mm6 \n\t"
860 #define FIND_MIN_MAX(addr) REAL_FIND_MIN_MAX(addr)
862 FIND_MIN_MAX((%%FF_REGa))
863 FIND_MIN_MAX((%%FF_REGa, %1))
864 FIND_MIN_MAX((%%FF_REGa, %1, 2))
865 FIND_MIN_MAX((%0, %1, 4))
866 FIND_MIN_MAX((%%FF_REGd))
867 FIND_MIN_MAX((%%FF_REGd, %1))
868 FIND_MIN_MAX((%%FF_REGd, %1, 2))
869 FIND_MIN_MAX((%0, %1, 8))
871 "movq %%mm7, %%mm4 \n\t"
872 "psrlq $8, %%mm7 \n\t"
873 "pminub %%mm4, %%mm7 \n\t"
874 "pshufw $0xF9, %%mm7, %%mm4 \n\t"
875 "pminub %%mm4, %%mm7 \n\t"
876 "pshufw $0xFE, %%mm7, %%mm4 \n\t"
877 "pminub %%mm4, %%mm7 \n\t"
880 "movq %%mm6, %%mm4 \n\t"
881 "psrlq $8, %%mm6 \n\t"
882 "pmaxub %%mm4, %%mm6 \n\t"
883 "pshufw $0xF9, %%mm6, %%mm4 \n\t"
884 "pmaxub %%mm4, %%mm6 \n\t"
885 "pshufw $0xFE, %%mm6, %%mm4 \n\t"
886 "pmaxub %%mm4, %%mm6 \n\t"
887 "movq %%mm6, %%mm0 \n\t"
888 "psubb %%mm7, %%mm6 \n\t"
889 "push %%"FF_REG_a
" \n\t"
890 "movd %%mm6, %%eax \n\t"
891 "cmpb "MANGLE(deringThreshold)
", %%al \n\t"
892 "pop %%"FF_REG_a
" \n\t"
895 "punpcklbw %%mm7, %%mm7 \n\t"
896 "punpcklbw %%mm7, %%mm7 \n\t"
897 "punpcklbw %%mm7, %%mm7 \n\t"
898 "movq %%mm7, (%4) \n\t"
900 "movq (%0), %%mm0 \n\t"
901 "movq %%mm0, %%mm1 \n\t"
902 "movq %%mm0, %%mm2 \n\t"
903 "psllq $8, %%mm1 \n\t"
904 "psrlq $8, %%mm2 \n\t"
905 "movd -4(%0), %%mm3 \n\t"
906 "movd 8(%0), %%mm4 \n\t"
907 "psrlq $24, %%mm3 \n\t"
908 "psllq $56, %%mm4 \n\t"
909 "por %%mm3, %%mm1 \n\t"
910 "por %%mm4, %%mm2 \n\t"
911 "movq %%mm1, %%mm3 \n\t"
914 "psubusb %%mm7, %%mm0 \n\t"
915 "psubusb %%mm7, %%mm2 \n\t"
916 "psubusb %%mm7, %%mm3 \n\t"
917 "pcmpeqb "MANGLE(b00)
", %%mm0 \n\t"
918 "pcmpeqb "MANGLE(b00)
", %%mm2 \n\t"
919 "pcmpeqb "MANGLE(b00)
", %%mm3 \n\t"
920 "paddb %%mm2, %%mm0 \n\t"
921 "paddb %%mm3, %%mm0 \n\t"
923 "movq (%%"FF_REG_a
"), %%mm2 \n\t"
924 "movq %%mm2, %%mm3 \n\t"
925 "movq %%mm2, %%mm4 \n\t"
926 "psllq $8, %%mm3 \n\t"
927 "psrlq $8, %%mm4 \n\t"
928 "movd -4(%%"FF_REG_a
"), %%mm5 \n\t"
929 "movd 8(%%"FF_REG_a
"), %%mm6 \n\t"
930 "psrlq $24, %%mm5 \n\t"
931 "psllq $56, %%mm6 \n\t"
932 "por %%mm5, %%mm3 \n\t"
933 "por %%mm6, %%mm4 \n\t"
934 "movq %%mm3, %%mm5 \n\t"
937 "psubusb %%mm7, %%mm2 \n\t"
938 "psubusb %%mm7, %%mm4 \n\t"
939 "psubusb %%mm7, %%mm5 \n\t"
940 "pcmpeqb "MANGLE(b00)
", %%mm2 \n\t"
941 "pcmpeqb "MANGLE(b00)
", %%mm4 \n\t"
942 "pcmpeqb "MANGLE(b00)
", %%mm5 \n\t"
943 "paddb %%mm4, %%mm2 \n\t"
944 "paddb %%mm5, %%mm2 \n\t"
946 #define REAL_DERING_CORE(dst,src,ppsx,psx,sx,pplx,plx,lx,t0,t1) \
947 "movq " #src ", " #sx " \n\t" \
948 "movq " #sx ", " #lx " \n\t" \
949 "movq " #sx ", " #t0 " \n\t" \
950 "psllq $8, " #lx " \n\t"\
951 "psrlq $8, " #t0 " \n\t"\
952 "movd -4" #src ", " #t1 " \n\t"\
953 "psrlq $24, " #t1 " \n\t"\
954 "por " #t1 ", " #lx " \n\t" \
955 "movd 8" #src ", " #t1 " \n\t"\
956 "psllq $56, " #t1 " \n\t"\
957 "por " #t1 ", " #t0 " \n\t" \
958 "movq " #lx ", " #t1 " \n\t" \
962 "movq " #lx ", 8(%4) \n\t"\
963 "movq (%4), " #lx " \n\t"\
964 "psubusb " #lx ", " #t1 " \n\t"\
965 "psubusb " #lx ", " #t0 " \n\t"\
966 "psubusb " #lx ", " #sx " \n\t"\
967 "movq "MANGLE(b00)", " #lx " \n\t"\
968 "pcmpeqb " #lx ", " #t1 " \n\t" \
969 "pcmpeqb " #lx ", " #t0 " \n\t" \
970 "pcmpeqb " #lx ", " #sx " \n\t" \
971 "paddb " #t1 ", " #t0 " \n\t"\
972 "paddb " #t0 ", " #sx " \n\t"\
975 "movq " #dst ", " #t0 " \n\t" \
976 "movq " #t0 ", " #t1 " \n\t" \
977 "psubusb %3, " #t0 " \n\t"\
978 "paddusb %3, " #t1 " \n\t"\
980 PMINUB(t1, pplx, t0)\
981 "paddb " #sx ", " #ppsx " \n\t"\
982 "paddb " #psx ", " #ppsx " \n\t"\
983 "#paddb "MANGLE(b02)", " #ppsx " \n\t"\
984 "pand "MANGLE(b08)", " #ppsx " \n\t"\
985 "pcmpeqb " #lx ", " #ppsx " \n\t"\
986 "pand " #ppsx ", " #pplx " \n\t"\
987 "pandn " #dst ", " #ppsx " \n\t"\
988 "por " #pplx ", " #ppsx " \n\t"\
989 "movq " #ppsx ", " #dst " \n\t"\
990 "movq 8(%4), " #lx " \n\t"
992 #define DERING_CORE(dst,src,ppsx,psx,sx,pplx,plx,lx,t0,t1) \
993 REAL_DERING_CORE(dst,src,ppsx,psx,sx,pplx,plx,lx,t0,t1)
1010 DERING_CORE((%%FF_REGa) ,(%%FF_REGa, %1) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7)
1011 DERING_CORE((%%FF_REGa, %1) ,(%%FF_REGa, %1, 2),%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7)
1012 DERING_CORE((%%FF_REGa, %1, 2),(%0, %1, 4) ,%%mm4,%%mm0,%%mm2,%%mm5,%%mm1,%%mm3,%%mm6,%%mm7)
1013 DERING_CORE((%0, %1, 4) ,(%%FF_REGd) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7)
1014 DERING_CORE((%%FF_REGd) ,(%%FF_REGd, %1) ,%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7)
1015 DERING_CORE((%%FF_REGd, %1) ,(%%FF_REGd, %1, 2),%%mm4,%%mm0,%%mm2,%%mm5,%%mm1,%%mm3,%%mm6,%%mm7)
1016 DERING_CORE((%%FF_REGd, %1, 2),(%0, %1, 8) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7)
1017 DERING_CORE((%0, %1, 8) ,(%%FF_REGd, %1, 4),%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7)
1022 :
"%"FF_REG_a,
"%"FF_REG_d
1024 #else // HAVE_7REGS && TEMPLATE_PP_MMXEXT
1031 const int QP2=
c->QP/2 + 1;
1045 if(
max -
min <deringThreshold)
return;
1047 for(y=0; y<10; y++){
1062 t &= (t<<1) & (t>>1);
1067 int t =
s[y-1] &
s[y] &
s[y+1];
1081 +2*(*(p -1)) + 4*(*p ) + 2*(*(p +1))
1085 #ifdef DEBUG_DERING_THRESHOLD
1086 __asm__ volatile(
"emms\n\t":);
1088 static uint64_t numPixels=0;
1089 if(x!=1 && x!=8 && y!=1 && y!=8) numPixels++;
1094 static int numSkipped=0;
1095 static int errorSum=0;
1096 static int worstQP=0;
1097 static int worstRange=0;
1098 static int worstDiff=0;
1103 if(x==1 || x==8 || y==1 || y==8)
continue;
1106 if(absDiff > worstDiff){
1113 if(1024LL*1024LL*1024LL % numSkipped == 0){
1115 "wRange:%d, wDiff:%d, relSkip:%1.3f\n",
1116 (
float)errorSum/numSkipped, numSkipped, worstQP, worstRange,
1117 worstDiff, (
float)numSkipped/numPixels);
1122 if (*p + QP2 <
f) *p= *p + QP2;
1123 else if(*p - QP2 >
f) *p= *p - QP2;
1128 #ifdef DEBUG_DERING_THRESHOLD
1136 *p =
FFMIN(*p + 20, 255);
1142 #endif //TEMPLATE_PP_MMXEXT
1144 #endif //TEMPLATE_PP_ALTIVEC
1154 #if TEMPLATE_PP_MMXEXT
1157 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1158 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_c
"\n\t"
1162 "movq (%0), %%mm0 \n\t"
1163 "movq (%%"FF_REG_a
", %1), %%mm1 \n\t"
1165 "movq %%mm0, (%%"FF_REG_a
") \n\t"
1166 "movq (%0, %1, 4), %%mm0 \n\t"
1168 "movq %%mm1, (%%"FF_REG_a
", %1, 2) \n\t"
1169 "movq (%%"FF_REG_c
", %1), %%mm1 \n\t"
1171 "movq %%mm0, (%%"FF_REG_c
") \n\t"
1172 "movq (%0, %1, 8), %%mm0 \n\t"
1174 "movq %%mm1, (%%"FF_REG_c
", %1, 2) \n\t"
1177 :
"%"FF_REG_a,
"%"FF_REG_c
1186 *(uint32_t*)&
src[
stride*1]= (
a|
b) - (((
a^
b)&0xFEFEFEFEUL)>>1);
1188 *(uint32_t*)&
src[
stride*3]= (
a|
b) - (((
a^
b)&0xFEFEFEFEUL)>>1);
1190 *(uint32_t*)&
src[
stride*5]= (
a|
b) - (((
a^
b)&0xFEFEFEFEUL)>>1);
1192 *(uint32_t*)&
src[
stride*7]= (
a|
b) - (((
a^
b)&0xFEFEFEFEUL)>>1);
1207 #if TEMPLATE_PP_SSE2
1210 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1211 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_d
"\n\t"
1212 "lea (%%"FF_REG_d
", %1, 4), %%"FF_REG_c
"\n\t"
1213 "add %1, %%"FF_REG_c
" \n\t"
1214 "pxor %%xmm7, %%xmm7 \n\t"
1215 #define REAL_DEINT_CUBIC(a,b,c,d,e)\
1216 "movq " #a ", %%xmm0 \n\t"\
1217 "movq " #b ", %%xmm1 \n\t"\
1218 "movq " #d ", %%xmm2 \n\t"\
1219 "movq " #e ", %%xmm3 \n\t"\
1220 "pavgb %%xmm2, %%xmm1 \n\t"\
1221 "pavgb %%xmm3, %%xmm0 \n\t"\
1222 "punpcklbw %%xmm7, %%xmm0 \n\t"\
1223 "punpcklbw %%xmm7, %%xmm1 \n\t"\
1224 "psubw %%xmm1, %%xmm0 \n\t"\
1225 "psraw $3, %%xmm0 \n\t"\
1226 "psubw %%xmm0, %%xmm1 \n\t"\
1227 "packuswb %%xmm1, %%xmm1 \n\t"\
1228 "movlps %%xmm1, " #c " \n\t"
1229 #define DEINT_CUBIC(a,b,c,d,e) REAL_DEINT_CUBIC(a,b,c,d,e)
1231 DEINT_CUBIC((%0) , (%%FF_REGa, %1), (%%FF_REGa, %1, 2), (%0, %1, 4) , (%%FF_REGd, %1))
1232 DEINT_CUBIC((%%FF_REGa, %1), (%0, %1, 4) , (%%FF_REGd) , (%%FF_REGd, %1), (%0, %1, 8))
1233 DEINT_CUBIC((%0, %1, 4) , (%%FF_REGd, %1), (%%FF_REGd, %1, 2), (%0, %1, 8) , (%%FF_REGc))
1234 DEINT_CUBIC((%%FF_REGd, %1), (%0, %1, 8) , (%%FF_REGd, %1, 4), (%%FF_REGc) , (%%FF_REGc, %1, 2))
1238 XMM_CLOBBERS(
"%xmm0",
"%xmm1",
"%xmm2",
"%xmm3",
"%xmm7",)
1239 "%"FF_REG_a,
"%"FF_REG_d,
"%"FF_REG_c
1241 #undef REAL_DEINT_CUBIC
1242 #else //TEMPLATE_PP_SSE2
1252 #endif //TEMPLATE_PP_SSE2
1264 #if TEMPLATE_PP_MMXEXT
1267 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1268 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_d
"\n\t"
1269 "pxor %%mm7, %%mm7 \n\t"
1270 "movq (%2), %%mm0 \n\t"
1274 #define REAL_DEINT_FF(a,b,c,d)\
1275 "movq " #a ", %%mm1 \n\t"\
1276 "movq " #b ", %%mm2 \n\t"\
1277 "movq " #c ", %%mm3 \n\t"\
1278 "movq " #d ", %%mm4 \n\t"\
1279 PAVGB(%%mm3, %%mm1) \
1280 PAVGB(%%mm4, %%mm0) \
1281 "movq %%mm0, %%mm3 \n\t"\
1282 "punpcklbw %%mm7, %%mm0 \n\t"\
1283 "punpckhbw %%mm7, %%mm3 \n\t"\
1284 "movq %%mm1, %%mm4 \n\t"\
1285 "punpcklbw %%mm7, %%mm1 \n\t"\
1286 "punpckhbw %%mm7, %%mm4 \n\t"\
1287 "psllw $2, %%mm1 \n\t"\
1288 "psllw $2, %%mm4 \n\t"\
1289 "psubw %%mm0, %%mm1 \n\t"\
1290 "psubw %%mm3, %%mm4 \n\t"\
1291 "movq %%mm2, %%mm5 \n\t"\
1292 "movq %%mm2, %%mm0 \n\t"\
1293 "punpcklbw %%mm7, %%mm2 \n\t"\
1294 "punpckhbw %%mm7, %%mm5 \n\t"\
1295 "paddw %%mm2, %%mm1 \n\t"\
1296 "paddw %%mm5, %%mm4 \n\t"\
1297 "psraw $2, %%mm1 \n\t"\
1298 "psraw $2, %%mm4 \n\t"\
1299 "packuswb %%mm4, %%mm1 \n\t"\
1300 "movq %%mm1, " #b " \n\t"\
1302 #define DEINT_FF(a,b,c,d) REAL_DEINT_FF(a,b,c,d)
1304 DEINT_FF((%0) , (%%FF_REGa) , (%%FF_REGa, %1), (%%FF_REGa, %1, 2))
1305 DEINT_FF((%%FF_REGa, %1), (%%FF_REGa, %1, 2), (%0, %1, 4) , (%%FF_REGd) )
1306 DEINT_FF((%0, %1, 4) , (%%FF_REGd) , (%%FF_REGd, %1), (%%FF_REGd, %1, 2))
1307 DEINT_FF((%%FF_REGd, %1), (%%FF_REGd, %1, 2), (%0, %1, 8) , (%%FF_REGd, %1, 4))
1309 "movq %%mm0, (%2) \n\t"
1311 :
"%"FF_REG_a,
"%"FF_REG_d
1313 #else //TEMPLATE_PP_MMXEXT
1331 #endif //TEMPLATE_PP_MMXEXT
1343 #if TEMPLATE_PP_MMXEXT && HAVE_6REGS
1346 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1347 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_d
"\n\t"
1348 "pxor %%mm7, %%mm7 \n\t"
1349 "movq (%2), %%mm0 \n\t"
1350 "movq (%3), %%mm1 \n\t"
1354 #define REAL_DEINT_L5(t1,t2,a,b,c)\
1355 "movq " #a ", %%mm2 \n\t"\
1356 "movq " #b ", %%mm3 \n\t"\
1357 "movq " #c ", %%mm4 \n\t"\
1360 "movq %%mm2, %%mm5 \n\t"\
1361 "movq %%mm2, " #t1 " \n\t"\
1362 "punpcklbw %%mm7, %%mm2 \n\t"\
1363 "punpckhbw %%mm7, %%mm5 \n\t"\
1364 "movq %%mm2, %%mm6 \n\t"\
1365 "paddw %%mm2, %%mm2 \n\t"\
1366 "paddw %%mm6, %%mm2 \n\t"\
1367 "movq %%mm5, %%mm6 \n\t"\
1368 "paddw %%mm5, %%mm5 \n\t"\
1369 "paddw %%mm6, %%mm5 \n\t"\
1370 "movq %%mm3, %%mm6 \n\t"\
1371 "punpcklbw %%mm7, %%mm3 \n\t"\
1372 "punpckhbw %%mm7, %%mm6 \n\t"\
1373 "paddw %%mm3, %%mm3 \n\t"\
1374 "paddw %%mm6, %%mm6 \n\t"\
1375 "paddw %%mm3, %%mm2 \n\t"\
1376 "paddw %%mm6, %%mm5 \n\t"\
1377 "movq %%mm4, %%mm6 \n\t"\
1378 "punpcklbw %%mm7, %%mm4 \n\t"\
1379 "punpckhbw %%mm7, %%mm6 \n\t"\
1380 "psubw %%mm4, %%mm2 \n\t"\
1381 "psubw %%mm6, %%mm5 \n\t"\
1382 "psraw $2, %%mm2 \n\t"\
1383 "psraw $2, %%mm5 \n\t"\
1384 "packuswb %%mm5, %%mm2 \n\t"\
1385 "movq %%mm2, " #a " \n\t"\
1387 #define DEINT_L5(t1,t2,a,b,c) REAL_DEINT_L5(t1,t2,a,b,c)
1389 DEINT_L5(%%mm0, %%mm1, (%0) , (%%FF_REGa) , (%%FF_REGa, %1) )
1390 DEINT_L5(%%mm1, %%mm0, (%%FF_REGa) , (%%FF_REGa, %1) , (%%FF_REGa, %1, 2))
1391 DEINT_L5(%%mm0, %%mm1, (%%FF_REGa, %1) , (%%FF_REGa, %1, 2), (%0, %1, 4) )
1392 DEINT_L5(%%mm1, %%mm0, (%%FF_REGa, %1, 2), (%0, %1, 4) , (%%FF_REGd) )
1393 DEINT_L5(%%mm0, %%mm1, (%0, %1, 4) , (%%FF_REGd) , (%%FF_REGd, %1) )
1394 DEINT_L5(%%mm1, %%mm0, (%%FF_REGd) , (%%FF_REGd, %1) , (%%FF_REGd, %1, 2))
1395 DEINT_L5(%%mm0, %%mm1, (%%FF_REGd, %1) , (%%FF_REGd, %1, 2), (%0, %1, 8) )
1396 DEINT_L5(%%mm1, %%mm0, (%%FF_REGd, %1, 2), (%0, %1, 8) , (%%FF_REGd, %1, 4))
1398 "movq %%mm0, (%2) \n\t"
1399 "movq %%mm1, (%3) \n\t"
1401 :
"%"FF_REG_a,
"%"FF_REG_d
1403 #else //TEMPLATE_PP_MMXEXT && HAVE_6REGS
1432 #endif // TEMPLATE_PP_MMXEXT && HAVE_6REGS
1444 #if TEMPLATE_PP_MMXEXT
1447 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1448 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_d
"\n\t"
1452 "movq (%2), %%mm0 \n\t"
1453 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
1455 "movq (%0), %%mm2 \n\t"
1457 "movq %%mm0, (%0) \n\t"
1458 "movq (%%"FF_REG_a
", %1), %%mm0 \n\t"
1461 "movq %%mm2, (%%"FF_REG_a
") \n\t"
1462 "movq (%%"FF_REG_a
", %1, 2), %%mm2 \n\t"
1465 "movq %%mm1, (%%"FF_REG_a
", %1) \n\t"
1466 "movq (%0, %1, 4), %%mm1 \n\t"
1469 "movq %%mm0, (%%"FF_REG_a
", %1, 2) \n\t"
1470 "movq (%%"FF_REG_d
"), %%mm0 \n\t"
1473 "movq %%mm2, (%0, %1, 4) \n\t"
1474 "movq (%%"FF_REG_d
", %1), %%mm2 \n\t"
1477 "movq %%mm1, (%%"FF_REG_d
") \n\t"
1478 "movq (%%"FF_REG_d
", %1, 2), %%mm1 \n\t"
1481 "movq %%mm0, (%%"FF_REG_d
", %1) \n\t"
1482 "movq (%0, %1, 8), %%mm0 \n\t"
1485 "movq %%mm2, (%%"FF_REG_d
", %1, 2) \n\t"
1486 "movq %%mm1, (%2) \n\t"
1489 :
"%"FF_REG_a,
"%"FF_REG_d
1491 #else //TEMPLATE_PP_MMXEXT
1499 a= (
a&
c) + (((
a^
c)&0xFEFEFEFEUL)>>1);
1500 *(uint32_t*)&
src[
stride*0]= (
a|
b) - (((
a^
b)&0xFEFEFEFEUL)>>1);
1503 b= (
a&
b) + (((
a^
b)&0xFEFEFEFEUL)>>1);
1504 *(uint32_t*)&
src[
stride*1]= (
c|
b) - (((
c^
b)&0xFEFEFEFEUL)>>1);
1507 c= (
b&
c) + (((
b^
c)&0xFEFEFEFEUL)>>1);
1508 *(uint32_t*)&
src[
stride*2]= (
c|
a) - (((
c^
a)&0xFEFEFEFEUL)>>1);
1511 a= (
a&
c) + (((
a^
c)&0xFEFEFEFEUL)>>1);
1512 *(uint32_t*)&
src[
stride*3]= (
a|
b) - (((
a^
b)&0xFEFEFEFEUL)>>1);
1515 b= (
a&
b) + (((
a^
b)&0xFEFEFEFEUL)>>1);
1516 *(uint32_t*)&
src[
stride*4]= (
c|
b) - (((
c^
b)&0xFEFEFEFEUL)>>1);
1519 c= (
b&
c) + (((
b^
c)&0xFEFEFEFEUL)>>1);
1520 *(uint32_t*)&
src[
stride*5]= (
c|
a) - (((
c^
a)&0xFEFEFEFEUL)>>1);
1523 a= (
a&
c) + (((
a^
c)&0xFEFEFEFEUL)>>1);
1524 *(uint32_t*)&
src[
stride*6]= (
a|
b) - (((
a^
b)&0xFEFEFEFEUL)>>1);
1527 b= (
a&
b) + (((
a^
b)&0xFEFEFEFEUL)>>1);
1528 *(uint32_t*)&
src[
stride*7]= (
c|
b) - (((
c^
b)&0xFEFEFEFEUL)>>1);
1534 #endif //TEMPLATE_PP_MMXEXT
1545 #if TEMPLATE_PP_MMXEXT
1548 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1549 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_d
"\n\t"
1553 "movq (%0), %%mm0 \n\t"
1554 "movq (%%"FF_REG_a
", %1), %%mm2 \n\t"
1555 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
1556 "movq %%mm0, %%mm3 \n\t"
1557 "pmaxub %%mm1, %%mm0 \n\t"
1558 "pminub %%mm3, %%mm1 \n\t"
1559 "pmaxub %%mm2, %%mm1 \n\t"
1560 "pminub %%mm1, %%mm0 \n\t"
1561 "movq %%mm0, (%%"FF_REG_a
") \n\t"
1563 "movq (%0, %1, 4), %%mm0 \n\t"
1564 "movq (%%"FF_REG_a
", %1, 2), %%mm1 \n\t"
1565 "movq %%mm2, %%mm3 \n\t"
1566 "pmaxub %%mm1, %%mm2 \n\t"
1567 "pminub %%mm3, %%mm1 \n\t"
1568 "pmaxub %%mm0, %%mm1 \n\t"
1569 "pminub %%mm1, %%mm2 \n\t"
1570 "movq %%mm2, (%%"FF_REG_a
", %1, 2) \n\t"
1572 "movq (%%"FF_REG_d
"), %%mm2 \n\t"
1573 "movq (%%"FF_REG_d
", %1), %%mm1 \n\t"
1574 "movq %%mm2, %%mm3 \n\t"
1575 "pmaxub %%mm0, %%mm2 \n\t"
1576 "pminub %%mm3, %%mm0 \n\t"
1577 "pmaxub %%mm1, %%mm0 \n\t"
1578 "pminub %%mm0, %%mm2 \n\t"
1579 "movq %%mm2, (%%"FF_REG_d
") \n\t"
1581 "movq (%%"FF_REG_d
", %1, 2), %%mm2 \n\t"
1582 "movq (%0, %1, 8), %%mm0 \n\t"
1583 "movq %%mm2, %%mm3 \n\t"
1584 "pmaxub %%mm0, %%mm2 \n\t"
1585 "pminub %%mm3, %%mm0 \n\t"
1586 "pmaxub %%mm1, %%mm0 \n\t"
1587 "pminub %%mm0, %%mm2 \n\t"
1588 "movq %%mm2, (%%"FF_REG_d
", %1, 2) \n\t"
1592 :
"%"FF_REG_a,
"%"FF_REG_d
1595 #else //TEMPLATE_PP_MMX
1600 uint8_t *colsrc =
src;
1601 for (y=0; y<4; y++){
1602 int a,
b,
c, d, e,
f;
1609 colsrc[
stride ] = (
a|(d^
f)) & (
b|(d^e)) & (
c|(e^
f));
1614 #endif //TEMPLATE_PP_MMX
1621 static inline void RENAME(transpose1)(uint8_t *dst1, uint8_t *dst2,
const uint8_t *
src,
int srcStride)
1624 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1627 "movq (%0), %%mm0 \n\t"
1628 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
1629 "movq %%mm0, %%mm2 \n\t"
1630 "punpcklbw %%mm1, %%mm0 \n\t"
1631 "punpckhbw %%mm1, %%mm2 \n\t"
1633 "movq (%%"FF_REG_a
", %1), %%mm1 \n\t"
1634 "movq (%%"FF_REG_a
", %1, 2), %%mm3 \n\t"
1635 "movq %%mm1, %%mm4 \n\t"
1636 "punpcklbw %%mm3, %%mm1 \n\t"
1637 "punpckhbw %%mm3, %%mm4 \n\t"
1639 "movq %%mm0, %%mm3 \n\t"
1640 "punpcklwd %%mm1, %%mm0 \n\t"
1641 "punpckhwd %%mm1, %%mm3 \n\t"
1642 "movq %%mm2, %%mm1 \n\t"
1643 "punpcklwd %%mm4, %%mm2 \n\t"
1644 "punpckhwd %%mm4, %%mm1 \n\t"
1646 "movd %%mm0, 128(%2) \n\t"
1647 "psrlq $32, %%mm0 \n\t"
1648 "movd %%mm0, 144(%2) \n\t"
1649 "movd %%mm3, 160(%2) \n\t"
1650 "psrlq $32, %%mm3 \n\t"
1651 "movd %%mm3, 176(%2) \n\t"
1652 "movd %%mm3, 48(%3) \n\t"
1653 "movd %%mm2, 192(%2) \n\t"
1654 "movd %%mm2, 64(%3) \n\t"
1655 "psrlq $32, %%mm2 \n\t"
1656 "movd %%mm2, 80(%3) \n\t"
1657 "movd %%mm1, 96(%3) \n\t"
1658 "psrlq $32, %%mm1 \n\t"
1659 "movd %%mm1, 112(%3) \n\t"
1661 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_a
"\n\t"
1663 "movq (%0, %1, 4), %%mm0 \n\t"
1664 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
1665 "movq %%mm0, %%mm2 \n\t"
1666 "punpcklbw %%mm1, %%mm0 \n\t"
1667 "punpckhbw %%mm1, %%mm2 \n\t"
1669 "movq (%%"FF_REG_a
", %1), %%mm1 \n\t"
1670 "movq (%%"FF_REG_a
", %1, 2), %%mm3 \n\t"
1671 "movq %%mm1, %%mm4 \n\t"
1672 "punpcklbw %%mm3, %%mm1 \n\t"
1673 "punpckhbw %%mm3, %%mm4 \n\t"
1675 "movq %%mm0, %%mm3 \n\t"
1676 "punpcklwd %%mm1, %%mm0 \n\t"
1677 "punpckhwd %%mm1, %%mm3 \n\t"
1678 "movq %%mm2, %%mm1 \n\t"
1679 "punpcklwd %%mm4, %%mm2 \n\t"
1680 "punpckhwd %%mm4, %%mm1 \n\t"
1682 "movd %%mm0, 132(%2) \n\t"
1683 "psrlq $32, %%mm0 \n\t"
1684 "movd %%mm0, 148(%2) \n\t"
1685 "movd %%mm3, 164(%2) \n\t"
1686 "psrlq $32, %%mm3 \n\t"
1687 "movd %%mm3, 180(%2) \n\t"
1688 "movd %%mm3, 52(%3) \n\t"
1689 "movd %%mm2, 196(%2) \n\t"
1690 "movd %%mm2, 68(%3) \n\t"
1691 "psrlq $32, %%mm2 \n\t"
1692 "movd %%mm2, 84(%3) \n\t"
1693 "movd %%mm1, 100(%3) \n\t"
1694 "psrlq $32, %%mm1 \n\t"
1695 "movd %%mm1, 116(%3) \n\t"
1698 ::
"r" (
src),
"r" ((
x86_reg)srcStride),
"r" (dst1),
"r" (dst2)
1706 static inline void RENAME(transpose2)(uint8_t *
dst,
int dstStride,
const uint8_t *
src)
1709 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1710 "lea (%%"FF_REG_a
",%1,4), %%"FF_REG_d
" \n\t"
1713 "movq (%2), %%mm0 \n\t"
1714 "movq 16(%2), %%mm1 \n\t"
1715 "movq %%mm0, %%mm2 \n\t"
1716 "punpcklbw %%mm1, %%mm0 \n\t"
1717 "punpckhbw %%mm1, %%mm2 \n\t"
1719 "movq 32(%2), %%mm1 \n\t"
1720 "movq 48(%2), %%mm3 \n\t"
1721 "movq %%mm1, %%mm4 \n\t"
1722 "punpcklbw %%mm3, %%mm1 \n\t"
1723 "punpckhbw %%mm3, %%mm4 \n\t"
1725 "movq %%mm0, %%mm3 \n\t"
1726 "punpcklwd %%mm1, %%mm0 \n\t"
1727 "punpckhwd %%mm1, %%mm3 \n\t"
1728 "movq %%mm2, %%mm1 \n\t"
1729 "punpcklwd %%mm4, %%mm2 \n\t"
1730 "punpckhwd %%mm4, %%mm1 \n\t"
1732 "movd %%mm0, (%0) \n\t"
1733 "psrlq $32, %%mm0 \n\t"
1734 "movd %%mm0, (%%"FF_REG_a
") \n\t"
1735 "movd %%mm3, (%%"FF_REG_a
", %1) \n\t"
1736 "psrlq $32, %%mm3 \n\t"
1737 "movd %%mm3, (%%"FF_REG_a
", %1, 2) \n\t"
1738 "movd %%mm2, (%0, %1, 4) \n\t"
1739 "psrlq $32, %%mm2 \n\t"
1740 "movd %%mm2, (%%"FF_REG_d
") \n\t"
1741 "movd %%mm1, (%%"FF_REG_d
", %1) \n\t"
1742 "psrlq $32, %%mm1 \n\t"
1743 "movd %%mm1, (%%"FF_REG_d
", %1, 2) \n\t"
1746 "movq 64(%2), %%mm0 \n\t"
1747 "movq 80(%2), %%mm1 \n\t"
1748 "movq %%mm0, %%mm2 \n\t"
1749 "punpcklbw %%mm1, %%mm0 \n\t"
1750 "punpckhbw %%mm1, %%mm2 \n\t"
1752 "movq 96(%2), %%mm1 \n\t"
1753 "movq 112(%2), %%mm3 \n\t"
1754 "movq %%mm1, %%mm4 \n\t"
1755 "punpcklbw %%mm3, %%mm1 \n\t"
1756 "punpckhbw %%mm3, %%mm4 \n\t"
1758 "movq %%mm0, %%mm3 \n\t"
1759 "punpcklwd %%mm1, %%mm0 \n\t"
1760 "punpckhwd %%mm1, %%mm3 \n\t"
1761 "movq %%mm2, %%mm1 \n\t"
1762 "punpcklwd %%mm4, %%mm2 \n\t"
1763 "punpckhwd %%mm4, %%mm1 \n\t"
1765 "movd %%mm0, 4(%0) \n\t"
1766 "psrlq $32, %%mm0 \n\t"
1767 "movd %%mm0, 4(%%"FF_REG_a
") \n\t"
1768 "movd %%mm3, 4(%%"FF_REG_a
", %1) \n\t"
1769 "psrlq $32, %%mm3 \n\t"
1770 "movd %%mm3, 4(%%"FF_REG_a
", %1, 2) \n\t"
1771 "movd %%mm2, 4(%0, %1, 4) \n\t"
1772 "psrlq $32, %%mm2 \n\t"
1773 "movd %%mm2, 4(%%"FF_REG_d
") \n\t"
1774 "movd %%mm1, 4(%%"FF_REG_d
", %1) \n\t"
1775 "psrlq $32, %%mm1 \n\t"
1776 "movd %%mm1, 4(%%"FF_REG_d
", %1, 2) \n\t"
1779 :
"%"FF_REG_a,
"%"FF_REG_d
1782 #endif //TEMPLATE_PP_MMX
1785 #if !TEMPLATE_PP_ALTIVEC
1787 uint8_t *tempBlurred, uint32_t *tempBlurredPast,
const int *maxNoise)
1790 tempBlurredPast[127]= maxNoise[0];
1791 tempBlurredPast[128]= maxNoise[1];
1792 tempBlurredPast[129]= maxNoise[2];
1794 #define FAST_L2_DIFF
1796 #if TEMPLATE_PP_MMXEXT && HAVE_6REGS
1798 "lea (%2, %2, 2), %%"FF_REG_a
" \n\t"
1799 "lea (%2, %2, 4), %%"FF_REG_d
" \n\t"
1800 "lea (%%"FF_REG_d
", %2, 2), %%"FF_REG_c
"\n\t"
1804 #ifdef L1_DIFF //needs mmx2
1805 "movq (%0), %%mm0 \n\t"
1806 "psadbw (%1), %%mm0 \n\t"
1807 "movq (%0, %2), %%mm1 \n\t"
1808 "psadbw (%1, %2), %%mm1 \n\t"
1809 "movq (%0, %2, 2), %%mm2 \n\t"
1810 "psadbw (%1, %2, 2), %%mm2 \n\t"
1811 "movq (%0, %%"FF_REG_a
"), %%mm3 \n\t"
1812 "psadbw (%1, %%"FF_REG_a
"), %%mm3 \n\t"
1814 "movq (%0, %2, 4), %%mm4 \n\t"
1815 "paddw %%mm1, %%mm0 \n\t"
1816 "psadbw (%1, %2, 4), %%mm4 \n\t"
1817 "movq (%0, %%"FF_REG_d
"), %%mm5 \n\t"
1818 "paddw %%mm2, %%mm0 \n\t"
1819 "psadbw (%1, %%"FF_REG_d
"), %%mm5 \n\t"
1820 "movq (%0, %%"FF_REG_a
", 2), %%mm6 \n\t"
1821 "paddw %%mm3, %%mm0 \n\t"
1822 "psadbw (%1, %%"FF_REG_a
", 2), %%mm6 \n\t"
1823 "movq (%0, %%"FF_REG_c
"), %%mm7 \n\t"
1824 "paddw %%mm4, %%mm0 \n\t"
1825 "psadbw (%1, %%"FF_REG_c
"), %%mm7 \n\t"
1826 "paddw %%mm5, %%mm6 \n\t"
1827 "paddw %%mm7, %%mm6 \n\t"
1828 "paddw %%mm6, %%mm0 \n\t"
1830 #if defined (FAST_L2_DIFF)
1831 "pcmpeqb %%mm7, %%mm7 \n\t"
1832 "movq "MANGLE(b80)
", %%mm6 \n\t"
1833 "pxor %%mm0, %%mm0 \n\t"
1834 #define REAL_L2_DIFF_CORE(a, b)\
1835 "movq " #a ", %%mm5 \n\t"\
1836 "movq " #b ", %%mm2 \n\t"\
1837 "pxor %%mm7, %%mm2 \n\t"\
1838 PAVGB(%%mm2, %%mm5)\
1839 "paddb %%mm6, %%mm5 \n\t"\
1840 "movq %%mm5, %%mm2 \n\t"\
1841 "psllw $8, %%mm5 \n\t"\
1842 "pmaddwd %%mm5, %%mm5 \n\t"\
1843 "pmaddwd %%mm2, %%mm2 \n\t"\
1844 "paddd %%mm2, %%mm5 \n\t"\
1845 "psrld $14, %%mm5 \n\t"\
1846 "paddd %%mm5, %%mm0 \n\t"
1848 #else //defined (FAST_L2_DIFF)
1849 "pxor %%mm7, %%mm7 \n\t"
1850 "pxor %%mm0, %%mm0 \n\t"
1851 #define REAL_L2_DIFF_CORE(a, b)\
1852 "movq " #a ", %%mm5 \n\t"\
1853 "movq " #b ", %%mm2 \n\t"\
1854 "movq %%mm5, %%mm1 \n\t"\
1855 "movq %%mm2, %%mm3 \n\t"\
1856 "punpcklbw %%mm7, %%mm5 \n\t"\
1857 "punpckhbw %%mm7, %%mm1 \n\t"\
1858 "punpcklbw %%mm7, %%mm2 \n\t"\
1859 "punpckhbw %%mm7, %%mm3 \n\t"\
1860 "psubw %%mm2, %%mm5 \n\t"\
1861 "psubw %%mm3, %%mm1 \n\t"\
1862 "pmaddwd %%mm5, %%mm5 \n\t"\
1863 "pmaddwd %%mm1, %%mm1 \n\t"\
1864 "paddd %%mm1, %%mm5 \n\t"\
1865 "paddd %%mm5, %%mm0 \n\t"
1867 #endif //defined (FAST_L2_DIFF)
1869 #define L2_DIFF_CORE(a, b) REAL_L2_DIFF_CORE(a, b)
1871 L2_DIFF_CORE((%0) , (%1))
1872 L2_DIFF_CORE((%0, %2) , (%1, %2))
1873 L2_DIFF_CORE((%0, %2, 2) , (%1, %2, 2))
1874 L2_DIFF_CORE((%0, %%FF_REGa) , (%1, %%FF_REGa))
1875 L2_DIFF_CORE((%0, %2, 4) , (%1, %2, 4))
1876 L2_DIFF_CORE((%0, %%FF_REGd) , (%1, %%FF_REGd))
1877 L2_DIFF_CORE((%0, %%FF_REGa,2), (%1, %%FF_REGa,2))
1878 L2_DIFF_CORE((%0, %%FF_REGc) , (%1, %%FF_REGc))
1882 "movq %%mm0, %%mm4 \n\t"
1883 "psrlq $32, %%mm0 \n\t"
1884 "paddd %%mm0, %%mm4 \n\t"
1885 "movd %%mm4, %%ecx \n\t"
1886 "shll $2, %%ecx \n\t"
1887 "mov %3, %%"FF_REG_d
" \n\t"
1888 "addl -4(%%"FF_REG_d
"), %%ecx \n\t"
1889 "addl 4(%%"FF_REG_d
"), %%ecx \n\t"
1890 "addl -1024(%%"FF_REG_d
"), %%ecx \n\t"
1891 "addl $4, %%ecx \n\t"
1892 "addl 1024(%%"FF_REG_d
"), %%ecx \n\t"
1893 "shrl $3, %%ecx \n\t"
1894 "movl %%ecx, (%%"FF_REG_d
") \n\t"
1899 "cmpl 512(%%"FF_REG_d
"), %%ecx \n\t"
1901 "cmpl 516(%%"FF_REG_d
"), %%ecx \n\t"
1904 "lea (%%"FF_REG_a
", %2, 2), %%"FF_REG_d
"\n\t"
1905 "lea (%%"FF_REG_d
", %2, 2), %%"FF_REG_c
"\n\t"
1906 "movq (%0), %%mm0 \n\t"
1907 "movq (%0, %2), %%mm1 \n\t"
1908 "movq (%0, %2, 2), %%mm2 \n\t"
1909 "movq (%0, %%"FF_REG_a
"), %%mm3 \n\t"
1910 "movq (%0, %2, 4), %%mm4 \n\t"
1911 "movq (%0, %%"FF_REG_d
"), %%mm5 \n\t"
1912 "movq (%0, %%"FF_REG_a
", 2), %%mm6 \n\t"
1913 "movq (%0, %%"FF_REG_c
"), %%mm7 \n\t"
1914 "movq %%mm0, (%1) \n\t"
1915 "movq %%mm1, (%1, %2) \n\t"
1916 "movq %%mm2, (%1, %2, 2) \n\t"
1917 "movq %%mm3, (%1, %%"FF_REG_a
") \n\t"
1918 "movq %%mm4, (%1, %2, 4) \n\t"
1919 "movq %%mm5, (%1, %%"FF_REG_d
") \n\t"
1920 "movq %%mm6, (%1, %%"FF_REG_a
", 2) \n\t"
1921 "movq %%mm7, (%1, %%"FF_REG_c
") \n\t"
1925 "lea (%%"FF_REG_a
", %2, 2), %%"FF_REG_d
"\n\t"
1926 "lea (%%"FF_REG_d
", %2, 2), %%"FF_REG_c
"\n\t"
1927 "movq (%0), %%mm0 \n\t"
1929 "movq (%0, %2), %%mm1 \n\t"
1930 PAVGB((%1, %2), %%mm1)
1931 "movq (%0, %2, 2), %%mm2 \n\t"
1932 PAVGB((%1, %2, 2), %%mm2)
1933 "movq (%0, %%"FF_REG_a
"), %%mm3 \n\t"
1934 PAVGB((%1, %%FF_REGa), %%mm3)
1935 "movq (%0, %2, 4), %%mm4 \n\t"
1936 PAVGB((%1, %2, 4), %%mm4)
1937 "movq (%0, %%"FF_REG_d
"), %%mm5 \n\t"
1938 PAVGB((%1, %%FF_REGd), %%mm5)
1939 "movq (%0, %%"FF_REG_a
", 2), %%mm6 \n\t"
1940 PAVGB((%1, %%FF_REGa, 2), %%mm6)
1941 "movq (%0, %%"FF_REG_c
"), %%mm7 \n\t"
1942 PAVGB((%1, %%FF_REGc), %%mm7)
1943 "movq %%mm0, (%1) \n\t"
1944 "movq %%mm1, (%1, %2) \n\t"
1945 "movq %%mm2, (%1, %2, 2) \n\t"
1946 "movq %%mm3, (%1, %%"FF_REG_a
") \n\t"
1947 "movq %%mm4, (%1, %2, 4) \n\t"
1948 "movq %%mm5, (%1, %%"FF_REG_d
") \n\t"
1949 "movq %%mm6, (%1, %%"FF_REG_a
", 2) \n\t"
1950 "movq %%mm7, (%1, %%"FF_REG_c
") \n\t"
1951 "movq %%mm0, (%0) \n\t"
1952 "movq %%mm1, (%0, %2) \n\t"
1953 "movq %%mm2, (%0, %2, 2) \n\t"
1954 "movq %%mm3, (%0, %%"FF_REG_a
") \n\t"
1955 "movq %%mm4, (%0, %2, 4) \n\t"
1956 "movq %%mm5, (%0, %%"FF_REG_d
") \n\t"
1957 "movq %%mm6, (%0, %%"FF_REG_a
", 2) \n\t"
1958 "movq %%mm7, (%0, %%"FF_REG_c
") \n\t"
1962 "cmpl 508(%%"FF_REG_d
"), %%ecx \n\t"
1965 "lea (%%"FF_REG_a
", %2, 2), %%"FF_REG_d
"\n\t"
1966 "lea (%%"FF_REG_d
", %2, 2), %%"FF_REG_c
"\n\t"
1967 "movq (%0), %%mm0 \n\t"
1968 "movq (%0, %2), %%mm1 \n\t"
1969 "movq (%0, %2, 2), %%mm2 \n\t"
1970 "movq (%0, %%"FF_REG_a
"), %%mm3 \n\t"
1971 "movq (%1), %%mm4 \n\t"
1972 "movq (%1, %2), %%mm5 \n\t"
1973 "movq (%1, %2, 2), %%mm6 \n\t"
1974 "movq (%1, %%"FF_REG_a
"), %%mm7 \n\t"
1983 "movq %%mm0, (%1) \n\t"
1984 "movq %%mm1, (%1, %2) \n\t"
1985 "movq %%mm2, (%1, %2, 2) \n\t"
1986 "movq %%mm3, (%1, %%"FF_REG_a
") \n\t"
1987 "movq %%mm0, (%0) \n\t"
1988 "movq %%mm1, (%0, %2) \n\t"
1989 "movq %%mm2, (%0, %2, 2) \n\t"
1990 "movq %%mm3, (%0, %%"FF_REG_a
") \n\t"
1992 "movq (%0, %2, 4), %%mm0 \n\t"
1993 "movq (%0, %%"FF_REG_d
"), %%mm1 \n\t"
1994 "movq (%0, %%"FF_REG_a
", 2), %%mm2 \n\t"
1995 "movq (%0, %%"FF_REG_c
"), %%mm3 \n\t"
1996 "movq (%1, %2, 4), %%mm4 \n\t"
1997 "movq (%1, %%"FF_REG_d
"), %%mm5 \n\t"
1998 "movq (%1, %%"FF_REG_a
", 2), %%mm6 \n\t"
1999 "movq (%1, %%"FF_REG_c
"), %%mm7 \n\t"
2008 "movq %%mm0, (%1, %2, 4) \n\t"
2009 "movq %%mm1, (%1, %%"FF_REG_d
") \n\t"
2010 "movq %%mm2, (%1, %%"FF_REG_a
", 2) \n\t"
2011 "movq %%mm3, (%1, %%"FF_REG_c
") \n\t"
2012 "movq %%mm0, (%0, %2, 4) \n\t"
2013 "movq %%mm1, (%0, %%"FF_REG_d
") \n\t"
2014 "movq %%mm2, (%0, %%"FF_REG_a
", 2) \n\t"
2015 "movq %%mm3, (%0, %%"FF_REG_c
") \n\t"
2019 "lea (%%"FF_REG_a
", %2, 2), %%"FF_REG_d
"\n\t"
2020 "lea (%%"FF_REG_d
", %2, 2), %%"FF_REG_c
"\n\t"
2021 "movq (%0), %%mm0 \n\t"
2022 "movq (%0, %2), %%mm1 \n\t"
2023 "movq (%0, %2, 2), %%mm2 \n\t"
2024 "movq (%0, %%"FF_REG_a
"), %%mm3 \n\t"
2025 "movq (%1), %%mm4 \n\t"
2026 "movq (%1, %2), %%mm5 \n\t"
2027 "movq (%1, %2, 2), %%mm6 \n\t"
2028 "movq (%1, %%"FF_REG_a
"), %%mm7 \n\t"
2041 "movq %%mm0, (%1) \n\t"
2042 "movq %%mm1, (%1, %2) \n\t"
2043 "movq %%mm2, (%1, %2, 2) \n\t"
2044 "movq %%mm3, (%1, %%"FF_REG_a
") \n\t"
2045 "movq %%mm0, (%0) \n\t"
2046 "movq %%mm1, (%0, %2) \n\t"
2047 "movq %%mm2, (%0, %2, 2) \n\t"
2048 "movq %%mm3, (%0, %%"FF_REG_a
") \n\t"
2050 "movq (%0, %2, 4), %%mm0 \n\t"
2051 "movq (%0, %%"FF_REG_d
"), %%mm1 \n\t"
2052 "movq (%0, %%"FF_REG_a
", 2), %%mm2 \n\t"
2053 "movq (%0, %%"FF_REG_c
"), %%mm3 \n\t"
2054 "movq (%1, %2, 4), %%mm4 \n\t"
2055 "movq (%1, %%"FF_REG_d
"), %%mm5 \n\t"
2056 "movq (%1, %%"FF_REG_a
", 2), %%mm6 \n\t"
2057 "movq (%1, %%"FF_REG_c
"), %%mm7 \n\t"
2070 "movq %%mm0, (%1, %2, 4) \n\t"
2071 "movq %%mm1, (%1, %%"FF_REG_d
") \n\t"
2072 "movq %%mm2, (%1, %%"FF_REG_a
", 2) \n\t"
2073 "movq %%mm3, (%1, %%"FF_REG_c
") \n\t"
2074 "movq %%mm0, (%0, %2, 4) \n\t"
2075 "movq %%mm1, (%0, %%"FF_REG_d
") \n\t"
2076 "movq %%mm2, (%0, %%"FF_REG_a
", 2) \n\t"
2077 "movq %%mm3, (%0, %%"FF_REG_c
") \n\t"
2081 ::
"r" (
src),
"r" (tempBlurred),
"r"((
x86_reg)
stride),
"m" (tempBlurredPast)
2083 :
"%"FF_REG_a,
"%"FF_REG_d,
"%"FF_REG_c,
"memory"
2085 #else //TEMPLATE_PP_MMXEXT && HAVE_6REGS
2108 +(*(tempBlurredPast-256))
2109 +(*(tempBlurredPast-1))+ (*(tempBlurredPast+1))
2110 +(*(tempBlurredPast+256))
2122 if(d > maxNoise[1]){
2123 if(d < maxNoise[2]){
2129 tempBlurred[ x + y*
stride ]=
2143 if(d < maxNoise[0]){
2149 tempBlurred[ x + y*
stride ]=
2151 (
ref*7 + cur + 4)>>3;
2160 tempBlurred[ x + y*
stride ]=
2162 (
ref*3 + cur + 2)>>2;
2168 #endif //TEMPLATE_PP_MMXEXT && HAVE_6REGS
2170 #endif //TEMPLATE_PP_ALTIVEC
2172 #if TEMPLATE_PP_MMXEXT
2177 int64_t dc_mask, eq_mask, both_masks;
2182 "movq %0, %%mm7 \n\t"
2183 "movq %1, %%mm6 \n\t"
2184 : :
"m" (
c->mmxDcOffset[
c->nonBQP]),
"m" (
c->mmxDcThreshold[
c->nonBQP])
2188 "lea (%2, %3), %%"FF_REG_a
" \n\t"
2192 "movq (%2), %%mm0 \n\t"
2193 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
2194 "movq %%mm1, %%mm3 \n\t"
2195 "movq %%mm1, %%mm4 \n\t"
2196 "psubb %%mm1, %%mm0 \n\t"
2197 "paddb %%mm7, %%mm0 \n\t"
2198 "pcmpgtb %%mm6, %%mm0 \n\t"
2200 "movq (%%"FF_REG_a
",%3), %%mm2 \n\t"
2201 PMAXUB(%%mm2, %%mm4)
2202 PMINUB(%%mm2, %%mm3, %%mm5)
2203 "psubb %%mm2, %%mm1 \n\t"
2204 "paddb %%mm7, %%mm1 \n\t"
2205 "pcmpgtb %%mm6, %%mm1 \n\t"
2206 "paddb %%mm1, %%mm0 \n\t"
2208 "movq (%%"FF_REG_a
", %3, 2), %%mm1 \n\t"
2209 PMAXUB(%%mm1, %%mm4)
2210 PMINUB(%%mm1, %%mm3, %%mm5)
2211 "psubb %%mm1, %%mm2 \n\t"
2212 "paddb %%mm7, %%mm2 \n\t"
2213 "pcmpgtb %%mm6, %%mm2 \n\t"
2214 "paddb %%mm2, %%mm0 \n\t"
2216 "lea (%%"FF_REG_a
", %3, 4), %%"FF_REG_a
"\n\t"
2218 "movq (%2, %3, 4), %%mm2 \n\t"
2219 PMAXUB(%%mm2, %%mm4)
2220 PMINUB(%%mm2, %%mm3, %%mm5)
2221 "psubb %%mm2, %%mm1 \n\t"
2222 "paddb %%mm7, %%mm1 \n\t"
2223 "pcmpgtb %%mm6, %%mm1 \n\t"
2224 "paddb %%mm1, %%mm0 \n\t"
2226 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
2227 PMAXUB(%%mm1, %%mm4)
2228 PMINUB(%%mm1, %%mm3, %%mm5)
2229 "psubb %%mm1, %%mm2 \n\t"
2230 "paddb %%mm7, %%mm2 \n\t"
2231 "pcmpgtb %%mm6, %%mm2 \n\t"
2232 "paddb %%mm2, %%mm0 \n\t"
2234 "movq (%%"FF_REG_a
", %3), %%mm2 \n\t"
2235 PMAXUB(%%mm2, %%mm4)
2236 PMINUB(%%mm2, %%mm3, %%mm5)
2237 "psubb %%mm2, %%mm1 \n\t"
2238 "paddb %%mm7, %%mm1 \n\t"
2239 "pcmpgtb %%mm6, %%mm1 \n\t"
2240 "paddb %%mm1, %%mm0 \n\t"
2242 "movq (%%"FF_REG_a
", %3, 2), %%mm1 \n\t"
2243 PMAXUB(%%mm1, %%mm4)
2244 PMINUB(%%mm1, %%mm3, %%mm5)
2245 "psubb %%mm1, %%mm2 \n\t"
2246 "paddb %%mm7, %%mm2 \n\t"
2247 "pcmpgtb %%mm6, %%mm2 \n\t"
2248 "paddb %%mm2, %%mm0 \n\t"
2250 "movq (%2, %3, 8), %%mm2 \n\t"
2251 PMAXUB(%%mm2, %%mm4)
2252 PMINUB(%%mm2, %%mm3, %%mm5)
2253 "psubb %%mm2, %%mm1 \n\t"
2254 "paddb %%mm7, %%mm1 \n\t"
2255 "pcmpgtb %%mm6, %%mm1 \n\t"
2256 "paddb %%mm1, %%mm0 \n\t"
2258 "movq (%%"FF_REG_a
", %3, 4), %%mm1 \n\t"
2259 "psubb %%mm1, %%mm2 \n\t"
2260 "paddb %%mm7, %%mm2 \n\t"
2261 "pcmpgtb %%mm6, %%mm2 \n\t"
2262 "paddb %%mm2, %%mm0 \n\t"
2263 "psubusb %%mm3, %%mm4 \n\t"
2265 "pxor %%mm6, %%mm6 \n\t"
2266 "movq %4, %%mm7 \n\t"
2267 "paddusb %%mm7, %%mm7 \n\t"
2268 "psubusb %%mm4, %%mm7 \n\t"
2269 "pcmpeqb %%mm6, %%mm7 \n\t"
2270 "pcmpeqb %%mm6, %%mm7 \n\t"
2271 "movq %%mm7, %1 \n\t"
2273 "movq %5, %%mm7 \n\t"
2274 "punpcklbw %%mm7, %%mm7 \n\t"
2275 "punpcklbw %%mm7, %%mm7 \n\t"
2276 "punpcklbw %%mm7, %%mm7 \n\t"
2277 "psubb %%mm0, %%mm6 \n\t"
2278 "pcmpgtb %%mm7, %%mm6 \n\t"
2279 "movq %%mm6, %0 \n\t"
2281 :
"=m" (eq_mask),
"=m" (dc_mask)
2282 :
"r" (
src),
"r" ((
x86_reg)
step),
"m" (
c->pQPb),
"m"(
c->ppMode.flatnessThreshold)
2286 both_masks = dc_mask & eq_mask;
2293 "movq %2, %%mm0 \n\t"
2294 "pxor %%mm4, %%mm4 \n\t"
2296 "movq (%0), %%mm6 \n\t"
2297 "movq (%0, %1), %%mm5 \n\t"
2298 "movq %%mm5, %%mm1 \n\t"
2299 "movq %%mm6, %%mm2 \n\t"
2300 "psubusb %%mm6, %%mm5 \n\t"
2301 "psubusb %%mm1, %%mm2 \n\t"
2302 "por %%mm5, %%mm2 \n\t"
2303 "psubusb %%mm2, %%mm0 \n\t"
2304 "pcmpeqb %%mm4, %%mm0 \n\t"
2306 "pxor %%mm6, %%mm1 \n\t"
2307 "pand %%mm0, %%mm1 \n\t"
2308 "pxor %%mm1, %%mm6 \n\t"
2311 "movq (%0, %1, 8), %%mm5 \n\t"
2313 "movq (%0, %1, 8), %%mm7 \n\t"
2314 "movq %%mm5, %%mm1 \n\t"
2315 "movq %%mm7, %%mm2 \n\t"
2316 "psubusb %%mm7, %%mm5 \n\t"
2317 "psubusb %%mm1, %%mm2 \n\t"
2318 "por %%mm5, %%mm2 \n\t"
2319 "movq %2, %%mm0 \n\t"
2320 "psubusb %%mm2, %%mm0 \n\t"
2321 "pcmpeqb %%mm4, %%mm0 \n\t"
2323 "pxor %%mm7, %%mm1 \n\t"
2324 "pand %%mm0, %%mm1 \n\t"
2325 "pxor %%mm1, %%mm7 \n\t"
2327 "movq %%mm6, %%mm5 \n\t"
2328 "punpckhbw %%mm4, %%mm6 \n\t"
2329 "punpcklbw %%mm4, %%mm5 \n\t"
2332 "movq %%mm5, %%mm0 \n\t"
2333 "movq %%mm6, %%mm1 \n\t"
2334 "psllw $2, %%mm0 \n\t"
2335 "psllw $2, %%mm1 \n\t"
2336 "paddw "MANGLE(w04)
", %%mm0 \n\t"
2337 "paddw "MANGLE(w04)
", %%mm1 \n\t"
2340 "movq (%0), %%mm2 \n\t"\
2341 "movq (%0), %%mm3 \n\t"\
2343 "punpcklbw %%mm4, %%mm2 \n\t"\
2344 "punpckhbw %%mm4, %%mm3 \n\t"\
2345 "paddw %%mm2, %%mm0 \n\t"\
2346 "paddw %%mm3, %%mm1 \n\t"
2349 "movq (%0), %%mm2 \n\t"\
2350 "movq (%0), %%mm3 \n\t"\
2352 "punpcklbw %%mm4, %%mm2 \n\t"\
2353 "punpckhbw %%mm4, %%mm3 \n\t"\
2354 "psubw %%mm2, %%mm0 \n\t"\
2355 "psubw %%mm3, %%mm1 \n\t"
2361 "movq %%mm0, (%3) \n\t"
2362 "movq %%mm1, 8(%3) \n\t"
2365 "psubw %%mm5, %%mm0 \n\t"
2366 "psubw %%mm6, %%mm1 \n\t"
2367 "movq %%mm0, 16(%3) \n\t"
2368 "movq %%mm1, 24(%3) \n\t"
2371 "psubw %%mm5, %%mm0 \n\t"
2372 "psubw %%mm6, %%mm1 \n\t"
2373 "movq %%mm0, 32(%3) \n\t"
2374 "movq %%mm1, 40(%3) \n\t"
2377 "psubw %%mm5, %%mm0 \n\t"
2378 "psubw %%mm6, %%mm1 \n\t"
2379 "movq %%mm0, 48(%3) \n\t"
2380 "movq %%mm1, 56(%3) \n\t"
2383 "psubw %%mm5, %%mm0 \n\t"
2384 "psubw %%mm6, %%mm1 \n\t"
2385 "movq %%mm0, 64(%3) \n\t"
2386 "movq %%mm1, 72(%3) \n\t"
2388 "movq %%mm7, %%mm6 \n\t"
2389 "punpckhbw %%mm4, %%mm7 \n\t"
2390 "punpcklbw %%mm4, %%mm6 \n\t"
2396 "movq %%mm0, 80(%3) \n\t"
2397 "movq %%mm1, 88(%3) \n\t"
2400 "paddw %%mm6, %%mm0 \n\t"
2401 "paddw %%mm7, %%mm1 \n\t"
2402 "movq %%mm0, 96(%3) \n\t"
2403 "movq %%mm1, 104(%3) \n\t"
2406 "paddw %%mm6, %%mm0 \n\t"
2407 "paddw %%mm7, %%mm1 \n\t"
2408 "movq %%mm0, 112(%3) \n\t"
2409 "movq %%mm1, 120(%3) \n\t"
2412 "paddw %%mm6, %%mm0 \n\t"
2413 "paddw %%mm7, %%mm1 \n\t"
2414 "movq %%mm0, 128(%3) \n\t"
2415 "movq %%mm1, 136(%3) \n\t"
2418 "paddw %%mm6, %%mm0 \n\t"
2419 "paddw %%mm7, %%mm1 \n\t"
2420 "movq %%mm0, 144(%3) \n\t"
2421 "movq %%mm1, 152(%3) \n\t"
2433 "movq %4, %%mm6 \n\t"
2434 "pcmpeqb %%mm5, %%mm5 \n\t"
2435 "pxor %%mm6, %%mm5 \n\t"
2436 "pxor %%mm7, %%mm7 \n\t"
2439 "movq (%1), %%mm0 \n\t"
2440 "movq 8(%1), %%mm1 \n\t"
2441 "paddw 32(%1), %%mm0 \n\t"
2442 "paddw 40(%1), %%mm1 \n\t"
2443 "movq (%0, %3), %%mm2 \n\t"
2444 "movq %%mm2, %%mm3 \n\t"
2445 "movq %%mm2, %%mm4 \n\t"
2446 "punpcklbw %%mm7, %%mm2 \n\t"
2447 "punpckhbw %%mm7, %%mm3 \n\t"
2448 "paddw %%mm2, %%mm0 \n\t"
2449 "paddw %%mm3, %%mm1 \n\t"
2450 "paddw %%mm2, %%mm0 \n\t"
2451 "paddw %%mm3, %%mm1 \n\t"
2452 "psrlw $4, %%mm0 \n\t"
2453 "psrlw $4, %%mm1 \n\t"
2454 "packuswb %%mm1, %%mm0 \n\t"
2455 "pand %%mm6, %%mm0 \n\t"
2456 "pand %%mm5, %%mm4 \n\t"
2457 "por %%mm4, %%mm0 \n\t"
2458 "movq %%mm0, (%0, %3) \n\t"
2463 :
"+r"(
offset),
"+r"(temp_sums)
2469 if(eq_mask != -1LL){
2470 uint8_t *temp_src=
src;
2473 "pxor %%mm7, %%mm7 \n\t"
2477 "movq (%0), %%mm0 \n\t"
2478 "movq %%mm0, %%mm1 \n\t"
2479 "punpcklbw %%mm7, %%mm0 \n\t"
2480 "punpckhbw %%mm7, %%mm1 \n\t"
2482 "movq (%0, %1), %%mm2 \n\t"
2483 "lea (%0, %1, 2), %%"FF_REG_a
" \n\t"
2484 "movq %%mm2, %%mm3 \n\t"
2485 "punpcklbw %%mm7, %%mm2 \n\t"
2486 "punpckhbw %%mm7, %%mm3 \n\t"
2488 "movq (%%"FF_REG_a
"), %%mm4 \n\t"
2489 "movq %%mm4, %%mm5 \n\t"
2490 "punpcklbw %%mm7, %%mm4 \n\t"
2491 "punpckhbw %%mm7, %%mm5 \n\t"
2493 "paddw %%mm0, %%mm0 \n\t"
2494 "paddw %%mm1, %%mm1 \n\t"
2495 "psubw %%mm4, %%mm2 \n\t"
2496 "psubw %%mm5, %%mm3 \n\t"
2497 "psubw %%mm2, %%mm0 \n\t"
2498 "psubw %%mm3, %%mm1 \n\t"
2500 "psllw $2, %%mm2 \n\t"
2501 "psllw $2, %%mm3 \n\t"
2502 "psubw %%mm2, %%mm0 \n\t"
2503 "psubw %%mm3, %%mm1 \n\t"
2505 "movq (%%"FF_REG_a
", %1), %%mm2 \n\t"
2506 "movq %%mm2, %%mm3 \n\t"
2507 "punpcklbw %%mm7, %%mm2 \n\t"
2508 "punpckhbw %%mm7, %%mm3 \n\t"
2510 "psubw %%mm2, %%mm0 \n\t"
2511 "psubw %%mm3, %%mm1 \n\t"
2512 "psubw %%mm2, %%mm0 \n\t"
2513 "psubw %%mm3, %%mm1 \n\t"
2514 "movq %%mm0, (%4) \n\t"
2515 "movq %%mm1, 8(%4) \n\t"
2517 "movq (%%"FF_REG_a
", %1, 2), %%mm0 \n\t"
2518 "movq %%mm0, %%mm1 \n\t"
2519 "punpcklbw %%mm7, %%mm0 \n\t"
2520 "punpckhbw %%mm7, %%mm1 \n\t"
2522 "psubw %%mm0, %%mm2 \n\t"
2523 "psubw %%mm1, %%mm3 \n\t"
2524 "movq %%mm2, 16(%4) \n\t"
2525 "movq %%mm3, 24(%4) \n\t"
2526 "paddw %%mm4, %%mm4 \n\t"
2527 "paddw %%mm5, %%mm5 \n\t"
2528 "psubw %%mm2, %%mm4 \n\t"
2529 "psubw %%mm3, %%mm5 \n\t"
2531 "lea (%%"FF_REG_a
", %1), %0 \n\t"
2532 "psllw $2, %%mm2 \n\t"
2533 "psllw $2, %%mm3 \n\t"
2534 "psubw %%mm2, %%mm4 \n\t"
2535 "psubw %%mm3, %%mm5 \n\t"
2537 "movq (%0, %1, 2), %%mm2 \n\t"
2538 "movq %%mm2, %%mm3 \n\t"
2539 "punpcklbw %%mm7, %%mm2 \n\t"
2540 "punpckhbw %%mm7, %%mm3 \n\t"
2541 "psubw %%mm2, %%mm4 \n\t"
2542 "psubw %%mm3, %%mm5 \n\t"
2543 "psubw %%mm2, %%mm4 \n\t"
2544 "psubw %%mm3, %%mm5 \n\t"
2546 "movq (%%"FF_REG_a
", %1, 4), %%mm6 \n\t"
2547 "punpcklbw %%mm7, %%mm6 \n\t"
2548 "psubw %%mm6, %%mm2 \n\t"
2549 "movq (%%"FF_REG_a
", %1, 4), %%mm6 \n\t"
2550 "punpckhbw %%mm7, %%mm6 \n\t"
2551 "psubw %%mm6, %%mm3 \n\t"
2553 "paddw %%mm0, %%mm0 \n\t"
2554 "paddw %%mm1, %%mm1 \n\t"
2555 "psubw %%mm2, %%mm0 \n\t"
2556 "psubw %%mm3, %%mm1 \n\t"
2558 "psllw $2, %%mm2 \n\t"
2559 "psllw $2, %%mm3 \n\t"
2560 "psubw %%mm2, %%mm0 \n\t"
2561 "psubw %%mm3, %%mm1 \n\t"
2563 "movq (%0, %1, 4), %%mm2 \n\t"
2564 "movq %%mm2, %%mm3 \n\t"
2565 "punpcklbw %%mm7, %%mm2 \n\t"
2566 "punpckhbw %%mm7, %%mm3 \n\t"
2568 "paddw %%mm2, %%mm2 \n\t"
2569 "paddw %%mm3, %%mm3 \n\t"
2570 "psubw %%mm2, %%mm0 \n\t"
2571 "psubw %%mm3, %%mm1 \n\t"
2573 "movq (%4), %%mm2 \n\t"
2574 "movq 8(%4), %%mm3 \n\t"
2576 "movq %%mm7, %%mm6 \n\t"
2577 "psubw %%mm0, %%mm6 \n\t"
2578 "pmaxsw %%mm6, %%mm0 \n\t"
2579 "movq %%mm7, %%mm6 \n\t"
2580 "psubw %%mm1, %%mm6 \n\t"
2581 "pmaxsw %%mm6, %%mm1 \n\t"
2582 "movq %%mm7, %%mm6 \n\t"
2583 "psubw %%mm2, %%mm6 \n\t"
2584 "pmaxsw %%mm6, %%mm2 \n\t"
2585 "movq %%mm7, %%mm6 \n\t"
2586 "psubw %%mm3, %%mm6 \n\t"
2587 "pmaxsw %%mm6, %%mm3 \n\t"
2589 "pminsw %%mm2, %%mm0 \n\t"
2590 "pminsw %%mm3, %%mm1 \n\t"
2592 "movd %2, %%mm2 \n\t"
2593 "punpcklbw %%mm7, %%mm2 \n\t"
2595 "movq %%mm7, %%mm6 \n\t"
2596 "pcmpgtw %%mm4, %%mm6 \n\t"
2597 "pxor %%mm6, %%mm4 \n\t"
2598 "psubw %%mm6, %%mm4 \n\t"
2599 "pcmpgtw %%mm5, %%mm7 \n\t"
2600 "pxor %%mm7, %%mm5 \n\t"
2601 "psubw %%mm7, %%mm5 \n\t"
2603 "psllw $3, %%mm2 \n\t"
2604 "movq %%mm2, %%mm3 \n\t"
2605 "pcmpgtw %%mm4, %%mm2 \n\t"
2606 "pcmpgtw %%mm5, %%mm3 \n\t"
2607 "pand %%mm2, %%mm4 \n\t"
2608 "pand %%mm3, %%mm5 \n\t"
2611 "psubusw %%mm0, %%mm4 \n\t"
2612 "psubusw %%mm1, %%mm5 \n\t"
2615 "movq "MANGLE(w05)
", %%mm2 \n\t"
2616 "pmullw %%mm2, %%mm4 \n\t"
2617 "pmullw %%mm2, %%mm5 \n\t"
2618 "movq "MANGLE(w20)
", %%mm2 \n\t"
2619 "paddw %%mm2, %%mm4 \n\t"
2620 "paddw %%mm2, %%mm5 \n\t"
2621 "psrlw $6, %%mm4 \n\t"
2622 "psrlw $6, %%mm5 \n\t"
2624 "movq 16(%4), %%mm0 \n\t"
2625 "movq 24(%4), %%mm1 \n\t"
2627 "pxor %%mm2, %%mm2 \n\t"
2628 "pxor %%mm3, %%mm3 \n\t"
2630 "pcmpgtw %%mm0, %%mm2 \n\t"
2631 "pcmpgtw %%mm1, %%mm3 \n\t"
2632 "pxor %%mm2, %%mm0 \n\t"
2633 "pxor %%mm3, %%mm1 \n\t"
2634 "psubw %%mm2, %%mm0 \n\t"
2635 "psubw %%mm3, %%mm1 \n\t"
2636 "psrlw $1, %%mm0 \n\t"
2637 "psrlw $1, %%mm1 \n\t"
2639 "pxor %%mm6, %%mm2 \n\t"
2640 "pxor %%mm7, %%mm3 \n\t"
2641 "pand %%mm2, %%mm4 \n\t"
2642 "pand %%mm3, %%mm5 \n\t"
2644 "pminsw %%mm0, %%mm4 \n\t"
2645 "pminsw %%mm1, %%mm5 \n\t"
2646 "pxor %%mm6, %%mm4 \n\t"
2647 "pxor %%mm7, %%mm5 \n\t"
2648 "psubw %%mm6, %%mm4 \n\t"
2649 "psubw %%mm7, %%mm5 \n\t"
2650 "packsswb %%mm5, %%mm4 \n\t"
2651 "movq %3, %%mm1 \n\t"
2652 "pandn %%mm4, %%mm1 \n\t"
2653 "movq (%0), %%mm0 \n\t"
2654 "paddb %%mm1, %%mm0 \n\t"
2655 "movq %%mm0, (%0) \n\t"
2656 "movq (%0, %1), %%mm0 \n\t"
2657 "psubb %%mm1, %%mm0 \n\t"
2658 "movq %%mm0, (%0, %1) \n\t"
2667 #endif //TEMPLATE_PP_MMX
2670 const int8_t QPs[],
int QPStride,
int isColor,
PPContext *
c);
2676 #undef REAL_SCALED_CPY
2679 static inline void RENAME(blockCopy)(uint8_t
dst[],
int dstStride,
const uint8_t
src[],
int srcStride,
2680 int levelFix,
int64_t *packedOffsetAndScale)
2683 #if TEMPLATE_PP_MMXEXT && HAVE_6REGS
2685 "movq (%%"FF_REG_a
"), %%mm2 \n\t"
2686 "movq 8(%%"FF_REG_a
"), %%mm3 \n\t"
2687 "lea (%2,%4), %%"FF_REG_a
" \n\t"
2688 "lea (%3,%5), %%"FF_REG_d
" \n\t"
2689 "pxor %%mm4, %%mm4 \n\t"
2690 #define REAL_SCALED_CPY(src1, src2, dst1, dst2) \
2691 "movq " #src1 ", %%mm0 \n\t"\
2692 "movq " #src1 ", %%mm5 \n\t"\
2693 "movq " #src2 ", %%mm1 \n\t"\
2694 "movq " #src2 ", %%mm6 \n\t"\
2695 "punpcklbw %%mm0, %%mm0 \n\t"\
2696 "punpckhbw %%mm5, %%mm5 \n\t"\
2697 "punpcklbw %%mm1, %%mm1 \n\t"\
2698 "punpckhbw %%mm6, %%mm6 \n\t"\
2699 "pmulhuw %%mm3, %%mm0 \n\t"\
2700 "pmulhuw %%mm3, %%mm5 \n\t"\
2701 "pmulhuw %%mm3, %%mm1 \n\t"\
2702 "pmulhuw %%mm3, %%mm6 \n\t"\
2703 "psubw %%mm2, %%mm0 \n\t"\
2704 "psubw %%mm2, %%mm5 \n\t"\
2705 "psubw %%mm2, %%mm1 \n\t"\
2706 "psubw %%mm2, %%mm6 \n\t"\
2707 "packuswb %%mm5, %%mm0 \n\t"\
2708 "packuswb %%mm6, %%mm1 \n\t"\
2709 "movq %%mm0, " #dst1 " \n\t"\
2710 "movq %%mm1, " #dst2 " \n\t"\
2712 #define SCALED_CPY(src1, src2, dst1, dst2)\
2713 REAL_SCALED_CPY(src1, src2, dst1, dst2)
2715 SCALED_CPY((%2) , (%2, %4) , (%3) , (%3, %5))
2716 SCALED_CPY((%2, %4, 2), (%%FF_REGa, %4, 2), (%3, %5, 2), (%%FF_REGd, %5, 2))
2717 SCALED_CPY((%2, %4, 4), (%%FF_REGa, %4, 4), (%3, %5, 4), (%%FF_REGd, %5, 4))
2718 "lea (%%"FF_REG_a
",%4,4), %%"FF_REG_a
" \n\t"
2719 "lea (%%"FF_REG_d
",%5,4), %%"FF_REG_d
" \n\t"
2720 SCALED_CPY((%%FF_REGa, %4), (%%FF_REGa, %4, 2), (%%FF_REGd, %5), (%%FF_REGd, %5, 2))
2723 :
"=&a" (packedOffsetAndScale)
2724 :
"0" (packedOffsetAndScale),
2731 #else //TEMPLATE_PP_MMX && HAVE_6REGS
2732 for (
int i = 0;
i < 8;
i++)
2733 memcpy( &(
dst[dstStride*
i]),
2735 #endif //TEMPLATE_PP_MMX && HAVE_6REGS
2737 #if TEMPLATE_PP_MMX && HAVE_6REGS
2739 "lea (%0,%2), %%"FF_REG_a
" \n\t"
2740 "lea (%1,%3), %%"FF_REG_d
" \n\t"
2742 #define REAL_SIMPLE_CPY(src1, src2, dst1, dst2) \
2743 "movq " #src1 ", %%mm0 \n\t"\
2744 "movq " #src2 ", %%mm1 \n\t"\
2745 "movq %%mm0, " #dst1 " \n\t"\
2746 "movq %%mm1, " #dst2 " \n\t"\
2748 #define SIMPLE_CPY(src1, src2, dst1, dst2)\
2749 REAL_SIMPLE_CPY(src1, src2, dst1, dst2)
2751 SIMPLE_CPY((%0) , (%0, %2) , (%1) , (%1, %3))
2752 SIMPLE_CPY((%0, %2, 2), (%%FF_REGa, %2, 2), (%1, %3, 2), (%%FF_REGd, %3, 2))
2753 SIMPLE_CPY((%0, %2, 4), (%%FF_REGa, %2, 4), (%1, %3, 4), (%%FF_REGd, %3, 4))
2754 "lea (%%"FF_REG_a
",%2,4), %%"FF_REG_a
" \n\t"
2755 "lea (%%"FF_REG_d
",%3,4), %%"FF_REG_d
" \n\t"
2756 SIMPLE_CPY((%%FF_REGa, %2), (%%FF_REGa, %2, 2), (%%FF_REGd, %3), (%%FF_REGd, %3, 2))
2762 :
"%"FF_REG_a,
"%"FF_REG_d
2764 #else //TEMPLATE_PP_MMX && HAVE_6REGS
2765 for (
int i = 0;
i < 8;
i++)
2766 memcpy( &(
dst[dstStride*
i]),
2768 #endif //TEMPLATE_PP_MMX && HAVE_6REGS
2779 "movq (%0), %%mm0 \n\t"
2780 "movq %%mm0, (%0, %1, 4) \n\t"
2782 "movq %%mm0, (%0) \n\t"
2783 "movq %%mm0, (%0, %1) \n\t"
2784 "movq %%mm0, (%0, %1, 2) \n\t"
2785 "movq %%mm0, (%0, %1, 4) \n\t"
2799 #if ARCH_X86 && TEMPLATE_PP_MMXEXT
2800 static inline void RENAME(prefetchnta)(
const void *p)
2802 __asm__ volatile(
"prefetchnta (%0)\n\t"
2807 static inline void RENAME(prefetcht0)(
const void *p)
2809 __asm__ volatile(
"prefetcht0 (%0)\n\t"
2814 static inline void RENAME(prefetcht1)(
const void *p)
2816 __asm__ volatile(
"prefetcht1 (%0)\n\t"
2821 static inline void RENAME(prefetcht2)(
const void *p)
2823 __asm__ volatile(
"prefetcht2 (%0)\n\t"
2827 #elif !ARCH_X86 && AV_GCC_VERSION_AT_LEAST(3,2)
2828 static inline void RENAME(prefetchnta)(
const void *p)
2830 __builtin_prefetch(p,0,0);
2832 static inline void RENAME(prefetcht0)(
const void *p)
2834 __builtin_prefetch(p,0,1);
2836 static inline void RENAME(prefetcht1)(
const void *p)
2838 __builtin_prefetch(p,0,2);
2840 static inline void RENAME(prefetcht2)(
const void *p)
2842 __builtin_prefetch(p,0,3);
2845 static inline void RENAME(prefetchnta)(
const void *p)
2849 static inline void RENAME(prefetcht0)(
const void *p)
2853 static inline void RENAME(prefetcht1)(
const void *p)
2857 static inline void RENAME(prefetcht2)(
const void *p)
2866 const int8_t QPs[],
int QPStride,
int isColor,
PPContext *
c)
2869 #ifdef TEMPLATE_PP_TIME_MODE
2870 const int mode= TEMPLATE_PP_TIME_MODE;
2872 const int mode = isColor ?
c->ppMode.chromMode :
c->ppMode.lumMode;
2874 int black=0, white=255;
2875 int QPCorrecture= 256*256;
2882 const int qpHShift = isColor ? 4 -
c->hChromaSubSample : 4;
2883 const int qpVShift = isColor ? 4 -
c->vChromaSubSample : 4;
2886 uint64_t *
const yHistogram=
c->yHistogram;
2887 uint8_t *
const tempSrc = srcStride > 0 ?
c->tempSrc :
c->tempSrc - 23*srcStride;
2888 uint8_t *
const tempDst = (dstStride > 0 ?
c->tempDst :
c->tempDst - 23*dstStride) + 32;
2893 av_log(
c,
AV_LOG_WARNING,
"Visualization is currently only supported with the accurate deblock filter without SIMD\n");
2898 for(
i=0;
i<57;
i++){
2899 int offset = ((
i *
c->ppMode.baseDcDiff) >> 8) + 1;
2900 int threshold=
offset*2 + 1;
2902 c->mmxDcThreshold[
i] = 0x7F - threshold;
2903 c->mmxDcOffset[
i] *= 0x0101010101010101LL;
2904 c->mmxDcThreshold[
i] *= 0x0101010101010101LL;
2926 uint64_t maxClipped;
2932 if (
c->frameNum == 1)
2933 yHistogram[0] =
width * (uint64_t)
height/64*15/256;
2935 for(
i=0;
i<256;
i++){
2936 sum+= yHistogram[
i];
2940 maxClipped =
av_rescale(sum,
c->ppMode.maxClippedThreshold.num,
2941 c->ppMode.maxClippedThreshold.den);
2944 for(black=255; black>0; black--){
2945 if(clipped < maxClipped)
break;
2946 clipped-= yHistogram[black];
2950 for(white=0; white<256; white++){
2951 if(clipped < maxClipped)
break;
2952 clipped-= yHistogram[white];
2955 scale = (
AVRational){
c->ppMode.maxAllowedY -
c->ppMode.minAllowedY, white - black};
2957 #if TEMPLATE_PP_MMXEXT
2959 c->packedYOffset = (((black*
c->packedYScale)>>8) -
c->ppMode.minAllowedY) & 0xFFFF;
2962 c->packedYOffset = (black -
c->ppMode.minAllowedY) & 0xFFFF;
2965 c->packedYOffset |=
c->packedYOffset<<32;
2966 c->packedYOffset |=
c->packedYOffset<<16;
2968 c->packedYScale |=
c->packedYScale<<32;
2969 c->packedYScale |=
c->packedYScale<<16;
2972 else QPCorrecture= 256*256;
2974 c->packedYScale = 0x0100010001000100LL;
2975 c->packedYOffset = 0;
2976 QPCorrecture= 256*256;
2982 const uint8_t *srcBlock= &(
src[y*srcStride]);
2983 uint8_t *dstBlock= tempDst + dstStride;
2989 RENAME(prefetchnta)(srcBlock + (((x>>2)&6) + copyAhead)*srcStride + 32);
2990 RENAME(prefetchnta)(srcBlock + (((x>>2)&6) + copyAhead+1)*srcStride + 32);
2991 RENAME(prefetcht0)(dstBlock + (((x>>2)&6) + copyAhead)*dstStride + 32);
2992 RENAME(prefetcht0)(dstBlock + (((x>>2)&6) + copyAhead+1)*dstStride + 32);
2994 RENAME(blockCopy)(dstBlock + dstStride*8, dstStride,
2995 srcBlock + srcStride*8, srcStride,
mode &
LEVEL_FIX, &
c->packedYOffset);
2997 RENAME(duplicate)(dstBlock + dstStride*8, dstStride);
3000 RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride);
3002 RENAME(deInterlaceBlendLinear)(dstBlock, dstStride,
c->deintTemp + x);
3004 RENAME(deInterlaceMedian)(dstBlock, dstStride);
3006 RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride);
3008 RENAME(deInterlaceFF)(dstBlock, dstStride,
c->deintTemp + x);
3010 RENAME(deInterlaceL5)(dstBlock, dstStride,
c->deintTemp + x,
c->deintTemp +
width + x);
3018 linecpy(
dst, tempDst + 9*dstStride, copyAhead, dstStride);
3021 for(
i=0;
i<copyAhead;
i++){
3022 memcpy(
dst +
i*dstStride, tempDst + (9+
i)*dstStride,
width);
3029 const uint8_t *srcBlock= &(
src[y*srcStride]);
3030 uint8_t *dstBlock= &(
dst[y*dstStride]);
3032 uint8_t *tempBlock1 =
c->tempBlocks;
3033 uint8_t *tempBlock2 =
c->tempBlocks + 8;
3035 const int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride];
3036 int8_t *nonBQPptr = &
c->nonBQPTable[(y>>qpVShift)*
FFABS(QPStride)];
3044 linecpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead,
3049 memcpy(tempSrc + srcStride*
i,
src + srcStride*(
height-1),
FFABS(srcStride));
3056 memcpy(tempDst + dstStride*
i,
dst + dstStride*(
height-1),
FFABS(dstStride));
3058 dstBlock= tempDst + dstStride;
3065 for(x=0; x<
width; ){
3068 uint8_t *dstBlockStart = dstBlock;
3069 const uint8_t *srcBlockStart = srcBlock;
3071 for(qp_index=0; qp_index < (endx-startx)/
BLOCK_SIZE; qp_index++){
3073 nonBQP = nonBQPptr[(x+qp_index*
BLOCK_SIZE)>>qpHShift];
3075 QP= (
QP* QPCorrecture + 256*128)>>16;
3076 nonBQP= (nonBQP* QPCorrecture + 256*128)>>16;
3077 yHistogram[(srcBlock+qp_index*8)[srcStride*12 + 4]]++;
3079 c->QP_block[qp_index] =
QP;
3080 c->nonBQP_block[qp_index] = nonBQP;
3083 "movd %1, %%mm7 \n\t"
3084 "packuswb %%mm7, %%mm7 \n\t"
3085 "packuswb %%mm7, %%mm7 \n\t"
3086 "packuswb %%mm7, %%mm7 \n\t"
3087 "movq %%mm7, %0 \n\t"
3088 :
"=m" (
c->pQPb_block[qp_index])
3094 RENAME(prefetchnta)(srcBlock + (((x>>2)&6) + copyAhead)*srcStride + 32);
3095 RENAME(prefetchnta)(srcBlock + (((x>>2)&6) + copyAhead+1)*srcStride + 32);
3096 RENAME(prefetcht0)(dstBlock + (((x>>2)&6) + copyAhead)*dstStride + 32);
3097 RENAME(prefetcht0)(dstBlock + (((x>>2)&6) + copyAhead+1)*dstStride + 32);
3099 RENAME(blockCopy)(dstBlock + dstStride*copyAhead, dstStride,
3100 srcBlock + srcStride*copyAhead, srcStride,
mode &
LEVEL_FIX, &
c->packedYOffset);
3103 RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride);
3105 RENAME(deInterlaceBlendLinear)(dstBlock, dstStride,
c->deintTemp + x);
3107 RENAME(deInterlaceMedian)(dstBlock, dstStride);
3109 RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride);
3111 RENAME(deInterlaceFF)(dstBlock, dstStride,
c->deintTemp + x);
3113 RENAME(deInterlaceL5)(dstBlock, dstStride,
c->deintTemp + x,
c->deintTemp +
width + x);
3121 dstBlock = dstBlockStart;
3122 srcBlock = srcBlockStart;
3124 for(x = startx, qp_index = 0; x < endx; x+=
BLOCK_SIZE, qp_index++){
3125 const int stride= dstStride;
3128 c->QP =
c->QP_block[qp_index];
3129 c->nonBQP =
c->nonBQP_block[qp_index];
3130 c->pQPb =
c->pQPb_block[qp_index];
3131 c->pQPb2 =
c->pQPb2_block[qp_index];
3153 dstBlock = dstBlockStart;
3154 srcBlock = srcBlockStart;
3156 for(x = startx, qp_index=0; x < endx; x+=
BLOCK_SIZE, qp_index++){
3157 const int stride= dstStride;
3158 c->QP =
c->QP_block[qp_index];
3159 c->nonBQP =
c->nonBQP_block[qp_index];
3160 c->pQPb =
c->pQPb_block[qp_index];
3161 c->pQPb2 =
c->pQPb2_block[qp_index];
3163 RENAME(transpose1)(tempBlock1, tempBlock2, dstBlock, dstStride);
3169 RENAME(vertX1Filter)(tempBlock1, 16,
c);
3171 const int t=
RENAME(vertClassify)(tempBlock1, 16,
c);
3173 RENAME(doVertLowPass)(tempBlock1, 16,
c);
3175 RENAME(doVertDefFilter)(tempBlock1, 16,
c);
3180 RENAME(transpose2)(dstBlock-4, dstStride, tempBlock1 + 4*16);
3186 #if TEMPLATE_PP_ALTIVEC
3211 #endif //TEMPLATE_PP_MMX
3220 c->tempBlurred[isColor] + y*dstStride + x,
3221 c->tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256,
3222 c->ppMode.maxTmpNoise);
3230 FFSWAP(uint8_t *, tempBlock1, tempBlock2);
3236 if(y > 0)
RENAME(dering)(dstBlock - dstStride - 8, dstStride,
c);
3240 RENAME(tempNoiseReducer)(dstBlock-8, dstStride,
3241 c->tempBlurred[isColor] + y*dstStride + x,
3242 c->tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256,
3243 c->ppMode.maxTmpNoise);
3248 uint8_t *dstBlock= &(
dst[y*dstStride]);
3250 linecpy(dstBlock, tempDst + dstStride,
height-y, dstStride);
3254 memcpy(dstBlock +
i*dstStride, tempDst + (
i+1)*dstStride,
width);
3263 #ifdef DEBUG_BRIGHTNESS
3267 for(
i=0;
i<256;
i++)
3268 if(yHistogram[
i] >
max)
max=yHistogram[
i];
3270 for(
i=1;
i<256;
i++){
3272 int start=yHistogram[
i-1]/(
max/256+1);
3273 int end=yHistogram[
i]/(
max/256+1);
3274 int inc= end > start ? 1 : -1;
3275 for(x=start; x!=end+
inc; x+=
inc)
3276 dst[
i*dstStride + x]+=128;
3279 for(
i=0;
i<100;
i+=2){
3280 dst[ (white)*dstStride +
i]+=128;
3281 dst[ (black)*dstStride +
i]+=128;
3288 #undef TEMPLATE_PP_C
3289 #undef TEMPLATE_PP_ALTIVEC
3290 #undef TEMPLATE_PP_MMX
3291 #undef TEMPLATE_PP_MMXEXT
3292 #undef TEMPLATE_PP_SSE2