diff options
| author | donkopunchstania <donkopunchstania@gmail.com> | 2008-10-15 14:07:03 +0000 |
|---|---|---|
| committer | donkopunchstania <donkopunchstania@gmail.com> | 2008-10-15 14:07:03 +0000 |
| commit | bbbe898839467c312c31456334540c20fedc7be3 (patch) | |
| tree | b8583709225461be81538c41e36dce5dd4b4b4de /Source/Core/VideoCommon/Src/XFBConvert.cpp | |
| parent | 70eebcb3a3d747b4aeb7096ab2c04968a9d2b3f5 (diff) | |
added option to use XFB in GL, but XFB support still needs work. modified viewport to include scissor offset.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@879 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon/Src/XFBConvert.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Src/XFBConvert.cpp | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/Source/Core/VideoCommon/Src/XFBConvert.cpp b/Source/Core/VideoCommon/Src/XFBConvert.cpp index 3d9884f861..7d08ecc924 100644 --- a/Source/Core/VideoCommon/Src/XFBConvert.cpp +++ b/Source/Core/VideoCommon/Src/XFBConvert.cpp @@ -34,26 +34,53 @@ void yuv2rgb(int y, int u, int v, int &r, int &g, int &b) r = bound((76283*(y - 16) + 104595*(v - 128))>>16);
}
+void rgb2yuv(int r, int g, int b, int &y, int &u, int &v)
+{
+ y = (((16843 * r) + (33030 * g) + (6423 * b)) >> 16) + 16;
+ v = (((28770 * r) - (24117 * g) - (4653 * b)) >> 16) + 128;
+ u = ((-(9699 * r) - (19071 * g) + (28770 * b)) >> 16) + 128;
+}
+
} // namespace
-void ConvertXFB(u32 *dst, const u8* _pXFB, int width, int height)
+void ConvertFromXFB(u32 *dst, const u8* _pXFB, int width, int height)
{
const unsigned char *src = _pXFB;
- for (int y = 0; y < height; y++)
+
+ u32 numBlocks = (width * height) / 2;
+
+ for (u32 i = 0; i < numBlocks; i++, src += 4)
+ {
+ int Y1 = src[0];
+ int U = src[1];
+ int Y2 = src[2];
+ int V = src[3];
+
+ int r, g, b;
+ yuv2rgb(Y1,U,V, r,g,b);
+ *dst++ = 0xFF000000 | (r<<16) | (g<<8) | (b);
+ yuv2rgb(Y2,U,V, r,g,b);
+ *dst++ = 0xFF000000 | (r<<16) | (g<<8) | (b);
+ }
+}
+
+void ConvertToXFB(u32 *dst, const u8* _pEFB, int width, int height)
+{
+ const unsigned char *src = _pEFB;
+
+ u32 numBlocks = (width * height) / 2;
+
+ for (u32 i = 0; i < numBlocks; i++)
{
- for (int x = 0; x < width; x++, src += 4)
- {
- int Y1 = src[0];
- int U = src[1];
- int Y2 = src[2];
- int V = src[3];
-
- int r, g, b;
- yuv2rgb(Y1,U,V, r,g,b);
- *dst++ = 0xFF000000 | (r<<16) | (g<<8) | (b);
- yuv2rgb(Y2,U,V, r,g,b);
- *dst++ = 0xFF000000 | (r<<16) | (g<<8) | (b);
- }
- }
+ int y1 = (((16843 * src[0]) + (33030 * src[1]) + (6423 * src[2])) >> 16) + 16;
+ int u1 = ((-(9699 * src[0]) - (19071 * src[1]) + (28770 * src[2])) >> 16) + 128;
+ src += 4;
+
+ int y2 = (((16843 * src[0]) + (33030 * src[1]) + (6423 * src[2])) >> 16) + 16;
+ int v2 = (((28770 * src[0]) - (24117 * src[1]) - (4653 * src[2])) >> 16) + 128;
+ src += 4;
+
+ *dst++ = (v2 << 24) | (y2 << 16) | (u1 << 8) | (y1);
+ }
}
|
