From e856559777805141109561e25aad87feec7e574d Mon Sep 17 00:00:00 2001 From: Pawel Kolodziejski Date: Tue, 17 Apr 2012 15:07:08 +0200 Subject: [PATCH] ALL: sync with scummvm --- backends/platform/sdl/sdl.h | 3 - common/rdft.h | 3 + common/util.h | 2 +- devtools/create_project/config.h | 1 - devtools/create_project/create_project.cpp | 11 ++- devtools/create_project/xcode.cpp | 57 ++++++++------- devtools/update-version.pl | 4 + graphics/decoders/bmp.h | 7 ++ graphics/decoders/jpeg.h | 7 ++ graphics/yuv_to_rgb.cpp | 85 ++++++++++++++++++++++ graphics/yuv_to_rgb.h | 19 +++++ 11 files changed, 161 insertions(+), 38 deletions(-) diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 672f34c272f..ada7234d530 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -61,9 +61,6 @@ public: #if defined(USE_TASKBAR) virtual void engineInit(); virtual void engineDone(); -#endif -#ifdef ENABLE_KEYMAPPER - virtual Common::HardwareKeySet *getHardwareKeySet(); #endif virtual void quit(); virtual void fatalError(); diff --git a/common/rdft.h b/common/rdft.h index 68be0f4dac7..3bdc4b0cbc8 100644 --- a/common/rdft.h +++ b/common/rdft.h @@ -36,6 +36,9 @@ namespace Common { /** * (Inverse) Real Discrete Fourier Transform. * + * Used in audio: + * - QDM2 + * * Used in engines: * - scumm */ diff --git a/common/util.h b/common/util.h index b90be0675b4..78340980d5c 100644 --- a/common/util.h +++ b/common/util.h @@ -83,7 +83,7 @@ namespace Common { * Print a hexdump of the data passed in. The number of bytes per line is * customizable. * @param data the data to be dumped - * @param len the lenght of that data + * @param len the length of that data * @param bytesPerLine number of bytes to print per line (default: 16) * @param startOffset shift the shown offsets by the starting offset (default: 0) */ diff --git a/devtools/create_project/config.h b/devtools/create_project/config.h index b0ebbefcdb3..03f14fd70af 100644 --- a/devtools/create_project/config.h +++ b/devtools/create_project/config.h @@ -28,7 +28,6 @@ #define LIBS_DEFINE "RESIDUALVM_LIBS" // Name of the include environment variable #define REVISION_DEFINE "SCUMMVM_INTERNAL_REVISION" -#define HAS_VIDEO_FOLDER 1 #define ADDITIONAL_LIBRARY "glu32" #define NEEDS_RTTI 1 diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp index 8d28c125996..cacf82065b6 100644 --- a/devtools/create_project/create_project.cpp +++ b/devtools/create_project/create_project.cpp @@ -575,8 +575,9 @@ int main(int argc, char *argv[]) { globalWarnings.push_back("-Wwrite-strings"); // The following are not warnings at all... We should consider adding them to // a different list of parameters. - //ResidualVM: disabled: -// globalWarnings.push_back("-fno-rtti"); +#if !NEEDS_RTTI + globalWarnings.push_back("-fno-rtti"); +#endif globalWarnings.push_back("-fno-exceptions"); globalWarnings.push_back("-fcheck-new"); @@ -1214,11 +1215,9 @@ void ProjectProvider::createProject(const BuildSetup &setup) { createModuleList(setup.srcDir + "/gui", setup.defines, in, ex); createModuleList(setup.srcDir + "/audio", setup.defines, in, ex); createModuleList(setup.srcDir + "/audio/softsynth/mt32", setup.defines, in, ex); - //ResidualVM specific - createModuleList(setup.srcDir + "/math", setup.defines, in, ex); -#if HAS_VIDEO_FOLDER createModuleList(setup.srcDir + "/video", setup.defines, in, ex); -#endif + //ResidualVM specific: + createModuleList(setup.srcDir + "/math", setup.defines, in, ex); // Resource files in.push_back(setup.srcDir + "/icons/" + setup.projectName + ".ico"); diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp index b28dd89e7de..39470f4e19d 100644 --- a/devtools/create_project/xcode.cpp +++ b/devtools/create_project/xcode.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "xcode.h" #include @@ -86,34 +87,34 @@ XCodeProvider::XCodeProvider(StringList &global_warnings, std::mapaddProperty("dependencies", "", "", SettingsNoValue|SettingsAsList); target->addProperty("name", _targets[i], "", SettingsNoValue|SettingsQuoteVariable); - target->addProperty("productName", "residualvm", "", SettingsNoValue); - target->addProperty("productReference", getHash("PBXFileReference_ResidualVM.app_" + _targets[i]), "ResidualVM.app", SettingsNoValue); + target->addProperty("productName", PROJECT_NAME, "", SettingsNoValue); + target->addProperty("productReference", getHash("PBXFileReference_" PROJECT_DESCRIPTION ".app_" + _targets[i]), PROJECT_DESCRIPTION ".app", SettingsNoValue); target->addProperty("productType", "com.apple.product-type.application", "", SettingsNoValue|SettingsQuoteVariable); _nativeTarget.add(target); @@ -405,7 +406,7 @@ void XCodeProvider::setupProject() { Object *project = new Object(this, "PBXProject", "PBXProject", "PBXProject", "", "Project object"); - project->addProperty("buildConfigurationList", getHash("XCConfigurationList_residualvm"), "Build configuration list for PBXProject \"residualvm\"", SettingsNoValue); + project->addProperty("buildConfigurationList", getHash("XCConfigurationList_scummvm"), "Build configuration list for PBXProject \"" PROJECT_NAME "\"", SettingsNoValue); project->addProperty("compatibilityVersion", "Xcode 3.2", "", SettingsNoValue|SettingsQuoteVariable); project->addProperty("developmentRegion", "English", "", SettingsNoValue); project->addProperty("hasScannedForEncodings", "1", "", SettingsNoValue); @@ -439,7 +440,8 @@ void XCodeProvider::setupResourcesBuildPhase() { // Setup resource file properties std::map properties; - properties["modern.zip"] = FileProperty("archive.zip", "", "modern.zip", "\"\""); + properties["scummclassic.zip"] = FileProperty("archive.zip", "", "scummclassic.zip", "\"\""); + properties["scummmodern.zip"] = FileProperty("archive.zip", "", "scummmodern.zip", "\"\""); properties["kyra.dat"] = FileProperty("file", "", "kyra.dat", "\"\""); properties["lure.dat"] = FileProperty("file", "", "lure.dat", "\"\""); @@ -467,7 +469,8 @@ void XCodeProvider::setupResourcesBuildPhase() { files.flags = SettingsAsList; ValueList files_list; - files_list.push_back("modern.zip"); + files_list.push_back("scummclassic.zip"); + files_list.push_back("scummmodern.zip"); files_list.push_back("kyra.dat"); files_list.push_back("lure.dat"); files_list.push_back("queen.tbl"); @@ -493,8 +496,8 @@ void XCodeProvider::setupResourcesBuildPhase() { } // Add custom files depending on the target - if (_targets[i] == "ResidualVM-OS X") { - files.settings[getHash("PBXResources_residualvm.icns")] = Setting("", "residualvm.icns in Resources", SettingsNoValue, 0, 6); + if (_targets[i] == PROJECT_DESCRIPTION "-OS X") { + files.settings[getHash("PBXResources_" PROJECT_NAME ".icns")] = Setting("", PROJECT_NAME ".icns in Resources", SettingsNoValue, 0, 6); // Remove 2 iphone icon files files.settings.erase(getHash("PBXResources_Default.png")); @@ -524,7 +527,7 @@ void XCodeProvider::setupBuildConfiguration() { // ****************************************/ // Debug - Object *iPhone_Debug_Object = new Object(this, "XCBuildConfiguration_ResidualVM-iPhone_Debug", _targets[0] /* ScummVM-iPhone */, "XCBuildConfiguration", "PBXNativeTarget", "Debug"); + Object *iPhone_Debug_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-iPhone_Debug", _targets[0] /* ScummVM-iPhone */, "XCBuildConfiguration", "PBXNativeTarget", "Debug"); Property iPhone_Debug; ADD_SETTING_QUOTE(iPhone_Debug, "ARCHS", "$(ARCHS_UNIVERSAL_IPHONE_OS)"); ADD_SETTING_QUOTE(iPhone_Debug, "CODE_SIGN_IDENTITY", "iPhone Developer"); @@ -556,7 +559,7 @@ void XCodeProvider::setupBuildConfiguration() { ADD_SETTING_LIST(iPhone_Debug, "LIBRARY_SEARCH_PATHS", iPhone_LibPaths, SettingsAsList, 5); ADD_SETTING(iPhone_Debug, "ONLY_ACTIVE_ARCH", "YES"); ADD_SETTING(iPhone_Debug, "PREBINDING", "NO"); - ADD_SETTING(iPhone_Debug, "PRODUCT_NAME", "ResidualVM"); + ADD_SETTING(iPhone_Debug, "PRODUCT_NAME", PROJECT_DESCRIPTION); ADD_SETTING_QUOTE(iPhone_Debug, "PROVISIONING_PROFILE", "EF590570-5FAC-4346-9071-D609DE2B28D8"); ADD_SETTING_QUOTE_VAR(iPhone_Debug, "PROVISIONING_PROFILE[sdk=iphoneos*]", ""); ADD_SETTING(iPhone_Debug, "SDKROOT", "iphoneos4.0"); @@ -566,7 +569,7 @@ void XCodeProvider::setupBuildConfiguration() { iPhone_Debug_Object->properties["buildSettings"] = iPhone_Debug; // Release - Object *iPhone_Release_Object = new Object(this, "XCBuildConfiguration_ResidualVM-iPhone_Release", _targets[0] /* ScummVM-iPhone */, "XCBuildConfiguration", "PBXNativeTarget", "Release"); + Object *iPhone_Release_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-iPhone_Release", _targets[0] /* ScummVM-iPhone */, "XCBuildConfiguration", "PBXNativeTarget", "Release"); Property iPhone_Release(iPhone_Debug); ADD_SETTING(iPhone_Release, "GCC_OPTIMIZATION_LEVEL", "3"); ADD_SETTING(iPhone_Release, "COPY_PHASE_STRIP", "YES"); @@ -584,7 +587,7 @@ void XCodeProvider::setupBuildConfiguration() { ****************************************/ // Debug - Object *scummvm_Debug_Object = new Object(this, "XCBuildConfiguration_residualvm_Debug", "residualvm", "XCBuildConfiguration", "PBXProject", "Debug"); + Object *scummvm_Debug_Object = new Object(this, "XCBuildConfiguration_" PROJECT_NAME "_Debug", PROJECT_NAME, "XCBuildConfiguration", "PBXProject", "Debug"); Property scummvm_Debug; ADD_SETTING(scummvm_Debug, "ALWAYS_SEARCH_USER_PATHS", "NO"); ADD_SETTING_QUOTE(scummvm_Debug, "ARCHS", "$(ARCHS_STANDARD_32_BIT)"); @@ -621,7 +624,7 @@ void XCodeProvider::setupBuildConfiguration() { scummvm_Debug_Object->properties["buildSettings"] = scummvm_Debug; // Release - Object *scummvm_Release_Object = new Object(this, "XCBuildConfiguration_scummvm_Release", "residualvm", "XCBuildConfiguration", "PBXProject", "Release"); + Object *scummvm_Release_Object = new Object(this, "XCBuildConfiguration_" PROJECT_NAME "_Release", PROJECT_NAME, "XCBuildConfiguration", "PBXProject", "Release"); Property scummvm_Release(scummvm_Debug); REMOVE_SETTING(scummvm_Release, "GCC_C_LANGUAGE_STANDARD"); // Not sure why we remove that, or any of the other warnings REMOVE_SETTING(scummvm_Release, "GCC_WARN_ABOUT_RETURN_TYPE"); @@ -639,7 +642,7 @@ void XCodeProvider::setupBuildConfiguration() { ****************************************/ // Debug - Object *scummvmOSX_Debug_Object = new Object(this, "XCBuildConfiguration_ResidualVM-OSX_Debug", _targets[1] /* ScummVM-OS X */, "XCBuildConfiguration", "PBXNativeTarget", "Debug"); + Object *scummvmOSX_Debug_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-OSX_Debug", _targets[1] /* ScummVM-OS X */, "XCBuildConfiguration", "PBXNativeTarget", "Debug"); Property scummvmOSX_Debug; ADD_SETTING_QUOTE(scummvmOSX_Debug, "ARCHS", "$(NATIVE_ARCH)"); ADD_SETTING(scummvmOSX_Debug, "COMPRESS_PNG_FILES", "NO"); @@ -685,13 +688,13 @@ void XCodeProvider::setupBuildConfiguration() { scummvmOSX_LdFlags.push_back("-lz"); ADD_SETTING_LIST(scummvmOSX_Debug, "OTHER_LDFLAGS", scummvmOSX_LdFlags, SettingsAsList, 5); ADD_SETTING(scummvmOSX_Debug, "PREBINDING", "NO"); - ADD_SETTING(scummvmOSX_Debug, "PRODUCT_NAME", "ResidualVM"); + ADD_SETTING(scummvmOSX_Debug, "PRODUCT_NAME", PROJECT_DESCRIPTION); scummvmOSX_Debug_Object->addProperty("name", "Debug", "", SettingsNoValue); scummvmOSX_Debug_Object->properties["buildSettings"] = scummvmOSX_Debug; // Release - Object *scummvmOSX_Release_Object = new Object(this, "XCBuildConfiguration_ResidualVMOSX_Release", _targets[1] /* ScummVM-OS X */, "XCBuildConfiguration", "PBXNativeTarget", "Release"); + Object *scummvmOSX_Release_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-OSX_Release", _targets[1] /* ScummVM-OS X */, "XCBuildConfiguration", "PBXNativeTarget", "Release"); Property scummvmOSX_Release(scummvmOSX_Debug); ADD_SETTING(scummvmOSX_Release, "COPY_PHASE_STRIP", "YES"); REMOVE_SETTING(scummvmOSX_Release, "GCC_DYNAMIC_NO_PIC"); @@ -709,7 +712,7 @@ void XCodeProvider::setupBuildConfiguration() { ****************************************/ // Debug - Object *scummvmSimulator_Debug_Object = new Object(this, "XCBuildConfiguration_ResidualVM-Simulator_Debug", _targets[2] /* ScummVM-Simulator */, "XCBuildConfiguration", "PBXNativeTarget", "Debug"); + Object *scummvmSimulator_Debug_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-Simulator_Debug", _targets[2] /* ScummVM-Simulator */, "XCBuildConfiguration", "PBXNativeTarget", "Debug"); Property scummvmSimulator_Debug(iPhone_Debug); ADD_SETTING_QUOTE(scummvmSimulator_Debug, "FRAMEWORK_SEARCH_PATHS", "$(inherited)"); ADD_SETTING_LIST(scummvmSimulator_Debug, "GCC_PREPROCESSOR_DEFINITIONS", scummvm_defines, SettingsNoQuote|SettingsAsList, 5); @@ -720,7 +723,7 @@ void XCodeProvider::setupBuildConfiguration() { scummvmSimulator_Debug_Object->properties["buildSettings"] = scummvmSimulator_Debug; // Release - Object *scummvmSimulator_Release_Object = new Object(this, "XCBuildConfiguration_ResidualVM-Simulator_Release", _targets[2] /* ScummVM-Simulator */, "XCBuildConfiguration", "PBXNativeTarget", "Release"); + Object *scummvmSimulator_Release_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-Simulator_Release", _targets[2] /* ScummVM-Simulator */, "XCBuildConfiguration", "PBXNativeTarget", "Release"); Property scummvmSimulator_Release(scummvmSimulator_Debug); ADD_SETTING(scummvmSimulator_Release, "COPY_PHASE_STRIP", "YES"); REMOVE_SETTING(scummvmSimulator_Release, "GCC_DYNAMIC_NO_PIC"); diff --git a/devtools/update-version.pl b/devtools/update-version.pl index 8a1065fec2f..ac45cc9d58a 100755 --- a/devtools/update-version.pl +++ b/devtools/update-version.pl @@ -32,8 +32,12 @@ print "Setting version to '$VERSION'\n"; # List of the files in which we need to perform substitution. my @subs_files = qw( base/internal_version.h + dists/redhat/residualvm.spec + dists/redhat/residualvm-tools.spec dists/residualvm.rc + dists/slackware/residualvm.SlackBuild dists/macosx/Info.plist + dists/irix/residualvm.spec ); my %subs = ( diff --git a/graphics/decoders/bmp.h b/graphics/decoders/bmp.h index e11b12fad69..6360aa81c9e 100644 --- a/graphics/decoders/bmp.h +++ b/graphics/decoders/bmp.h @@ -19,6 +19,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/** + * @file + * Image decoder used in engines: + * - hugo + * - mohawk + */ + #ifndef GRAPHICS_DECODERS_BMP_H #define GRAPHICS_DECODERS_BMP_H diff --git a/graphics/decoders/jpeg.h b/graphics/decoders/jpeg.h index c566d5ad210..c74aa57ca1a 100644 --- a/graphics/decoders/jpeg.h +++ b/graphics/decoders/jpeg.h @@ -20,6 +20,13 @@ * */ +/** + * @file + * Image decoder used in engines: + * - groovie + * - mohawk + */ + #ifndef GRAPHICS_JPEG_H #define GRAPHICS_JPEG_H diff --git a/graphics/yuv_to_rgb.cpp b/graphics/yuv_to_rgb.cpp index ac7f217feea..78903d0cd87 100644 --- a/graphics/yuv_to_rgb.cpp +++ b/graphics/yuv_to_rgb.cpp @@ -300,4 +300,89 @@ void convertYUV420ToRGB(Graphics::Surface *dst, const byte *ySrc, const byte *uS convertYUV420ToRGB((byte *)dst->pixels, dst->pitch, lookup, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch); } +#define READ_QUAD(ptr, prefix) \ + byte prefix##A = ptr[index]; \ + byte prefix##B = ptr[index + 1]; \ + byte prefix##C = ptr[index + uvPitch]; \ + byte prefix##D = ptr[index + uvPitch + 1] + +#define DO_INTERPOLATION(out) \ + out = (out##A * (4 - xDiff) * (4 - yDiff) + out##B * xDiff * (4 - yDiff) + \ + out##C * yDiff * (4 - xDiff) + out##D * xDiff * yDiff) >> 4 + +#define DO_YUV410_PIXEL() \ + DO_INTERPOLATION(u); \ + DO_INTERPOLATION(v); \ + \ + cr_r = Cr_r_tab[v]; \ + crb_g = Cr_g_tab[v] + Cb_g_tab[u]; \ + cb_b = Cb_b_tab[u]; \ + \ + PUT_PIXEL(*ySrc, dstPtr); \ + dstPtr += sizeof(PixelInt); \ + \ + ySrc++; \ + xDiff++ + +template +void convertYUV410ToRGB(byte *dstPtr, int dstPitch, const YUVToRGBLookup *lookup, const byte *ySrc, const byte *uSrc, const byte *vSrc, int yWidth, int yHeight, int yPitch, int uvPitch) { + // Keep the tables in pointers here to avoid a dereference on each pixel + const int16 *Cr_r_tab = lookup->_colorTab; + const int16 *Cr_g_tab = Cr_r_tab + 256; + const int16 *Cb_g_tab = Cr_g_tab + 256; + const int16 *Cb_b_tab = Cb_g_tab + 256; + const uint32 *rgbToPix = lookup->_rgbToPix; + + int quarterWidth = yWidth >> 2; + + for (int y = 0; y < yHeight; y++) { + for (int x = 0; x < quarterWidth; x++) { + // Perform bilinear interpolation on the the chroma values + // Based on the algorithm found here: http://tech-algorithm.com/articles/bilinear-image-scaling/ + // Feel free to optimize further + int targetY = y >> 2; + int xDiff = 0; + int yDiff = y & 3; + int index = targetY * uvPitch + x; + + // Declare some variables for the following macros + byte u, v; + int16 cr_r, crb_g, cb_b; + register const uint32 *L; + + READ_QUAD(uSrc, u); + READ_QUAD(vSrc, v); + + DO_YUV410_PIXEL(); + DO_YUV410_PIXEL(); + DO_YUV410_PIXEL(); + DO_YUV410_PIXEL(); + } + + dstPtr += dstPitch - yWidth * sizeof(PixelInt); + ySrc += yPitch - yWidth; + } +} + +#undef READ_QUAD +#undef DO_INTERPOLATION +#undef DO_YUV410_PIXEL + +void convertYUV410ToRGB(Graphics::Surface *dst, const byte *ySrc, const byte *uSrc, const byte *vSrc, int yWidth, int yHeight, int yPitch, int uvPitch) { + // Sanity checks + assert(dst && dst->pixels); + assert(dst->format.bytesPerPixel == 2 || dst->format.bytesPerPixel == 4); + assert(ySrc && uSrc && vSrc); + assert((yWidth & 3) == 0); + assert((yHeight & 3) == 0); + + const YUVToRGBLookup *lookup = YUVToRGBMan.getLookup(dst->format); + + // Use a templated function to avoid an if check on every pixel + if (dst->format.bytesPerPixel == 2) + convertYUV410ToRGB((byte *)dst->pixels, dst->pitch, lookup, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch); + else + convertYUV410ToRGB((byte *)dst->pixels, dst->pitch, lookup, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch); +} + } // End of namespace Graphics diff --git a/graphics/yuv_to_rgb.h b/graphics/yuv_to_rgb.h index 8e025042dcf..73a2c69d7d4 100644 --- a/graphics/yuv_to_rgb.h +++ b/graphics/yuv_to_rgb.h @@ -64,6 +64,25 @@ void convertYUV444ToRGB(Graphics::Surface *dst, const byte *ySrc, const byte *uS */ void convertYUV420ToRGB(Graphics::Surface *dst, const byte *ySrc, const byte *uSrc, const byte *vSrc, int yWidth, int yHeight, int yPitch, int uvPitch); +/** + * Convert a YUV410 image to an RGB surface + * + * Since the chroma has a very low resolution in 410, we perform bilinear scaling + * on the two chroma planes to produce the image. The chroma planes must have + * at least one extra row that can be read from in order to produce a proper + * image (filled with 0x80). This is required in order to speed up this function. + * + * @param dst the destination surface + * @param ySrc the source of the y component + * @param uSrc the source of the u component + * @param vSrc the source of the v component + * @param yWidth the width of the y surface (must be divisible by 4) + * @param yHeight the height of the y surface (must be divisible by 4) + * @param yPitch the pitch of the y surface + * @param uvPitch the pitch of the u and v surfaces + */ +void convertYUV410ToRGB(Graphics::Surface *dst, const byte *ySrc, const byte *uSrc, const byte *vSrc, int yWidth, int yHeight, int yPitch, int uvPitch); + } // End of namespace Graphics #endif