Commit 40fa5140 authored by Ramiro Polla's avatar Ramiro Polla

swscale: Use function pointers for swScale functions.

Originally committed as revision 29145 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
parent 14d5c18c
......@@ -1776,42 +1776,55 @@ static void globalInit(void){
}
}
static SwsFunc getSwsFunc(int flags)
static SwsFunc getSwsFunc(SwsContext *c)
{
int flags = c->flags;
#if defined(RUNTIME_CPUDETECT) && CONFIG_GPL
#if ARCH_X86
// ordered per speed fastest first
if (flags & SWS_CPU_CAPS_MMX2) {
sws_init_swScale_MMX2(c);
return swScale_MMX2;
} else if (flags & SWS_CPU_CAPS_3DNOW) {
sws_init_swScale_3DNow(c);
return swScale_3DNow;
} else if (flags & SWS_CPU_CAPS_MMX) {
sws_init_swScale_MMX(c);
return swScale_MMX;
} else {
sws_init_swScale_C(c);
return swScale_C;
}
#else
#if ARCH_PPC
if (flags & SWS_CPU_CAPS_ALTIVEC) {
sws_init_swScale_altivec(c);
return swScale_altivec;
} else {
sws_init_swScale_C(c);
return swScale_C;
}
#endif
sws_init_swScale_C(c);
return swScale_C;
#endif /* ARCH_X86 */
#else //RUNTIME_CPUDETECT
#if HAVE_MMX2
sws_init_swScale_MMX2(c);
return swScale_MMX2;
#elif HAVE_AMD3DNOW
sws_init_swScale_3DNow(c);
return swScale_3DNow;
#elif HAVE_MMX
sws_init_swScale_MMX(c);
return swScale_MMX;
#elif HAVE_ALTIVEC
sws_init_swScale_altivec(c);
return swScale_altivec;
#else
sws_init_swScale_C(c);
return swScale_C;
#endif
#endif //!RUNTIME_CPUDETECT
......@@ -2932,7 +2945,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH, c->chrXInc, c->chrYInc);
}
c->swScale= getSwsFunc(flags);
c->swScale= getSwsFunc(c);
return c;
}
......
......@@ -214,6 +214,57 @@ typedef struct SwsContext{
uint64_t sparc_coeffs[10] __attribute__((aligned(8)));
#endif
/* function pointers for swScale() */
void (*yuv2nv12X )(struct SwsContext *c,
const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest,
int dstW, int chrDstW, int dstFormat);
void (*yuv2yuv1 )(struct SwsContext *c,
const int16_t *lumSrc, const int16_t *chrSrc, const int16_t *alpSrc,
uint8_t *dest,
uint8_t *uDest, uint8_t *vDest, uint8_t *aDest,
long dstW, long chrDstW);
void (*yuv2yuvX )(struct SwsContext *c,
const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
const int16_t **alpSrc,
uint8_t *dest,
uint8_t *uDest, uint8_t *vDest, uint8_t *aDest,
long dstW, long chrDstW);
void (*yuv2packed1)(struct SwsContext *c,
const uint16_t *buf0,
const uint16_t *uvbuf0, const uint16_t *uvbuf1,
const uint16_t *abuf0,
uint8_t *dest,
int dstW, int uvalpha, int dstFormat, int flags, int y);
void (*yuv2packed2)(struct SwsContext *c,
const uint16_t *buf0, const uint16_t *buf1,
const uint16_t *uvbuf0, const uint16_t *uvbuf1,
const uint16_t *abuf0, const uint16_t *abuf1,
uint8_t *dest,
int dstW, int yalpha, int uvalpha, int y);
void (*yuv2packedX)(struct SwsContext *c,
const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
const int16_t **alpSrc, uint8_t *dest,
long dstW, long dstY);
void (*hyscale_internal)(uint8_t *dst, const uint8_t *src,
long width, uint32_t *pal);
void (*hcscale_internal)(uint8_t *dstU, uint8_t *dstV,
const uint8_t *src1, const uint8_t *src2,
long width, uint32_t *pal);
void (*hyscale_fast)(struct SwsContext *c,
int16_t *dst, int dstWidth,
const uint8_t *src, int srcW, int xInc);
void (*hcscale_fast)(struct SwsContext *c,
int16_t *dst, int dstWidth,
const uint8_t *src1, const uint8_t *src2, int srcW, int xInc);
void (*hScale)(int16_t *dst, int dstW, const uint8_t *src, int srcW,
int xInc, const int16_t *filter, const int16_t *filterPos, long filterSize);
} SwsContext;
//FIXME check init (where 0)
......
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