diff options
author | Alan Curry <pacman@world.std.com> | 2006-02-11 13:35:46 +0000 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2006-02-11 13:35:46 +0000 |
commit | f688668c3caf1413fb510070c140a37f2eb80971 (patch) | |
tree | 57429220a4613cf6c18962669f9ceaf78f295837 /postproc/rgb2rgb.c | |
parent | 0b2bb3543fabd38d6c98d5678dc4098ec5c37dec (diff) | |
download | ffmpeg-f688668c3caf1413fb510070c140a37f2eb80971.tar.gz |
Fix big-endian color permutation problems.
patch by Alan Curry, pacman_at_TheWorld_dot_com
Originally committed as revision 17587 to svn://svn.mplayerhq.hu/mplayer/trunk/postproc
Diffstat (limited to 'postproc/rgb2rgb.c')
-rw-r--r-- | postproc/rgb2rgb.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/postproc/rgb2rgb.c b/postproc/rgb2rgb.c index 94289a43bc..d7a3360be0 100644 --- a/postproc/rgb2rgb.c +++ b/postproc/rgb2rgb.c @@ -446,9 +446,16 @@ void rgb32tobgr24(const uint8_t *src, uint8_t *dst, long src_size) long num_pixels = src_size >> 2; for(i=0; i<num_pixels; i++) { + #ifdef WORDS_BIGENDIAN + /* RGB32 (= A,B,G,R) -> BGR24 (= B,G,R) */ + dst[3*i + 0] = src[4*i + 1]; + dst[3*i + 1] = src[4*i + 2]; + dst[3*i + 2] = src[4*i + 3]; + #else dst[3*i + 0] = src[4*i + 2]; dst[3*i + 1] = src[4*i + 1]; dst[3*i + 2] = src[4*i + 0]; + #endif } } @@ -457,10 +464,18 @@ void rgb24tobgr32(const uint8_t *src, uint8_t *dst, long src_size) long i; for(i=0; 3*i<src_size; i++) { + #ifdef WORDS_BIGENDIAN + /* RGB24 (= R,G,B) -> BGR32 (= A,R,G,B) */ + dst[4*i + 0] = 0; + dst[4*i + 1] = src[3*i + 0]; + dst[4*i + 2] = src[3*i + 1]; + dst[4*i + 3] = src[3*i + 2]; + #else dst[4*i + 0] = src[3*i + 2]; dst[4*i + 1] = src[3*i + 1]; dst[4*i + 2] = src[3*i + 0]; dst[4*i + 3] = 0; + #endif } } @@ -474,10 +489,17 @@ void rgb16tobgr32(const uint8_t *src, uint8_t *dst, long src_size) { register uint16_t bgr; bgr = *s++; + #ifdef WORDS_BIGENDIAN + *d++ = 0; + *d++ = (bgr&0x1F)<<3; + *d++ = (bgr&0x7E0)>>3; + *d++ = (bgr&0xF800)>>8; + #else *d++ = (bgr&0xF800)>>8; *d++ = (bgr&0x7E0)>>3; *d++ = (bgr&0x1F)<<3; *d++ = 0; + #endif } } @@ -541,10 +563,17 @@ void rgb15tobgr32(const uint8_t *src, uint8_t *dst, long src_size) { register uint16_t bgr; bgr = *s++; + #ifdef WORDS_BIGENDIAN + *d++ = 0; + *d++ = (bgr&0x1F)<<3; + *d++ = (bgr&0x3E0)>>2; + *d++ = (bgr&0x7C00)>>7; + #else *d++ = (bgr&0x7C00)>>7; *d++ = (bgr&0x3E0)>>2; *d++ = (bgr&0x1F)<<3; *d++ = 0; + #endif } } |