diff --git a/Common/ColorConv.cpp b/Common/ColorConv.cpp
new file mode 100644
index 0000000000..a971d89f05
--- /dev/null
+++ b/Common/ColorConv.cpp
@@ -0,0 +1,21 @@
+// Copyright (c) 2015- PPSSPP Project.
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 2.0 or later versions.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License 2.0 for more details.
+
+// A copy of the GPL 2.0 should have been included with the program.
+// If not, see http://www.gnu.org/licenses/
+
+// Official git repository and contact information can be found at
+// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
+
+
+#include "ColorConv.h"
+#include "CommonTypes.h"
+
diff --git a/Common/ColorConv.h b/Common/ColorConv.h
new file mode 100644
index 0000000000..7f64ecf282
--- /dev/null
+++ b/Common/ColorConv.h
@@ -0,0 +1,158 @@
+// Copyright (c) 2015- PPSSPP Project.
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 2.0 or later versions.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License 2.0 for more details.
+
+// A copy of the GPL 2.0 should have been included with the program.
+// If not, see http://www.gnu.org/licenses/
+
+// Official git repository and contact information can be found at
+// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
+
+
+#pragma once
+
+#include "CommonTypes.h"
+
+inline u8 Convert4To8(u8 v)
+{
+ // Swizzle bits: 00001234 -> 12341234
+ return (v << 4) | (v);
+}
+
+inline u8 Convert5To8(u8 v)
+{
+ // Swizzle bits: 00012345 -> 12345123
+ return (v << 3) | (v >> 2);
+}
+
+inline u8 Convert6To8(u8 v)
+{
+ // Swizzle bits: 00123456 -> 12345612
+ return (v << 2) | (v >> 4);
+}
+
+inline u16 RGBA8888toRGB565(u32 px) {
+ return ((px >> 3) & 0x001F) | ((px >> 5) & 0x07E0) | ((px >> 8) & 0xF800);
+}
+
+inline u16 RGBA8888toRGBA4444(u32 px) {
+ return ((px >> 4) & 0x000F) | ((px >> 8) & 0x00F0) | ((px >> 12) & 0x0F00) | ((px >> 16) & 0xF000);
+}
+
+inline u16 BGRA8888toRGB565(u32 px) {
+ return ((px >> 19) & 0x001F) | ((px >> 5) & 0x07E0) | ((px << 8) & 0xF800);
+}
+
+inline u16 BGRA8888toRGBA4444(u32 px) {
+ return ((px >> 20) & 0x000F) | ((px >> 8) & 0x00F0) | ((px << 4) & 0x0F00) | ((px >> 16) & 0xF000);
+}
+
+inline u16 RGBA8888toRGBA5551(u32 px) {
+ return ((px >> 3) & 0x001F) | ((px >> 6) & 0x03E0) | ((px >> 9) & 0x7C00) | ((px >> 16) & 0x8000);
+}
+
+inline void ARGB8From4444(u16 c, u32 * dst) {
+ *dst = ((c & 0xf) << 4) | (((c >> 4) & 0xf) << 12) | (((c >> 8) & 0xf) << 20) | ((c >> 12) << 28);
+}
+
+inline void ARGB8From565(u16 c, u32 * dst) {
+ *dst = ((c & 0x001f) << 19) | (((c >> 5) & 0x003f) << 11) | ((((c >> 10) & 0x001f) << 3)) | 0xFF000000;
+}
+
+inline void ARGB8From5551(u16 c, u32 * dst) {
+ *dst = ((c & 0x001f) << 19) | (((c >> 5) & 0x001f) << 11) | ((((c >> 10) & 0x001f) << 3)) | 0xFF000000;
+}
+
+// TODO: Swizzle the texture access instead.
+inline u32 RGBA2BGRA(u32 src) {
+ const u32 r = (src & 0x000000FF) << 16;
+ const u32 ga = src & 0xFF00FF00;
+ const u32 b = (src & 0x00FF0000) >> 16;
+ return r | ga | b;
+}
+
+
+inline u32 DecodeRGBA4444(u16 src)
+{
+ const u32 r = (src & 0x000F) << 0;
+ const u32 g = (src & 0x00F0) << 4;
+ const u32 b = (src & 0x0F00) << 8;
+ const u32 a = (src & 0xF000) << 12;
+
+ const u32 c = r | g | b | a;
+ return c | (c << 4);
+}
+
+inline u32 DecodeRGBA5551(u16 src)
+{
+ u8 r = Convert5To8((src >> 0) & 0x1F);
+ u8 g = Convert5To8((src >> 5) & 0x1F);
+ u8 b = Convert5To8((src >> 10) & 0x1F);
+ u8 a = (src >> 15) & 0x1;
+ a = (a) ? 0xff : 0;
+ return (a << 24) | (b << 16) | (g << 8) | r;
+}
+
+inline u32 DecodeRGB565(u16 src)
+{
+ u8 r = Convert5To8((src >> 0) & 0x1F);
+ u8 g = Convert6To8((src >> 5) & 0x3F);
+ u8 b = Convert5To8((src >> 11) & 0x1F);
+ u8 a = 0xFF;
+ return (a << 24) | (b << 16) | (g << 8) | r;
+}
+
+inline u32 DecodeRGBA8888(u32 src)
+{
+#if 1
+ return src;
+#else
+ // This is the order of the bits.
+ u8 r = src & 0xFF;
+ u8 g = (src >> 8) & 0xFF;
+ u8 b = (src >> 16) & 0xFF;
+ u8 a = (src >> 24) & 0xFF;
+ return (a << 24) | (b << 16) | (g << 8) | r;
+#endif
+}
+
+inline u16 RGBA8888To565(u32 value)
+{
+ u8 r = value & 0xFF;
+ u8 g = (value >> 8) & 0xFF;
+ u8 b = (value >> 16) & 0xFF;
+ r >>= 3;
+ g >>= 2;
+ b >>= 3;
+ return (u16)r | ((u16)g << 5) | ((u16)b << 11);
+}
+
+inline u16 RGBA8888To5551(u32 value)
+{
+ u8 r = value & 0xFF;
+ u8 g = (value >> 8) & 0xFF;
+ u8 b = (value >> 16) & 0xFF;
+ u8 a = (value >> 24) & 0xFF;
+ r >>= 3;
+ g >>= 3;
+ b >>= 3;
+ a >>= 7;
+ return (u16)r | ((u16)g << 5) | ((u16)b << 10) | ((u16)a << 15);
+}
+
+inline u16 RGBA8888To4444(u32 value)
+{
+ const u32 c = value >> 4;
+ const u16 r = (c >> 0) & 0x000F;
+ const u16 g = (c >> 4) & 0x00F0;
+ const u16 b = (c >> 8) & 0x0F00;
+ const u16 a = (c >> 12) & 0xF000;
+ return r | g | b | a;
+}
diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj
index 74e1dd7051..7d151892dc 100644
--- a/Common/Common.vcxproj
+++ b/Common/Common.vcxproj
@@ -196,6 +196,7 @@
+
@@ -242,6 +243,7 @@
true
+
diff --git a/Common/Common.vcxproj.filters b/Common/Common.vcxproj.filters
index 8aaa5b299d..d164587676 100644
--- a/Common/Common.vcxproj.filters
+++ b/Common/Common.vcxproj.filters
@@ -45,6 +45,7 @@
+
@@ -79,6 +80,7 @@
+
diff --git a/Core/Screenshot.cpp b/Core/Screenshot.cpp
index c8fa0ab4d8..405c611420 100644
--- a/Core/Screenshot.cpp
+++ b/Core/Screenshot.cpp
@@ -22,6 +22,7 @@
#include "ext/jpge/jpge.h"
#endif
+#include "Common/ColorConv.h"
#include "Common/FileUtil.h"
#include "Core/Config.h"
#include "Core/Screenshot.h"
diff --git a/GPU/Common/TextureDecoder.cpp b/GPU/Common/TextureDecoder.cpp
index c868b2a202..5a390b13b9 100644
--- a/GPU/Common/TextureDecoder.cpp
+++ b/GPU/Common/TextureDecoder.cpp
@@ -17,6 +17,7 @@
#include "ext/xxhash.h"
#include "Common/CPUDetect.h"
+#include "Common/ColorConv.h"
#include "GPU/Common/TextureDecoder.h"
// NEON is in a separate file so that it can be compiled with a runtime check.
#include "GPU/Common/TextureDecoderNEON.h"
@@ -361,10 +362,6 @@ void ConvertBGRA8888ToRGBA8888(u32 *dst, const u32 *src, const u32 numPixels) {
}
}
-inline u16 RGBA8888toRGBA5551(u32 px) {
- return ((px >> 3) & 0x001F) | ((px >> 6) & 0x03E0) | ((px >> 9) & 0x7C00) | ((px >> 16) & 0x8000);
-}
-
void ConvertRGBA8888ToRGBA5551(u16 *dst, const u32 *src, const u32 numPixels) {
#if _M_SSE >= 0x401
const __m128i maskAG = _mm_set1_epi32(0x8000F800);
diff --git a/GPU/Common/VertexDecoderCommon.cpp b/GPU/Common/VertexDecoderCommon.cpp
index 5faa7c826c..79f2674331 100644
--- a/GPU/Common/VertexDecoderCommon.cpp
+++ b/GPU/Common/VertexDecoderCommon.cpp
@@ -21,6 +21,7 @@
#include "base/logging.h"
#include "Common/CPUDetect.h"
+#include "Common/ColorConv.h"
#include "Core/Config.h"
#include "Core/MemMap.h"
#include "Core/HDRemaster.h"
diff --git a/GPU/Directx9/FramebufferDX9.cpp b/GPU/Directx9/FramebufferDX9.cpp
index 3181330c3f..1dfc3b4dd8 100644
--- a/GPU/Directx9/FramebufferDX9.cpp
+++ b/GPU/Directx9/FramebufferDX9.cpp
@@ -16,6 +16,8 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "math/lin/matrix4x4.h"
+
+#include "Common/ColorConv.h"
#include "Core/Host.h"
#include "Core/MemMap.h"
#include "Core/Config.h"
@@ -38,26 +40,6 @@
#include
namespace DX9 {
- inline u16 RGBA8888toRGB565(u32 px) {
- return ((px >> 3) & 0x001F) | ((px >> 5) & 0x07E0) | ((px >> 8) & 0xF800);
- }
-
- inline u16 RGBA8888toRGBA4444(u32 px) {
- return ((px >> 4) & 0x000F) | ((px >> 8) & 0x00F0) | ((px >> 12) & 0x0F00) | ((px >> 16) & 0xF000);
- }
-
- inline u16 RGBA8888toRGBA5551(u32 px) {
- return ((px >> 3) & 0x001F) | ((px >> 6) & 0x03E0) | ((px >> 9) & 0x7C00) | ((px >> 16) & 0x8000);
- }
-
- inline u16 BGRA8888toRGB565(u32 px) {
- return ((px >> 19) & 0x001F) | ((px >> 5) & 0x07E0) | ((px << 8) & 0xF800);
- }
-
- inline u16 BGRA8888toRGBA4444(u32 px) {
- return ((px >> 20) & 0x000F) | ((px >> 8) & 0x00F0) | ((px << 4) & 0x0F00) | ((px >> 16) & 0xF000);
- }
-
static void ConvertFromRGBA8888(u8 *dst, u8 *src, u32 dstStride, u32 srcStride, u32 width, u32 height, GEBufferFormat format);
void CenterRect(float *x, float *y, float *w, float *h,
@@ -149,24 +131,6 @@ namespace DX9 {
}
}
- static inline void ARGB8From4444(u16 c, u32 * dst) {
- *dst = ((c & 0xf) << 4) | (((c >> 4) & 0xf) << 12) | (((c >> 8) & 0xf) << 20) | ((c >> 12) << 28);
- }
- static inline void ARGB8From565(u16 c, u32 * dst) {
- *dst = ((c & 0x001f) << 19) | (((c >> 5) & 0x003f) << 11) | ((((c >> 10) & 0x001f) << 3)) | 0xFF000000;
- }
- static inline void ARGB8From5551(u16 c, u32 * dst) {
- *dst = ((c & 0x001f) << 19) | (((c >> 5) & 0x001f) << 11) | ((((c >> 10) & 0x001f) << 3)) | 0xFF000000;
- }
-
- // TODO: Swizzle the texture access instead.
- static inline u32 RGBA2BGRA(u32 src) {
- const u32 r = (src & 0x000000FF) << 16;
- const u32 ga = src & 0xFF00FF00;
- const u32 b = (src & 0x00FF0000) >> 16;
- return r | ga | b;
- }
-
void FramebufferManagerDX9::MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) {
u8 *convBuf = NULL;
D3DLOCKED_RECT rect;
diff --git a/GPU/Directx9/StencilBufferDX9.cpp b/GPU/Directx9/StencilBufferDX9.cpp
index 4812d21e26..22e512ef3c 100644
--- a/GPU/Directx9/StencilBufferDX9.cpp
+++ b/GPU/Directx9/StencilBufferDX9.cpp
@@ -261,7 +261,7 @@ bool FramebufferManagerDX9::NotifyStencilUpload(u32 addr, int size, bool skipZer
continue;
}
if (dstBuffer->format == GE_FORMAT_4444) {
- dxstate.stencilMask.set(Convert4To8(i));
+ dxstate.stencilMask.set(i | (i << 4));
const float f[4] = {i * (16.0f / 255.0f)};
pD3Ddevice->SetPixelShaderConstantF(CONST_PS_STENCILVALUE, f, 1);
} else if (dstBuffer->format == GE_FORMAT_5551) {
diff --git a/GPU/Directx9/TextureScalerDX9.cpp b/GPU/Directx9/TextureScalerDX9.cpp
index 12e6208983..ecfd088fc0 100644
--- a/GPU/Directx9/TextureScalerDX9.cpp
+++ b/GPU/Directx9/TextureScalerDX9.cpp
@@ -26,6 +26,7 @@
#include "GPU/Directx9/TextureScalerDX9.h"
#include "Core/Config.h"
+#include "Common/ColorConv.h"
#include "Common/Common.h"
#include "Common/Log.h"
#include "Common/MsgHandler.h"
diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp
index 0eab00a5fc..64ae4620e7 100644
--- a/GPU/GLES/Framebuffer.cpp
+++ b/GPU/GLES/Framebuffer.cpp
@@ -25,6 +25,7 @@
#include "base/timeutil.h"
#include "math/lin/matrix4x4.h"
+#include "Common/ColorConv.h"
#include "Core/Host.h"
#include "Core/MemMap.h"
#include "Core/Config.h"
@@ -97,22 +98,6 @@ static const char color_vs[] =
" gl_Position = a_position;\n"
"}\n";
-inline u16 RGBA8888toRGB565(u32 px) {
- return ((px >> 3) & 0x001F) | ((px >> 5) & 0x07E0) | ((px >> 8) & 0xF800);
-}
-
-inline u16 RGBA8888toRGBA4444(u32 px) {
- return ((px >> 4) & 0x000F) | ((px >> 8) & 0x00F0) | ((px >> 12) & 0x0F00) | ((px >> 16) & 0xF000);
-}
-
-inline u16 BGRA8888toRGB565(u32 px) {
- return ((px >> 19) & 0x001F) | ((px >> 5) & 0x07E0) | ((px << 8) & 0xF800);
-}
-
-inline u16 BGRA8888toRGBA4444(u32 px) {
- return ((px >> 20) & 0x000F) | ((px >> 8) & 0x00F0) | ((px << 4) & 0x0F00) | ((px >> 16) & 0xF000);
-}
-
void ConvertFromRGBA8888(u8 *dst, const u8 *src, u32 dstStride, u32 srcStride, u32 width, u32 height, GEBufferFormat format);
void CenterRect(float *x, float *y, float *w, float *h,
diff --git a/GPU/GLES/StencilBuffer.cpp b/GPU/GLES/StencilBuffer.cpp
index d2a4e6eaab..cc1195805a 100644
--- a/GPU/GLES/StencilBuffer.cpp
+++ b/GPU/GLES/StencilBuffer.cpp
@@ -215,7 +215,7 @@ bool FramebufferManager::NotifyStencilUpload(u32 addr, int size, bool skipZero)
// DrawActiveTexture unbinds it, so rebind here before setting uniforms.
glsl_bind(stencilUploadProgram_);
if (dstBuffer->format == GE_FORMAT_4444) {
- glstate.stencilMask.set(Convert4To8(i));
+ glstate.stencilMask.set((i << 4) | i);
glUniform1f(u_stencilValue, i * (16.0f / 255.0f));
} else if (dstBuffer->format == GE_FORMAT_5551) {
glstate.stencilMask.set(0xFF);
diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp
index 9fced84fe1..01fafdf2d6 100644
--- a/GPU/GLES/TextureCache.cpp
+++ b/GPU/GLES/TextureCache.cpp
@@ -18,6 +18,7 @@
#include
#include
+#include "Common/ColorConv.h"
#include "Core/Host.h"
#include "Core/MemMap.h"
#include "Core/Reporting.h"
diff --git a/GPU/GLES/TextureScaler.cpp b/GPU/GLES/TextureScaler.cpp
index 8a3a0152b5..523d00eb63 100644
--- a/GPU/GLES/TextureScaler.cpp
+++ b/GPU/GLES/TextureScaler.cpp
@@ -24,6 +24,7 @@
#include "GPU/GLES/TextureScaler.h"
#include "Core/Config.h"
+#include "Common/ColorConv.h"
#include "Common/Common.h"
#include "Common/Log.h"
#include "Common/MsgHandler.h"
diff --git a/GPU/GPU.vcxproj b/GPU/GPU.vcxproj
index 465e58e3cc..c14b81ac9f 100644
--- a/GPU/GPU.vcxproj
+++ b/GPU/GPU.vcxproj
@@ -232,7 +232,6 @@
-
diff --git a/GPU/GPU.vcxproj.filters b/GPU/GPU.vcxproj.filters
index 75035c8a7c..151e9e6e84 100644
--- a/GPU/GPU.vcxproj.filters
+++ b/GPU/GPU.vcxproj.filters
@@ -42,9 +42,6 @@
Common
-
- Software
-
Software
diff --git a/GPU/Software/Colors.h b/GPU/Software/Colors.h
deleted file mode 100644
index 6bd9674b86..0000000000
--- a/GPU/Software/Colors.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (c) 2013- PPSSPP Project.
-
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, version 2.0 or later versions.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License 2.0 for more details.
-
-// A copy of the GPL 2.0 should have been included with the program.
-// If not, see http://www.gnu.org/licenses/
-
-// Official git repository and contact information can be found at
-// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
-
-#pragma once
-
-#include "Common/CommonTypes.h"
-
-static inline u32 DecodeRGBA4444(u16 src)
-{
- const u32 r = (src & 0x000F) << 0;
- const u32 g = (src & 0x00F0) << 4;
- const u32 b = (src & 0x0F00) << 8;
- const u32 a = (src & 0xF000) << 12;
-
- const u32 c = r | g | b | a;
- return c | (c << 4);
-}
-
-static inline u32 DecodeRGBA5551(u16 src)
-{
- u8 r = Convert5To8((src >> 0) & 0x1F);
- u8 g = Convert5To8((src >> 5) & 0x1F);
- u8 b = Convert5To8((src >> 10) & 0x1F);
- u8 a = (src >> 15) & 0x1;
- a = (a) ? 0xff : 0;
- return (a << 24) | (b << 16) | (g << 8) | r;
-}
-
-static inline u32 DecodeRGB565(u16 src)
-{
- u8 r = Convert5To8((src >> 0) & 0x1F);
- u8 g = Convert6To8((src >> 5) & 0x3F);
- u8 b = Convert5To8((src >> 11) & 0x1F);
- u8 a = 0xFF;
- return (a << 24) | (b << 16) | (g << 8) | r;
-}
-
-static inline u32 DecodeRGBA8888(u32 src)
-{
-#if 1
- return src;
-#else
- // This is the order of the bits.
- u8 r = src & 0xFF;
- u8 g = (src >> 8) & 0xFF;
- u8 b = (src >> 16) & 0xFF;
- u8 a = (src >> 24) & 0xFF;
- return (a << 24) | (b << 16) | (g << 8) | r;
-#endif
-}
-
-static inline u16 RGBA8888To565(u32 value)
-{
- u8 r = value & 0xFF;
- u8 g = (value >> 8) & 0xFF;
- u8 b = (value >> 16) & 0xFF;
- r >>= 3;
- g >>= 2;
- b >>= 3;
- return (u16)r | ((u16)g << 5) | ((u16)b << 11);
-}
-
-static inline u16 RGBA8888To5551(u32 value)
-{
- u8 r = value & 0xFF;
- u8 g = (value >> 8) & 0xFF;
- u8 b = (value >> 16) & 0xFF;
- u8 a = (value >> 24) & 0xFF;
- r >>= 3;
- g >>= 3;
- b >>= 3;
- a >>= 7;
- return (u16)r | ((u16)g << 5) | ((u16)b << 10) | ((u16)a << 15);
-}
-
-static inline u16 RGBA8888To4444(u32 value)
-{
- const u32 c = value >> 4;
- const u16 r = (c >> 0) & 0x000F;
- const u16 g = (c >> 4) & 0x00F0;
- const u16 b = (c >> 8) & 0x0F00;
- const u16 a = (c >> 12) & 0xF000;
- return r | g | b | a;
-}
diff --git a/GPU/Software/Rasterizer.cpp b/GPU/Software/Rasterizer.cpp
index e02e2b225d..10311a940d 100644
--- a/GPU/Software/Rasterizer.cpp
+++ b/GPU/Software/Rasterizer.cpp
@@ -18,6 +18,7 @@
#include "base/basictypes.h"
#include "Common/ThreadPools.h"
+#include "Common/ColorConv.h"
#include "Core/Config.h"
#include "Core/MemMap.h"
#include "Core/Reporting.h"
@@ -26,7 +27,6 @@
#include "GPU/Common/TextureDecoder.h"
#include "GPU/Software/SoftGpu.h"
#include "GPU/Software/Rasterizer.h"
-#include "GPU/Software/Colors.h"
#include
diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp
index 12f6795c9f..405e2dc236 100644
--- a/GPU/Software/SoftGpu.cpp
+++ b/GPU/Software/SoftGpu.cpp
@@ -19,6 +19,7 @@
#include "GPU/GPUState.h"
#include "GPU/ge_constants.h"
#include "GPU/Common/TextureDecoder.h"
+#include "Common/ColorConv.h"
#include "Core/Config.h"
#include "Core/Debugger/Breakpoints.h"
#include "Core/Host.h"
@@ -32,7 +33,6 @@
#include "GPU/Software/SoftGpu.h"
#include "GPU/Software/TransformUnit.h"
-#include "GPU/Software/Colors.h"
#include "GPU/Software/Rasterizer.h"
static GLuint temp_texture = 0;
diff --git a/Globals.h b/Globals.h
index f5a3c869c5..356744660e 100644
--- a/Globals.h
+++ b/Globals.h
@@ -30,24 +30,6 @@
#define IS_LITTLE_ENDIAN (*(const u16 *)"\0\xff" >= 0x100)
#define IS_BIG_ENDIAN (*(const u16 *)"\0\xff" < 0x100)
-inline u8 Convert4To8(u8 v)
-{
- // Swizzle bits: 00001234 -> 12341234
- return (v << 4) | (v);
-}
-
-inline u8 Convert5To8(u8 v)
-{
- // Swizzle bits: 00012345 -> 12345123
- return (v << 3) | (v >> 2);
-}
-
-inline u8 Convert6To8(u8 v)
-{
- // Swizzle bits: 00123456 -> 12345612
- return (v << 2) | (v >> 4);
-}
-
static inline u8 clamp_u8(int i) {
#ifdef ARM
asm("usat %0, #8, %1" : "=r"(i) : "r"(i));