summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/TextureDecoder_x64.cpp
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2017-11-19 04:58:59 +0100
committerGitHub <noreply@github.com>2017-11-19 04:58:59 +0100
commit609a17a0cd41a12c0fbf9a7c47c8889232594778 (patch)
tree0a5f6f4b0a7d480accc4dfbcc3e9c1c6e3652dc0 /Source/Core/VideoCommon/TextureDecoder_x64.cpp
parentd800b0f79868a28356b4e40cb9b2e5af43977042 (diff)
parent1f1574b7ab032afa7b3a600a071699f2cbea124e (diff)
Merge pull request #5498 from iwubcode/hybrid_xfb
Hybrid xfb
Diffstat (limited to 'Source/Core/VideoCommon/TextureDecoder_x64.cpp')
-rw-r--r--Source/Core/VideoCommon/TextureDecoder_x64.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/TextureDecoder_x64.cpp b/Source/Core/VideoCommon/TextureDecoder_x64.cpp
index 135fc60629..8a55bb5a53 100644
--- a/Source/Core/VideoCommon/TextureDecoder_x64.cpp
+++ b/Source/Core/VideoCommon/TextureDecoder_x64.cpp
@@ -9,6 +9,7 @@
#include "Common/CPUDetect.h"
#include "Common/CommonTypes.h"
#include "Common/Intrinsics.h"
+#include "Common/MathUtil.h"
#include "Common/MsgHandler.h"
#include "Common/Swap.h"
@@ -1486,6 +1487,39 @@ void _TexDecoder_DecodeImpl(u32* dst, const u8* src, int width, int height, Text
TexDecoder_DecodeImpl_CMPR(dst, src, width, height, texformat, tlut, tlutfmt, Wsteps4, Wsteps8);
break;
+ case TextureFormat::XFB:
+ {
+ for (int y = 0; y < height; y += 1)
+ {
+ for (int x = 0; x < width; x += 2)
+ {
+ size_t offset = static_cast<size_t>((y * width + x) * 2);
+
+ // We do this one color sample (aka 2 RGB pixles) at a time
+ int Y1 = int(src[offset]) - 16;
+ int U = int(src[offset + 1]) - 128;
+ int Y2 = int(src[offset + 2]) - 16;
+ int V = int(src[offset + 3]) - 128;
+
+ // We do the inverse BT.601 conversion for YCbCr to RGB
+ // http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion
+ u8 R1 = static_cast<u8>(MathUtil::Clamp(int(1.164f * Y1 + 1.596f * V), 0, 255));
+ u8 G1 =
+ static_cast<u8>(MathUtil::Clamp(int(1.164f * Y1 - 0.392f * U - 0.813f * V), 0, 255));
+ u8 B1 = static_cast<u8>(MathUtil::Clamp(int(1.164f * Y1 + 2.017f * U), 0, 255));
+
+ u8 R2 = static_cast<u8>(MathUtil::Clamp(int(1.164f * Y2 + 1.596f * V), 0, 255));
+ u8 G2 =
+ static_cast<u8>(MathUtil::Clamp(int(1.164f * Y2 - 0.392f * U - 0.813f * V), 0, 255));
+ u8 B2 = static_cast<u8>(MathUtil::Clamp(int(1.164f * Y2 + 2.017f * U), 0, 255));
+
+ dst[y * width + x] = 0xff000000 | B1 << 16 | G1 << 8 | R1;
+ dst[y * width + x + 1] = 0xff000000 | B2 << 16 | G2 << 8 | R2;
+ }
+ }
+ }
+ break;
+
default:
PanicAlert("Invalid Texture Format (0x%X)! (_TexDecoder_DecodeImpl)",
static_cast<int>(texformat));