35 # define RENAME(a) a ## _C
37 # define TEMPLATE_PP_C 0
40 #ifdef TEMPLATE_PP_ALTIVEC
41 # define RENAME(a) a ## _altivec
43 # define TEMPLATE_PP_ALTIVEC 0
46 #ifdef TEMPLATE_PP_MMX
47 # define RENAME(a) a ## _MMX
49 # define TEMPLATE_PP_MMX 0
52 #ifdef TEMPLATE_PP_MMXEXT
53 # undef TEMPLATE_PP_MMX
54 # define TEMPLATE_PP_MMX 1
55 # define RENAME(a) a ## _MMX2
57 # define TEMPLATE_PP_MMXEXT 0
60 #ifdef TEMPLATE_PP_SSE2
61 # undef TEMPLATE_PP_MMX
62 # define TEMPLATE_PP_MMX 1
63 # undef TEMPLATE_PP_MMXEXT
64 # define TEMPLATE_PP_MMXEXT 1
65 # define RENAME(a) a ## _SSE2
67 # define TEMPLATE_PP_SSE2 0
75 #if TEMPLATE_PP_MMXEXT
76 #define REAL_PAVGB(a,b) "pavgb " #a ", " #b " \n\t"
78 #define PAVGB(a,b) REAL_PAVGB(a,b)
80 #if TEMPLATE_PP_MMXEXT
81 #define PMINUB(a,b,t) "pminub " #a ", " #b " \n\t"
84 #if TEMPLATE_PP_MMXEXT
85 #define PMAXUB(a,b) "pmaxub " #a ", " #b " \n\t"
89 #if TEMPLATE_PP_MMXEXT
99 : :
"m" (
c->mmxDcOffset[
c->nonBQP]),
"m" (
c->mmxDcThreshold[
c->nonBQP])
103 "lea (%2, %3), %%"FF_REG_a
" \n\t"
107 "movq (%2), %%mm0 \n\t"
108 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
109 "movq %%mm0, %%mm3 \n\t"
110 "movq %%mm0, %%mm4 \n\t"
112 PMINUB(%%mm1, %%mm3, %%mm5)
113 "psubb %%mm1, %%mm0 \n\t"
114 "paddb %%mm7, %%mm0 \n\t"
115 "pcmpgtb %%mm6, %%mm0 \n\t"
117 "movq (%%"FF_REG_a
",%3), %%mm2 \n\t"
119 PMINUB(%%mm2, %%mm3, %%mm5)
120 "psubb %%mm2, %%mm1 \n\t"
121 "paddb %%mm7, %%mm1 \n\t"
122 "pcmpgtb %%mm6, %%mm1 \n\t"
123 "paddb %%mm1, %%mm0 \n\t"
125 "movq (%%"FF_REG_a
", %3, 2), %%mm1 \n\t"
127 PMINUB(%%mm1, %%mm3, %%mm5)
128 "psubb %%mm1, %%mm2 \n\t"
129 "paddb %%mm7, %%mm2 \n\t"
130 "pcmpgtb %%mm6, %%mm2 \n\t"
131 "paddb %%mm2, %%mm0 \n\t"
133 "lea (%%"FF_REG_a
", %3, 4), %%"FF_REG_a
"\n\t"
135 "movq (%2, %3, 4), %%mm2 \n\t"
137 PMINUB(%%mm2, %%mm3, %%mm5)
138 "psubb %%mm2, %%mm1 \n\t"
139 "paddb %%mm7, %%mm1 \n\t"
140 "pcmpgtb %%mm6, %%mm1 \n\t"
141 "paddb %%mm1, %%mm0 \n\t"
143 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
145 PMINUB(%%mm1, %%mm3, %%mm5)
146 "psubb %%mm1, %%mm2 \n\t"
147 "paddb %%mm7, %%mm2 \n\t"
148 "pcmpgtb %%mm6, %%mm2 \n\t"
149 "paddb %%mm2, %%mm0 \n\t"
151 "movq (%%"FF_REG_a
", %3), %%mm2 \n\t"
153 PMINUB(%%mm2, %%mm3, %%mm5)
154 "psubb %%mm2, %%mm1 \n\t"
155 "paddb %%mm7, %%mm1 \n\t"
156 "pcmpgtb %%mm6, %%mm1 \n\t"
157 "paddb %%mm1, %%mm0 \n\t"
159 "movq (%%"FF_REG_a
", %3, 2), %%mm1 \n\t"
161 PMINUB(%%mm1, %%mm3, %%mm5)
162 "psubb %%mm1, %%mm2 \n\t"
163 "paddb %%mm7, %%mm2 \n\t"
164 "pcmpgtb %%mm6, %%mm2 \n\t"
165 "paddb %%mm2, %%mm0 \n\t"
166 "psubusb %%mm3, %%mm4 \n\t"
169 "pxor %%mm7, %%mm7 \n\t"
170 "psadbw %%mm7, %%mm0 \n\t"
171 "movq %4, %%mm7 \n\t"
172 "paddusb %%mm7, %%mm7 \n\t"
173 "psubusb %%mm7, %%mm4 \n\t"
174 "packssdw %%mm4, %%mm4 \n\t"
175 "movd %%mm0, %0 \n\t"
176 "movd %%mm4, %1 \n\t"
178 :
"=r" (numEq),
"=r" (dcOk)
183 numEq= (-numEq) &0xFF;
184 if(numEq >
c->ppMode.flatnessThreshold){
191 #endif //TEMPLATE_PP_MMXEXT
197 #if !TEMPLATE_PP_ALTIVEC
200 #if TEMPLATE_PP_MMXEXT
203 "movq %2, %%mm0 \n\t"
204 "pxor %%mm4, %%mm4 \n\t"
206 "movq (%0), %%mm6 \n\t"
207 "movq (%0, %1), %%mm5 \n\t"
208 "movq %%mm5, %%mm1 \n\t"
209 "movq %%mm6, %%mm2 \n\t"
210 "psubusb %%mm6, %%mm5 \n\t"
211 "psubusb %%mm1, %%mm2 \n\t"
212 "por %%mm5, %%mm2 \n\t"
213 "psubusb %%mm0, %%mm2 \n\t"
214 "pcmpeqb %%mm4, %%mm2 \n\t"
216 "pand %%mm2, %%mm6 \n\t"
217 "pandn %%mm1, %%mm2 \n\t"
218 "por %%mm2, %%mm6 \n\t"
220 "movq (%0, %1, 8), %%mm5 \n\t"
221 "lea (%0, %1, 4), %%"FF_REG_a
" \n\t"
222 "lea (%0, %1, 8), %%"FF_REG_c
" \n\t"
223 "sub %1, %%"FF_REG_c
" \n\t"
225 "movq (%0, %1, 8), %%mm7 \n\t"
226 "movq %%mm5, %%mm1 \n\t"
227 "movq %%mm7, %%mm2 \n\t"
228 "psubusb %%mm7, %%mm5 \n\t"
229 "psubusb %%mm1, %%mm2 \n\t"
230 "por %%mm5, %%mm2 \n\t"
231 "psubusb %%mm0, %%mm2 \n\t"
232 "pcmpeqb %%mm4, %%mm2 \n\t"
234 "pand %%mm2, %%mm7 \n\t"
235 "pandn %%mm1, %%mm2 \n\t"
236 "por %%mm2, %%mm7 \n\t"
245 "movq (%0, %1), %%mm0 \n\t"
246 "movq %%mm0, %%mm1 \n\t"
250 "movq (%0, %1, 4), %%mm2 \n\t"
251 "movq %%mm2, %%mm5 \n\t"
252 PAVGB((%%FF_REGa), %%mm2)
253 PAVGB((%0, %1, 2), %%mm2)
254 "movq %%mm2, %%mm3 \n\t"
255 "movq (%0), %%mm4 \n\t"
258 "movq %%mm3, (%0) \n\t"
260 "movq %%mm1, %%mm0 \n\t"
262 "movq %%mm4, %%mm3 \n\t"
263 PAVGB((%0,%1,2), %%mm3)
264 PAVGB((%%FF_REGa,%1,2), %%mm5)
265 PAVGB((%%FF_REGa), %%mm5)
268 "movq %%mm3, (%0,%1) \n\t"
271 "movq (%%"FF_REG_c
"), %%mm0 \n\t"
272 PAVGB((%%FF_REGa, %1, 2), %%mm0)
273 "movq %%mm0, %%mm3 \n\t"
277 "movq (%0, %1, 2), %%mm2 \n\t"
278 "movq %%mm0, (%0, %1, 2) \n\t"
280 "movq (%%"FF_REG_a
", %1, 4), %%mm0 \n\t"
281 PAVGB((%%FF_REGc), %%mm0)
287 "movq (%%"FF_REG_a
"), %%mm5 \n\t"
288 "movq %%mm6, (%%"FF_REG_a
") \n\t"
290 "movq (%%"FF_REG_a
", %1, 4), %%mm6 \n\t"
295 "movq (%0, %1, 4), %%mm4 \n\t"
298 "movq %%mm6, (%0, %1, 4) \n\t"
303 "movq (%%"FF_REG_a
", %1, 2), %%mm6 \n\t"
306 "movq %%mm1, (%%"FF_REG_a
", %1, 2) \n\t"
308 PAVGB((%%FF_REGc), %%mm2)
309 "movq (%%"FF_REG_a
", %1, 4), %%mm0 \n\t"
313 "movq %%mm6, (%%"FF_REG_c
") \n\t"
320 "movq %%mm5, (%%"FF_REG_a
", %1, 4) \n\t"
325 :
"%"FF_REG_a,
"%"FF_REG_c
327 #else //TEMPLATE_PP_MMXEXT
329 const int l2=
stride + l1;
330 const int l3=
stride + l2;
331 const int l4=
stride + l3;
332 const int l5=
stride + l4;
333 const int l6=
stride + l5;
334 const int l7=
stride + l6;
335 const int l8=
stride + l7;
336 const int l9=
stride + l8;
345 sums[1] = sums[0] -
first +
src[l4];
346 sums[2] = sums[1] -
first +
src[l5];
347 sums[3] = sums[2] -
first +
src[l6];
348 sums[4] = sums[3] -
first +
src[l7];
349 sums[5] = sums[4] -
src[l1] +
src[l8];
350 sums[6] = sums[5] -
src[l2] + last;
351 sums[7] = sums[6] -
src[l3] + last;
352 sums[8] = sums[7] -
src[l4] + last;
353 sums[9] = sums[8] -
src[l5] + last;
355 src[l1]= (sums[0] + sums[2] + 2*
src[l1])>>4;
356 src[l2]= (sums[1] + sums[3] + 2*
src[l2])>>4;
357 src[l3]= (sums[2] + sums[4] + 2*
src[l3])>>4;
358 src[l4]= (sums[3] + sums[5] + 2*
src[l4])>>4;
359 src[l5]= (sums[4] + sums[6] + 2*
src[l5])>>4;
360 src[l6]= (sums[5] + sums[7] + 2*
src[l6])>>4;
361 src[l7]= (sums[6] + sums[8] + 2*
src[l7])>>4;
362 src[l8]= (sums[7] + sums[9] + 2*
src[l8])>>4;
366 #endif //TEMPLATE_PP_MMXEXT
368 #endif //TEMPLATE_PP_ALTIVEC
379 #if TEMPLATE_PP_MMXEXT
383 "pxor %%mm7, %%mm7 \n\t"
384 "lea (%0, %1), %%"FF_REG_a
" \n\t"
385 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_c
"\n\t"
388 "movq (%%"FF_REG_a
", %1, 2), %%mm0 \n\t"
389 "movq (%0, %1, 4), %%mm1 \n\t"
390 "movq %%mm1, %%mm2 \n\t"
391 "psubusb %%mm0, %%mm1 \n\t"
392 "psubusb %%mm2, %%mm0 \n\t"
393 "por %%mm1, %%mm0 \n\t"
394 "movq (%%"FF_REG_c
"), %%mm3 \n\t"
395 "movq (%%"FF_REG_c
", %1), %%mm4 \n\t"
396 "movq %%mm3, %%mm5 \n\t"
397 "psubusb %%mm4, %%mm3 \n\t"
398 "psubusb %%mm5, %%mm4 \n\t"
399 "por %%mm4, %%mm3 \n\t"
401 "movq %%mm2, %%mm1 \n\t"
402 "psubusb %%mm5, %%mm2 \n\t"
403 "movq %%mm2, %%mm4 \n\t"
404 "pcmpeqb %%mm7, %%mm2 \n\t"
405 "psubusb %%mm1, %%mm5 \n\t"
406 "por %%mm5, %%mm4 \n\t"
407 "psubusb %%mm0, %%mm4 \n\t"
408 "movq %%mm4, %%mm3 \n\t"
409 "movq %2, %%mm0 \n\t"
410 "paddusb %%mm0, %%mm0 \n\t"
411 "psubusb %%mm0, %%mm4 \n\t"
412 "pcmpeqb %%mm7, %%mm4 \n\t"
413 "psubusb "MANGLE(b01)
", %%mm3 \n\t"
414 "pand %%mm4, %%mm3 \n\t"
417 "movq %%mm3, %%mm1 \n\t"
421 "movq (%0, %1, 4), %%mm0 \n\t"
422 "pxor %%mm2, %%mm0 \n\t"
423 "psubusb %%mm3, %%mm0 \n\t"
424 "pxor %%mm2, %%mm0 \n\t"
425 "movq %%mm0, (%0, %1, 4) \n\t"
427 "movq (%%"FF_REG_c
"), %%mm0 \n\t"
428 "pxor %%mm2, %%mm0 \n\t"
429 "paddusb %%mm3, %%mm0 \n\t"
430 "pxor %%mm2, %%mm0 \n\t"
431 "movq %%mm0, (%%"FF_REG_c
") \n\t"
435 "movq (%%"FF_REG_a
", %1, 2), %%mm0 \n\t"
436 "pxor %%mm2, %%mm0 \n\t"
437 "psubusb %%mm1, %%mm0 \n\t"
438 "pxor %%mm2, %%mm0 \n\t"
439 "movq %%mm0, (%%"FF_REG_a
", %1, 2) \n\t"
441 "movq (%%"FF_REG_c
", %1), %%mm0 \n\t"
442 "pxor %%mm2, %%mm0 \n\t"
443 "paddusb %%mm1, %%mm0 \n\t"
444 "pxor %%mm2, %%mm0 \n\t"
445 "movq %%mm0, (%%"FF_REG_c
", %1) \n\t"
449 "movq (%%"FF_REG_a
", %1), %%mm0 \n\t"
450 "pxor %%mm2, %%mm0 \n\t"
451 "psubusb %%mm1, %%mm0 \n\t"
452 "pxor %%mm2, %%mm0 \n\t"
453 "movq %%mm0, (%%"FF_REG_a
", %1) \n\t"
455 "movq (%%"FF_REG_c
", %1, 2), %%mm0 \n\t"
456 "pxor %%mm2, %%mm0 \n\t"
457 "paddusb %%mm1, %%mm0 \n\t"
458 "pxor %%mm2, %%mm0 \n\t"
459 "movq %%mm0, (%%"FF_REG_c
", %1, 2) \n\t"
464 :
"%"FF_REG_a,
"%"FF_REG_c
466 #else //TEMPLATE_PP_MMXEXT
469 const int l2=
stride + l1;
470 const int l3=
stride + l2;
471 const int l4=
stride + l3;
472 const int l5=
stride + l4;
473 const int l6=
stride + l5;
474 const int l7=
stride + l6;
500 #endif //TEMPLATE_PP_MMXEXT
503 #if !TEMPLATE_PP_ALTIVEC
506 #if TEMPLATE_PP_MMXEXT
524 #if 0 //slightly more accurate and slightly slower
525 "pxor %%mm7, %%mm7 \n\t"
526 "lea (%0, %1), %%"FF_REG_a
" \n\t"
527 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_c
"\n\t"
533 "movq (%0, %1, 2), %%mm0 \n\t"
534 "movq (%0), %%mm1 \n\t"
535 "movq %%mm0, %%mm2 \n\t"
540 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
541 "movq (%%"FF_REG_a
", %1, 2), %%mm3 \n\t"
542 "movq %%mm1, %%mm4 \n\t"
547 "movq %%mm0, %%mm4 \n\t"
548 "psubusb %%mm1, %%mm0 \n\t"
549 "psubusb %%mm4, %%mm1 \n\t"
550 "por %%mm0, %%mm1 \n\t"
553 "movq (%0, %1, 4), %%mm0 \n\t"
554 "movq %%mm0, %%mm4 \n\t"
559 "movq (%%"FF_REG_c
"), %%mm2 \n\t"
560 "movq %%mm3, %%mm5 \n\t"
565 "movq %%mm0, %%mm6 \n\t"
566 "psubusb %%mm3, %%mm0 \n\t"
567 "psubusb %%mm6, %%mm3 \n\t"
568 "por %%mm0, %%mm3 \n\t"
569 "pcmpeqb %%mm7, %%mm0 \n\t"
572 "movq (%%"FF_REG_c
", %1), %%mm6 \n\t"
573 "movq %%mm6, %%mm5 \n\t"
578 "movq (%%"FF_REG_c
", %1, 2), %%mm5 \n\t"
579 "movq %%mm2, %%mm4 \n\t"
584 "movq %%mm6, %%mm4 \n\t"
585 "psubusb %%mm2, %%mm6 \n\t"
586 "psubusb %%mm4, %%mm2 \n\t"
587 "por %%mm6, %%mm2 \n\t"
591 PMINUB(%%mm2, %%mm1, %%mm4)
592 "movq %2, %%mm4 \n\t"
593 "paddusb "MANGLE(b01)
", %%mm4 \n\t"
594 "pcmpgtb %%mm3, %%mm4 \n\t"
595 "psubusb %%mm1, %%mm3 \n\t"
596 "pand %%mm4, %%mm3 \n\t"
598 "movq %%mm3, %%mm1 \n\t"
602 "paddusb %%mm1, %%mm3 \n\t"
605 "movq (%%"FF_REG_a
", %1, 2), %%mm6 \n\t"
606 "movq (%0, %1, 4), %%mm5 \n\t"
607 "movq (%0, %1, 4), %%mm4 \n\t"
608 "psubusb %%mm6, %%mm5 \n\t"
609 "psubusb %%mm4, %%mm6 \n\t"
610 "por %%mm6, %%mm5 \n\t"
611 "pcmpeqb %%mm7, %%mm6 \n\t"
612 "pxor %%mm6, %%mm0 \n\t"
613 "pand %%mm0, %%mm3 \n\t"
614 PMINUB(%%mm5, %%mm3, %%mm0)
616 "psubusb "MANGLE(b01)
", %%mm3 \n\t"
619 "movq (%%"FF_REG_a
", %1, 2), %%mm0 \n\t"
620 "movq (%0, %1, 4), %%mm2 \n\t"
621 "pxor %%mm6, %%mm0 \n\t"
622 "pxor %%mm6, %%mm2 \n\t"
623 "psubb %%mm3, %%mm0 \n\t"
624 "paddb %%mm3, %%mm2 \n\t"
625 "pxor %%mm6, %%mm0 \n\t"
626 "pxor %%mm6, %%mm2 \n\t"
627 "movq %%mm0, (%%"FF_REG_a
", %1, 2) \n\t"
628 "movq %%mm2, (%0, %1, 4) \n\t"
631 "lea (%0, %1), %%"FF_REG_a
" \n\t"
632 "pcmpeqb %%mm6, %%mm6 \n\t"
638 "movq (%%"FF_REG_a
", %1, 2), %%mm1 \n\t"
639 "movq (%0, %1, 4), %%mm0 \n\t"
640 "pxor %%mm6, %%mm1 \n\t"
644 "movq (%%"FF_REG_a
", %1, 4), %%mm2 \n\t"
645 "movq (%%"FF_REG_a
", %1), %%mm3 \n\t"
646 "pxor %%mm6, %%mm2 \n\t"
647 "movq %%mm2, %%mm5 \n\t"
648 "movq "MANGLE(b80)
", %%mm4 \n\t"
649 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_c
"\n\t"
656 "movq (%%"FF_REG_a
"), %%mm2 \n\t"
657 "pxor %%mm6, %%mm2 \n\t"
660 "movq "MANGLE(b80)
", %%mm3 \n\t"
666 PAVGB((%%FF_REGc, %1), %%mm5)
667 "movq (%%"FF_REG_c
", %1, 2), %%mm1 \n\t"
668 "pxor %%mm6, %%mm1 \n\t"
669 PAVGB((%0, %1, 4), %%mm1)
670 "movq "MANGLE(b80)
", %%mm2 \n\t"
676 "movq "MANGLE(b00)
", %%mm1 \n\t"
677 "movq "MANGLE(b00)
", %%mm5 \n\t"
678 "psubb %%mm2, %%mm1 \n\t"
679 "psubb %%mm3, %%mm5 \n\t"
682 PMINUB(%%mm2, %%mm3, %%mm1)
686 "movq "MANGLE(b00)
", %%mm7 \n\t"
687 "movq %2, %%mm2 \n\t"
689 "psubb %%mm6, %%mm2 \n\t"
691 "movq %%mm4, %%mm1 \n\t"
692 "pcmpgtb %%mm7, %%mm1 \n\t"
693 "pxor %%mm1, %%mm4 \n\t"
694 "psubb %%mm1, %%mm4 \n\t"
695 "pcmpgtb %%mm4, %%mm2 \n\t"
696 "psubusb %%mm3, %%mm4 \n\t"
699 "movq %%mm4, %%mm3 \n\t"
700 "psubusb "MANGLE(b01)
", %%mm4 \n\t"
703 "paddb %%mm3, %%mm4 \n\t"
704 "pand %%mm2, %%mm4 \n\t"
706 "movq "MANGLE(b80)
", %%mm5 \n\t"
707 "psubb %%mm0, %%mm5 \n\t"
708 "paddsb %%mm6, %%mm5 \n\t"
709 "pcmpgtb %%mm5, %%mm7 \n\t"
710 "pxor %%mm7, %%mm5 \n\t"
712 PMINUB(%%mm5, %%mm4, %%mm3)
713 "pxor %%mm1, %%mm7 \n\t"
715 "pand %%mm7, %%mm4 \n\t"
716 "movq (%%"FF_REG_a
", %1, 2), %%mm0 \n\t"
717 "movq (%0, %1, 4), %%mm2 \n\t"
718 "pxor %%mm1, %%mm0 \n\t"
719 "pxor %%mm1, %%mm2 \n\t"
720 "paddb %%mm4, %%mm0 \n\t"
721 "psubb %%mm4, %%mm2 \n\t"
722 "pxor %%mm1, %%mm0 \n\t"
723 "pxor %%mm1, %%mm2 \n\t"
724 "movq %%mm0, (%%"FF_REG_a
", %1, 2) \n\t"
725 "movq %%mm2, (%0, %1, 4) \n\t"
730 :
"%"FF_REG_a,
"%"FF_REG_c
788 #else //TEMPLATE_PP_MMXEXT
790 const int l2=
stride + l1;
791 const int l3=
stride + l2;
792 const int l4=
stride + l3;
793 const int l5=
stride + l4;
794 const int l6=
stride + l5;
795 const int l7=
stride + l6;
796 const int l8=
stride + l7;
801 const int middleEnergy= 5*(
src[l5] -
src[l4]) + 2*(
src[l3] -
src[l6]);
802 if(
FFABS(middleEnergy) < 8*
c->QP){
803 const int q=(
src[l4] -
src[l5])/2;
804 const int leftEnergy= 5*(
src[l3] -
src[l2]) + 2*(
src[l1] -
src[l4]);
805 const int rightEnergy= 5*(
src[l7] -
src[l6]) + 2*(
src[l5] -
src[l8]);
826 #endif //TEMPLATE_PP_MMXEXT
828 #endif //TEMPLATE_PP_ALTIVEC
830 #if !TEMPLATE_PP_ALTIVEC
833 #if HAVE_7REGS && TEMPLATE_PP_MMXEXT
836 "pxor %%mm6, %%mm6 \n\t"
837 "pcmpeqb %%mm7, %%mm7 \n\t"
838 "movq %2, %%mm0 \n\t"
839 "punpcklbw %%mm6, %%mm0 \n\t"
840 "psrlw $1, %%mm0 \n\t"
841 "psubw %%mm7, %%mm0 \n\t"
842 "packuswb %%mm0, %%mm0 \n\t"
843 "movq %%mm0, %3 \n\t"
845 "lea (%0, %1), %%"FF_REG_a
" \n\t"
846 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_d
"\n\t"
851 #undef REAL_FIND_MIN_MAX
853 #define REAL_FIND_MIN_MAX(addr)\
854 "movq " #addr ", %%mm0 \n\t"\
855 "pminub %%mm0, %%mm7 \n\t"\
856 "pmaxub %%mm0, %%mm6 \n\t"
857 #define FIND_MIN_MAX(addr) REAL_FIND_MIN_MAX(addr)
859 FIND_MIN_MAX((%%FF_REGa))
860 FIND_MIN_MAX((%%FF_REGa, %1))
861 FIND_MIN_MAX((%%FF_REGa, %1, 2))
862 FIND_MIN_MAX((%0, %1, 4))
863 FIND_MIN_MAX((%%FF_REGd))
864 FIND_MIN_MAX((%%FF_REGd, %1))
865 FIND_MIN_MAX((%%FF_REGd, %1, 2))
866 FIND_MIN_MAX((%0, %1, 8))
868 "movq %%mm7, %%mm4 \n\t"
869 "psrlq $8, %%mm7 \n\t"
870 "pminub %%mm4, %%mm7 \n\t"
871 "pshufw $0xF9, %%mm7, %%mm4 \n\t"
872 "pminub %%mm4, %%mm7 \n\t"
873 "pshufw $0xFE, %%mm7, %%mm4 \n\t"
874 "pminub %%mm4, %%mm7 \n\t"
877 "movq %%mm6, %%mm4 \n\t"
878 "psrlq $8, %%mm6 \n\t"
879 "pmaxub %%mm4, %%mm6 \n\t"
880 "pshufw $0xF9, %%mm6, %%mm4 \n\t"
881 "pmaxub %%mm4, %%mm6 \n\t"
882 "pshufw $0xFE, %%mm6, %%mm4 \n\t"
883 "pmaxub %%mm4, %%mm6 \n\t"
884 "movq %%mm6, %%mm0 \n\t"
885 "psubb %%mm7, %%mm6 \n\t"
886 "push %%"FF_REG_a
" \n\t"
887 "movd %%mm6, %%eax \n\t"
888 "cmpb "MANGLE(deringThreshold)
", %%al \n\t"
889 "pop %%"FF_REG_a
" \n\t"
892 "punpcklbw %%mm7, %%mm7 \n\t"
893 "punpcklbw %%mm7, %%mm7 \n\t"
894 "punpcklbw %%mm7, %%mm7 \n\t"
895 "movq %%mm7, (%4) \n\t"
897 "movq (%0), %%mm0 \n\t"
898 "movq %%mm0, %%mm1 \n\t"
899 "movq %%mm0, %%mm2 \n\t"
900 "psllq $8, %%mm1 \n\t"
901 "psrlq $8, %%mm2 \n\t"
902 "movd -4(%0), %%mm3 \n\t"
903 "movd 8(%0), %%mm4 \n\t"
904 "psrlq $24, %%mm3 \n\t"
905 "psllq $56, %%mm4 \n\t"
906 "por %%mm3, %%mm1 \n\t"
907 "por %%mm4, %%mm2 \n\t"
908 "movq %%mm1, %%mm3 \n\t"
911 "psubusb %%mm7, %%mm0 \n\t"
912 "psubusb %%mm7, %%mm2 \n\t"
913 "psubusb %%mm7, %%mm3 \n\t"
914 "pcmpeqb "MANGLE(b00)
", %%mm0 \n\t"
915 "pcmpeqb "MANGLE(b00)
", %%mm2 \n\t"
916 "pcmpeqb "MANGLE(b00)
", %%mm3 \n\t"
917 "paddb %%mm2, %%mm0 \n\t"
918 "paddb %%mm3, %%mm0 \n\t"
920 "movq (%%"FF_REG_a
"), %%mm2 \n\t"
921 "movq %%mm2, %%mm3 \n\t"
922 "movq %%mm2, %%mm4 \n\t"
923 "psllq $8, %%mm3 \n\t"
924 "psrlq $8, %%mm4 \n\t"
925 "movd -4(%%"FF_REG_a
"), %%mm5 \n\t"
926 "movd 8(%%"FF_REG_a
"), %%mm6 \n\t"
927 "psrlq $24, %%mm5 \n\t"
928 "psllq $56, %%mm6 \n\t"
929 "por %%mm5, %%mm3 \n\t"
930 "por %%mm6, %%mm4 \n\t"
931 "movq %%mm3, %%mm5 \n\t"
934 "psubusb %%mm7, %%mm2 \n\t"
935 "psubusb %%mm7, %%mm4 \n\t"
936 "psubusb %%mm7, %%mm5 \n\t"
937 "pcmpeqb "MANGLE(b00)
", %%mm2 \n\t"
938 "pcmpeqb "MANGLE(b00)
", %%mm4 \n\t"
939 "pcmpeqb "MANGLE(b00)
", %%mm5 \n\t"
940 "paddb %%mm4, %%mm2 \n\t"
941 "paddb %%mm5, %%mm2 \n\t"
943 #define REAL_DERING_CORE(dst,src,ppsx,psx,sx,pplx,plx,lx,t0,t1) \
944 "movq " #src ", " #sx " \n\t" \
945 "movq " #sx ", " #lx " \n\t" \
946 "movq " #sx ", " #t0 " \n\t" \
947 "psllq $8, " #lx " \n\t"\
948 "psrlq $8, " #t0 " \n\t"\
949 "movd -4" #src ", " #t1 " \n\t"\
950 "psrlq $24, " #t1 " \n\t"\
951 "por " #t1 ", " #lx " \n\t" \
952 "movd 8" #src ", " #t1 " \n\t"\
953 "psllq $56, " #t1 " \n\t"\
954 "por " #t1 ", " #t0 " \n\t" \
955 "movq " #lx ", " #t1 " \n\t" \
959 "movq " #lx ", 8(%4) \n\t"\
960 "movq (%4), " #lx " \n\t"\
961 "psubusb " #lx ", " #t1 " \n\t"\
962 "psubusb " #lx ", " #t0 " \n\t"\
963 "psubusb " #lx ", " #sx " \n\t"\
964 "movq "MANGLE(b00)", " #lx " \n\t"\
965 "pcmpeqb " #lx ", " #t1 " \n\t" \
966 "pcmpeqb " #lx ", " #t0 " \n\t" \
967 "pcmpeqb " #lx ", " #sx " \n\t" \
968 "paddb " #t1 ", " #t0 " \n\t"\
969 "paddb " #t0 ", " #sx " \n\t"\
972 "movq " #dst ", " #t0 " \n\t" \
973 "movq " #t0 ", " #t1 " \n\t" \
974 "psubusb %3, " #t0 " \n\t"\
975 "paddusb %3, " #t1 " \n\t"\
977 PMINUB(t1, pplx, t0)\
978 "paddb " #sx ", " #ppsx " \n\t"\
979 "paddb " #psx ", " #ppsx " \n\t"\
980 "#paddb "MANGLE(b02)", " #ppsx " \n\t"\
981 "pand "MANGLE(b08)", " #ppsx " \n\t"\
982 "pcmpeqb " #lx ", " #ppsx " \n\t"\
983 "pand " #ppsx ", " #pplx " \n\t"\
984 "pandn " #dst ", " #ppsx " \n\t"\
985 "por " #pplx ", " #ppsx " \n\t"\
986 "movq " #ppsx ", " #dst " \n\t"\
987 "movq 8(%4), " #lx " \n\t"
989 #define DERING_CORE(dst,src,ppsx,psx,sx,pplx,plx,lx,t0,t1) \
990 REAL_DERING_CORE(dst,src,ppsx,psx,sx,pplx,plx,lx,t0,t1)
1007 DERING_CORE((%%FF_REGa) ,(%%FF_REGa, %1) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7)
1008 DERING_CORE((%%FF_REGa, %1) ,(%%FF_REGa, %1, 2),%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7)
1009 DERING_CORE((%%FF_REGa, %1, 2),(%0, %1, 4) ,%%mm4,%%mm0,%%mm2,%%mm5,%%mm1,%%mm3,%%mm6,%%mm7)
1010 DERING_CORE((%0, %1, 4) ,(%%FF_REGd) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7)
1011 DERING_CORE((%%FF_REGd) ,(%%FF_REGd, %1) ,%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7)
1012 DERING_CORE((%%FF_REGd, %1) ,(%%FF_REGd, %1, 2),%%mm4,%%mm0,%%mm2,%%mm5,%%mm1,%%mm3,%%mm6,%%mm7)
1013 DERING_CORE((%%FF_REGd, %1, 2),(%0, %1, 8) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7)
1014 DERING_CORE((%0, %1, 8) ,(%%FF_REGd, %1, 4),%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7)
1019 :
"%"FF_REG_a,
"%"FF_REG_d
1021 #else // HAVE_7REGS && TEMPLATE_PP_MMXEXT
1028 const int QP2=
c->QP/2 + 1;
1042 if(
max -
min <deringThreshold)
return;
1044 for(y=0; y<10; y++){
1059 t &= (t<<1) & (t>>1);
1064 int t =
s[y-1] &
s[y] &
s[y+1];
1078 +2*(*(p -1)) + 4*(*p ) + 2*(*(p +1))
1082 #ifdef DEBUG_DERING_THRESHOLD
1083 __asm__ volatile(
"emms\n\t":);
1085 static uint64_t numPixels=0;
1086 if(x!=1 && x!=8 && y!=1 && y!=8) numPixels++;
1091 static int numSkipped=0;
1092 static int errorSum=0;
1093 static int worstQP=0;
1094 static int worstRange=0;
1095 static int worstDiff=0;
1100 if(x==1 || x==8 || y==1 || y==8)
continue;
1103 if(absDiff > worstDiff){
1110 if(1024LL*1024LL*1024LL % numSkipped == 0){
1112 "wRange:%d, wDiff:%d, relSkip:%1.3f\n",
1113 (
float)errorSum/numSkipped, numSkipped, worstQP, worstRange,
1114 worstDiff, (
float)numSkipped/numPixels);
1119 if (*p + QP2 <
f) *p= *p + QP2;
1120 else if(*p - QP2 >
f) *p= *p - QP2;
1125 #ifdef DEBUG_DERING_THRESHOLD
1133 *p =
FFMIN(*p + 20, 255);
1139 #endif //TEMPLATE_PP_MMXEXT
1141 #endif //TEMPLATE_PP_ALTIVEC
1151 #if TEMPLATE_PP_MMXEXT
1154 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1155 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_c
"\n\t"
1159 "movq (%0), %%mm0 \n\t"
1160 "movq (%%"FF_REG_a
", %1), %%mm1 \n\t"
1162 "movq %%mm0, (%%"FF_REG_a
") \n\t"
1163 "movq (%0, %1, 4), %%mm0 \n\t"
1165 "movq %%mm1, (%%"FF_REG_a
", %1, 2) \n\t"
1166 "movq (%%"FF_REG_c
", %1), %%mm1 \n\t"
1168 "movq %%mm0, (%%"FF_REG_c
") \n\t"
1169 "movq (%0, %1, 8), %%mm0 \n\t"
1171 "movq %%mm1, (%%"FF_REG_c
", %1, 2) \n\t"
1174 :
"%"FF_REG_a,
"%"FF_REG_c
1183 *(uint32_t*)&
src[
stride*1]= (
a|
b) - (((
a^
b)&0xFEFEFEFEUL)>>1);
1185 *(uint32_t*)&
src[
stride*3]= (
a|
b) - (((
a^
b)&0xFEFEFEFEUL)>>1);
1187 *(uint32_t*)&
src[
stride*5]= (
a|
b) - (((
a^
b)&0xFEFEFEFEUL)>>1);
1189 *(uint32_t*)&
src[
stride*7]= (
a|
b) - (((
a^
b)&0xFEFEFEFEUL)>>1);
1204 #if TEMPLATE_PP_SSE2
1207 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1208 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_d
"\n\t"
1209 "lea (%%"FF_REG_d
", %1, 4), %%"FF_REG_c
"\n\t"
1210 "add %1, %%"FF_REG_c
" \n\t"
1211 "pxor %%xmm7, %%xmm7 \n\t"
1212 #define REAL_DEINT_CUBIC(a,b,c,d,e)\
1213 "movq " #a ", %%xmm0 \n\t"\
1214 "movq " #b ", %%xmm1 \n\t"\
1215 "movq " #d ", %%xmm2 \n\t"\
1216 "movq " #e ", %%xmm3 \n\t"\
1217 "pavgb %%xmm2, %%xmm1 \n\t"\
1218 "pavgb %%xmm3, %%xmm0 \n\t"\
1219 "punpcklbw %%xmm7, %%xmm0 \n\t"\
1220 "punpcklbw %%xmm7, %%xmm1 \n\t"\
1221 "psubw %%xmm1, %%xmm0 \n\t"\
1222 "psraw $3, %%xmm0 \n\t"\
1223 "psubw %%xmm0, %%xmm1 \n\t"\
1224 "packuswb %%xmm1, %%xmm1 \n\t"\
1225 "movlps %%xmm1, " #c " \n\t"
1226 #define DEINT_CUBIC(a,b,c,d,e) REAL_DEINT_CUBIC(a,b,c,d,e)
1228 DEINT_CUBIC((%0) , (%%FF_REGa, %1), (%%FF_REGa, %1, 2), (%0, %1, 4) , (%%FF_REGd, %1))
1229 DEINT_CUBIC((%%FF_REGa, %1), (%0, %1, 4) , (%%FF_REGd) , (%%FF_REGd, %1), (%0, %1, 8))
1230 DEINT_CUBIC((%0, %1, 4) , (%%FF_REGd, %1), (%%FF_REGd, %1, 2), (%0, %1, 8) , (%%FF_REGc))
1231 DEINT_CUBIC((%%FF_REGd, %1), (%0, %1, 8) , (%%FF_REGd, %1, 4), (%%FF_REGc) , (%%FF_REGc, %1, 2))
1235 XMM_CLOBBERS(
"%xmm0",
"%xmm1",
"%xmm2",
"%xmm3",
"%xmm7",)
1236 "%"FF_REG_a,
"%"FF_REG_d,
"%"FF_REG_c
1238 #undef REAL_DEINT_CUBIC
1239 #else //TEMPLATE_PP_SSE2
1249 #endif //TEMPLATE_PP_SSE2
1261 #if TEMPLATE_PP_MMXEXT
1264 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1265 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_d
"\n\t"
1266 "pxor %%mm7, %%mm7 \n\t"
1267 "movq (%2), %%mm0 \n\t"
1271 #define REAL_DEINT_FF(a,b,c,d)\
1272 "movq " #a ", %%mm1 \n\t"\
1273 "movq " #b ", %%mm2 \n\t"\
1274 "movq " #c ", %%mm3 \n\t"\
1275 "movq " #d ", %%mm4 \n\t"\
1276 PAVGB(%%mm3, %%mm1) \
1277 PAVGB(%%mm4, %%mm0) \
1278 "movq %%mm0, %%mm3 \n\t"\
1279 "punpcklbw %%mm7, %%mm0 \n\t"\
1280 "punpckhbw %%mm7, %%mm3 \n\t"\
1281 "movq %%mm1, %%mm4 \n\t"\
1282 "punpcklbw %%mm7, %%mm1 \n\t"\
1283 "punpckhbw %%mm7, %%mm4 \n\t"\
1284 "psllw $2, %%mm1 \n\t"\
1285 "psllw $2, %%mm4 \n\t"\
1286 "psubw %%mm0, %%mm1 \n\t"\
1287 "psubw %%mm3, %%mm4 \n\t"\
1288 "movq %%mm2, %%mm5 \n\t"\
1289 "movq %%mm2, %%mm0 \n\t"\
1290 "punpcklbw %%mm7, %%mm2 \n\t"\
1291 "punpckhbw %%mm7, %%mm5 \n\t"\
1292 "paddw %%mm2, %%mm1 \n\t"\
1293 "paddw %%mm5, %%mm4 \n\t"\
1294 "psraw $2, %%mm1 \n\t"\
1295 "psraw $2, %%mm4 \n\t"\
1296 "packuswb %%mm4, %%mm1 \n\t"\
1297 "movq %%mm1, " #b " \n\t"\
1299 #define DEINT_FF(a,b,c,d) REAL_DEINT_FF(a,b,c,d)
1301 DEINT_FF((%0) , (%%FF_REGa) , (%%FF_REGa, %1), (%%FF_REGa, %1, 2))
1302 DEINT_FF((%%FF_REGa, %1), (%%FF_REGa, %1, 2), (%0, %1, 4) , (%%FF_REGd) )
1303 DEINT_FF((%0, %1, 4) , (%%FF_REGd) , (%%FF_REGd, %1), (%%FF_REGd, %1, 2))
1304 DEINT_FF((%%FF_REGd, %1), (%%FF_REGd, %1, 2), (%0, %1, 8) , (%%FF_REGd, %1, 4))
1306 "movq %%mm0, (%2) \n\t"
1308 :
"%"FF_REG_a,
"%"FF_REG_d
1310 #else //TEMPLATE_PP_MMXEXT
1328 #endif //TEMPLATE_PP_MMXEXT
1340 #if TEMPLATE_PP_MMXEXT && HAVE_6REGS
1343 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1344 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_d
"\n\t"
1345 "pxor %%mm7, %%mm7 \n\t"
1346 "movq (%2), %%mm0 \n\t"
1347 "movq (%3), %%mm1 \n\t"
1351 #define REAL_DEINT_L5(t1,t2,a,b,c)\
1352 "movq " #a ", %%mm2 \n\t"\
1353 "movq " #b ", %%mm3 \n\t"\
1354 "movq " #c ", %%mm4 \n\t"\
1357 "movq %%mm2, %%mm5 \n\t"\
1358 "movq %%mm2, " #t1 " \n\t"\
1359 "punpcklbw %%mm7, %%mm2 \n\t"\
1360 "punpckhbw %%mm7, %%mm5 \n\t"\
1361 "movq %%mm2, %%mm6 \n\t"\
1362 "paddw %%mm2, %%mm2 \n\t"\
1363 "paddw %%mm6, %%mm2 \n\t"\
1364 "movq %%mm5, %%mm6 \n\t"\
1365 "paddw %%mm5, %%mm5 \n\t"\
1366 "paddw %%mm6, %%mm5 \n\t"\
1367 "movq %%mm3, %%mm6 \n\t"\
1368 "punpcklbw %%mm7, %%mm3 \n\t"\
1369 "punpckhbw %%mm7, %%mm6 \n\t"\
1370 "paddw %%mm3, %%mm3 \n\t"\
1371 "paddw %%mm6, %%mm6 \n\t"\
1372 "paddw %%mm3, %%mm2 \n\t"\
1373 "paddw %%mm6, %%mm5 \n\t"\
1374 "movq %%mm4, %%mm6 \n\t"\
1375 "punpcklbw %%mm7, %%mm4 \n\t"\
1376 "punpckhbw %%mm7, %%mm6 \n\t"\
1377 "psubw %%mm4, %%mm2 \n\t"\
1378 "psubw %%mm6, %%mm5 \n\t"\
1379 "psraw $2, %%mm2 \n\t"\
1380 "psraw $2, %%mm5 \n\t"\
1381 "packuswb %%mm5, %%mm2 \n\t"\
1382 "movq %%mm2, " #a " \n\t"\
1384 #define DEINT_L5(t1,t2,a,b,c) REAL_DEINT_L5(t1,t2,a,b,c)
1386 DEINT_L5(%%mm0, %%mm1, (%0) , (%%FF_REGa) , (%%FF_REGa, %1) )
1387 DEINT_L5(%%mm1, %%mm0, (%%FF_REGa) , (%%FF_REGa, %1) , (%%FF_REGa, %1, 2))
1388 DEINT_L5(%%mm0, %%mm1, (%%FF_REGa, %1) , (%%FF_REGa, %1, 2), (%0, %1, 4) )
1389 DEINT_L5(%%mm1, %%mm0, (%%FF_REGa, %1, 2), (%0, %1, 4) , (%%FF_REGd) )
1390 DEINT_L5(%%mm0, %%mm1, (%0, %1, 4) , (%%FF_REGd) , (%%FF_REGd, %1) )
1391 DEINT_L5(%%mm1, %%mm0, (%%FF_REGd) , (%%FF_REGd, %1) , (%%FF_REGd, %1, 2))
1392 DEINT_L5(%%mm0, %%mm1, (%%FF_REGd, %1) , (%%FF_REGd, %1, 2), (%0, %1, 8) )
1393 DEINT_L5(%%mm1, %%mm0, (%%FF_REGd, %1, 2), (%0, %1, 8) , (%%FF_REGd, %1, 4))
1395 "movq %%mm0, (%2) \n\t"
1396 "movq %%mm1, (%3) \n\t"
1398 :
"%"FF_REG_a,
"%"FF_REG_d
1400 #else //TEMPLATE_PP_MMXEXT && HAVE_6REGS
1429 #endif // TEMPLATE_PP_MMXEXT && HAVE_6REGS
1441 #if TEMPLATE_PP_MMXEXT
1444 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1445 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_d
"\n\t"
1449 "movq (%2), %%mm0 \n\t"
1450 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
1452 "movq (%0), %%mm2 \n\t"
1454 "movq %%mm0, (%0) \n\t"
1455 "movq (%%"FF_REG_a
", %1), %%mm0 \n\t"
1458 "movq %%mm2, (%%"FF_REG_a
") \n\t"
1459 "movq (%%"FF_REG_a
", %1, 2), %%mm2 \n\t"
1462 "movq %%mm1, (%%"FF_REG_a
", %1) \n\t"
1463 "movq (%0, %1, 4), %%mm1 \n\t"
1466 "movq %%mm0, (%%"FF_REG_a
", %1, 2) \n\t"
1467 "movq (%%"FF_REG_d
"), %%mm0 \n\t"
1470 "movq %%mm2, (%0, %1, 4) \n\t"
1471 "movq (%%"FF_REG_d
", %1), %%mm2 \n\t"
1474 "movq %%mm1, (%%"FF_REG_d
") \n\t"
1475 "movq (%%"FF_REG_d
", %1, 2), %%mm1 \n\t"
1478 "movq %%mm0, (%%"FF_REG_d
", %1) \n\t"
1479 "movq (%0, %1, 8), %%mm0 \n\t"
1482 "movq %%mm2, (%%"FF_REG_d
", %1, 2) \n\t"
1483 "movq %%mm1, (%2) \n\t"
1486 :
"%"FF_REG_a,
"%"FF_REG_d
1488 #else //TEMPLATE_PP_MMXEXT
1496 a= (
a&
c) + (((
a^
c)&0xFEFEFEFEUL)>>1);
1497 *(uint32_t*)&
src[
stride*0]= (
a|
b) - (((
a^
b)&0xFEFEFEFEUL)>>1);
1500 b= (
a&
b) + (((
a^
b)&0xFEFEFEFEUL)>>1);
1501 *(uint32_t*)&
src[
stride*1]= (
c|
b) - (((
c^
b)&0xFEFEFEFEUL)>>1);
1504 c= (
b&
c) + (((
b^
c)&0xFEFEFEFEUL)>>1);
1505 *(uint32_t*)&
src[
stride*2]= (
c|
a) - (((
c^
a)&0xFEFEFEFEUL)>>1);
1508 a= (
a&
c) + (((
a^
c)&0xFEFEFEFEUL)>>1);
1509 *(uint32_t*)&
src[
stride*3]= (
a|
b) - (((
a^
b)&0xFEFEFEFEUL)>>1);
1512 b= (
a&
b) + (((
a^
b)&0xFEFEFEFEUL)>>1);
1513 *(uint32_t*)&
src[
stride*4]= (
c|
b) - (((
c^
b)&0xFEFEFEFEUL)>>1);
1516 c= (
b&
c) + (((
b^
c)&0xFEFEFEFEUL)>>1);
1517 *(uint32_t*)&
src[
stride*5]= (
c|
a) - (((
c^
a)&0xFEFEFEFEUL)>>1);
1520 a= (
a&
c) + (((
a^
c)&0xFEFEFEFEUL)>>1);
1521 *(uint32_t*)&
src[
stride*6]= (
a|
b) - (((
a^
b)&0xFEFEFEFEUL)>>1);
1524 b= (
a&
b) + (((
a^
b)&0xFEFEFEFEUL)>>1);
1525 *(uint32_t*)&
src[
stride*7]= (
c|
b) - (((
c^
b)&0xFEFEFEFEUL)>>1);
1531 #endif //TEMPLATE_PP_MMXEXT
1542 #if TEMPLATE_PP_MMXEXT
1545 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1546 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_d
"\n\t"
1550 "movq (%0), %%mm0 \n\t"
1551 "movq (%%"FF_REG_a
", %1), %%mm2 \n\t"
1552 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
1553 "movq %%mm0, %%mm3 \n\t"
1554 "pmaxub %%mm1, %%mm0 \n\t"
1555 "pminub %%mm3, %%mm1 \n\t"
1556 "pmaxub %%mm2, %%mm1 \n\t"
1557 "pminub %%mm1, %%mm0 \n\t"
1558 "movq %%mm0, (%%"FF_REG_a
") \n\t"
1560 "movq (%0, %1, 4), %%mm0 \n\t"
1561 "movq (%%"FF_REG_a
", %1, 2), %%mm1 \n\t"
1562 "movq %%mm2, %%mm3 \n\t"
1563 "pmaxub %%mm1, %%mm2 \n\t"
1564 "pminub %%mm3, %%mm1 \n\t"
1565 "pmaxub %%mm0, %%mm1 \n\t"
1566 "pminub %%mm1, %%mm2 \n\t"
1567 "movq %%mm2, (%%"FF_REG_a
", %1, 2) \n\t"
1569 "movq (%%"FF_REG_d
"), %%mm2 \n\t"
1570 "movq (%%"FF_REG_d
", %1), %%mm1 \n\t"
1571 "movq %%mm2, %%mm3 \n\t"
1572 "pmaxub %%mm0, %%mm2 \n\t"
1573 "pminub %%mm3, %%mm0 \n\t"
1574 "pmaxub %%mm1, %%mm0 \n\t"
1575 "pminub %%mm0, %%mm2 \n\t"
1576 "movq %%mm2, (%%"FF_REG_d
") \n\t"
1578 "movq (%%"FF_REG_d
", %1, 2), %%mm2 \n\t"
1579 "movq (%0, %1, 8), %%mm0 \n\t"
1580 "movq %%mm2, %%mm3 \n\t"
1581 "pmaxub %%mm0, %%mm2 \n\t"
1582 "pminub %%mm3, %%mm0 \n\t"
1583 "pmaxub %%mm1, %%mm0 \n\t"
1584 "pminub %%mm0, %%mm2 \n\t"
1585 "movq %%mm2, (%%"FF_REG_d
", %1, 2) \n\t"
1589 :
"%"FF_REG_a,
"%"FF_REG_d
1592 #else //TEMPLATE_PP_MMX
1597 uint8_t *colsrc =
src;
1598 for (y=0; y<4; y++){
1599 int a,
b,
c,
d, e,
f;
1611 #endif //TEMPLATE_PP_MMX
1618 static inline void RENAME(transpose1)(uint8_t *dst1, uint8_t *dst2,
const uint8_t *
src,
int srcStride)
1621 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1624 "movq (%0), %%mm0 \n\t"
1625 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
1626 "movq %%mm0, %%mm2 \n\t"
1627 "punpcklbw %%mm1, %%mm0 \n\t"
1628 "punpckhbw %%mm1, %%mm2 \n\t"
1630 "movq (%%"FF_REG_a
", %1), %%mm1 \n\t"
1631 "movq (%%"FF_REG_a
", %1, 2), %%mm3 \n\t"
1632 "movq %%mm1, %%mm4 \n\t"
1633 "punpcklbw %%mm3, %%mm1 \n\t"
1634 "punpckhbw %%mm3, %%mm4 \n\t"
1636 "movq %%mm0, %%mm3 \n\t"
1637 "punpcklwd %%mm1, %%mm0 \n\t"
1638 "punpckhwd %%mm1, %%mm3 \n\t"
1639 "movq %%mm2, %%mm1 \n\t"
1640 "punpcklwd %%mm4, %%mm2 \n\t"
1641 "punpckhwd %%mm4, %%mm1 \n\t"
1643 "movd %%mm0, 128(%2) \n\t"
1644 "psrlq $32, %%mm0 \n\t"
1645 "movd %%mm0, 144(%2) \n\t"
1646 "movd %%mm3, 160(%2) \n\t"
1647 "psrlq $32, %%mm3 \n\t"
1648 "movd %%mm3, 176(%2) \n\t"
1649 "movd %%mm3, 48(%3) \n\t"
1650 "movd %%mm2, 192(%2) \n\t"
1651 "movd %%mm2, 64(%3) \n\t"
1652 "psrlq $32, %%mm2 \n\t"
1653 "movd %%mm2, 80(%3) \n\t"
1654 "movd %%mm1, 96(%3) \n\t"
1655 "psrlq $32, %%mm1 \n\t"
1656 "movd %%mm1, 112(%3) \n\t"
1658 "lea (%%"FF_REG_a
", %1, 4), %%"FF_REG_a
"\n\t"
1660 "movq (%0, %1, 4), %%mm0 \n\t"
1661 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
1662 "movq %%mm0, %%mm2 \n\t"
1663 "punpcklbw %%mm1, %%mm0 \n\t"
1664 "punpckhbw %%mm1, %%mm2 \n\t"
1666 "movq (%%"FF_REG_a
", %1), %%mm1 \n\t"
1667 "movq (%%"FF_REG_a
", %1, 2), %%mm3 \n\t"
1668 "movq %%mm1, %%mm4 \n\t"
1669 "punpcklbw %%mm3, %%mm1 \n\t"
1670 "punpckhbw %%mm3, %%mm4 \n\t"
1672 "movq %%mm0, %%mm3 \n\t"
1673 "punpcklwd %%mm1, %%mm0 \n\t"
1674 "punpckhwd %%mm1, %%mm3 \n\t"
1675 "movq %%mm2, %%mm1 \n\t"
1676 "punpcklwd %%mm4, %%mm2 \n\t"
1677 "punpckhwd %%mm4, %%mm1 \n\t"
1679 "movd %%mm0, 132(%2) \n\t"
1680 "psrlq $32, %%mm0 \n\t"
1681 "movd %%mm0, 148(%2) \n\t"
1682 "movd %%mm3, 164(%2) \n\t"
1683 "psrlq $32, %%mm3 \n\t"
1684 "movd %%mm3, 180(%2) \n\t"
1685 "movd %%mm3, 52(%3) \n\t"
1686 "movd %%mm2, 196(%2) \n\t"
1687 "movd %%mm2, 68(%3) \n\t"
1688 "psrlq $32, %%mm2 \n\t"
1689 "movd %%mm2, 84(%3) \n\t"
1690 "movd %%mm1, 100(%3) \n\t"
1691 "psrlq $32, %%mm1 \n\t"
1692 "movd %%mm1, 116(%3) \n\t"
1695 ::
"r" (
src),
"r" ((
x86_reg)srcStride),
"r" (dst1),
"r" (dst2)
1703 static inline void RENAME(transpose2)(uint8_t *dst,
int dstStride,
const uint8_t *
src)
1706 "lea (%0, %1), %%"FF_REG_a
" \n\t"
1707 "lea (%%"FF_REG_a
",%1,4), %%"FF_REG_d
" \n\t"
1710 "movq (%2), %%mm0 \n\t"
1711 "movq 16(%2), %%mm1 \n\t"
1712 "movq %%mm0, %%mm2 \n\t"
1713 "punpcklbw %%mm1, %%mm0 \n\t"
1714 "punpckhbw %%mm1, %%mm2 \n\t"
1716 "movq 32(%2), %%mm1 \n\t"
1717 "movq 48(%2), %%mm3 \n\t"
1718 "movq %%mm1, %%mm4 \n\t"
1719 "punpcklbw %%mm3, %%mm1 \n\t"
1720 "punpckhbw %%mm3, %%mm4 \n\t"
1722 "movq %%mm0, %%mm3 \n\t"
1723 "punpcklwd %%mm1, %%mm0 \n\t"
1724 "punpckhwd %%mm1, %%mm3 \n\t"
1725 "movq %%mm2, %%mm1 \n\t"
1726 "punpcklwd %%mm4, %%mm2 \n\t"
1727 "punpckhwd %%mm4, %%mm1 \n\t"
1729 "movd %%mm0, (%0) \n\t"
1730 "psrlq $32, %%mm0 \n\t"
1731 "movd %%mm0, (%%"FF_REG_a
") \n\t"
1732 "movd %%mm3, (%%"FF_REG_a
", %1) \n\t"
1733 "psrlq $32, %%mm3 \n\t"
1734 "movd %%mm3, (%%"FF_REG_a
", %1, 2) \n\t"
1735 "movd %%mm2, (%0, %1, 4) \n\t"
1736 "psrlq $32, %%mm2 \n\t"
1737 "movd %%mm2, (%%"FF_REG_d
") \n\t"
1738 "movd %%mm1, (%%"FF_REG_d
", %1) \n\t"
1739 "psrlq $32, %%mm1 \n\t"
1740 "movd %%mm1, (%%"FF_REG_d
", %1, 2) \n\t"
1743 "movq 64(%2), %%mm0 \n\t"
1744 "movq 80(%2), %%mm1 \n\t"
1745 "movq %%mm0, %%mm2 \n\t"
1746 "punpcklbw %%mm1, %%mm0 \n\t"
1747 "punpckhbw %%mm1, %%mm2 \n\t"
1749 "movq 96(%2), %%mm1 \n\t"
1750 "movq 112(%2), %%mm3 \n\t"
1751 "movq %%mm1, %%mm4 \n\t"
1752 "punpcklbw %%mm3, %%mm1 \n\t"
1753 "punpckhbw %%mm3, %%mm4 \n\t"
1755 "movq %%mm0, %%mm3 \n\t"
1756 "punpcklwd %%mm1, %%mm0 \n\t"
1757 "punpckhwd %%mm1, %%mm3 \n\t"
1758 "movq %%mm2, %%mm1 \n\t"
1759 "punpcklwd %%mm4, %%mm2 \n\t"
1760 "punpckhwd %%mm4, %%mm1 \n\t"
1762 "movd %%mm0, 4(%0) \n\t"
1763 "psrlq $32, %%mm0 \n\t"
1764 "movd %%mm0, 4(%%"FF_REG_a
") \n\t"
1765 "movd %%mm3, 4(%%"FF_REG_a
", %1) \n\t"
1766 "psrlq $32, %%mm3 \n\t"
1767 "movd %%mm3, 4(%%"FF_REG_a
", %1, 2) \n\t"
1768 "movd %%mm2, 4(%0, %1, 4) \n\t"
1769 "psrlq $32, %%mm2 \n\t"
1770 "movd %%mm2, 4(%%"FF_REG_d
") \n\t"
1771 "movd %%mm1, 4(%%"FF_REG_d
", %1) \n\t"
1772 "psrlq $32, %%mm1 \n\t"
1773 "movd %%mm1, 4(%%"FF_REG_d
", %1, 2) \n\t"
1775 ::
"r" (dst),
"r" ((
x86_reg)dstStride),
"r" (
src)
1776 :
"%"FF_REG_a,
"%"FF_REG_d
1779 #endif //TEMPLATE_PP_MMX
1782 #if !TEMPLATE_PP_ALTIVEC
1784 uint8_t *tempBlurred, uint32_t *tempBlurredPast,
const int *maxNoise)
1787 tempBlurredPast[127]= maxNoise[0];
1788 tempBlurredPast[128]= maxNoise[1];
1789 tempBlurredPast[129]= maxNoise[2];
1791 #define FAST_L2_DIFF
1793 #if TEMPLATE_PP_MMXEXT && HAVE_6REGS
1795 "lea (%2, %2, 2), %%"FF_REG_a
" \n\t"
1796 "lea (%2, %2, 4), %%"FF_REG_d
" \n\t"
1797 "lea (%%"FF_REG_d
", %2, 2), %%"FF_REG_c
"\n\t"
1801 #ifdef L1_DIFF //needs mmx2
1802 "movq (%0), %%mm0 \n\t"
1803 "psadbw (%1), %%mm0 \n\t"
1804 "movq (%0, %2), %%mm1 \n\t"
1805 "psadbw (%1, %2), %%mm1 \n\t"
1806 "movq (%0, %2, 2), %%mm2 \n\t"
1807 "psadbw (%1, %2, 2), %%mm2 \n\t"
1808 "movq (%0, %%"FF_REG_a
"), %%mm3 \n\t"
1809 "psadbw (%1, %%"FF_REG_a
"), %%mm3 \n\t"
1811 "movq (%0, %2, 4), %%mm4 \n\t"
1812 "paddw %%mm1, %%mm0 \n\t"
1813 "psadbw (%1, %2, 4), %%mm4 \n\t"
1814 "movq (%0, %%"FF_REG_d
"), %%mm5 \n\t"
1815 "paddw %%mm2, %%mm0 \n\t"
1816 "psadbw (%1, %%"FF_REG_d
"), %%mm5 \n\t"
1817 "movq (%0, %%"FF_REG_a
", 2), %%mm6 \n\t"
1818 "paddw %%mm3, %%mm0 \n\t"
1819 "psadbw (%1, %%"FF_REG_a
", 2), %%mm6 \n\t"
1820 "movq (%0, %%"FF_REG_c
"), %%mm7 \n\t"
1821 "paddw %%mm4, %%mm0 \n\t"
1822 "psadbw (%1, %%"FF_REG_c
"), %%mm7 \n\t"
1823 "paddw %%mm5, %%mm6 \n\t"
1824 "paddw %%mm7, %%mm6 \n\t"
1825 "paddw %%mm6, %%mm0 \n\t"
1827 #if defined (FAST_L2_DIFF)
1828 "pcmpeqb %%mm7, %%mm7 \n\t"
1829 "movq "MANGLE(b80)
", %%mm6 \n\t"
1830 "pxor %%mm0, %%mm0 \n\t"
1831 #define REAL_L2_DIFF_CORE(a, b)\
1832 "movq " #a ", %%mm5 \n\t"\
1833 "movq " #b ", %%mm2 \n\t"\
1834 "pxor %%mm7, %%mm2 \n\t"\
1835 PAVGB(%%mm2, %%mm5)\
1836 "paddb %%mm6, %%mm5 \n\t"\
1837 "movq %%mm5, %%mm2 \n\t"\
1838 "psllw $8, %%mm5 \n\t"\
1839 "pmaddwd %%mm5, %%mm5 \n\t"\
1840 "pmaddwd %%mm2, %%mm2 \n\t"\
1841 "paddd %%mm2, %%mm5 \n\t"\
1842 "psrld $14, %%mm5 \n\t"\
1843 "paddd %%mm5, %%mm0 \n\t"
1845 #else //defined (FAST_L2_DIFF)
1846 "pxor %%mm7, %%mm7 \n\t"
1847 "pxor %%mm0, %%mm0 \n\t"
1848 #define REAL_L2_DIFF_CORE(a, b)\
1849 "movq " #a ", %%mm5 \n\t"\
1850 "movq " #b ", %%mm2 \n\t"\
1851 "movq %%mm5, %%mm1 \n\t"\
1852 "movq %%mm2, %%mm3 \n\t"\
1853 "punpcklbw %%mm7, %%mm5 \n\t"\
1854 "punpckhbw %%mm7, %%mm1 \n\t"\
1855 "punpcklbw %%mm7, %%mm2 \n\t"\
1856 "punpckhbw %%mm7, %%mm3 \n\t"\
1857 "psubw %%mm2, %%mm5 \n\t"\
1858 "psubw %%mm3, %%mm1 \n\t"\
1859 "pmaddwd %%mm5, %%mm5 \n\t"\
1860 "pmaddwd %%mm1, %%mm1 \n\t"\
1861 "paddd %%mm1, %%mm5 \n\t"\
1862 "paddd %%mm5, %%mm0 \n\t"
1864 #endif //defined (FAST_L2_DIFF)
1866 #define L2_DIFF_CORE(a, b) REAL_L2_DIFF_CORE(a, b)
1868 L2_DIFF_CORE((%0) , (%1))
1869 L2_DIFF_CORE((%0, %2) , (%1, %2))
1870 L2_DIFF_CORE((%0, %2, 2) , (%1, %2, 2))
1871 L2_DIFF_CORE((%0, %%FF_REGa) , (%1, %%FF_REGa))
1872 L2_DIFF_CORE((%0, %2, 4) , (%1, %2, 4))
1873 L2_DIFF_CORE((%0, %%FF_REGd) , (%1, %%FF_REGd))
1874 L2_DIFF_CORE((%0, %%FF_REGa,2), (%1, %%FF_REGa,2))
1875 L2_DIFF_CORE((%0, %%FF_REGc) , (%1, %%FF_REGc))
1879 "movq %%mm0, %%mm4 \n\t"
1880 "psrlq $32, %%mm0 \n\t"
1881 "paddd %%mm0, %%mm4 \n\t"
1882 "movd %%mm4, %%ecx \n\t"
1883 "shll $2, %%ecx \n\t"
1884 "mov %3, %%"FF_REG_d
" \n\t"
1885 "addl -4(%%"FF_REG_d
"), %%ecx \n\t"
1886 "addl 4(%%"FF_REG_d
"), %%ecx \n\t"
1887 "addl -1024(%%"FF_REG_d
"), %%ecx \n\t"
1888 "addl $4, %%ecx \n\t"
1889 "addl 1024(%%"FF_REG_d
"), %%ecx \n\t"
1890 "shrl $3, %%ecx \n\t"
1891 "movl %%ecx, (%%"FF_REG_d
") \n\t"
1896 "cmpl 512(%%"FF_REG_d
"), %%ecx \n\t"
1898 "cmpl 516(%%"FF_REG_d
"), %%ecx \n\t"
1901 "lea (%%"FF_REG_a
", %2, 2), %%"FF_REG_d
"\n\t"
1902 "lea (%%"FF_REG_d
", %2, 2), %%"FF_REG_c
"\n\t"
1903 "movq (%0), %%mm0 \n\t"
1904 "movq (%0, %2), %%mm1 \n\t"
1905 "movq (%0, %2, 2), %%mm2 \n\t"
1906 "movq (%0, %%"FF_REG_a
"), %%mm3 \n\t"
1907 "movq (%0, %2, 4), %%mm4 \n\t"
1908 "movq (%0, %%"FF_REG_d
"), %%mm5 \n\t"
1909 "movq (%0, %%"FF_REG_a
", 2), %%mm6 \n\t"
1910 "movq (%0, %%"FF_REG_c
"), %%mm7 \n\t"
1911 "movq %%mm0, (%1) \n\t"
1912 "movq %%mm1, (%1, %2) \n\t"
1913 "movq %%mm2, (%1, %2, 2) \n\t"
1914 "movq %%mm3, (%1, %%"FF_REG_a
") \n\t"
1915 "movq %%mm4, (%1, %2, 4) \n\t"
1916 "movq %%mm5, (%1, %%"FF_REG_d
") \n\t"
1917 "movq %%mm6, (%1, %%"FF_REG_a
", 2) \n\t"
1918 "movq %%mm7, (%1, %%"FF_REG_c
") \n\t"
1922 "lea (%%"FF_REG_a
", %2, 2), %%"FF_REG_d
"\n\t"
1923 "lea (%%"FF_REG_d
", %2, 2), %%"FF_REG_c
"\n\t"
1924 "movq (%0), %%mm0 \n\t"
1926 "movq (%0, %2), %%mm1 \n\t"
1927 PAVGB((%1, %2), %%mm1)
1928 "movq (%0, %2, 2), %%mm2 \n\t"
1929 PAVGB((%1, %2, 2), %%mm2)
1930 "movq (%0, %%"FF_REG_a
"), %%mm3 \n\t"
1931 PAVGB((%1, %%FF_REGa), %%mm3)
1932 "movq (%0, %2, 4), %%mm4 \n\t"
1933 PAVGB((%1, %2, 4), %%mm4)
1934 "movq (%0, %%"FF_REG_d
"), %%mm5 \n\t"
1935 PAVGB((%1, %%FF_REGd), %%mm5)
1936 "movq (%0, %%"FF_REG_a
", 2), %%mm6 \n\t"
1937 PAVGB((%1, %%FF_REGa, 2), %%mm6)
1938 "movq (%0, %%"FF_REG_c
"), %%mm7 \n\t"
1939 PAVGB((%1, %%FF_REGc), %%mm7)
1940 "movq %%mm0, (%1) \n\t"
1941 "movq %%mm1, (%1, %2) \n\t"
1942 "movq %%mm2, (%1, %2, 2) \n\t"
1943 "movq %%mm3, (%1, %%"FF_REG_a
") \n\t"
1944 "movq %%mm4, (%1, %2, 4) \n\t"
1945 "movq %%mm5, (%1, %%"FF_REG_d
") \n\t"
1946 "movq %%mm6, (%1, %%"FF_REG_a
", 2) \n\t"
1947 "movq %%mm7, (%1, %%"FF_REG_c
") \n\t"
1948 "movq %%mm0, (%0) \n\t"
1949 "movq %%mm1, (%0, %2) \n\t"
1950 "movq %%mm2, (%0, %2, 2) \n\t"
1951 "movq %%mm3, (%0, %%"FF_REG_a
") \n\t"
1952 "movq %%mm4, (%0, %2, 4) \n\t"
1953 "movq %%mm5, (%0, %%"FF_REG_d
") \n\t"
1954 "movq %%mm6, (%0, %%"FF_REG_a
", 2) \n\t"
1955 "movq %%mm7, (%0, %%"FF_REG_c
") \n\t"
1959 "cmpl 508(%%"FF_REG_d
"), %%ecx \n\t"
1962 "lea (%%"FF_REG_a
", %2, 2), %%"FF_REG_d
"\n\t"
1963 "lea (%%"FF_REG_d
", %2, 2), %%"FF_REG_c
"\n\t"
1964 "movq (%0), %%mm0 \n\t"
1965 "movq (%0, %2), %%mm1 \n\t"
1966 "movq (%0, %2, 2), %%mm2 \n\t"
1967 "movq (%0, %%"FF_REG_a
"), %%mm3 \n\t"
1968 "movq (%1), %%mm4 \n\t"
1969 "movq (%1, %2), %%mm5 \n\t"
1970 "movq (%1, %2, 2), %%mm6 \n\t"
1971 "movq (%1, %%"FF_REG_a
"), %%mm7 \n\t"
1980 "movq %%mm0, (%1) \n\t"
1981 "movq %%mm1, (%1, %2) \n\t"
1982 "movq %%mm2, (%1, %2, 2) \n\t"
1983 "movq %%mm3, (%1, %%"FF_REG_a
") \n\t"
1984 "movq %%mm0, (%0) \n\t"
1985 "movq %%mm1, (%0, %2) \n\t"
1986 "movq %%mm2, (%0, %2, 2) \n\t"
1987 "movq %%mm3, (%0, %%"FF_REG_a
") \n\t"
1989 "movq (%0, %2, 4), %%mm0 \n\t"
1990 "movq (%0, %%"FF_REG_d
"), %%mm1 \n\t"
1991 "movq (%0, %%"FF_REG_a
", 2), %%mm2 \n\t"
1992 "movq (%0, %%"FF_REG_c
"), %%mm3 \n\t"
1993 "movq (%1, %2, 4), %%mm4 \n\t"
1994 "movq (%1, %%"FF_REG_d
"), %%mm5 \n\t"
1995 "movq (%1, %%"FF_REG_a
", 2), %%mm6 \n\t"
1996 "movq (%1, %%"FF_REG_c
"), %%mm7 \n\t"
2005 "movq %%mm0, (%1, %2, 4) \n\t"
2006 "movq %%mm1, (%1, %%"FF_REG_d
") \n\t"
2007 "movq %%mm2, (%1, %%"FF_REG_a
", 2) \n\t"
2008 "movq %%mm3, (%1, %%"FF_REG_c
") \n\t"
2009 "movq %%mm0, (%0, %2, 4) \n\t"
2010 "movq %%mm1, (%0, %%"FF_REG_d
") \n\t"
2011 "movq %%mm2, (%0, %%"FF_REG_a
", 2) \n\t"
2012 "movq %%mm3, (%0, %%"FF_REG_c
") \n\t"
2016 "lea (%%"FF_REG_a
", %2, 2), %%"FF_REG_d
"\n\t"
2017 "lea (%%"FF_REG_d
", %2, 2), %%"FF_REG_c
"\n\t"
2018 "movq (%0), %%mm0 \n\t"
2019 "movq (%0, %2), %%mm1 \n\t"
2020 "movq (%0, %2, 2), %%mm2 \n\t"
2021 "movq (%0, %%"FF_REG_a
"), %%mm3 \n\t"
2022 "movq (%1), %%mm4 \n\t"
2023 "movq (%1, %2), %%mm5 \n\t"
2024 "movq (%1, %2, 2), %%mm6 \n\t"
2025 "movq (%1, %%"FF_REG_a
"), %%mm7 \n\t"
2038 "movq %%mm0, (%1) \n\t"
2039 "movq %%mm1, (%1, %2) \n\t"
2040 "movq %%mm2, (%1, %2, 2) \n\t"
2041 "movq %%mm3, (%1, %%"FF_REG_a
") \n\t"
2042 "movq %%mm0, (%0) \n\t"
2043 "movq %%mm1, (%0, %2) \n\t"
2044 "movq %%mm2, (%0, %2, 2) \n\t"
2045 "movq %%mm3, (%0, %%"FF_REG_a
") \n\t"
2047 "movq (%0, %2, 4), %%mm0 \n\t"
2048 "movq (%0, %%"FF_REG_d
"), %%mm1 \n\t"
2049 "movq (%0, %%"FF_REG_a
", 2), %%mm2 \n\t"
2050 "movq (%0, %%"FF_REG_c
"), %%mm3 \n\t"
2051 "movq (%1, %2, 4), %%mm4 \n\t"
2052 "movq (%1, %%"FF_REG_d
"), %%mm5 \n\t"
2053 "movq (%1, %%"FF_REG_a
", 2), %%mm6 \n\t"
2054 "movq (%1, %%"FF_REG_c
"), %%mm7 \n\t"
2067 "movq %%mm0, (%1, %2, 4) \n\t"
2068 "movq %%mm1, (%1, %%"FF_REG_d
") \n\t"
2069 "movq %%mm2, (%1, %%"FF_REG_a
", 2) \n\t"
2070 "movq %%mm3, (%1, %%"FF_REG_c
") \n\t"
2071 "movq %%mm0, (%0, %2, 4) \n\t"
2072 "movq %%mm1, (%0, %%"FF_REG_d
") \n\t"
2073 "movq %%mm2, (%0, %%"FF_REG_a
", 2) \n\t"
2074 "movq %%mm3, (%0, %%"FF_REG_c
") \n\t"
2078 ::
"r" (
src),
"r" (tempBlurred),
"r"((
x86_reg)
stride),
"m" (tempBlurredPast)
2080 :
"%"FF_REG_a,
"%"FF_REG_d,
"%"FF_REG_c,
"memory"
2082 #else //TEMPLATE_PP_MMXEXT && HAVE_6REGS
2105 +(*(tempBlurredPast-256))
2106 +(*(tempBlurredPast-1))+ (*(tempBlurredPast+1))
2107 +(*(tempBlurredPast+256))
2119 if(
d > maxNoise[1]){
2120 if(
d < maxNoise[2]){
2126 tempBlurred[ x + y*
stride ]=
2140 if(
d < maxNoise[0]){
2146 tempBlurred[ x + y*
stride ]=
2148 (
ref*7 + cur + 4)>>3;
2157 tempBlurred[ x + y*
stride ]=
2159 (
ref*3 + cur + 2)>>2;
2165 #endif //TEMPLATE_PP_MMXEXT && HAVE_6REGS
2167 #endif //TEMPLATE_PP_ALTIVEC
2169 #if TEMPLATE_PP_MMXEXT
2174 int64_t dc_mask, eq_mask, both_masks;
2175 int64_t sums[10*8*2];
2179 "movq %0, %%mm7 \n\t"
2180 "movq %1, %%mm6 \n\t"
2181 : :
"m" (
c->mmxDcOffset[
c->nonBQP]),
"m" (
c->mmxDcThreshold[
c->nonBQP])
2185 "lea (%2, %3), %%"FF_REG_a
" \n\t"
2189 "movq (%2), %%mm0 \n\t"
2190 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
2191 "movq %%mm1, %%mm3 \n\t"
2192 "movq %%mm1, %%mm4 \n\t"
2193 "psubb %%mm1, %%mm0 \n\t"
2194 "paddb %%mm7, %%mm0 \n\t"
2195 "pcmpgtb %%mm6, %%mm0 \n\t"
2197 "movq (%%"FF_REG_a
",%3), %%mm2 \n\t"
2198 PMAXUB(%%mm2, %%mm4)
2199 PMINUB(%%mm2, %%mm3, %%mm5)
2200 "psubb %%mm2, %%mm1 \n\t"
2201 "paddb %%mm7, %%mm1 \n\t"
2202 "pcmpgtb %%mm6, %%mm1 \n\t"
2203 "paddb %%mm1, %%mm0 \n\t"
2205 "movq (%%"FF_REG_a
", %3, 2), %%mm1 \n\t"
2206 PMAXUB(%%mm1, %%mm4)
2207 PMINUB(%%mm1, %%mm3, %%mm5)
2208 "psubb %%mm1, %%mm2 \n\t"
2209 "paddb %%mm7, %%mm2 \n\t"
2210 "pcmpgtb %%mm6, %%mm2 \n\t"
2211 "paddb %%mm2, %%mm0 \n\t"
2213 "lea (%%"FF_REG_a
", %3, 4), %%"FF_REG_a
"\n\t"
2215 "movq (%2, %3, 4), %%mm2 \n\t"
2216 PMAXUB(%%mm2, %%mm4)
2217 PMINUB(%%mm2, %%mm3, %%mm5)
2218 "psubb %%mm2, %%mm1 \n\t"
2219 "paddb %%mm7, %%mm1 \n\t"
2220 "pcmpgtb %%mm6, %%mm1 \n\t"
2221 "paddb %%mm1, %%mm0 \n\t"
2223 "movq (%%"FF_REG_a
"), %%mm1 \n\t"
2224 PMAXUB(%%mm1, %%mm4)
2225 PMINUB(%%mm1, %%mm3, %%mm5)
2226 "psubb %%mm1, %%mm2 \n\t"
2227 "paddb %%mm7, %%mm2 \n\t"
2228 "pcmpgtb %%mm6, %%mm2 \n\t"
2229 "paddb %%mm2, %%mm0 \n\t"
2231 "movq (%%"FF_REG_a
", %3), %%mm2 \n\t"
2232 PMAXUB(%%mm2, %%mm4)
2233 PMINUB(%%mm2, %%mm3, %%mm5)
2234 "psubb %%mm2, %%mm1 \n\t"
2235 "paddb %%mm7, %%mm1 \n\t"
2236 "pcmpgtb %%mm6, %%mm1 \n\t"
2237 "paddb %%mm1, %%mm0 \n\t"
2239 "movq (%%"FF_REG_a
", %3, 2), %%mm1 \n\t"
2240 PMAXUB(%%mm1, %%mm4)
2241 PMINUB(%%mm1, %%mm3, %%mm5)
2242 "psubb %%mm1, %%mm2 \n\t"
2243 "paddb %%mm7, %%mm2 \n\t"
2244 "pcmpgtb %%mm6, %%mm2 \n\t"
2245 "paddb %%mm2, %%mm0 \n\t"
2247 "movq (%2, %3, 8), %%mm2 \n\t"
2248 PMAXUB(%%mm2, %%mm4)
2249 PMINUB(%%mm2, %%mm3, %%mm5)
2250 "psubb %%mm2, %%mm1 \n\t"
2251 "paddb %%mm7, %%mm1 \n\t"
2252 "pcmpgtb %%mm6, %%mm1 \n\t"
2253 "paddb %%mm1, %%mm0 \n\t"
2255 "movq (%%"FF_REG_a
", %3, 4), %%mm1 \n\t"
2256 "psubb %%mm1, %%mm2 \n\t"
2257 "paddb %%mm7, %%mm2 \n\t"
2258 "pcmpgtb %%mm6, %%mm2 \n\t"
2259 "paddb %%mm2, %%mm0 \n\t"
2260 "psubusb %%mm3, %%mm4 \n\t"
2262 "pxor %%mm6, %%mm6 \n\t"
2263 "movq %4, %%mm7 \n\t"
2264 "paddusb %%mm7, %%mm7 \n\t"
2265 "psubusb %%mm4, %%mm7 \n\t"
2266 "pcmpeqb %%mm6, %%mm7 \n\t"
2267 "pcmpeqb %%mm6, %%mm7 \n\t"
2268 "movq %%mm7, %1 \n\t"
2270 "movq %5, %%mm7 \n\t"
2271 "punpcklbw %%mm7, %%mm7 \n\t"
2272 "punpcklbw %%mm7, %%mm7 \n\t"
2273 "punpcklbw %%mm7, %%mm7 \n\t"
2274 "psubb %%mm0, %%mm6 \n\t"
2275 "pcmpgtb %%mm7, %%mm6 \n\t"
2276 "movq %%mm6, %0 \n\t"
2278 :
"=m" (eq_mask),
"=m" (dc_mask)
2279 :
"r" (
src),
"r" ((
x86_reg)
step),
"m" (
c->pQPb),
"m"(
c->ppMode.flatnessThreshold)
2283 both_masks = dc_mask & eq_mask;
2287 int64_t *temp_sums= sums;
2290 "movq %2, %%mm0 \n\t"
2291 "pxor %%mm4, %%mm4 \n\t"
2293 "movq (%0), %%mm6 \n\t"
2294 "movq (%0, %1), %%mm5 \n\t"
2295 "movq %%mm5, %%mm1 \n\t"
2296 "movq %%mm6, %%mm2 \n\t"
2297 "psubusb %%mm6, %%mm5 \n\t"
2298 "psubusb %%mm1, %%mm2 \n\t"
2299 "por %%mm5, %%mm2 \n\t"
2300 "psubusb %%mm2, %%mm0 \n\t"
2301 "pcmpeqb %%mm4, %%mm0 \n\t"
2303 "pxor %%mm6, %%mm1 \n\t"
2304 "pand %%mm0, %%mm1 \n\t"
2305 "pxor %%mm1, %%mm6 \n\t"
2308 "movq (%0, %1, 8), %%mm5 \n\t"
2310 "movq (%0, %1, 8), %%mm7 \n\t"
2311 "movq %%mm5, %%mm1 \n\t"
2312 "movq %%mm7, %%mm2 \n\t"
2313 "psubusb %%mm7, %%mm5 \n\t"
2314 "psubusb %%mm1, %%mm2 \n\t"
2315 "por %%mm5, %%mm2 \n\t"
2316 "movq %2, %%mm0 \n\t"
2317 "psubusb %%mm2, %%mm0 \n\t"
2318 "pcmpeqb %%mm4, %%mm0 \n\t"
2320 "pxor %%mm7, %%mm1 \n\t"
2321 "pand %%mm0, %%mm1 \n\t"
2322 "pxor %%mm1, %%mm7 \n\t"
2324 "movq %%mm6, %%mm5 \n\t"
2325 "punpckhbw %%mm4, %%mm6 \n\t"
2326 "punpcklbw %%mm4, %%mm5 \n\t"
2329 "movq %%mm5, %%mm0 \n\t"
2330 "movq %%mm6, %%mm1 \n\t"
2331 "psllw $2, %%mm0 \n\t"
2332 "psllw $2, %%mm1 \n\t"
2333 "paddw "MANGLE(w04)
", %%mm0 \n\t"
2334 "paddw "MANGLE(w04)
", %%mm1 \n\t"
2337 "movq (%0), %%mm2 \n\t"\
2338 "movq (%0), %%mm3 \n\t"\
2340 "punpcklbw %%mm4, %%mm2 \n\t"\
2341 "punpckhbw %%mm4, %%mm3 \n\t"\
2342 "paddw %%mm2, %%mm0 \n\t"\
2343 "paddw %%mm3, %%mm1 \n\t"
2346 "movq (%0), %%mm2 \n\t"\
2347 "movq (%0), %%mm3 \n\t"\
2349 "punpcklbw %%mm4, %%mm2 \n\t"\
2350 "punpckhbw %%mm4, %%mm3 \n\t"\
2351 "psubw %%mm2, %%mm0 \n\t"\
2352 "psubw %%mm3, %%mm1 \n\t"
2358 "movq %%mm0, (%3) \n\t"
2359 "movq %%mm1, 8(%3) \n\t"
2362 "psubw %%mm5, %%mm0 \n\t"
2363 "psubw %%mm6, %%mm1 \n\t"
2364 "movq %%mm0, 16(%3) \n\t"
2365 "movq %%mm1, 24(%3) \n\t"
2368 "psubw %%mm5, %%mm0 \n\t"
2369 "psubw %%mm6, %%mm1 \n\t"
2370 "movq %%mm0, 32(%3) \n\t"
2371 "movq %%mm1, 40(%3) \n\t"
2374 "psubw %%mm5, %%mm0 \n\t"
2375 "psubw %%mm6, %%mm1 \n\t"
2376 "movq %%mm0, 48(%3) \n\t"
2377 "movq %%mm1, 56(%3) \n\t"
2380 "psubw %%mm5, %%mm0 \n\t"
2381 "psubw %%mm6, %%mm1 \n\t"
2382 "movq %%mm0, 64(%3) \n\t"
2383 "movq %%mm1, 72(%3) \n\t"
2385 "movq %%mm7, %%mm6 \n\t"
2386 "punpckhbw %%mm4, %%mm7 \n\t"
2387 "punpcklbw %%mm4, %%mm6 \n\t"
2393 "movq %%mm0, 80(%3) \n\t"
2394 "movq %%mm1, 88(%3) \n\t"
2397 "paddw %%mm6, %%mm0 \n\t"
2398 "paddw %%mm7, %%mm1 \n\t"
2399 "movq %%mm0, 96(%3) \n\t"
2400 "movq %%mm1, 104(%3) \n\t"
2403 "paddw %%mm6, %%mm0 \n\t"
2404 "paddw %%mm7, %%mm1 \n\t"
2405 "movq %%mm0, 112(%3) \n\t"
2406 "movq %%mm1, 120(%3) \n\t"
2409 "paddw %%mm6, %%mm0 \n\t"
2410 "paddw %%mm7, %%mm1 \n\t"
2411 "movq %%mm0, 128(%3) \n\t"
2412 "movq %%mm1, 136(%3) \n\t"
2415 "paddw %%mm6, %%mm0 \n\t"
2416 "paddw %%mm7, %%mm1 \n\t"
2417 "movq %%mm0, 144(%3) \n\t"
2418 "movq %%mm1, 152(%3) \n\t"
2430 "movq %4, %%mm6 \n\t"
2431 "pcmpeqb %%mm5, %%mm5 \n\t"
2432 "pxor %%mm6, %%mm5 \n\t"
2433 "pxor %%mm7, %%mm7 \n\t"
2436 "movq (%1), %%mm0 \n\t"
2437 "movq 8(%1), %%mm1 \n\t"
2438 "paddw 32(%1), %%mm0 \n\t"
2439 "paddw 40(%1), %%mm1 \n\t"
2440 "movq (%0, %3), %%mm2 \n\t"
2441 "movq %%mm2, %%mm3 \n\t"
2442 "movq %%mm2, %%mm4 \n\t"
2443 "punpcklbw %%mm7, %%mm2 \n\t"
2444 "punpckhbw %%mm7, %%mm3 \n\t"
2445 "paddw %%mm2, %%mm0 \n\t"
2446 "paddw %%mm3, %%mm1 \n\t"
2447 "paddw %%mm2, %%mm0 \n\t"
2448 "paddw %%mm3, %%mm1 \n\t"
2449 "psrlw $4, %%mm0 \n\t"
2450 "psrlw $4, %%mm1 \n\t"
2451 "packuswb %%mm1, %%mm0 \n\t"
2452 "pand %%mm6, %%mm0 \n\t"
2453 "pand %%mm5, %%mm4 \n\t"
2454 "por %%mm4, %%mm0 \n\t"
2455 "movq %%mm0, (%0, %3) \n\t"
2460 :
"+r"(
offset),
"+r"(temp_sums)
2466 if(eq_mask != -1LL){
2467 uint8_t *temp_src=
src;
2470 "pxor %%mm7, %%mm7 \n\t"
2474 "movq (%0), %%mm0 \n\t"
2475 "movq %%mm0, %%mm1 \n\t"
2476 "punpcklbw %%mm7, %%mm0 \n\t"
2477 "punpckhbw %%mm7, %%mm1 \n\t"
2479 "movq (%0, %1), %%mm2 \n\t"
2480 "lea (%0, %1, 2), %%"FF_REG_a
" \n\t"
2481 "movq %%mm2, %%mm3 \n\t"
2482 "punpcklbw %%mm7, %%mm2 \n\t"
2483 "punpckhbw %%mm7, %%mm3 \n\t"
2485 "movq (%%"FF_REG_a
"), %%mm4 \n\t"
2486 "movq %%mm4, %%mm5 \n\t"
2487 "punpcklbw %%mm7, %%mm4 \n\t"
2488 "punpckhbw %%mm7, %%mm5 \n\t"
2490 "paddw %%mm0, %%mm0 \n\t"
2491 "paddw %%mm1, %%mm1 \n\t"
2492 "psubw %%mm4, %%mm2 \n\t"
2493 "psubw %%mm5, %%mm3 \n\t"
2494 "psubw %%mm2, %%mm0 \n\t"
2495 "psubw %%mm3, %%mm1 \n\t"
2497 "psllw $2, %%mm2 \n\t"
2498 "psllw $2, %%mm3 \n\t"
2499 "psubw %%mm2, %%mm0 \n\t"
2500 "psubw %%mm3, %%mm1 \n\t"
2502 "movq (%%"FF_REG_a
", %1), %%mm2 \n\t"
2503 "movq %%mm2, %%mm3 \n\t"
2504 "punpcklbw %%mm7, %%mm2 \n\t"
2505 "punpckhbw %%mm7, %%mm3 \n\t"
2507 "psubw %%mm2, %%mm0 \n\t"
2508 "psubw %%mm3, %%mm1 \n\t"
2509 "psubw %%mm2, %%mm0 \n\t"
2510 "psubw %%mm3, %%mm1 \n\t"
2511 "movq %%mm0, (%4) \n\t"
2512 "movq %%mm1, 8(%4) \n\t"
2514 "movq (%%"FF_REG_a
", %1, 2), %%mm0 \n\t"
2515 "movq %%mm0, %%mm1 \n\t"
2516 "punpcklbw %%mm7, %%mm0 \n\t"
2517 "punpckhbw %%mm7, %%mm1 \n\t"
2519 "psubw %%mm0, %%mm2 \n\t"
2520 "psubw %%mm1, %%mm3 \n\t"
2521 "movq %%mm2, 16(%4) \n\t"
2522 "movq %%mm3, 24(%4) \n\t"
2523 "paddw %%mm4, %%mm4 \n\t"
2524 "paddw %%mm5, %%mm5 \n\t"
2525 "psubw %%mm2, %%mm4 \n\t"
2526 "psubw %%mm3, %%mm5 \n\t"
2528 "lea (%%"FF_REG_a
", %1), %0 \n\t"
2529 "psllw $2, %%mm2 \n\t"
2530 "psllw $2, %%mm3 \n\t"
2531 "psubw %%mm2, %%mm4 \n\t"
2532 "psubw %%mm3, %%mm5 \n\t"
2534 "movq (%0, %1, 2), %%mm2 \n\t"
2535 "movq %%mm2, %%mm3 \n\t"
2536 "punpcklbw %%mm7, %%mm2 \n\t"
2537 "punpckhbw %%mm7, %%mm3 \n\t"
2538 "psubw %%mm2, %%mm4 \n\t"
2539 "psubw %%mm3, %%mm5 \n\t"
2540 "psubw %%mm2, %%mm4 \n\t"
2541 "psubw %%mm3, %%mm5 \n\t"
2543 "movq (%%"FF_REG_a
", %1, 4), %%mm6 \n\t"
2544 "punpcklbw %%mm7, %%mm6 \n\t"
2545 "psubw %%mm6, %%mm2 \n\t"
2546 "movq (%%"FF_REG_a
", %1, 4), %%mm6 \n\t"
2547 "punpckhbw %%mm7, %%mm6 \n\t"
2548 "psubw %%mm6, %%mm3 \n\t"
2550 "paddw %%mm0, %%mm0 \n\t"
2551 "paddw %%mm1, %%mm1 \n\t"
2552 "psubw %%mm2, %%mm0 \n\t"
2553 "psubw %%mm3, %%mm1 \n\t"
2555 "psllw $2, %%mm2 \n\t"
2556 "psllw $2, %%mm3 \n\t"
2557 "psubw %%mm2, %%mm0 \n\t"
2558 "psubw %%mm3, %%mm1 \n\t"
2560 "movq (%0, %1, 4), %%mm2 \n\t"
2561 "movq %%mm2, %%mm3 \n\t"
2562 "punpcklbw %%mm7, %%mm2 \n\t"
2563 "punpckhbw %%mm7, %%mm3 \n\t"
2565 "paddw %%mm2, %%mm2 \n\t"
2566 "paddw %%mm3, %%mm3 \n\t"
2567 "psubw %%mm2, %%mm0 \n\t"
2568 "psubw %%mm3, %%mm1 \n\t"
2570 "movq (%4), %%mm2 \n\t"
2571 "movq 8(%4), %%mm3 \n\t"
2573 "movq %%mm7, %%mm6 \n\t"
2574 "psubw %%mm0, %%mm6 \n\t"
2575 "pmaxsw %%mm6, %%mm0 \n\t"
2576 "movq %%mm7, %%mm6 \n\t"
2577 "psubw %%mm1, %%mm6 \n\t"
2578 "pmaxsw %%mm6, %%mm1 \n\t"
2579 "movq %%mm7, %%mm6 \n\t"
2580 "psubw %%mm2, %%mm6 \n\t"
2581 "pmaxsw %%mm6, %%mm2 \n\t"
2582 "movq %%mm7, %%mm6 \n\t"
2583 "psubw %%mm3, %%mm6 \n\t"
2584 "pmaxsw %%mm6, %%mm3 \n\t"
2586 "pminsw %%mm2, %%mm0 \n\t"
2587 "pminsw %%mm3, %%mm1 \n\t"
2589 "movd %2, %%mm2 \n\t"
2590 "punpcklbw %%mm7, %%mm2 \n\t"
2592 "movq %%mm7, %%mm6 \n\t"
2593 "pcmpgtw %%mm4, %%mm6 \n\t"
2594 "pxor %%mm6, %%mm4 \n\t"
2595 "psubw %%mm6, %%mm4 \n\t"
2596 "pcmpgtw %%mm5, %%mm7 \n\t"
2597 "pxor %%mm7, %%mm5 \n\t"
2598 "psubw %%mm7, %%mm5 \n\t"
2600 "psllw $3, %%mm2 \n\t"
2601 "movq %%mm2, %%mm3 \n\t"
2602 "pcmpgtw %%mm4, %%mm2 \n\t"
2603 "pcmpgtw %%mm5, %%mm3 \n\t"
2604 "pand %%mm2, %%mm4 \n\t"
2605 "pand %%mm3, %%mm5 \n\t"
2608 "psubusw %%mm0, %%mm4 \n\t"
2609 "psubusw %%mm1, %%mm5 \n\t"
2612 "movq "MANGLE(w05)
", %%mm2 \n\t"
2613 "pmullw %%mm2, %%mm4 \n\t"
2614 "pmullw %%mm2, %%mm5 \n\t"
2615 "movq "MANGLE(w20)
", %%mm2 \n\t"
2616 "paddw %%mm2, %%mm4 \n\t"
2617 "paddw %%mm2, %%mm5 \n\t"
2618 "psrlw $6, %%mm4 \n\t"
2619 "psrlw $6, %%mm5 \n\t"
2621 "movq 16(%4), %%mm0 \n\t"
2622 "movq 24(%4), %%mm1 \n\t"
2624 "pxor %%mm2, %%mm2 \n\t"
2625 "pxor %%mm3, %%mm3 \n\t"
2627 "pcmpgtw %%mm0, %%mm2 \n\t"
2628 "pcmpgtw %%mm1, %%mm3 \n\t"
2629 "pxor %%mm2, %%mm0 \n\t"
2630 "pxor %%mm3, %%mm1 \n\t"
2631 "psubw %%mm2, %%mm0 \n\t"
2632 "psubw %%mm3, %%mm1 \n\t"
2633 "psrlw $1, %%mm0 \n\t"
2634 "psrlw $1, %%mm1 \n\t"
2636 "pxor %%mm6, %%mm2 \n\t"
2637 "pxor %%mm7, %%mm3 \n\t"
2638 "pand %%mm2, %%mm4 \n\t"
2639 "pand %%mm3, %%mm5 \n\t"
2641 "pminsw %%mm0, %%mm4 \n\t"
2642 "pminsw %%mm1, %%mm5 \n\t"
2643 "pxor %%mm6, %%mm4 \n\t"
2644 "pxor %%mm7, %%mm5 \n\t"
2645 "psubw %%mm6, %%mm4 \n\t"
2646 "psubw %%mm7, %%mm5 \n\t"
2647 "packsswb %%mm5, %%mm4 \n\t"
2648 "movq %3, %%mm1 \n\t"
2649 "pandn %%mm4, %%mm1 \n\t"
2650 "movq (%0), %%mm0 \n\t"
2651 "paddb %%mm1, %%mm0 \n\t"
2652 "movq %%mm0, (%0) \n\t"
2653 "movq (%0, %1), %%mm0 \n\t"
2654 "psubb %%mm1, %%mm0 \n\t"
2655 "movq %%mm0, (%0, %1) \n\t"
2664 #endif //TEMPLATE_PP_MMX
2667 const int8_t QPs[],
int QPStride,
int isColor,
PPContext *
c);
2673 #undef REAL_SCALED_CPY
2676 static inline void RENAME(blockCopy)(uint8_t dst[],
int dstStride,
const uint8_t
src[],
int srcStride,
2677 int levelFix, int64_t *packedOffsetAndScale)
2680 #if TEMPLATE_PP_MMXEXT && HAVE_6REGS
2682 "movq (%%"FF_REG_a
"), %%mm2 \n\t"
2683 "movq 8(%%"FF_REG_a
"), %%mm3 \n\t"
2684 "lea (%2,%4), %%"FF_REG_a
" \n\t"
2685 "lea (%3,%5), %%"FF_REG_d
" \n\t"
2686 "pxor %%mm4, %%mm4 \n\t"
2687 #define REAL_SCALED_CPY(src1, src2, dst1, dst2) \
2688 "movq " #src1 ", %%mm0 \n\t"\
2689 "movq " #src1 ", %%mm5 \n\t"\
2690 "movq " #src2 ", %%mm1 \n\t"\
2691 "movq " #src2 ", %%mm6 \n\t"\
2692 "punpcklbw %%mm0, %%mm0 \n\t"\
2693 "punpckhbw %%mm5, %%mm5 \n\t"\
2694 "punpcklbw %%mm1, %%mm1 \n\t"\
2695 "punpckhbw %%mm6, %%mm6 \n\t"\
2696 "pmulhuw %%mm3, %%mm0 \n\t"\
2697 "pmulhuw %%mm3, %%mm5 \n\t"\
2698 "pmulhuw %%mm3, %%mm1 \n\t"\
2699 "pmulhuw %%mm3, %%mm6 \n\t"\
2700 "psubw %%mm2, %%mm0 \n\t"\
2701 "psubw %%mm2, %%mm5 \n\t"\
2702 "psubw %%mm2, %%mm1 \n\t"\
2703 "psubw %%mm2, %%mm6 \n\t"\
2704 "packuswb %%mm5, %%mm0 \n\t"\
2705 "packuswb %%mm6, %%mm1 \n\t"\
2706 "movq %%mm0, " #dst1 " \n\t"\
2707 "movq %%mm1, " #dst2 " \n\t"\
2709 #define SCALED_CPY(src1, src2, dst1, dst2)\
2710 REAL_SCALED_CPY(src1, src2, dst1, dst2)
2712 SCALED_CPY((%2) , (%2, %4) , (%3) , (%3, %5))
2713 SCALED_CPY((%2, %4, 2), (%%FF_REGa, %4, 2), (%3, %5, 2), (%%FF_REGd, %5, 2))
2714 SCALED_CPY((%2, %4, 4), (%%FF_REGa, %4, 4), (%3, %5, 4), (%%FF_REGd, %5, 4))
2715 "lea (%%"FF_REG_a
",%4,4), %%"FF_REG_a
" \n\t"
2716 "lea (%%"FF_REG_d
",%5,4), %%"FF_REG_d
" \n\t"
2717 SCALED_CPY((%%FF_REGa, %4), (%%FF_REGa, %4, 2), (%%FF_REGd, %5), (%%FF_REGd, %5, 2))
2720 :
"=&a" (packedOffsetAndScale)
2721 :
"0" (packedOffsetAndScale),
2728 #else //TEMPLATE_PP_MMX && HAVE_6REGS
2729 for (
int i = 0;
i < 8;
i++)
2730 memcpy( &(dst[dstStride*
i]),
2732 #endif //TEMPLATE_PP_MMX && HAVE_6REGS
2734 #if TEMPLATE_PP_MMX && HAVE_6REGS
2736 "lea (%0,%2), %%"FF_REG_a
" \n\t"
2737 "lea (%1,%3), %%"FF_REG_d
" \n\t"
2739 #define REAL_SIMPLE_CPY(src1, src2, dst1, dst2) \
2740 "movq " #src1 ", %%mm0 \n\t"\
2741 "movq " #src2 ", %%mm1 \n\t"\
2742 "movq %%mm0, " #dst1 " \n\t"\
2743 "movq %%mm1, " #dst2 " \n\t"\
2745 #define SIMPLE_CPY(src1, src2, dst1, dst2)\
2746 REAL_SIMPLE_CPY(src1, src2, dst1, dst2)
2748 SIMPLE_CPY((%0) , (%0, %2) , (%1) , (%1, %3))
2749 SIMPLE_CPY((%0, %2, 2), (%%FF_REGa, %2, 2), (%1, %3, 2), (%%FF_REGd, %3, 2))
2750 SIMPLE_CPY((%0, %2, 4), (%%FF_REGa, %2, 4), (%1, %3, 4), (%%FF_REGd, %3, 4))
2751 "lea (%%"FF_REG_a
",%2,4), %%"FF_REG_a
" \n\t"
2752 "lea (%%"FF_REG_d
",%3,4), %%"FF_REG_d
" \n\t"
2753 SIMPLE_CPY((%%FF_REGa, %2), (%%FF_REGa, %2, 2), (%%FF_REGd, %3), (%%FF_REGd, %3, 2))
2759 :
"%"FF_REG_a,
"%"FF_REG_d
2761 #else //TEMPLATE_PP_MMX && HAVE_6REGS
2762 for (
int i = 0;
i < 8;
i++)
2763 memcpy( &(dst[dstStride*
i]),
2765 #endif //TEMPLATE_PP_MMX && HAVE_6REGS
2776 "movq (%0), %%mm0 \n\t"
2777 "movq %%mm0, (%0, %1, 4) \n\t"
2779 "movq %%mm0, (%0) \n\t"
2780 "movq %%mm0, (%0, %1) \n\t"
2781 "movq %%mm0, (%0, %1, 2) \n\t"
2782 "movq %%mm0, (%0, %1, 4) \n\t"
2796 #if ARCH_X86 && TEMPLATE_PP_MMXEXT
2797 static inline void RENAME(prefetchnta)(
const void *p)
2799 __asm__ volatile(
"prefetchnta (%0)\n\t"
2804 static inline void RENAME(prefetcht0)(
const void *p)
2806 __asm__ volatile(
"prefetcht0 (%0)\n\t"
2811 static inline void RENAME(prefetcht1)(
const void *p)
2813 __asm__ volatile(
"prefetcht1 (%0)\n\t"
2818 static inline void RENAME(prefetcht2)(
const void *p)
2820 __asm__ volatile(
"prefetcht2 (%0)\n\t"
2824 #elif !ARCH_X86 && AV_GCC_VERSION_AT_LEAST(3,2)
2825 static inline void RENAME(prefetchnta)(
const void *p)
2827 __builtin_prefetch(p,0,0);
2829 static inline void RENAME(prefetcht0)(
const void *p)
2831 __builtin_prefetch(p,0,1);
2833 static inline void RENAME(prefetcht1)(
const void *p)
2835 __builtin_prefetch(p,0,2);
2837 static inline void RENAME(prefetcht2)(
const void *p)
2839 __builtin_prefetch(p,0,3);
2842 static inline void RENAME(prefetchnta)(
const void *p)
2846 static inline void RENAME(prefetcht0)(
const void *p)
2850 static inline void RENAME(prefetcht1)(
const void *p)
2854 static inline void RENAME(prefetcht2)(
const void *p)
2863 const int8_t QPs[],
int QPStride,
int isColor,
PPContext *
c)
2866 #ifdef TEMPLATE_PP_TIME_MODE
2867 const int mode= TEMPLATE_PP_TIME_MODE;
2869 const int mode = isColor ?
c->ppMode.chromMode :
c->ppMode.lumMode;
2871 int black=0, white=255;
2872 int QPCorrecture= 256*256;
2879 const int qpHShift = isColor ? 4 -
c->hChromaSubSample : 4;
2880 const int qpVShift = isColor ? 4 -
c->vChromaSubSample : 4;
2883 uint64_t *
const yHistogram=
c->yHistogram;
2884 uint8_t *
const tempSrc = srcStride > 0 ?
c->tempSrc :
c->tempSrc - 23*srcStride;
2885 uint8_t *
const tempDst = (dstStride > 0 ?
c->tempDst :
c->tempDst - 23*dstStride) + 32;
2890 av_log(
c,
AV_LOG_WARNING,
"Visualization is currently only supported with the accurate deblock filter without SIMD\n");
2895 for(
i=0;
i<57;
i++){
2896 int offset = ((
i *
c->ppMode.baseDcDiff) >> 8) + 1;
2897 int threshold=
offset*2 + 1;
2899 c->mmxDcThreshold[
i] = 0x7F - threshold;
2900 c->mmxDcOffset[
i] *= 0x0101010101010101LL;
2901 c->mmxDcThreshold[
i] *= 0x0101010101010101LL;
2923 uint64_t maxClipped;
2929 if (
c->frameNum == 1)
2930 yHistogram[0] =
width * (uint64_t)
height/64*15/256;
2932 for(
i=0;
i<256;
i++){
2933 sum+= yHistogram[
i];
2937 maxClipped =
av_rescale(sum,
c->ppMode.maxClippedThreshold.num,
2938 c->ppMode.maxClippedThreshold.den);
2941 for(black=255; black>0; black--){
2942 if(clipped < maxClipped)
break;
2943 clipped-= yHistogram[black];
2947 for(white=0; white<256; white++){
2948 if(clipped < maxClipped)
break;
2949 clipped-= yHistogram[white];
2952 scale = (
AVRational){
c->ppMode.maxAllowedY -
c->ppMode.minAllowedY, white - black};
2954 #if TEMPLATE_PP_MMXEXT
2956 c->packedYOffset = (((black*
c->packedYScale)>>8) -
c->ppMode.minAllowedY) & 0xFFFF;
2959 c->packedYOffset = (black -
c->ppMode.minAllowedY) & 0xFFFF;
2962 c->packedYOffset |=
c->packedYOffset<<32;
2963 c->packedYOffset |=
c->packedYOffset<<16;
2965 c->packedYScale |=
c->packedYScale<<32;
2966 c->packedYScale |=
c->packedYScale<<16;
2969 else QPCorrecture= 256*256;
2971 c->packedYScale = 0x0100010001000100LL;
2972 c->packedYOffset = 0;
2973 QPCorrecture= 256*256;
2979 const uint8_t *srcBlock= &(
src[y*srcStride]);
2980 uint8_t *dstBlock= tempDst + dstStride;
2986 RENAME(prefetchnta)(srcBlock + (((x>>2)&6) + copyAhead)*srcStride + 32);
2987 RENAME(prefetchnta)(srcBlock + (((x>>2)&6) + copyAhead+1)*srcStride + 32);
2988 RENAME(prefetcht0)(dstBlock + (((x>>2)&6) + copyAhead)*dstStride + 32);
2989 RENAME(prefetcht0)(dstBlock + (((x>>2)&6) + copyAhead+1)*dstStride + 32);
2991 RENAME(blockCopy)(dstBlock + dstStride*8, dstStride,
2992 srcBlock + srcStride*8, srcStride,
mode &
LEVEL_FIX, &
c->packedYOffset);
2994 RENAME(duplicate)(dstBlock + dstStride*8, dstStride);
2997 RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride);
2999 RENAME(deInterlaceBlendLinear)(dstBlock, dstStride,
c->deintTemp + x);
3001 RENAME(deInterlaceMedian)(dstBlock, dstStride);
3003 RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride);
3005 RENAME(deInterlaceFF)(dstBlock, dstStride,
c->deintTemp + x);
3007 RENAME(deInterlaceL5)(dstBlock, dstStride,
c->deintTemp + x,
c->deintTemp +
width + x);
3015 linecpy(dst, tempDst + 9*dstStride, copyAhead, dstStride);
3018 for(
i=0;
i<copyAhead;
i++){
3019 memcpy(dst +
i*dstStride, tempDst + (9+
i)*dstStride,
width);
3026 const uint8_t *srcBlock= &(
src[y*srcStride]);
3027 uint8_t *dstBlock= &(dst[y*dstStride]);
3029 uint8_t *tempBlock1 =
c->tempBlocks;
3030 uint8_t *tempBlock2 =
c->tempBlocks + 8;
3032 const int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride];
3033 int8_t *nonBQPptr = &
c->nonBQPTable[(y>>qpVShift)*
FFABS(QPStride)];
3041 linecpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead,
3046 memcpy(tempSrc + srcStride*
i,
src + srcStride*(
height-1),
FFABS(srcStride));
3053 memcpy(tempDst + dstStride*
i, dst + dstStride*(
height-1),
FFABS(dstStride));
3055 dstBlock= tempDst + dstStride;
3062 for(x=0; x<
width; ){
3065 uint8_t *dstBlockStart = dstBlock;
3066 const uint8_t *srcBlockStart = srcBlock;
3068 for(qp_index=0; qp_index < (endx-startx)/
BLOCK_SIZE; qp_index++){
3070 nonBQP = nonBQPptr[(x+qp_index*
BLOCK_SIZE)>>qpHShift];
3072 QP= (
QP* QPCorrecture + 256*128)>>16;
3073 nonBQP= (nonBQP* QPCorrecture + 256*128)>>16;
3074 yHistogram[(srcBlock+qp_index*8)[srcStride*12 + 4]]++;
3076 c->QP_block[qp_index] =
QP;
3077 c->nonBQP_block[qp_index] = nonBQP;
3080 "movd %1, %%mm7 \n\t"
3081 "packuswb %%mm7, %%mm7 \n\t"
3082 "packuswb %%mm7, %%mm7 \n\t"
3083 "packuswb %%mm7, %%mm7 \n\t"
3084 "movq %%mm7, %0 \n\t"
3085 :
"=m" (
c->pQPb_block[qp_index])
3091 RENAME(prefetchnta)(srcBlock + (((x>>2)&6) + copyAhead)*srcStride + 32);
3092 RENAME(prefetchnta)(srcBlock + (((x>>2)&6) + copyAhead+1)*srcStride + 32);
3093 RENAME(prefetcht0)(dstBlock + (((x>>2)&6) + copyAhead)*dstStride + 32);
3094 RENAME(prefetcht0)(dstBlock + (((x>>2)&6) + copyAhead+1)*dstStride + 32);
3096 RENAME(blockCopy)(dstBlock + dstStride*copyAhead, dstStride,
3097 srcBlock + srcStride*copyAhead, srcStride,
mode &
LEVEL_FIX, &
c->packedYOffset);
3100 RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride);
3102 RENAME(deInterlaceBlendLinear)(dstBlock, dstStride,
c->deintTemp + x);
3104 RENAME(deInterlaceMedian)(dstBlock, dstStride);
3106 RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride);
3108 RENAME(deInterlaceFF)(dstBlock, dstStride,
c->deintTemp + x);
3110 RENAME(deInterlaceL5)(dstBlock, dstStride,
c->deintTemp + x,
c->deintTemp +
width + x);
3118 dstBlock = dstBlockStart;
3119 srcBlock = srcBlockStart;
3121 for(x = startx, qp_index = 0; x < endx; x+=
BLOCK_SIZE, qp_index++){
3122 const int stride= dstStride;
3125 c->QP =
c->QP_block[qp_index];
3126 c->nonBQP =
c->nonBQP_block[qp_index];
3127 c->pQPb =
c->pQPb_block[qp_index];
3128 c->pQPb2 =
c->pQPb2_block[qp_index];
3150 dstBlock = dstBlockStart;
3151 srcBlock = srcBlockStart;
3153 for(x = startx, qp_index=0; x < endx; x+=
BLOCK_SIZE, qp_index++){
3154 const int stride= dstStride;
3155 c->QP =
c->QP_block[qp_index];
3156 c->nonBQP =
c->nonBQP_block[qp_index];
3157 c->pQPb =
c->pQPb_block[qp_index];
3158 c->pQPb2 =
c->pQPb2_block[qp_index];
3160 RENAME(transpose1)(tempBlock1, tempBlock2, dstBlock, dstStride);
3166 RENAME(vertX1Filter)(tempBlock1, 16,
c);
3168 const int t=
RENAME(vertClassify)(tempBlock1, 16,
c);
3170 RENAME(doVertLowPass)(tempBlock1, 16,
c);
3172 RENAME(doVertDefFilter)(tempBlock1, 16,
c);
3177 RENAME(transpose2)(dstBlock-4, dstStride, tempBlock1 + 4*16);
3183 #if TEMPLATE_PP_ALTIVEC
3208 #endif //TEMPLATE_PP_MMX
3217 c->tempBlurred[isColor] + y*dstStride + x,
3218 c->tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256,
3219 c->ppMode.maxTmpNoise);
3227 FFSWAP(uint8_t *, tempBlock1, tempBlock2);
3233 if(y > 0)
RENAME(dering)(dstBlock - dstStride - 8, dstStride,
c);
3237 RENAME(tempNoiseReducer)(dstBlock-8, dstStride,
3238 c->tempBlurred[isColor] + y*dstStride + x,
3239 c->tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256,
3240 c->ppMode.maxTmpNoise);
3245 uint8_t *dstBlock= &(dst[y*dstStride]);
3247 linecpy(dstBlock, tempDst + dstStride,
height-y, dstStride);
3251 memcpy(dstBlock +
i*dstStride, tempDst + (
i+1)*dstStride,
width);
3260 #ifdef DEBUG_BRIGHTNESS
3264 for(
i=0;
i<256;
i++)
3265 if(yHistogram[
i] >
max)
max=yHistogram[
i];
3267 for(
i=1;
i<256;
i++){
3269 int start=yHistogram[
i-1]/(
max/256+1);
3270 int end=yHistogram[
i]/(
max/256+1);
3271 int inc= end > start ? 1 : -1;
3272 for(x=start; x!=end+inc; x+=inc)
3273 dst[
i*dstStride + x]+=128;
3276 for(
i=0;
i<100;
i+=2){
3277 dst[ (white)*dstStride +
i]+=128;
3278 dst[ (black)*dstStride +
i]+=128;
3285 #undef TEMPLATE_PP_C
3286 #undef TEMPLATE_PP_ALTIVEC
3287 #undef TEMPLATE_PP_MMX
3288 #undef TEMPLATE_PP_MMXEXT
3289 #undef TEMPLATE_PP_SSE2