mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-19 13:27:00 +00:00
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
This commit is contained in:
parent
0b2bb3543f
commit
f688668c3c
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,10 +104,12 @@ static inline void RENAME(rgb24to32)(const uint8_t *src,uint8_t *dst,long src_si
|
||||
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 @@ static inline void RENAME(rgb32to24)(const uint8_t *src,uint8_t *dst,long src_si
|
||||
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 @@ static inline void RENAME(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, long s
|
||||
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 @@ static inline void RENAME(rgb32to15)(const uint8_t *src, uint8_t *dst, long src_
|
||||
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 @@ static inline void RENAME(rgb32tobgr15)(const uint8_t *src, uint8_t *dst, long s
|
||||
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 @@ static inline void RENAME(rgb15to32)(const uint8_t *src, uint8_t *dst, long src_
|
||||
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&0x3E0)>>2;
|
||||
*d++ = (bgr&0x7C00)>>7;
|
||||
*d++ = (bgr&0x3E0)>>2;
|
||||
*d++ = (bgr&0x1F)<<3;
|
||||
#else
|
||||
*d++ = (bgr&0x1F)<<3;
|
||||
*d++ = (bgr&0x3E0)>>2;
|
||||
@ -1326,9 +1332,9 @@ static inline void RENAME(rgb16to32)(const uint8_t *src, uint8_t *dst, long src_
|
||||
bgr = *s++;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
*d++ = 0;
|
||||
*d++ = (bgr&0x1F)<<3;
|
||||
*d++ = (bgr&0x7E0)>>3;
|
||||
*d++ = (bgr&0xF800)>>8;
|
||||
*d++ = (bgr&0x7E0)>>3;
|
||||
*d++ = (bgr&0x1F)<<3;
|
||||
#else
|
||||
*d++ = (bgr&0x1F)<<3;
|
||||
*d++ = (bgr&0x7E0)>>3;
|
||||
|
Loading…
Reference in New Issue
Block a user