comparison libswscale/swscale.c @ 21683:befebdb3ebaa

Allow to compile swscale's non-SIMD code under the LGPL license. Since mplayer always define CONFIG_GPL, this commit should not change anything for mplayer.
author lucabe
date Wed, 20 Dec 2006 13:09:29 +0000
parents 1f2ba24b4e47
children 5ff16d925594
comparison
equal deleted inserted replaced
21682:67e1aa5951e9 21683:befebdb3ebaa
147 optimize bgr24 & bgr32 147 optimize bgr24 & bgr32
148 add BGR4 output support 148 add BGR4 output support
149 write special BGR->BGR scaler 149 write special BGR->BGR scaler
150 */ 150 */
151 151
152 #if defined(ARCH_X86) 152 #if defined(ARCH_X86) && defined (CONFIG_GPL)
153 static uint64_t attribute_used __attribute__((aligned(8))) bF8= 0xF8F8F8F8F8F8F8F8LL; 153 static uint64_t attribute_used __attribute__((aligned(8))) bF8= 0xF8F8F8F8F8F8F8F8LL;
154 static uint64_t attribute_used __attribute__((aligned(8))) bFC= 0xFCFCFCFCFCFCFCFCLL; 154 static uint64_t attribute_used __attribute__((aligned(8))) bFC= 0xFCFCFCFCFCFCFCFCLL;
155 static uint64_t __attribute__((aligned(8))) w10= 0x0010001000100010LL; 155 static uint64_t __attribute__((aligned(8))) w10= 0x0010001000100010LL;
156 static uint64_t attribute_used __attribute__((aligned(8))) w02= 0x0002000200020002LL; 156 static uint64_t attribute_used __attribute__((aligned(8))) w02= 0x0002000200020002LL;
157 static uint64_t attribute_used __attribute__((aligned(8))) bm00001111=0x00000000FFFFFFFFLL; 157 static uint64_t attribute_used __attribute__((aligned(8))) bm00001111=0x00000000FFFFFFFFLL;
288 default: 288 default:
289 return "Unknown format"; 289 return "Unknown format";
290 } 290 }
291 } 291 }
292 292
293 #if defined(ARCH_X86) 293 #if defined(ARCH_X86) && defined (CONFIG_GPL)
294 void in_asm_used_var_warning_killer() 294 void in_asm_used_var_warning_killer()
295 { 295 {
296 volatile int i= bF8+bFC+w10+ 296 volatile int i= bF8+bFC+w10+
297 bm00001111+bm00000111+bm11111000+b16Mask+g16Mask+r16Mask+b15Mask+g15Mask+r15Mask+ 297 bm00001111+bm00000111+bm11111000+b16Mask+g16Mask+r16Mask+b15Mask+g15Mask+r15Mask+
298 M24A+M24B+M24C+w02 + b5Dither+g5Dither+r5Dither+g6Dither+dither4[0]+dither8[0]+bm01010101; 298 M24A+M24B+M24C+w02 + b5Dither+g5Dither+r5Dither+g6Dither+dither4[0]+dither8[0]+bm01010101;
801 } 801 }
802 802
803 803
804 //Note: we have C, X86, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one 804 //Note: we have C, X86, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one
805 //Plain C versions 805 //Plain C versions
806 #if !defined (HAVE_MMX) || defined (RUNTIME_CPUDETECT) 806 #if !defined (HAVE_MMX) || defined (RUNTIME_CPUDETECT) || !defined(CONFIG_GPL)
807 #define COMPILE_C 807 #define COMPILE_C
808 #endif 808 #endif
809 809
810 #ifdef ARCH_POWERPC 810 #ifdef ARCH_POWERPC
811 #if defined (HAVE_ALTIVEC) || defined (RUNTIME_CPUDETECT) 811 #if (defined (HAVE_ALTIVEC) || defined (RUNTIME_CPUDETECT)) && defined (CONFIG_GPL)
812 #define COMPILE_ALTIVEC 812 #define COMPILE_ALTIVEC
813 #endif //HAVE_ALTIVEC 813 #endif //HAVE_ALTIVEC
814 #endif //ARCH_POWERPC 814 #endif //ARCH_POWERPC
815 815
816 #if defined(ARCH_X86) 816 #if defined(ARCH_X86)
817 817
818 #if (defined (HAVE_MMX) && !defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT) 818 #if ((defined (HAVE_MMX) && !defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)) && defined (CONFIG_GPL)
819 #define COMPILE_MMX 819 #define COMPILE_MMX
820 #endif 820 #endif
821 821
822 #if defined (HAVE_MMX2) || defined (RUNTIME_CPUDETECT) 822 #if (defined (HAVE_MMX2) || defined (RUNTIME_CPUDETECT)) && defined (CONFIG_GPL)
823 #define COMPILE_MMX2 823 #define COMPILE_MMX2
824 #endif 824 #endif
825 825
826 #if (defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT) 826 #if ((defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)) && defined (CONFIG_GPL)
827 #define COMPILE_3DNOW 827 #define COMPILE_3DNOW
828 #endif 828 #endif
829 #endif //ARCH_X86 || ARCH_X86_64 829 #endif //ARCH_X86 || ARCH_X86_64
830 830
831 #undef HAVE_MMX 831 #undef HAVE_MMX
1468 } 1468 }
1469 } 1469 }
1470 1470
1471 static SwsFunc getSwsFunc(int flags){ 1471 static SwsFunc getSwsFunc(int flags){
1472 1472
1473 #ifdef RUNTIME_CPUDETECT 1473 #if defined(RUNTIME_CPUDETECT) && defined (CONFIG_GPL)
1474 #if defined(ARCH_X86) 1474 #if defined(ARCH_X86)
1475 // ordered per speed fasterst first 1475 // ordered per speed fasterst first
1476 if(flags & SWS_CPU_CAPS_MMX2) 1476 if(flags & SWS_CPU_CAPS_MMX2)
1477 return swScale_MMX2; 1477 return swScale_MMX2;
1478 else if(flags & SWS_CPU_CAPS_3DNOW) 1478 else if(flags & SWS_CPU_CAPS_3DNOW)
1946 #if defined(ARCH_X86) 1946 #if defined(ARCH_X86)
1947 if(flags & SWS_CPU_CAPS_MMX) 1947 if(flags & SWS_CPU_CAPS_MMX)
1948 asm volatile("emms\n\t"::: "memory"); 1948 asm volatile("emms\n\t"::: "memory");
1949 #endif 1949 #endif
1950 1950
1951 #ifndef RUNTIME_CPUDETECT //ensure that the flags match the compiled variant if cpudetect is off 1951 #if !defined(RUNTIME_CPUDETECT) || !defined (CONFIG_GPL) //ensure that the flags match the compiled variant if cpudetect is off
1952 flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC); 1952 flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC);
1953 #ifdef HAVE_MMX2 1953 #ifdef HAVE_MMX2
1954 flags |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2; 1954 flags |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2;
1955 #elif defined (HAVE_3DNOW) 1955 #elif defined (HAVE_3DNOW)
1956 flags |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_3DNOW; 1956 flags |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_3DNOW;
2056 /* yv12_to_nv12 */ 2056 /* yv12_to_nv12 */
2057 if(srcFormat == PIX_FMT_YUV420P && (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21)) 2057 if(srcFormat == PIX_FMT_YUV420P && (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21))
2058 { 2058 {
2059 c->swScale= PlanarToNV12Wrapper; 2059 c->swScale= PlanarToNV12Wrapper;
2060 } 2060 }
2061 #ifdef CONFIG_GPL
2061 /* yuv2bgr */ 2062 /* yuv2bgr */
2062 if((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P) && (isBGR(dstFormat) || isRGB(dstFormat))) 2063 if((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P) && (isBGR(dstFormat) || isRGB(dstFormat)))
2063 { 2064 {
2064 c->swScale= yuv2rgb_get_func_ptr(c); 2065 c->swScale= yuv2rgb_get_func_ptr(c);
2065 } 2066 }
2067 #endif
2066 2068
2067 if( srcFormat==PIX_FMT_YUV410P && dstFormat==PIX_FMT_YUV420P ) 2069 if( srcFormat==PIX_FMT_YUV410P && dstFormat==PIX_FMT_YUV420P )
2068 { 2070 {
2069 c->swScale= yvu9toyv12Wrapper; 2071 c->swScale= yvu9toyv12Wrapper;
2070 } 2072 }
2800 av_free(c->hLumFilterPos); 2802 av_free(c->hLumFilterPos);
2801 c->hLumFilterPos = NULL; 2803 c->hLumFilterPos = NULL;
2802 av_free(c->hChrFilterPos); 2804 av_free(c->hChrFilterPos);
2803 c->hChrFilterPos = NULL; 2805 c->hChrFilterPos = NULL;
2804 2806
2805 #if defined(ARCH_X86) 2807 #if defined(ARCH_X86) && defined(CONFIG_GPL)
2806 #ifdef MAP_ANONYMOUS 2808 #ifdef MAP_ANONYMOUS
2807 if(c->funnyYCode) munmap(c->funnyYCode, MAX_FUNNY_CODE_SIZE); 2809 if(c->funnyYCode) munmap(c->funnyYCode, MAX_FUNNY_CODE_SIZE);
2808 if(c->funnyUVCode) munmap(c->funnyUVCode, MAX_FUNNY_CODE_SIZE); 2810 if(c->funnyUVCode) munmap(c->funnyUVCode, MAX_FUNNY_CODE_SIZE);
2809 #else 2811 #else
2810 av_free(c->funnyYCode); 2812 av_free(c->funnyYCode);