From c28ed102eaac6814959a0668de8be2f39b9c46a5 Mon Sep 17 00:00:00 2001 From: lucabe Date: Thu, 2 Nov 2006 09:01:01 +0000 Subject: Add support for conversions from the rgb565 and rgb555 formats git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@20605 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale.c | 2 +- libswscale/swscale_template.c | 93 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) (limited to 'libswscale') diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 09261e61bf..1502b7bce6 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -109,7 +109,7 @@ untested special converters #define isSupportedIn(x) ((x)==PIX_FMT_YUV420P || (x)==PIX_FMT_YUYV422 || (x)==PIX_FMT_UYVY422\ || (x)==PIX_FMT_RGB32|| (x)==PIX_FMT_BGR24|| (x)==PIX_FMT_BGR565|| (x)==PIX_FMT_BGR555\ - || (x)==PIX_FMT_BGR32|| (x)==PIX_FMT_RGB24\ + || (x)==PIX_FMT_BGR32|| (x)==PIX_FMT_RGB24|| (x)==PIX_FMT_RGB565|| (x)==PIX_FMT_RGB555\ || (x)==PIX_FMT_GRAY8 || (x)==PIX_FMT_YUV410P\ || (x)==PIX_FMT_GRAY16BE || (x)==PIX_FMT_GRAY16LE\ || (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_YUV422P || (x)==PIX_FMT_YUV411P) diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c index b9b264bc62..773f8f7811 100644 --- a/libswscale/swscale_template.c +++ b/libswscale/swscale_template.c @@ -2246,6 +2246,77 @@ static inline void RENAME(rgb24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1 } } +static inline void RENAME(rgb16ToY)(uint8_t *dst, uint8_t *src, int width) +{ + int i; + for(i=0; i>5)&0x3F; + int b= (d>>11)&0x1F; + + dst[i]= ((2*RY*r + GY*g + 2*BY*b)>>(RGB2YUV_SHIFT-2)) + 16; + } +} + +static inline void RENAME(rgb16ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) +{ + int i; + for(i=0; i>5)&0x07C0F83F) + ((d1>>5)&0x07C0F83F); + + int dh2= (dh>>11) + (dh<<21); + int d= dh2 + dl; + + int r= d&0x7F; + int b= (d>>11)&0x7F; + int g= d>>21; + dstU[i]= ((2*RU*r + GU*g + 2*BU*b)>>(RGB2YUV_SHIFT+2-2)) + 128; + dstV[i]= ((2*RV*r + GV*g + 2*BV*b)>>(RGB2YUV_SHIFT+2-2)) + 128; + } +} + +static inline void RENAME(rgb15ToY)(uint8_t *dst, uint8_t *src, int width) +{ + int i; + for(i=0; i>5)&0x1F; + int b= (d>>10)&0x1F; + + dst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16; + } +} + +static inline void RENAME(rgb15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) +{ + int i; + for(i=0; i>5)&0x03E0F81F) + ((d1>>5)&0x03E0F81F); + + int dh2= (dh>>11) + (dh<<21); + int d= dh2 + dl; + + int g= d&0x7F; + int r= (d>>10)&0x7F; + int b= d>>21; + dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2-3)) + 128; + dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2-3)) + 128; + } +} // Bilinear / Bicubic scaling static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc, @@ -2477,6 +2548,16 @@ static inline void RENAME(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, i RENAME(rgb24ToY)(formatConvBuffer, src, srcW); src= formatConvBuffer; } + else if(srcFormat==PIX_FMT_RGB565) + { + RENAME(rgb16ToY)(formatConvBuffer, src, srcW); + src= formatConvBuffer; + } + else if(srcFormat==PIX_FMT_RGB555) + { + RENAME(rgb15ToY)(formatConvBuffer, src, srcW); + src= formatConvBuffer; + } #ifdef HAVE_MMX // use the new MMX scaler if the mmx2 can't be used (its faster than the x86asm one) @@ -2672,6 +2753,18 @@ inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1, src1= formatConvBuffer; src2= formatConvBuffer+2048; } + else if(srcFormat==PIX_FMT_RGB565) + { + RENAME(rgb16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); + src1= formatConvBuffer; + src2= formatConvBuffer+2048; + } + else if(srcFormat==PIX_FMT_RGB555) + { + RENAME(rgb15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); + src1= formatConvBuffer; + src2= formatConvBuffer+2048; + } else if(isGray(srcFormat)) { return; -- cgit v1.2.3