aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/gob/video_v6.cpp5
-rw-r--r--engines/groovie/roq.cpp4
-rw-r--r--graphics/conversion.h17
-rw-r--r--graphics/dither.cpp1
-rw-r--r--graphics/dither.h13
-rw-r--r--graphics/video/coktelvideo/coktelvideo.cpp5
6 files changed, 24 insertions, 21 deletions
diff --git a/engines/gob/video_v6.cpp b/engines/gob/video_v6.cpp
index c4efadde90..f0d554bd01 100644
--- a/engines/gob/video_v6.cpp
+++ b/engines/gob/video_v6.cpp
@@ -25,6 +25,7 @@
#include "common/endian.h"
#include "common/savefile.h"
+#include "graphics/conversion.h"
#include "graphics/dither.h"
#include "gob/gob.h"
@@ -45,8 +46,8 @@ void Video_v6::setPrePalette() {
for (int i = 0; i < 256; i++) {
byte r, g, b;
- Graphics::PaletteLUT::YUV2RGB(fpal[i * 3 + 0], fpal[i * 3 + 1], fpal[i * 3 + 2],
- r, g, b);
+ Graphics::YUV2RGB(fpal[i * 3 + 0], fpal[i * 3 + 1], fpal[i * 3 + 2],
+ r, g, b);
tpal[i * 3 + 0] = r >> 2;
tpal[i * 3 + 1] = g >> 2;
diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp
index 3868443e96..4c8bbe55ac 100644
--- a/engines/groovie/roq.cpp
+++ b/engines/groovie/roq.cpp
@@ -33,7 +33,7 @@
#ifdef ENABLE_RGB_COLOR
// Required for the YUV to RGB conversion
-#include "graphics/dither.h"
+#include "graphics/conversion.h"
#endif
#include "sound/mixer.h"
@@ -173,7 +173,7 @@ void ROQPlayer::buildShowBuf() {
} else {
// Do the format conversion (YUV -> RGB -> Screen format)
byte r, g, b;
- Graphics::PaletteLUT::YUV2RGB(*in, *(in + 1), *(in + 2), r, g, b);
+ Graphics::YUV2RGB(*in, *(in + 1), *(in + 2), r, g, b);
// FIXME: this is fixed to 16bit
*(uint16 *)out = (uint16)_vm->_pixelFormat.RGBToColor(r, g, b);
#endif // ENABLE_RGB_COLOR
diff --git a/graphics/conversion.h b/graphics/conversion.h
index aa7cade982..3226c38817 100644
--- a/graphics/conversion.h
+++ b/graphics/conversion.h
@@ -26,12 +26,25 @@
#ifndef GRAPHICS_CONVERSION_H
#define GRAPHICS_CONVERSION_H
-#include "common/scummsys.h"
+#include "common/util.h"
#include "graphics/pixelformat.h"
namespace Graphics {
-// TODO: generic YUV to RGB pixel conversion
+/** Converting a color from YUV to RGB colorspace. */
+inline static void YUV2RGB(byte y, byte u, byte v, byte &r, byte &g, byte &b) {
+ r = CLIP<int>(y + ((1357 * (v - 128)) >> 10), 0, 255);
+ g = CLIP<int>(y - (( 691 * (v - 128)) >> 10) - ((333 * (u - 128)) >> 10), 0, 255);
+ b = CLIP<int>(y + ((1715 * (u - 128)) >> 10), 0, 255);
+}
+
+/** Converting a color from RGB to YUV colorspace. */
+inline static void RGB2YUV(byte r, byte g, byte b, byte &y, byte &u, byte &v) {
+ y = CLIP<int>( ((r * 306) >> 10) + ((g * 601) >> 10) + ((b * 117) >> 10) , 0, 255);
+ u = CLIP<int>(-((r * 172) >> 10) - ((g * 340) >> 10) + ((b * 512) >> 10) + 128, 0, 255);
+ v = CLIP<int>( ((r * 512) >> 10) - ((g * 429) >> 10) - ((b * 83) >> 10) + 128, 0, 255);
+}
+
// TODO: generic YUV to RGB blit
/**
diff --git a/graphics/dither.cpp b/graphics/dither.cpp
index 7a92441571..e671de265e 100644
--- a/graphics/dither.cpp
+++ b/graphics/dither.cpp
@@ -23,6 +23,7 @@
*/
#include "common/endian.h"
+#include "graphics/conversion.h"
#include "graphics/dither.h"
namespace Graphics {
diff --git a/graphics/dither.h b/graphics/dither.h
index e6d606cdd4..18f98ce4e0 100644
--- a/graphics/dither.h
+++ b/graphics/dither.h
@@ -43,19 +43,6 @@ public:
kPaletteYUV //!< Palette in YUV colorspace
};
- /** Converting a color from YUV to RGB colorspace. */
- inline static void YUV2RGB(byte y, byte u, byte v, byte &r, byte &g, byte &b) {
- r = CLIP<int>(y + ((1357 * (v - 128)) >> 10), 0, 255);
- g = CLIP<int>(y - (( 691 * (v - 128)) >> 10) - ((333 * (u - 128)) >> 10), 0, 255);
- b = CLIP<int>(y + ((1715 * (u - 128)) >> 10), 0, 255);
- }
- /** Converting a color from RGB to YUV colorspace. */
- inline static void RGB2YUV(byte r, byte g, byte b, byte &y, byte &u, byte &v) {
- y = CLIP<int>( ((r * 306) >> 10) + ((g * 601) >> 10) + ((b * 117) >> 10) , 0, 255);
- u = CLIP<int>(-((r * 172) >> 10) - ((g * 340) >> 10) + ((b * 512) >> 10) + 128, 0, 255);
- v = CLIP<int>( ((r * 512) >> 10) - ((g * 429) >> 10) - ((b * 83) >> 10) + 128, 0, 255);
- }
-
/** Create a lookup table of a given depth and palette format.
*
* @param depth How many bits of each color component to consider.
diff --git a/graphics/video/coktelvideo/coktelvideo.cpp b/graphics/video/coktelvideo/coktelvideo.cpp
index 8603e125a6..9e0391ecc5 100644
--- a/graphics/video/coktelvideo/coktelvideo.cpp
+++ b/graphics/video/coktelvideo/coktelvideo.cpp
@@ -26,6 +26,7 @@
#include "common/endian.h"
#include "common/system.h"
+#include "graphics/conversion.h"
#include "graphics/dither.h"
#include "graphics/video/coktelvideo/coktelvideo.h"
#include "graphics/video/coktelvideo/indeo3.h"
@@ -1624,7 +1625,7 @@ void Vmd::blit16(byte *dest, byte *src, int16 srcPitch, int16 width, int16 heigh
byte b = ((data & 0x001F) >> 0);
byte dY, dU, dV;
- Graphics::PaletteLUT::RGB2YUV(r << 3, g << 3, b << 3, dY, dU, dV);
+ Graphics::RGB2YUV(r << 3, g << 3, b << 3, dY, dU, dV);
byte p = dither->dither(dY, dU, dV, j);
@@ -1658,7 +1659,7 @@ void Vmd::blit24(byte *dest, byte *src, int16 srcPitch, int16 width, int16 heigh
byte b = s[0];
byte dY, dU, dV;
- Graphics::PaletteLUT::RGB2YUV(r, g, b, dY, dU, dV);
+ Graphics::RGB2YUV(r, g, b, dY, dU, dV);
byte p = dither->dither(dY, dU, dV, j);