comparison postprocess.c @ 118:bdd1788fb53b libpostproc

Change semantic of CONFIG_*, HAVE_* and ARCH_*. They are now always defined to either 0 or 1.
author aurel
date Tue, 13 Jan 2009 23:44:16 +0000
parents 3a76063f4145
children dd89aa84269b
comparison
equal deleted inserted replaced
117:3a76063f4145 118:bdd1788fb53b
90 unsigned postproc_version(void) 90 unsigned postproc_version(void)
91 { 91 {
92 return LIBPOSTPROC_VERSION_INT; 92 return LIBPOSTPROC_VERSION_INT;
93 } 93 }
94 94
95 #ifdef HAVE_ALTIVEC_H 95 #if HAVE_ALTIVEC_H
96 #include <altivec.h> 96 #include <altivec.h>
97 #endif 97 #endif
98 98
99 #define GET_MODE_BUFFER_SIZE 500 99 #define GET_MODE_BUFFER_SIZE 500
100 #define OPTIONS_ARRAY_SIZE 10 100 #define OPTIONS_ARRAY_SIZE 10
101 #define BLOCK_SIZE 8 101 #define BLOCK_SIZE 8
102 #define TEMP_STRIDE 8 102 #define TEMP_STRIDE 8
103 //#define NUM_BLOCKS_AT_ONCE 16 //not used yet 103 //#define NUM_BLOCKS_AT_ONCE 16 //not used yet
104 104
105 #if defined(ARCH_X86) 105 #if ARCH_X86
106 DECLARE_ASM_CONST(8, uint64_t, w05)= 0x0005000500050005LL; 106 DECLARE_ASM_CONST(8, uint64_t, w05)= 0x0005000500050005LL;
107 DECLARE_ASM_CONST(8, uint64_t, w04)= 0x0004000400040004LL; 107 DECLARE_ASM_CONST(8, uint64_t, w04)= 0x0004000400040004LL;
108 DECLARE_ASM_CONST(8, uint64_t, w20)= 0x0020002000200020LL; 108 DECLARE_ASM_CONST(8, uint64_t, w20)= 0x0020002000200020LL;
109 DECLARE_ASM_CONST(8, uint64_t, b00)= 0x0000000000000000LL; 109 DECLARE_ASM_CONST(8, uint64_t, b00)= 0x0000000000000000LL;
110 DECLARE_ASM_CONST(8, uint64_t, b01)= 0x0101010101010101LL; 110 DECLARE_ASM_CONST(8, uint64_t, b01)= 0x0101010101010101LL;
148 "ac", "ha:a:128:7,va:a,dr:a", 148 "ac", "ha:a:128:7,va:a,dr:a",
149 NULL //End Marker 149 NULL //End Marker
150 }; 150 };
151 151
152 152
153 #if defined(ARCH_X86) 153 #if ARCH_X86
154 static inline void prefetchnta(void *p) 154 static inline void prefetchnta(void *p)
155 { 155 {
156 __asm__ volatile( "prefetchnta (%0)\n\t" 156 __asm__ volatile( "prefetchnta (%0)\n\t"
157 : : "r" (p) 157 : : "r" (p)
158 ); 158 );
552 }*/ 552 }*/
553 } 553 }
554 554
555 //Note: we have C, MMX, MMX2, 3DNOW version there is no 3DNOW+MMX2 one 555 //Note: we have C, MMX, MMX2, 3DNOW version there is no 3DNOW+MMX2 one
556 //Plain C versions 556 //Plain C versions
557 #if !(defined (HAVE_MMX) || defined (HAVE_ALTIVEC)) || defined (RUNTIME_CPUDETECT) 557 #if !(HAVE_MMX || HAVE_ALTIVEC) || defined (RUNTIME_CPUDETECT)
558 #define COMPILE_C 558 #define COMPILE_C
559 #endif 559 #endif
560 560
561 #ifdef HAVE_ALTIVEC 561 #if HAVE_ALTIVEC
562 #define COMPILE_ALTIVEC 562 #define COMPILE_ALTIVEC
563 #endif //HAVE_ALTIVEC 563 #endif //HAVE_ALTIVEC
564 564
565 #if defined(ARCH_X86) 565 #if ARCH_X86
566 566
567 #if (defined (HAVE_MMX) && !defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT) 567 #if (HAVE_MMX && !HAVE_3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)
568 #define COMPILE_MMX 568 #define COMPILE_MMX
569 #endif 569 #endif
570 570
571 #if defined (HAVE_MMX2) || defined (RUNTIME_CPUDETECT) 571 #if HAVE_MMX2 || defined (RUNTIME_CPUDETECT)
572 #define COMPILE_MMX2 572 #define COMPILE_MMX2
573 #endif 573 #endif
574 574
575 #if (defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT) 575 #if (HAVE_3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)
576 #define COMPILE_3DNOW 576 #define COMPILE_3DNOW
577 #endif 577 #endif
578 #endif /* defined(ARCH_X86) */ 578 #endif /* ARCH_X86 */
579 579
580 #undef HAVE_MMX
581 #define HAVE_MMX 0
582 #undef HAVE_MMX2
583 #define HAVE_MMX2 0
584 #undef HAVE_3DNOW
585 #define HAVE_3DNOW 0
586 #undef HAVE_ALTIVEC
587 #define HAVE_ALTIVEC 0
588
589 #ifdef COMPILE_C
590 #define RENAME(a) a ## _C
591 #include "postprocess_template.c"
592 #endif
593
594 #ifdef COMPILE_ALTIVEC
595 #undef RENAME
596 #undef HAVE_ALTIVEC
597 #define HAVE_ALTIVEC 1
598 #define RENAME(a) a ## _altivec
599 #include "postprocess_altivec_template.c"
600 #include "postprocess_template.c"
601 #endif
602
603 //MMX versions
604 #ifdef COMPILE_MMX
605 #undef RENAME
606 #undef HAVE_MMX
607 #define HAVE_MMX 1
608 #define RENAME(a) a ## _MMX
609 #include "postprocess_template.c"
610 #endif
611
612 //MMX2 versions
613 #ifdef COMPILE_MMX2
614 #undef RENAME
615 #undef HAVE_MMX
616 #undef HAVE_MMX2
617 #define HAVE_MMX 1
618 #define HAVE_MMX2 1
619 #define RENAME(a) a ## _MMX2
620 #include "postprocess_template.c"
621 #endif
622
623 //3DNOW versions
624 #ifdef COMPILE_3DNOW
625 #undef RENAME
580 #undef HAVE_MMX 626 #undef HAVE_MMX
581 #undef HAVE_MMX2 627 #undef HAVE_MMX2
582 #undef HAVE_3DNOW 628 #undef HAVE_3DNOW
583 #undef HAVE_ALTIVEC 629 #define HAVE_MMX 1
584 630 #define HAVE_MMX2 0
585 #ifdef COMPILE_C 631 #define HAVE_3DNOW 1
586 #undef HAVE_MMX
587 #undef HAVE_MMX2
588 #undef HAVE_3DNOW
589 #define RENAME(a) a ## _C
590 #include "postprocess_template.c"
591 #endif
592
593 #ifdef COMPILE_ALTIVEC
594 #undef RENAME
595 #define HAVE_ALTIVEC
596 #define RENAME(a) a ## _altivec
597 #include "postprocess_altivec_template.c"
598 #include "postprocess_template.c"
599 #endif
600
601 //MMX versions
602 #ifdef COMPILE_MMX
603 #undef RENAME
604 #define HAVE_MMX
605 #undef HAVE_MMX2
606 #undef HAVE_3DNOW
607 #define RENAME(a) a ## _MMX
608 #include "postprocess_template.c"
609 #endif
610
611 //MMX2 versions
612 #ifdef COMPILE_MMX2
613 #undef RENAME
614 #define HAVE_MMX
615 #define HAVE_MMX2
616 #undef HAVE_3DNOW
617 #define RENAME(a) a ## _MMX2
618 #include "postprocess_template.c"
619 #endif
620
621 //3DNOW versions
622 #ifdef COMPILE_3DNOW
623 #undef RENAME
624 #define HAVE_MMX
625 #undef HAVE_MMX2
626 #define HAVE_3DNOW
627 #define RENAME(a) a ## _3DNow 632 #define RENAME(a) a ## _3DNow
628 #include "postprocess_template.c" 633 #include "postprocess_template.c"
629 #endif 634 #endif
630 635
631 // minor note: the HAVE_xyz is messed up after that line so do not use it. 636 // minor note: the HAVE_xyz is messed up after that line so do not use it.
639 644
640 // Using ifs here as they are faster than function pointers although the 645 // Using ifs here as they are faster than function pointers although the
641 // difference would not be measurable here but it is much better because 646 // difference would not be measurable here but it is much better because
642 // someone might exchange the CPU whithout restarting MPlayer ;) 647 // someone might exchange the CPU whithout restarting MPlayer ;)
643 #ifdef RUNTIME_CPUDETECT 648 #ifdef RUNTIME_CPUDETECT
644 #if defined(ARCH_X86) 649 #if ARCH_X86
645 // ordered per speed fastest first 650 // ordered per speed fastest first
646 if(c->cpuCaps & PP_CPU_CAPS_MMX2) 651 if(c->cpuCaps & PP_CPU_CAPS_MMX2)
647 postProcess_MMX2(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); 652 postProcess_MMX2(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
648 else if(c->cpuCaps & PP_CPU_CAPS_3DNOW) 653 else if(c->cpuCaps & PP_CPU_CAPS_3DNOW)
649 postProcess_3DNow(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); 654 postProcess_3DNow(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
650 else if(c->cpuCaps & PP_CPU_CAPS_MMX) 655 else if(c->cpuCaps & PP_CPU_CAPS_MMX)
651 postProcess_MMX(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); 656 postProcess_MMX(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
652 else 657 else
653 postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); 658 postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
654 #else 659 #else
655 #ifdef HAVE_ALTIVEC 660 #if HAVE_ALTIVEC
656 if(c->cpuCaps & PP_CPU_CAPS_ALTIVEC) 661 if(c->cpuCaps & PP_CPU_CAPS_ALTIVEC)
657 postProcess_altivec(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); 662 postProcess_altivec(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
658 else 663 else
659 #endif 664 #endif
660 postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); 665 postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
661 #endif 666 #endif
662 #else //RUNTIME_CPUDETECT 667 #else //RUNTIME_CPUDETECT
663 #ifdef HAVE_MMX2 668 #if HAVE_MMX2
664 postProcess_MMX2(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); 669 postProcess_MMX2(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
665 #elif defined (HAVE_3DNOW) 670 #elif HAVE_3DNOW
666 postProcess_3DNow(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); 671 postProcess_3DNow(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
667 #elif defined (HAVE_MMX) 672 #elif HAVE_MMX
668 postProcess_MMX(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); 673 postProcess_MMX(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
669 #elif defined (HAVE_ALTIVEC) 674 #elif HAVE_ALTIVEC
670 postProcess_altivec(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); 675 postProcess_altivec(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
671 #else 676 #else
672 postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); 677 postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
673 #endif 678 #endif
674 #endif //!RUNTIME_CPUDETECT 679 #endif //!RUNTIME_CPUDETECT