diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-11-04 15:04:59 +0300 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-11-04 15:04:59 +0300 |
commit | 1886b7bf52f73f03d60967504b474cdde7a4e1e7 (patch) | |
tree | 688163d0a7fc0330c6438ff9be890f8b2e7ed8d1 /source/gameengine/VideoTexture/FilterSource.h | |
parent | 6eb3bf53dd753d4b00f0f76f9f7739aecb9af2f8 (diff) |
VideoTexture: fix RGB/BGR confusion, make code compatible with big endian CPU, add RGBA source filter.
Diffstat (limited to 'source/gameengine/VideoTexture/FilterSource.h')
-rw-r--r-- | source/gameengine/VideoTexture/FilterSource.h | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/source/gameengine/VideoTexture/FilterSource.h b/source/gameengine/VideoTexture/FilterSource.h index c3d4e0079f9..7e90747d252 100644 --- a/source/gameengine/VideoTexture/FilterSource.h +++ b/source/gameengine/VideoTexture/FilterSource.h @@ -44,7 +44,34 @@ protected: /// filter pixel, source byte buffer virtual unsigned int filter (unsigned char * src, short x, short y, short * size, unsigned int pixSize, unsigned int val) - { return 0xFF000000 | src[0] << 16 | src[1] << 8 | src[2]; } + { VT_RGBA(val,src[0],src[1],src[2],0xFF); return val; } +}; + +/// class for RGBA32 conversion +class FilterRGBA32 : public FilterBase +{ +public: + /// constructor + FilterRGBA32 (void) {} + /// destructor + virtual ~FilterRGBA32 (void) {} + + /// get source pixel size + virtual unsigned int getPixelSize (void) { return 4; } + +protected: + /// filter pixel, source byte buffer + virtual unsigned int filter (unsigned char * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val) + { + if ((intptr_t(src)&0x3) == 0) + return *(unsigned int*)src; + else + { + VT_RGBA(val,src[0],src[1],src[2],src[3]); + return val; + } + } }; /// class for BGR24 conversion @@ -63,7 +90,7 @@ protected: /// filter pixel, source byte buffer virtual unsigned int filter (unsigned char * src, short x, short y, short * size, unsigned int pixSize, unsigned int val) - { return 0xFF000000 | src[2] << 16 | src[1] << 8 | src[0]; } + { VT_RGBA(val,src[2],src[1],src[0],0xFF); return val; } }; /// class for YV12 conversion @@ -215,15 +242,15 @@ protected: int red = (298 * c + 409 * e + 128) >> 8; if (red >= 0x100) red = 0xFF; else if (red < 0) red = 0; - int green = 298 * c - 100 * d - 208 * e; - if (green > 0x10000) green = 0xFF00; + int green = (298 * c - 100 * d - 208 * e) >> 8; + if (green >= 0x100) green = 0xFF; else if (green < 0) green = 0; - int blue = (298 * c + 516 * d + 128) << 8; - if (blue > 0x1000000) blue = 0xFF0000; + int blue = (298 * c + 516 * d + 128) >> 8; + if (blue >= 0x100) blue = 0xFF; else if (blue < 0) blue = 0; // return result - return 0xFF000000 | blue & 0xFF0000 | green & 0xFF00 - | red & 0xFF; + VT_RGBA(val, red, green, blue, 0xFF); + return val; } }; |