summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Software/EfbInterface.cpp
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2022-02-22 20:40:07 -0800
committerPokechu22 <Pokechu022@gmail.com>2022-07-16 00:07:10 -0700
commit2f43889141179bd46f027e017fead35371fdd104 (patch)
tree0dcd0394f714a0420d69b59bb0170289f990cf2e /Source/Core/VideoBackends/Software/EfbInterface.cpp
parente7339d63f15bdf2b41e3f6fab1c16b844514ae3a (diff)
Software: Use hardware-verified numbers for RGB->YUV conversion
Diffstat (limited to 'Source/Core/VideoBackends/Software/EfbInterface.cpp')
-rw-r--r--Source/Core/VideoBackends/Software/EfbInterface.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/Source/Core/VideoBackends/Software/EfbInterface.cpp b/Source/Core/VideoBackends/Software/EfbInterface.cpp
index 1e5498e28a..399e0bb57f 100644
--- a/Source/Core/VideoBackends/Software/EfbInterface.cpp
+++ b/Source/Core/VideoBackends/Software/EfbInterface.cpp
@@ -535,9 +535,14 @@ static yuv444 ConvertColorToYUV(u32 color)
// GameCube/Wii uses the BT.601 standard algorithm for converting to YCbCr; see
// http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion
- return {static_cast<u8>(0.257f * red + 0.504f * green + 0.098f * blue),
- static_cast<s8>(-0.148f * red + -0.291f * green + 0.439f * blue),
- static_cast<s8>(0.439f * red + -0.368f * green + -0.071f * blue)};
+ // These numbers were determined by hardware testing
+ const u16 y = +66 * red + 129 * green + +25 * blue;
+ const s16 u = -38 * red + -74 * green + 112 * blue;
+ const s16 v = 112 * red + -94 * green + -18 * blue;
+ const u8 y_round = static_cast<u8>((y >> 8) + ((y >> 7) & 1));
+ const s8 u_round = static_cast<s8>((u >> 8) + ((u >> 7) & 1));
+ const s8 v_round = static_cast<s8>((v >> 8) + ((v >> 7) & 1));
+ return {y_round, u_round, v_round};
}
u32 GetDepth(u16 x, u16 y)