Mercurial > mplayer.hg
diff postproc/rgb2rgb_template.c @ 17586:65b39a32a7c4
Fix big-endian color permutation problems.
patch by Alan Curry, pacman_at_TheWorld_dot_com
author | diego |
---|---|
date | Sat, 11 Feb 2006 13:35:46 +0000 |
parents | e91f944f6ed9 |
children | 6a6db6b74735 |
line wrap: on
line diff
--- a/postproc/rgb2rgb_template.c Sat Feb 11 09:56:49 2006 +0000 +++ b/postproc/rgb2rgb_template.c Sat Feb 11 13:35:46 2006 +0000 @@ -104,10 +104,12 @@ while(s < end) { #ifdef WORDS_BIGENDIAN + /* RGB24 (= R,G,B) -> RGB32 (= A,B,G,R) */ *dest++ = 0; - *dest++ = *s++; - *dest++ = *s++; - *dest++ = *s++; + *dest++ = s[2]; + *dest++ = s[1]; + *dest++ = s[0]; + s+=3; #else *dest++ = *s++; *dest++ = *s++; @@ -188,10 +190,12 @@ while(s < end) { #ifdef WORDS_BIGENDIAN + /* RGB32 (= A,B,G,R) -> RGB24 (= R,G,B) */ s++; - *dest++ = *s++; - *dest++ = *s++; - *dest++ = *s++; + dest[2] = *s++; + dest[1] = *s++; + dest[0] = *s++; + dest += 3; #else *dest++ = *s++; *dest++ = *s++; @@ -465,6 +469,7 @@ while(s < end) { // FIXME on bigendian + /* Looks bigendian-OK to me. --Pac. */ const int src= *s; s += 4; *d++ = ((src&0xF8)<<8) + ((src&0xFC00)>>5) + ((src&0xF80000)>>19); } @@ -562,6 +567,7 @@ while(s < end) { // FIXME on bigendian + /* Looks bigendian-OK to me. --Pac. */ const int src= *s; s += 4; *d++ = ((src&0xFF)>>3) + ((src&0xF800)>>6) + ((src&0xF80000)>>9); } @@ -624,6 +630,7 @@ while(s < end) { // FIXME on bigendian + /* Looks bigendian-OK to me. --Pac. */ const int src= *s; s += 4; *d++ = ((src&0xF8)<<7) + ((src&0xF800)>>6) + ((src&0xF80000)>>19); } @@ -1247,14 +1254,13 @@ int bgr= *s++; *((uint32_t*)d)++ = ((bgr&0x1F)<<3) + ((bgr&0x3E0)<<6) + ((bgr&0x7C00)<<9); #else -//FIXME this is very likely wrong for bigendian (and the following converters too) register uint16_t bgr; bgr = *s++; #ifdef WORDS_BIGENDIAN *d++ = 0; - *d++ = (bgr&0x1F)<<3; + *d++ = (bgr&0x7C00)>>7; *d++ = (bgr&0x3E0)>>2; - *d++ = (bgr&0x7C00)>>7; + *d++ = (bgr&0x1F)<<3; #else *d++ = (bgr&0x1F)<<3; *d++ = (bgr&0x3E0)>>2; @@ -1326,9 +1332,9 @@ bgr = *s++; #ifdef WORDS_BIGENDIAN *d++ = 0; - *d++ = (bgr&0x1F)<<3; + *d++ = (bgr&0xF800)>>8; *d++ = (bgr&0x7E0)>>3; - *d++ = (bgr&0xF800)>>8; + *d++ = (bgr&0x1F)<<3; #else *d++ = (bgr&0x1F)<<3; *d++ = (bgr&0x7E0)>>3;