[Scummvm-cvs-logs] SF.net SVN: scummvm:[42080] scummvm/branches/gsoc2009-16bit
jvprat at users.sourceforge.net
jvprat at users.sourceforge.net
Sat Jul 4 01:02:37 CEST 2009
Revision: 42080
http://scummvm.svn.sourceforge.net/scummvm/?rev=42080&view=rev
Author: jvprat
Date: 2009-07-03 23:02:37 +0000 (Fri, 03 Jul 2009)
Log Message:
-----------
Moved the YUV<->RGB routines to graphics/conversion.h
Modified Paths:
--------------
scummvm/branches/gsoc2009-16bit/engines/gob/video_v6.cpp
scummvm/branches/gsoc2009-16bit/engines/groovie/roq.cpp
scummvm/branches/gsoc2009-16bit/graphics/conversion.h
scummvm/branches/gsoc2009-16bit/graphics/dither.cpp
scummvm/branches/gsoc2009-16bit/graphics/dither.h
scummvm/branches/gsoc2009-16bit/graphics/video/coktelvideo/coktelvideo.cpp
Modified: scummvm/branches/gsoc2009-16bit/engines/gob/video_v6.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/engines/gob/video_v6.cpp 2009-07-03 21:59:07 UTC (rev 42079)
+++ scummvm/branches/gsoc2009-16bit/engines/gob/video_v6.cpp 2009-07-03 23:02:37 UTC (rev 42080)
@@ -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 @@
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;
Modified: scummvm/branches/gsoc2009-16bit/engines/groovie/roq.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/engines/groovie/roq.cpp 2009-07-03 21:59:07 UTC (rev 42079)
+++ scummvm/branches/gsoc2009-16bit/engines/groovie/roq.cpp 2009-07-03 23:02:37 UTC (rev 42080)
@@ -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 @@
} 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
Modified: scummvm/branches/gsoc2009-16bit/graphics/conversion.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/graphics/conversion.h 2009-07-03 21:59:07 UTC (rev 42079)
+++ scummvm/branches/gsoc2009-16bit/graphics/conversion.h 2009-07-03 23:02:37 UTC (rev 42080)
@@ -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
/**
Modified: scummvm/branches/gsoc2009-16bit/graphics/dither.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/graphics/dither.cpp 2009-07-03 21:59:07 UTC (rev 42079)
+++ scummvm/branches/gsoc2009-16bit/graphics/dither.cpp 2009-07-03 23:02:37 UTC (rev 42080)
@@ -23,6 +23,7 @@
*/
#include "common/endian.h"
+#include "graphics/conversion.h"
#include "graphics/dither.h"
namespace Graphics {
Modified: scummvm/branches/gsoc2009-16bit/graphics/dither.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/graphics/dither.h 2009-07-03 21:59:07 UTC (rev 42079)
+++ scummvm/branches/gsoc2009-16bit/graphics/dither.h 2009-07-03 23:02:37 UTC (rev 42080)
@@ -43,19 +43,6 @@
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.
Modified: scummvm/branches/gsoc2009-16bit/graphics/video/coktelvideo/coktelvideo.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/graphics/video/coktelvideo/coktelvideo.cpp 2009-07-03 21:59:07 UTC (rev 42079)
+++ scummvm/branches/gsoc2009-16bit/graphics/video/coktelvideo/coktelvideo.cpp 2009-07-03 23:02:37 UTC (rev 42080)
@@ -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 @@
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 @@
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);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list