summaryrefslogtreecommitdiffstats
path: root/libswscale
diff options
context:
space:
mode:
Diffstat (limited to 'libswscale')
-rw-r--r--libswscale/swscale.c68
-rw-r--r--libswscale/swscale_internal.h51
-rw-r--r--libswscale/swscale_template.c441
3 files changed, 268 insertions, 292 deletions
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 316f4517e4..4799542421 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -472,9 +472,9 @@ const char *sws_format_name(enum PixelFormat format)
}
}
-static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
- int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
- int16_t **alpSrc, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, int dstW, int chrDstW)
+static inline void yuv2yuvXinC(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, int dstW, int chrDstW)
{
//FIXME Optimize (just quickly written not optimized..)
int i;
@@ -516,8 +516,8 @@ static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilt
}
-static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
- int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
+static inline void yuv2nv12XinC(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)
{
//FIXME Optimize (just quickly written not optimized..)
@@ -993,17 +993,17 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
}\
-static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
- int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
- int16_t **alpSrc, uint8_t *dest, int dstW, int y)
+static inline void yuv2packedXinC(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, int dstW, int y)
{
int i;
YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGBX_C, YSCALE_YUV_2_PACKEDX_C(void,0), YSCALE_YUV_2_GRAY16_C, YSCALE_YUV_2_MONOX_C)
}
-static inline void yuv2rgbXinC_full(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
- int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
- int16_t **alpSrc, uint8_t *dest, int dstW, int y)
+static inline void yuv2rgbXinC_full(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, int dstW, int y)
{
int i;
int step= fmt_depth(c->dstFormat)/8;
@@ -1094,7 +1094,7 @@ static void fillPlane(uint8_t* plane, int stride, int width, int height, int y,
}
}
-//Note: we have C, X86, MMX, MMX2, 3DNOW versions, there is no 3DNOW+MMX2 one
+//Note: we have C, MMX, MMX2, 3DNOW versions, there is no 3DNOW+MMX2 one
//Plain C versions
#if !HAVE_MMX || defined (RUNTIME_CPUDETECT) || !CONFIG_GPL
#define COMPILE_C
@@ -1146,16 +1146,6 @@ static void fillPlane(uint8_t* plane, int stride, int width, int height, int y,
#if ARCH_X86
-//x86 versions
-/*
-#undef RENAME
-#undef HAVE_MMX
-#undef HAVE_MMX2
-#undef HAVE_AMD3DNOW
-#define ARCH_X86
-#define RENAME(a) a ## _X86
-#include "swscale_template.c"
-*/
//MMX versions
#ifdef COMPILE_MMX
#undef RENAME
@@ -1776,39 +1766,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)
+ if (flags & SWS_CPU_CAPS_MMX2) {
+ sws_init_swScale_MMX2(c);
return swScale_MMX2;
- else if (flags & SWS_CPU_CAPS_3DNOW)
+ } else if (flags & SWS_CPU_CAPS_3DNOW) {
+ sws_init_swScale_3DNow(c);
return swScale_3DNow;
- else if (flags & SWS_CPU_CAPS_MMX)
+ } else if (flags & SWS_CPU_CAPS_MMX) {
+ sws_init_swScale_MMX(c);
return swScale_MMX;
- else
+ } else {
+ sws_init_swScale_C(c);
return swScale_C;
+ }
#else
#if ARCH_PPC
- if (flags & SWS_CPU_CAPS_ALTIVEC)
+ if (flags & SWS_CPU_CAPS_ALTIVEC) {
+ sws_init_swScale_altivec(c);
return swScale_altivec;
- else
+ } 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
@@ -1823,7 +1829,7 @@ static int PlanarToNV12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], i
else
{
int i;
- uint8_t *srcPtr= src[0];
+ const uint8_t *srcPtr= src[0];
uint8_t *dstPtr= dst;
for (i=0; i<srcSliceH; i++)
{
@@ -2929,7 +2935,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;
}
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 785c00aa3c..070161900b 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -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)
diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c
index 4562866b7b..49ce0d32d5 100644
--- a/libswscale/swscale_template.c
+++ b/libswscale/swscale_template.c
@@ -901,8 +901,8 @@
#define WRITEYUY2(dst, dstw, index) REAL_WRITEYUY2(dst, dstw, index)
-static inline void RENAME(yuv2yuvX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
- int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, int16_t **alpSrc,
+static inline void RENAME(yuv2yuvX)(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)
{
#if HAVE_MMX
@@ -942,8 +942,8 @@ yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize,
#endif //!HAVE_ALTIVEC
}
-static inline void RENAME(yuv2nv12X)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
- int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
+static inline void RENAME(yuv2nv12X)(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)
{
yuv2nv12XinC(lumFilter, lumSrc, lumFilterSize,
@@ -951,7 +951,7 @@ yuv2nv12XinC(lumFilter, lumSrc, lumFilterSize,
dest, uDest, dstW, chrDstW, dstFormat);
}
-static inline void RENAME(yuv2yuv1)(SwsContext *c, int16_t *lumSrc, int16_t *chrSrc, int16_t *alpSrc,
+static inline void RENAME(yuv2yuv1)(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)
{
int i;
@@ -1028,9 +1028,9 @@ static inline void RENAME(yuv2yuv1)(SwsContext *c, int16_t *lumSrc, int16_t *chr
/**
* vertical scale YV12 to RGB
*/
-static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
- int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
- int16_t **alpSrc, uint8_t *dest, long dstW, long dstY)
+static inline void RENAME(yuv2packedX)(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)
{
#if HAVE_MMX
x86_reg dummy=0;
@@ -1214,8 +1214,8 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_
/**
* vertical bilinear scale YV12 to RGB
*/
-static inline void RENAME(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, uint16_t *uvbuf1,
- uint16_t *abuf0, uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
+static inline void RENAME(yuv2packed2)(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)
{
int yalpha1=4095- yalpha;
int uvalpha1=4095-uvalpha;
@@ -1364,18 +1364,18 @@ YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C(void,0), YSCAL
/**
* YV12 to RGB without scaling or interpolating
*/
-static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *uvbuf0, uint16_t *uvbuf1,
- uint16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int dstFormat, int flags, int y)
+static inline void RENAME(yuv2packed1)(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)
{
const int yalpha1=0;
int i;
- uint16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
+ const uint16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
const int yalpha= 4096; //FIXME ...
if (flags&SWS_FULL_CHR_H_INT)
{
- RENAME(yuv2packed2)(c, buf0, buf0, uvbuf0, uvbuf1, abuf0, abuf0, dest, dstW, 0, uvalpha, y);
+ c->yuv2packed2(c, buf0, buf0, uvbuf0, uvbuf1, abuf0, abuf0, dest, dstW, 0, uvalpha, y);
return;
}
@@ -1611,7 +1611,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *
//FIXME yuy2* can read up to 7 samples too much
-static inline void RENAME(yuy2ToY)(uint8_t *dst, uint8_t *src, long width, uint32_t *unused)
+static inline void RENAME(yuy2ToY)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)
{
#if HAVE_MMX
__asm__ volatile(
@@ -1636,7 +1636,7 @@ static inline void RENAME(yuy2ToY)(uint8_t *dst, uint8_t *src, long width, uint3
#endif
}
-static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width, uint32_t *unused)
+static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
{
#if HAVE_MMX
__asm__ volatile(
@@ -1673,7 +1673,7 @@ static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1,
/* This is almost identical to the previous, end exists only because
* yuy2ToY/UV)(dst, src+1, ...) would have 100% unaligned accesses. */
-static inline void RENAME(uyvyToY)(uint8_t *dst, uint8_t *src, long width, uint32_t *unused)
+static inline void RENAME(uyvyToY)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)
{
#if HAVE_MMX
__asm__ volatile(
@@ -1697,7 +1697,7 @@ static inline void RENAME(uyvyToY)(uint8_t *dst, uint8_t *src, long width, uint3
#endif
}
-static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width, uint32_t *unused)
+static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
{
#if HAVE_MMX
__asm__ volatile(
@@ -1733,14 +1733,14 @@ static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1,
}
#define BGR2Y(type, name, shr, shg, shb, maskr, maskg, maskb, RY, GY, BY, S)\
-static inline void RENAME(name)(uint8_t *dst, uint8_t *src, long width, uint32_t *unused)\
+static inline void RENAME(name)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)\
{\
int i;\
for (i=0; i<width; i++)\
{\
- int b= (((type*)src)[i]>>shb)&maskb;\
- int g= (((type*)src)[i]>>shg)&maskg;\
- int r= (((type*)src)[i]>>shr)&maskr;\
+ int b= (((const type*)src)[i]>>shb)&maskb;\
+ int g= (((const type*)src)[i]>>shg)&maskg;\
+ int r= (((const type*)src)[i]>>shr)&maskr;\
\
dst[i]= (((RY)*r + (GY)*g + (BY)*b + (33<<((S)-1)))>>(S));\
}\
@@ -1753,7 +1753,7 @@ BGR2Y(uint16_t, bgr15ToY, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, RY<<10, GY<<5, BY
BGR2Y(uint16_t, rgb16ToY, 0, 0, 0, 0xF800, 0x07E0, 0x001F, RY , GY<<5, BY<<11, RGB2YUV_SHIFT+8)
BGR2Y(uint16_t, rgb15ToY, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, RY , GY<<5, BY<<10, RGB2YUV_SHIFT+7)
-static inline void RENAME(abgrToA)(uint8_t *dst, uint8_t *src, long width, uint32_t *unused){
+static inline void RENAME(abgrToA)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused){
int i;
for (i=0; i<width; i++){
dst[i]= src[4*i];
@@ -1761,26 +1761,26 @@ static inline void RENAME(abgrToA)(uint8_t *dst, uint8_t *src, long width, uint3
}
#define BGR2UV(type, name, shr, shg, shb, maska, maskr, maskg, maskb, RU, GU, BU, RV, GV, BV, S)\
-static inline void RENAME(name)(uint8_t *dstU, uint8_t *dstV, uint8_t *src, uint8_t *dummy, long width, uint32_t *unused)\
+static inline void RENAME(name)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, const uint8_t *dummy, long width, uint32_t *unused)\
{\
int i;\
for (i=0; i<width; i++)\
{\
- int b= (((type*)src)[i]&maskb)>>shb;\
- int g= (((type*)src)[i]&maskg)>>shg;\
- int r= (((type*)src)[i]&maskr)>>shr;\
+ int b= (((const type*)src)[i]&maskb)>>shb;\
+ int g= (((const type*)src)[i]&maskg)>>shg;\
+ int r= (((const type*)src)[i]&maskr)>>shr;\
\
dstU[i]= ((RU)*r + (GU)*g + (BU)*b + (257<<((S)-1)))>>(S);\
dstV[i]= ((RV)*r + (GV)*g + (BV)*b + (257<<((S)-1)))>>(S);\
}\
}\
-static inline void RENAME(name ## _half)(uint8_t *dstU, uint8_t *dstV, uint8_t *src, uint8_t *dummy, long width, uint32_t *unused)\
+static inline void RENAME(name ## _half)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, const uint8_t *dummy, long width, uint32_t *unused)\
{\
int i;\
for (i=0; i<width; i++)\
{\
- int pix0= ((type*)src)[2*i+0];\
- int pix1= ((type*)src)[2*i+1];\
+ int pix0= ((const type*)src)[2*i+0];\
+ int pix1= ((const type*)src)[2*i+1];\
int g= (pix0&~(maskr|maskb))+(pix1&~(maskr|maskb));\
int b= ((pix0+pix1-g)&(maskb|(2*maskb)))>>shb;\
int r= ((pix0+pix1-g)&(maskr|(2*maskr)))>>shr;\
@@ -1801,7 +1801,7 @@ BGR2UV(uint16_t, rgb16ToUV, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, RU
BGR2UV(uint16_t, rgb15ToUV, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, RU , GU<<5, BU<<10, RV , GV<<5, BV<<10, RGB2YUV_SHIFT+7)
#if HAVE_MMX
-static inline void RENAME(bgr24ToY_mmx)(uint8_t *dst, uint8_t *src, long width, int srcFormat)
+static inline void RENAME(bgr24ToY_mmx)(uint8_t *dst, const uint8_t *src, long width, int srcFormat)
{
if(srcFormat == PIX_FMT_BGR24){
@@ -1854,7 +1854,7 @@ static inline void RENAME(bgr24ToY_mmx)(uint8_t *dst, uint8_t *src, long width,
);
}
-static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, uint8_t *src, long width, int srcFormat)
+static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, long width, int srcFormat)
{
__asm__ volatile(
"movq 24+%4, %%mm6 \n\t"
@@ -1913,7 +1913,7 @@ static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, uint8_t *
}
#endif
-static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, long width, uint32_t *unused)
+static inline void RENAME(bgr24ToY)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)
{
#if HAVE_MMX
RENAME(bgr24ToY_mmx)(dst, src, width, PIX_FMT_BGR24);
@@ -1930,7 +1930,7 @@ static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, long width, uint
#endif /* HAVE_MMX */
}
-static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width, uint32_t *unused)
+static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
{
#if HAVE_MMX
RENAME(bgr24ToUV_mmx)(dstU, dstV, src1, width, PIX_FMT_BGR24);
@@ -1949,7 +1949,7 @@ static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1
assert(src1 == src2);
}
-static inline void RENAME(bgr24ToUV_half)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width, uint32_t *unused)
+static inline void RENAME(bgr24ToUV_half)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
{
int i;
for (i=0; i<width; i++)
@@ -1964,7 +1964,7 @@ static inline void RENAME(bgr24ToUV_half)(uint8_t *dstU, uint8_t *dstV, uint8_t
assert(src1 == src2);
}
-static inline void RENAME(rgb24ToY)(uint8_t *dst, uint8_t *src, long width, uint32_t *unused)
+static inline void RENAME(rgb24ToY)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)
{
#if HAVE_MMX
RENAME(bgr24ToY_mmx)(dst, src, width, PIX_FMT_RGB24);
@@ -1981,7 +1981,7 @@ static inline void RENAME(rgb24ToY)(uint8_t *dst, uint8_t *src, long width, uint
#endif
}
-static inline void RENAME(rgb24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width, uint32_t *unused)
+static inline void RENAME(rgb24ToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
{
#if HAVE_MMX
assert(src1==src2);
@@ -2001,7 +2001,7 @@ static inline void RENAME(rgb24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1
#endif
}
-static inline void RENAME(rgb24ToUV_half)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width, uint32_t *unused)
+static inline void RENAME(rgb24ToUV_half)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
{
int i;
assert(src1==src2);
@@ -2017,7 +2017,7 @@ static inline void RENAME(rgb24ToUV_half)(uint8_t *dstU, uint8_t *dstV, uint8_t
}
-static inline void RENAME(palToY)(uint8_t *dst, uint8_t *src, long width, uint32_t *pal)
+static inline void RENAME(palToY)(uint8_t *dst, const uint8_t *src, long width, uint32_t *pal)
{
int i;
for (i=0; i<width; i++)
@@ -2028,7 +2028,9 @@ static inline void RENAME(palToY)(uint8_t *dst, uint8_t *src, long width, uint32
}
}
-static inline void RENAME(palToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width, uint32_t *pal)
+static inline void RENAME(palToUV)(uint8_t *dstU, uint8_t *dstV,
+ const uint8_t *src1, const uint8_t *src2,
+ long width, uint32_t *pal)
{
int i;
assert(src1 == src2);
@@ -2041,7 +2043,7 @@ static inline void RENAME(palToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1,
}
}
-static inline void RENAME(monowhite2Y)(uint8_t *dst, uint8_t *src, long width, uint32_t *unused)
+static inline void RENAME(monowhite2Y)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)
{
int i, j;
for (i=0; i<width/8; i++){
@@ -2051,7 +2053,7 @@ static inline void RENAME(monowhite2Y)(uint8_t *dst, uint8_t *src, long width, u
}
}
-static inline void RENAME(monoblack2Y)(uint8_t *dst, uint8_t *src, long width, uint32_t *unused)
+static inline void RENAME(monoblack2Y)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)
{
int i, j;
for (i=0; i<width/8; i++){
@@ -2062,8 +2064,8 @@ static inline void RENAME(monoblack2Y)(uint8_t *dst, uint8_t *src, long width, u
}
// bilinear / bicubic scaling
-static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc,
- int16_t *filter, int16_t *filterPos, long filterSize)
+static inline void RENAME(hScale)(int16_t *dst, int dstW, const uint8_t *src, int srcW, int xInc,
+ const int16_t *filter, const int16_t *filterPos, long filterSize)
{
#if HAVE_MMX
assert(filterSize % 4 == 0 && filterSize>0);
@@ -2245,7 +2247,7 @@ static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW
}
static inline void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
- int dstWidth, uint8_t *src, int srcW,
+ int dstWidth, const uint8_t *src, int srcW,
int xInc)
{
int i;
@@ -2260,9 +2262,9 @@ static inline void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
}
// *** horizontal scale Y line to temp buffer
-static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth, uint8_t *src, int srcW, int xInc,
- int flags, int16_t *hLumFilter,
- int16_t *hLumFilterPos, int hLumFilterSize,
+static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src, int srcW, int xInc,
+ int flags, const int16_t *hLumFilter,
+ const int16_t *hLumFilterPos, int hLumFilterSize,
int srcFormat, uint8_t *formatConvBuffer,
uint32_t *pal, int isAlpha)
{
@@ -2271,91 +2273,16 @@ static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth,
int canMMX2BeUsed = c->canMMX2BeUsed;
void *funnyYCode = c->funnyYCode;
- if (srcFormat==PIX_FMT_YUYV422 || srcFormat==PIX_FMT_GRAY16BE)
- {
- RENAME(yuy2ToY)(formatConvBuffer, src, srcW, pal);
- src= formatConvBuffer;
- }
- else if (srcFormat==PIX_FMT_UYVY422 || srcFormat==PIX_FMT_GRAY16LE)
- {
- RENAME(uyvyToY)(formatConvBuffer, src, srcW, pal);
- src= formatConvBuffer;
- }
- else if (srcFormat==PIX_FMT_RGB32)
- {
- if (isAlpha)
- RENAME(abgrToA)(formatConvBuffer, src+3, srcW, pal);
- else
- RENAME(bgr32ToY)(formatConvBuffer, src, srcW, pal);
- src= formatConvBuffer;
- }
- else if (srcFormat==PIX_FMT_RGB32_1)
- {
- if (isAlpha)
- RENAME(abgrToA)(formatConvBuffer, src, srcW, pal);
- else
- RENAME(bgr32ToY)(formatConvBuffer, src+ALT32_CORR, srcW, pal);
- src= formatConvBuffer;
- }
- else if (srcFormat==PIX_FMT_BGR24)
- {
- RENAME(bgr24ToY)(formatConvBuffer, src, srcW, pal);
- src= formatConvBuffer;
- }
- else if (srcFormat==PIX_FMT_BGR565)
- {
- RENAME(bgr16ToY)(formatConvBuffer, src, srcW, pal);
- src= formatConvBuffer;
- }
- else if (srcFormat==PIX_FMT_BGR555)
- {
- RENAME(bgr15ToY)(formatConvBuffer, src, srcW, pal);
- src= formatConvBuffer;
- }
- else if (srcFormat==PIX_FMT_BGR32)
- {
- if (isAlpha)
- RENAME(abgrToA)(formatConvBuffer, src+3, srcW, pal);
- else
- RENAME(rgb32ToY)(formatConvBuffer, src, srcW, pal);
- src= formatConvBuffer;
- }
- else if (srcFormat==PIX_FMT_BGR32_1)
- {
- if (isAlpha)
- RENAME(abgrToA)(formatConvBuffer, src, srcW, pal);
- else
- RENAME(rgb32ToY)(formatConvBuffer, src+ALT32_CORR, srcW, pal);
- src= formatConvBuffer;
+ if (isAlpha) {
+ if (srcFormat == PIX_FMT_RGB32 || srcFormat == PIX_FMT_BGR32 )
+ src += 3;
+ } else {
+ if (srcFormat == PIX_FMT_RGB32_1 || srcFormat == PIX_FMT_BGR32_1)
+ src += ALT32_CORR;
}
- else if (srcFormat==PIX_FMT_RGB24)
- {
- RENAME(rgb24ToY)(formatConvBuffer, src, srcW, pal);
- src= formatConvBuffer;
- }
- else if (srcFormat==PIX_FMT_RGB565)
- {
- RENAME(rgb16ToY)(formatConvBuffer, src, srcW, pal);
- src= formatConvBuffer;
- }
- else if (srcFormat==PIX_FMT_RGB555)
- {
- RENAME(rgb15ToY)(formatConvBuffer, src, srcW, pal);
- src= formatConvBuffer;
- }
- else if (srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8 || srcFormat==PIX_FMT_BGR4_BYTE || srcFormat==PIX_FMT_RGB4_BYTE)
- {
- RENAME(palToY)(formatConvBuffer, src, srcW, pal);
- src= formatConvBuffer;
- }
- else if (srcFormat==PIX_FMT_MONOBLACK)
- {
- RENAME(monoblack2Y)(formatConvBuffer, src, srcW, pal);
- src= formatConvBuffer;
- }
- else if (srcFormat==PIX_FMT_MONOWHITE)
- {
- RENAME(monowhite2Y)(formatConvBuffer, src, srcW, pal);
+
+ if (c->hyscale_internal) {
+ c->hyscale_internal(formatConvBuffer, src, srcW, pal);
src= formatConvBuffer;
}
@@ -2366,7 +2293,7 @@ static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth,
if (!(flags&SWS_FAST_BILINEAR))
#endif
{
- RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
+ c->hScale(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
}
else // fast bilinear upscale / crap downscale
{
@@ -2486,7 +2413,7 @@ FUNNY_Y_CODE
} //if MMX2 can't be used
#endif
#else
- RENAME(hyscale_fast)(c, dst, dstWidth, src, srcW, xInc);
+ c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc);
#endif /* ARCH_X86 */
}
@@ -2505,8 +2432,8 @@ FUNNY_Y_CODE
}
static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst,
- int dstWidth, uint8_t *src1,
- uint8_t *src2, int srcW, int xInc)
+ int dstWidth, const uint8_t *src1,
+ const uint8_t *src2, int srcW, int xInc)
{
int i;
unsigned int xpos=0;
@@ -2524,9 +2451,9 @@ static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst,
}
}
-inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2,
- int srcW, int xInc, int flags, int16_t *hChrFilter,
- int16_t *hChrFilterPos, int hChrFilterSize,
+inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src1, const uint8_t *src2,
+ int srcW, int xInc, int flags, const int16_t *hChrFilter,
+ const int16_t *hChrFilterPos, int hChrFilterSize,
int srcFormat, uint8_t *formatConvBuffer,
uint32_t *pal)
{
@@ -2535,115 +2462,16 @@ inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth,
int canMMX2BeUsed = c->canMMX2BeUsed;
void *funnyUVCode = c->funnyUVCode;
- if (srcFormat==PIX_FMT_YUYV422)
- {
- RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- src1= formatConvBuffer;
- src2= formatConvBuffer+VOFW;
- }
- else if (srcFormat==PIX_FMT_UYVY422)
- {
- RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- src1= formatConvBuffer;
- src2= formatConvBuffer+VOFW;
- }
- else if (srcFormat==PIX_FMT_RGB32)
- {
- if(c->chrSrcHSubSample)
- RENAME(bgr32ToUV_half)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- else
- RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- src1= formatConvBuffer;
- src2= formatConvBuffer+VOFW;
- }
- else if (srcFormat==PIX_FMT_RGB32_1)
- {
- if(c->chrSrcHSubSample)
- RENAME(bgr32ToUV_half)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW, pal);
- else
- RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW, pal);
- src1= formatConvBuffer;
- src2= formatConvBuffer+VOFW;
- }
- else if (srcFormat==PIX_FMT_BGR24)
- {
- if(c->chrSrcHSubSample)
- RENAME(bgr24ToUV_half)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- else
- RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- src1= formatConvBuffer;
- src2= formatConvBuffer+VOFW;
- }
- else if (srcFormat==PIX_FMT_BGR565)
- {
- if(c->chrSrcHSubSample)
- RENAME(bgr16ToUV_half)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- else
- RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- src1= formatConvBuffer;
- src2= formatConvBuffer+VOFW;
- }
- else if (srcFormat==PIX_FMT_BGR555)
- {
- if(c->chrSrcHSubSample)
- RENAME(bgr15ToUV_half)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- else
- RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- src1= formatConvBuffer;
- src2= formatConvBuffer+VOFW;
- }
- else if (srcFormat==PIX_FMT_BGR32)
- {
- if(c->chrSrcHSubSample)
- RENAME(rgb32ToUV_half)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- else
- RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- src1= formatConvBuffer;
- src2= formatConvBuffer+VOFW;
- }
- else if (srcFormat==PIX_FMT_BGR32_1)
- {
- if(c->chrSrcHSubSample)
- RENAME(rgb32ToUV_half)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW, pal);
- else
- RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW, pal);
- src1= formatConvBuffer;
- src2= formatConvBuffer+VOFW;
- }
- else if (srcFormat==PIX_FMT_RGB24)
- {
- if(c->chrSrcHSubSample)
- RENAME(rgb24ToUV_half)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- else
- RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- src1= formatConvBuffer;
- src2= formatConvBuffer+VOFW;
- }
- else if (srcFormat==PIX_FMT_RGB565)
- {
- if(c->chrSrcHSubSample)
- RENAME(rgb16ToUV_half)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- else
- RENAME(rgb16ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- src1= formatConvBuffer;
- src2= formatConvBuffer+VOFW;
- }
- else if (srcFormat==PIX_FMT_RGB555)
- {
- if(c->chrSrcHSubSample)
- RENAME(rgb15ToUV_half)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- else
- RENAME(rgb15ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
- src1= formatConvBuffer;
- src2= formatConvBuffer+VOFW;
- }
- else if (isGray(srcFormat) || srcFormat==PIX_FMT_MONOBLACK || srcFormat==PIX_FMT_MONOWHITE)
- {
+ if (isGray(srcFormat) || srcFormat==PIX_FMT_MONOBLACK || srcFormat==PIX_FMT_MONOWHITE)
return;
+
+ if (srcFormat==PIX_FMT_RGB32_1) {
+ src1 += ALT32_CORR;
+ src2 += ALT32_CORR;
}
- else if (srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8 || srcFormat==PIX_FMT_BGR4_BYTE || srcFormat==PIX_FMT_RGB4_BYTE)
- {
- RENAME(palToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
+
+ if (c->hcscale_internal) {
+ c->hcscale_internal(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
@@ -2655,8 +2483,8 @@ inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth,
if (!(flags&SWS_FAST_BILINEAR))
#endif
{
- RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
- RENAME(hScale)(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
+ c->hScale(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
+ c->hScale(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
}
else // fast bilinear upscale / crap downscale
{
@@ -2792,7 +2620,7 @@ FUNNY_UV_CODE
} //if MMX2 can't be used
#endif
#else
- RENAME(hcscale_fast)(c, dst, dstWidth, src1, src2, srcW, xInc);
+ c->hcscale_fast(c, dst, dstWidth, src1, src2, srcW, xInc);
#endif /* ARCH_X86 */
}
if(c->srcRange != c->dstRange && !(isRGB(c->dstFormat) || isBGR(c->dstFormat))){
@@ -3039,9 +2867,9 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s
#endif
if (dstY < dstH-2)
{
- int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
- int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
- int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
+ const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
+ const int16_t **chrSrcPtr= (const int16_t **) chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
+ const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
#if HAVE_MMX