summaryrefslogtreecommitdiffstats
path: root/libswscale/swscale_template.c
diff options
context:
space:
mode:
Diffstat (limited to 'libswscale/swscale_template.c')
-rw-r--r--libswscale/swscale_template.c441
1 files changed, 180 insertions, 261 deletions
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
int i;
if (flags & SWS_ACCURATE_RND){
@@ -3094,7 +2922,7 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s
if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21){
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if (dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
- RENAME(yuv2nv12X)(c,
+ c->yuv2nv12X(c,
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
dest, uDest, dstW, chrDstW, dstFormat);
@@ -3108,11 +2936,11 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s
int16_t *lumBuf = lumPixBuf[0];
int16_t *chrBuf= chrPixBuf[0];
int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpPixBuf[0] : NULL;
- RENAME(yuv2yuv1)(c, lumBuf, chrBuf, alpBuf, dest, uDest, vDest, aDest, dstW, chrDstW);
+ c->yuv2yuv1(c, lumBuf, chrBuf, alpBuf, dest, uDest, vDest, aDest, dstW, chrDstW);
}
else //General YV12
{
- RENAME(yuv2yuvX)(c,
+ c->yuv2yuvX(c,
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW);
@@ -3131,7 +2959,7 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
}else{
- RENAME(yuv2packed1)(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1),
+ c->yuv2packed1(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1),
alpPixBuf ? *alpSrcPtr : NULL,
dest, dstW, chrAlpha, dstFormat, flags, dstY);
}
@@ -3150,7 +2978,7 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
}else{
- RENAME(yuv2packed2)(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1),
+ c->yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1),
alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL,
dest, dstW, lumAlpha, chrAlpha, dstY);
}
@@ -3163,7 +2991,7 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
}else{
- RENAME(yuv2packedX)(c,
+ c->yuv2packedX(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
@@ -3173,9 +3001,9 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s
}
else // hmm looks like we can't use MMX here without overwriting this array's tail
{
- 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 (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21){
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if (dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
@@ -3230,3 +3058,94 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s
return dstY - lastDstY;
}
+
+static void RENAME(sws_init_swScale)(SwsContext *c)
+{
+ enum PixelFormat srcFormat = c->srcFormat;
+
+ c->yuv2nv12X = RENAME(yuv2nv12X );
+ c->yuv2yuv1 = RENAME(yuv2yuv1 );
+ c->yuv2yuvX = RENAME(yuv2yuvX );
+ c->yuv2packed1 = RENAME(yuv2packed1 );
+ c->yuv2packed2 = RENAME(yuv2packed2 );
+ c->yuv2packedX = RENAME(yuv2packedX );
+
+ c->hScale = RENAME(hScale );
+
+ c->hyscale_fast = RENAME(hyscale_fast);
+ c->hcscale_fast = RENAME(hcscale_fast);
+
+ c->hcscale_internal = NULL;
+ switch(srcFormat) {
+ case PIX_FMT_YUYV422 : c->hcscale_internal = RENAME(yuy2ToUV); break;
+ case PIX_FMT_UYVY422 : c->hcscale_internal = RENAME(uyvyToUV); break;
+ case PIX_FMT_RGB8 :
+ case PIX_FMT_BGR8 :
+ case PIX_FMT_PAL8 :
+ case PIX_FMT_BGR4_BYTE:
+ case PIX_FMT_RGB4_BYTE: c->hcscale_internal = RENAME(palToUV); break;
+ }
+ if (c->chrSrcHSubSample) {
+ switch(srcFormat) {
+ case PIX_FMT_RGB32 :
+ case PIX_FMT_RGB32_1: c->hcscale_internal = RENAME(bgr32ToUV_half); break;
+ case PIX_FMT_BGR24 : c->hcscale_internal = RENAME(bgr24ToUV_half); break;
+ case PIX_FMT_BGR565 : c->hcscale_internal = RENAME(bgr16ToUV_half); break;
+ case PIX_FMT_BGR555 : c->hcscale_internal = RENAME(bgr15ToUV_half); break;
+ case PIX_FMT_BGR32 :
+ case PIX_FMT_BGR32_1: c->hcscale_internal = RENAME(rgb32ToUV_half); break;
+ case PIX_FMT_RGB24 : c->hcscale_internal = RENAME(rgb24ToUV_half); break;
+ case PIX_FMT_RGB565 : c->hcscale_internal = RENAME(rgb16ToUV_half); break;
+ case PIX_FMT_RGB555 : c->hcscale_internal = RENAME(rgb15ToUV_half); break;
+ }
+ } else {
+ switch(srcFormat) {
+ case PIX_FMT_RGB32 :
+ case PIX_FMT_RGB32_1: c->hcscale_internal = RENAME(bgr32ToUV); break;
+ case PIX_FMT_BGR24 : c->hcscale_internal = RENAME(bgr24ToUV); break;
+ case PIX_FMT_BGR565 : c->hcscale_internal = RENAME(bgr16ToUV); break;
+ case PIX_FMT_BGR555 : c->hcscale_internal = RENAME(bgr15ToUV); break;
+ case PIX_FMT_BGR32 :
+ case PIX_FMT_BGR32_1: c->hcscale_internal = RENAME(rgb32ToUV); break;
+ case PIX_FMT_RGB24 : c->hcscale_internal = RENAME(rgb24ToUV); break;
+ case PIX_FMT_RGB565 : c->hcscale_internal = RENAME(rgb16ToUV); break;
+ case PIX_FMT_RGB555 : c->hcscale_internal = RENAME(rgb15ToUV); break;
+ }
+ }
+
+ c->hyscale_internal = NULL;
+ switch (srcFormat) {
+ case PIX_FMT_YUYV422 :
+ case PIX_FMT_GRAY16BE : c->hyscale_internal = RENAME(yuy2ToY); break;
+ case PIX_FMT_UYVY422 :
+ case PIX_FMT_GRAY16LE : c->hyscale_internal = RENAME(uyvyToY); break;
+ case PIX_FMT_BGR24 : c->hyscale_internal = RENAME(bgr24ToY); break;
+ case PIX_FMT_BGR565 : c->hyscale_internal = RENAME(bgr16ToY); break;
+ case PIX_FMT_BGR555 : c->hyscale_internal = RENAME(bgr15ToY); break;
+ case PIX_FMT_RGB24 : c->hyscale_internal = RENAME(rgb24ToY); break;
+ case PIX_FMT_RGB565 : c->hyscale_internal = RENAME(rgb16ToY); break;
+ case PIX_FMT_RGB555 : c->hyscale_internal = RENAME(rgb15ToY); break;
+ case PIX_FMT_RGB8 :
+ case PIX_FMT_BGR8 :
+ case PIX_FMT_PAL8 :
+ case PIX_FMT_BGR4_BYTE:
+ case PIX_FMT_RGB4_BYTE: c->hyscale_internal = RENAME(palToY); break;
+ case PIX_FMT_MONOBLACK: c->hyscale_internal = RENAME(monoblack2Y); break;
+ case PIX_FMT_MONOWHITE: c->hyscale_internal = RENAME(monowhite2Y); break;
+ }
+ if (c->alpPixBuf) {
+ switch (srcFormat) {
+ case PIX_FMT_RGB32 :
+ case PIX_FMT_RGB32_1:
+ case PIX_FMT_BGR32 :
+ case PIX_FMT_BGR32_1: c->hyscale_internal = RENAME(abgrToA); break;
+ }
+ } else {
+ switch (srcFormat) {
+ case PIX_FMT_RGB32 :
+ case PIX_FMT_RGB32_1: c->hyscale_internal = RENAME(bgr32ToY); break;
+ case PIX_FMT_BGR32 :
+ case PIX_FMT_BGR32_1: c->hyscale_internal = RENAME(rgb32ToY); break;
+ }
+ }
+}