summaryrefslogtreecommitdiffstats
path: root/libswscale
diff options
context:
space:
mode:
authormichael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-09-10 03:42:45 +0000
committermichael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-09-10 03:42:45 +0000
commitd49d2d9a864cf36e8b16208e0f9c1e9c8bbc7e89 (patch)
tree8c488e5aab6863b2a9b97125778948d57bcae07e /libswscale
parent50e3ffeacb7485c160e71f94692f052612745346 (diff)
downloadmpv-d49d2d9a864cf36e8b16208e0f9c1e9c8bbc7e89.tar.bz2
mpv-d49d2d9a864cf36e8b16208e0f9c1e9c8bbc7e89.tar.xz
Factorize rgb/bgr15/16/32->Y by using the preprocessor.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27565 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libswscale')
-rw-r--r--libswscale/swscale_template.c101
1 files changed, 20 insertions, 81 deletions
diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c
index b4456c3bc8..50fd6921c6 100644
--- a/libswscale/swscale_template.c
+++ b/libswscale/swscale_template.c
@@ -1843,19 +1843,28 @@ static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1,
assert(src1 == src2);
}
-static inline void RENAME(bgr32ToY)(uint8_t *dst, uint8_t *src, long width)
-{
- int i;
- for (i=0; i<width; i++)
- {
- int b= ((uint32_t*)src)[i]&0xFF;
- int g= (((uint32_t*)src)[i]>>8)&0xFF;
- int r= (((uint32_t*)src)[i]>>16)&0xFF;
-
- dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT);
- }
+#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)\
+{\
+ 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;\
+\
+ dst[i]= (((RY)*r + (GY)*g + (BY)*b + (33<<((S)-1)))>>(S));\
+ }\
}
+BGR2Y(uint32_t, bgr32ToY,16, 0, 0, 0x00FF, 0xFF00, 0x00FF, RY<< 8, GY , BY<< 8, RGB2YUV_SHIFT+8)
+BGR2Y(uint32_t, rgb32ToY, 0, 0,16, 0x00FF, 0xFF00, 0x00FF, RY<< 8, GY , BY<< 8, RGB2YUV_SHIFT+8)
+BGR2Y(uint16_t, bgr16ToY, 0, 0, 0, 0x001F, 0x07E0, 0xF800, RY<<11, GY<<5, BY , RGB2YUV_SHIFT+8)
+BGR2Y(uint16_t, bgr15ToY, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, RY<<10, GY<<5, BY , RGB2YUV_SHIFT+7)
+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(bgr32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
{
int i;
@@ -2052,20 +2061,6 @@ static inline void RENAME(bgr24ToUV_half)(uint8_t *dstU, uint8_t *dstV, uint8_t
assert(src1 == src2);
}
-static inline void RENAME(rgb16ToY)(uint8_t *dst, uint8_t *src, long width)
-{
- int i;
- for (i=0; i<width; i++)
- {
- int d= ((uint16_t*)src)[i];
- int b= d&0x1F;
- int g= (d>>5)&0x3F;
- int r= (d>>11)&0x1F;
-
- dst[i]= (2*RY*r + GY*g + 2*BY*b + (33<<(RGB2YUV_SHIFT-3)))>>(RGB2YUV_SHIFT-2);
- }
-}
-
static inline void RENAME(rgb16ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
{
int i;
@@ -2104,20 +2099,6 @@ static inline void RENAME(rgb16ToUV_half)(uint8_t *dstU, uint8_t *dstV, uint8_t
}
}
-static inline void RENAME(rgb15ToY)(uint8_t *dst, uint8_t *src, long width)
-{
- int i;
- for (i=0; i<width; i++)
- {
- int d= ((uint16_t*)src)[i];
- int b= d&0x1F;
- int g= (d>>5)&0x1F;
- int r= (d>>10)&0x1F;
-
- dst[i]= (RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-4)))>>(RGB2YUV_SHIFT-3);
- }
-}
-
static inline void RENAME(rgb15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
{
int i;
@@ -2156,20 +2137,6 @@ static inline void RENAME(rgb15ToUV_half)(uint8_t *dstU, uint8_t *dstV, uint8_t
}
}
-
-static inline void RENAME(rgb32ToY)(uint8_t *dst, uint8_t *src, long width)
-{
- int i;
- for (i=0; i<width; i++)
- {
- int r= ((uint32_t*)src)[i]&0xFF;
- int g= (((uint32_t*)src)[i]>>8)&0xFF;
- int b= (((uint32_t*)src)[i]>>16)&0xFF;
-
- dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT);
- }
-}
-
static inline void RENAME(rgb32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
{
int i;
@@ -2255,20 +2222,6 @@ static inline void RENAME(rgb24ToUV_half)(uint8_t *dstU, uint8_t *dstV, uint8_t
}
}
-static inline void RENAME(bgr16ToY)(uint8_t *dst, uint8_t *src, long width)
-{
- int i;
- for (i=0; i<width; i++)
- {
- int d= ((uint16_t*)src)[i];
- int r= d&0x1F;
- int g= (d>>5)&0x3F;
- int b= (d>>11)&0x1F;
-
- dst[i]= (2*RY*r + GY*g + 2*BY*b + (33<<(RGB2YUV_SHIFT-3)))>>(RGB2YUV_SHIFT-2);
- }
-}
-
static inline void RENAME(bgr16ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
{
int i;
@@ -2304,20 +2257,6 @@ static inline void RENAME(bgr16ToUV_half)(uint8_t *dstU, uint8_t *dstV, uint8_t
}
}
-static inline void RENAME(bgr15ToY)(uint8_t *dst, uint8_t *src, long width)
-{
- int i;
- for (i=0; i<width; i++)
- {
- int d= ((uint16_t*)src)[i];
- int r= d&0x1F;
- int g= (d>>5)&0x1F;
- int b= (d>>10)&0x1F;
-
- dst[i]= (RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-4)))>>(RGB2YUV_SHIFT-3);
- }
-}
-
static inline void RENAME(bgr15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
{
int i;