diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2002-02-06 22:55:57 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2002-02-06 22:55:57 +0000 |
commit | a861d4d7f3a715fe33da2d2742b5d75a5e02b6ba (patch) | |
tree | bfd57456b41872b19f167816ad0e1662f89ecea7 /postproc/swscale_template.c | |
parent | b6654a5464a77bb885ce0d17224f9edbe07d67ba (diff) | |
download | ffmpeg-a861d4d7f3a715fe33da2d2742b5d75a5e02b6ba.tar.gz |
rgb32 & rgb24 input support
squished a endianness bug in the 15/16bgr output
Originally committed as revision 4559 to svn://svn.mplayerhq.hu/mplayer/trunk/postproc
Diffstat (limited to 'postproc/swscale_template.c')
-rw-r--r-- | postproc/swscale_template.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/postproc/swscale_template.c b/postproc/swscale_template.c index b56d414984..a98bb2c96e 100644 --- a/postproc/swscale_template.c +++ b/postproc/swscale_template.c @@ -1666,6 +1666,60 @@ static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1 #endif } +static inline void RENAME(rgb32ToY)(uint8_t *dst, uint8_t *src, int width) +{ + int i; + for(i=0; i<width; i++) + { + int r= src[i*4+0]; + int g= src[i*4+1]; + int b= src[i*4+2]; + + dst[i]= ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; + } +} + +static inline void RENAME(rgb32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) +{ + int i; + for(i=0; i<width; i++) + { + int r= src1[8*i + 0] + src1[8*i + 4] + src2[8*i + 0] + src2[8*i + 4]; + int g= src1[8*i + 1] + src1[8*i + 5] + src2[8*i + 1] + src2[8*i + 5]; + int b= src1[8*i + 2] + src1[8*i + 6] + src2[8*i + 2] + src2[8*i + 6]; + + dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; + dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; + } +} + +static inline void RENAME(rgb24ToY)(uint8_t *dst, uint8_t *src, int width) +{ + int i; + for(i=0; i<width; i++) + { + int r= src[i*3+0]; + int g= src[i*3+1]; + int b= src[i*3+2]; + + dst[i]= ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; + } +} + +static inline void RENAME(rgb24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) +{ + int i; + for(i=0; i<width; i++) + { + int r= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3]; + int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4]; + int b= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5]; + + dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; + dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; + } +} + // Bilinear / Bicubic scaling static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc, @@ -1849,6 +1903,16 @@ static inline void RENAME(hyscale)(uint16_t *dst, int dstWidth, uint8_t *src, in RENAME(bgr24ToY)(formatConvBuffer, src, srcW); src= formatConvBuffer; } + else if(srcFormat==IMGFMT_RGB32) + { + RENAME(rgb32ToY)(formatConvBuffer, src, srcW); + src= formatConvBuffer; + } + else if(srcFormat==IMGFMT_RGB24) + { + RENAME(rgb24ToY)(formatConvBuffer, src, srcW); + src= formatConvBuffer; + } #ifdef HAVE_MMX // use the new MMX scaler if th mmx2 cant be used (its faster than the x86asm one) @@ -1996,6 +2060,18 @@ inline static void RENAME(hcscale)(uint16_t *dst, int dstWidth, uint8_t *src1, u src1= formatConvBuffer; src2= formatConvBuffer+2048; } + else if(srcFormat==IMGFMT_RGB32) + { + RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); + src1= formatConvBuffer; + src2= formatConvBuffer+2048; + } + else if(srcFormat==IMGFMT_RGB24) + { + RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); + src1= formatConvBuffer; + src2= formatConvBuffer+2048; + } else if(isGray(srcFormat)) { return; |