Commit 9bde778e authored by Luca Abeni's avatar Luca Abeni

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.

Originally committed as revision 21699 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
parent ff8dc81b
......@@ -9,10 +9,15 @@ endif
EXTRALIBS := -L$(BUILD_ROOT)/libavutil -lavutil$(BUILDSUF) $(EXTRALIBS)
OBJS= swscale.o rgb2rgb.o yuv2rgb.o
OBJS= swscale.o rgb2rgb.o
ifeq ($(TARGET_ALTIVEC),yes)
OBJS+= yuv2rgb_altivec.o
endif
ifeq ($(CONFIG_GPL),yes)
OBJS+= yuv2rgb.o
else
OBJS+= yuv2rgb_init.o
endif
HEADERS = swscale.h rgb2rgb.h
......
......@@ -91,7 +91,7 @@ void (*yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2, const uint8_t *sr
long srcStride1, long srcStride2,
long srcStride3, long dstStride);
#if defined(ARCH_X86)
#if defined(ARCH_X86) && defined(CONFIG_GPL)
static const uint64_t mmx_null __attribute__((aligned(8))) = 0x0000000000000000ULL;
static const uint64_t mmx_one __attribute__((aligned(8))) = 0xFFFFFFFFFFFFFFFFULL;
static const uint64_t mask32b attribute_used __attribute__((aligned(8))) = 0x000000FF000000FFULL;
......@@ -175,7 +175,7 @@ static uint64_t __attribute__((aligned(8))) dither8[2]={
#define RENAME(a) a ## _C
#include "rgb2rgb_template.c"
#if defined(ARCH_X86)
#if defined(ARCH_X86) && defined(CONFIG_GPL)
//MMX versions
#undef RENAME
......@@ -214,7 +214,7 @@ static uint64_t __attribute__((aligned(8))) dither8[2]={
*/
void sws_rgb2rgb_init(int flags){
#if defined(HAVE_MMX2) || defined(HAVE_3DNOW) || defined(HAVE_MMX)
#if (defined(HAVE_MMX2) || defined(HAVE_3DNOW) || defined(HAVE_MMX)) && defined(CONFIG_GPL)
if(flags & SWS_CPU_CAPS_MMX2){
rgb15to16= rgb15to16_MMX2;
rgb15to24= rgb15to24_MMX2;
......
......@@ -149,7 +149,7 @@ add BGR4 output support
write special BGR->BGR scaler
*/
#if defined(ARCH_X86)
#if defined(ARCH_X86) && defined (CONFIG_GPL)
static uint64_t attribute_used __attribute__((aligned(8))) bF8= 0xF8F8F8F8F8F8F8F8LL;
static uint64_t attribute_used __attribute__((aligned(8))) bFC= 0xFCFCFCFCFCFCFCFCLL;
static uint64_t __attribute__((aligned(8))) w10= 0x0010001000100010LL;
......@@ -290,7 +290,7 @@ char *sws_format_name(enum PixelFormat format)
}
}
#if defined(ARCH_X86)
#if defined(ARCH_X86) && defined (CONFIG_GPL)
void in_asm_used_var_warning_killer()
{
volatile int i= bF8+bFC+w10+
......@@ -803,27 +803,27 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
//Note: we have C, X86, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one
//Plain C versions
#if !defined (HAVE_MMX) || defined (RUNTIME_CPUDETECT)
#if !defined (HAVE_MMX) || defined (RUNTIME_CPUDETECT) || !defined(CONFIG_GPL)
#define COMPILE_C
#endif
#ifdef ARCH_POWERPC
#if defined (HAVE_ALTIVEC) || defined (RUNTIME_CPUDETECT)
#if (defined (HAVE_ALTIVEC) || defined (RUNTIME_CPUDETECT)) && defined (CONFIG_GPL)
#define COMPILE_ALTIVEC
#endif //HAVE_ALTIVEC
#endif //ARCH_POWERPC
#if defined(ARCH_X86)
#if (defined (HAVE_MMX) && !defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)
#if ((defined (HAVE_MMX) && !defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)) && defined (CONFIG_GPL)
#define COMPILE_MMX
#endif
#if defined (HAVE_MMX2) || defined (RUNTIME_CPUDETECT)
#if (defined (HAVE_MMX2) || defined (RUNTIME_CPUDETECT)) && defined (CONFIG_GPL)
#define COMPILE_MMX2
#endif
#if (defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)
#if ((defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)) && defined (CONFIG_GPL)
#define COMPILE_3DNOW
#endif
#endif //ARCH_X86 || ARCH_X86_64
......@@ -1470,7 +1470,7 @@ static void globalInit(void){
static SwsFunc getSwsFunc(int flags){
#ifdef RUNTIME_CPUDETECT
#if defined(RUNTIME_CPUDETECT) && defined (CONFIG_GPL)
#if defined(ARCH_X86)
// ordered per speed fasterst first
if(flags & SWS_CPU_CAPS_MMX2)
......@@ -1948,7 +1948,7 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
asm volatile("emms\n\t"::: "memory");
#endif
#ifndef RUNTIME_CPUDETECT //ensure that the flags match the compiled variant if cpudetect is off
#if !defined(RUNTIME_CPUDETECT) || !defined (CONFIG_GPL) //ensure that the flags match the compiled variant if cpudetect is off
flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC);
#ifdef HAVE_MMX2
flags |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2;
......@@ -2058,11 +2058,13 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
{
c->swScale= PlanarToNV12Wrapper;
}
#ifdef CONFIG_GPL
/* yuv2bgr */
if((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P) && (isBGR(dstFormat) || isRGB(dstFormat)))
{
c->swScale= yuv2rgb_get_func_ptr(c);
}
#endif
if( srcFormat==PIX_FMT_YUV410P && dstFormat==PIX_FMT_YUV420P )
{
......@@ -2802,7 +2804,7 @@ void sws_freeContext(SwsContext *c){
av_free(c->hChrFilterPos);
c->hChrFilterPos = NULL;
#if defined(ARCH_X86)
#if defined(ARCH_X86) && defined(CONFIG_GPL)
#ifdef MAP_ANONYMOUS
if(c->funnyYCode) munmap(c->funnyYCode, MAX_FUNNY_CODE_SIZE);
if(c->funnyUVCode) munmap(c->funnyUVCode, MAX_FUNNY_CODE_SIZE);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment