diff --git a/src/textures/hires/xbr/xbrz_config_old.h b/src/textures/hires/xbr/xbrz_config_old.h index 480af7976a..885dff9f80 100644 --- a/src/textures/hires/xbr/xbrz_config_old.h +++ b/src/textures/hires/xbr/xbrz_config_old.h @@ -11,11 +11,6 @@ // * If you modify this file, you may extend this exception to your version * // * of the file, but you are not obligated to do so. If you do not wish to * // * do so, delete this exception statement from your version. * -// * * -// * An explicit permission was granted to use xBRZ in combination with ZDoom * -// * and derived projects as long as it is used for non-commercial purposes. * -// * * -// * Backported to C++98 by Alexey Lysiuk * // **************************************************************************** #ifndef __XBRZ_CONFIG_OLD_HEADER_INCLUDED__ diff --git a/src/textures/hires/xbr/xbrz_old.cpp b/src/textures/hires/xbr/xbrz_old.cpp index 07527cb95e..8eb19bb808 100644 --- a/src/textures/hires/xbr/xbrz_old.cpp +++ b/src/textures/hires/xbr/xbrz_old.cpp @@ -11,11 +11,6 @@ // * If you modify this file, you may extend this exception to your version * // * of the file, but you are not obligated to do so. If you do not wish to * // * do so, delete this exception statement from your version. * -// * * -// * An explicit permission was granted to use xBRZ in combination with ZDoom * -// * and derived projects as long as it is used for non-commercial purposes. * -// * * -// * Backported to C++98 by Alexey Lysiuk * // **************************************************************************** #include "xbrz_old.h" @@ -24,10 +19,6 @@ #include #include -#if __cplusplus > 199711 -#define XBRZ_CXX11 -#endif // __cplusplus > 199711 - namespace { template inline @@ -40,9 +31,7 @@ inline unsigned char getBlue (uint32_t val) { return getByte<0>(val); } template inline T abs(T value) { -#ifdef XBRZ_CXX11 - static_assert(std::numeric_limits::is_signed, ""); -#endif // XBRZ_CXX11 + static_assert(std::is_signed::value, ""); return value < 0 ? -value : value; } @@ -53,11 +42,9 @@ const uint32_t blueMask = 0x0000ff; template inline void alphaBlend(uint32_t& dst, uint32_t col) //blend color over destination with opacity N / M { -#ifdef XBRZ_CXX11 static_assert(N < 256, "possible overflow of (col & redMask) * N"); static_assert(M < 256, "possible overflow of (col & redMask ) * N + (dst & redMask ) * (M - N)"); static_assert(0 < N && N < M, ""); -#endif // XBRZ_CXX11 static const uint32_t ALPHA_MASK = 0xFF000000; static const uint32_t ALPHA_SHIFT = 24; @@ -526,20 +513,12 @@ BlendResult preProcessCorners(const Kernel_4x4& ker, const xbrz_old::ScalerCfg& ker.g == ker.k)) return result; -#ifdef XBRZ_CXX11 auto dist = [&](uint32_t col1, uint32_t col2) { return colorDist(col1, col2, cfg.luminanceWeight_); }; -#else // !XBRZ_CXX11 -#define dist(C1, C2) colorDist((C1), (C2), cfg.luminanceWeight_) -#endif // XBRZ_CXX11 const int weight = 4; double jg = dist(ker.i, ker.f) + dist(ker.f, ker.c) + dist(ker.n, ker.k) + dist(ker.k, ker.h) + weight * dist(ker.j, ker.g); double fk = dist(ker.e, ker.j) + dist(ker.j, ker.o) + dist(ker.b, ker.g) + dist(ker.g, ker.l) + weight * dist(ker.f, ker.k); -#ifndef XBRZ_CXX11 -#undef dist -#endif // !XBRZ_CXX11 - if (jg < fk) //test sample: 70% of values max(jg, fk) / min(jg, fk) are between 1.1 and 3.7 with median being 1.8 { const bool dominantGradient = cfg.dominantDirectionThreshold * jg < fk; @@ -621,42 +600,6 @@ int debugPixelY = 84; bool breakIntoDebugger = false; #endif -#define a get_a(ker) -#define b get_b(ker) -#define c get_c(ker) -#define d get_d(ker) -#define e get_e(ker) -#define f get_f(ker) -#define g get_g(ker) -#define h get_h(ker) -#define i get_i(ker) - -#ifndef XBRZ_CXX11 - -template -bool doLineBlend(const Kernel_3x3& ker, const xbrz_old::ScalerCfg& cfg, const unsigned char blend) -{ - if (getBottomR(blend) >= BLEND_DOMINANT) - return true; - -#define eq(C1, C2) (colorDist((C1), (C2), cfg.luminanceWeight_) < cfg.equalColorTolerance_) - - //make sure there is no second blending in an adjacent rotation for this pixel: handles insular pixels, mario eyes - if (getTopR(blend) != BLEND_NONE && !eq(e, g)) //but support double-blending for 90 degree corners - return false; - if (getBottomL(blend) != BLEND_NONE && !eq(e, c)) - return false; - - //no full blending for L-shapes; blend corner only (handles "mario mushroom eyes") - if (eq(g, h) && eq(h , i) && eq(i, f) && eq(f, c) && !eq(e, i)) - return false; - -#undef eq - - return true; -}; - -#endif // !XBRZ_CXX11 /* input kernel area naming convention: @@ -675,20 +618,25 @@ void scalePixel(const Kernel_3x3& ker, unsigned char blendInfo, //result of preprocessing all four corners of pixel "e" const xbrz_old::ScalerCfg& cfg) { -#ifndef NDEBUG +#define a get_a(ker) +#define b get_b(ker) +#define c get_c(ker) +#define d get_d(ker) +#define e get_e(ker) +#define f get_f(ker) +#define g get_g(ker) +#define h get_h(ker) +#define i get_i(ker) + +#if 0 //#ifndef NDEBUG if (breakIntoDebugger) -#ifdef _MSC_VER __debugbreak(); //__asm int 3; -#else // !_MSC_VER - __builtin_trap(); -#endif // _MSC_VER #endif const unsigned char blend = rotateBlendInfo(blendInfo); if (getBottomR(blend) >= BLEND_NORMAL) { -#ifdef XBRZ_CXX11 auto eq = [&](uint32_t col1, uint32_t col2) { return colorDist(col1, col2, cfg.luminanceWeight_) < cfg.equalColorTolerance_; }; auto dist = [&](uint32_t col1, uint32_t col2) { return colorDist(col1, col2, cfg.luminanceWeight_); }; @@ -709,19 +657,12 @@ void scalePixel(const Kernel_3x3& ker, return true; }(); -#else // !XBRZ_CXX11 -#define dist(C1, C2) colorDist((C1), (C2), cfg.luminanceWeight_) -#endif // XBRZ_CXX11 const uint32_t px = dist(e, f) <= dist(e, h) ? f : h; //choose most similar color OutputMatrix out(target, trgWidth); -#ifdef XBRZ_CXX11 if (doLineBlend) -#else // !XBRZ_CXX11 - if (doLineBlend(ker, cfg, blend)) -#endif // XBRZ_CXX11 { const double fg = dist(f, g); //test sample: 70% of values max(fg, hc) / min(fg, hc) are between 1.1 and 3.7 with median being 1.9 const double hc = dist(h, c); // @@ -748,10 +689,6 @@ void scalePixel(const Kernel_3x3& ker, Scaler::blendCorner(px, out); } -#ifndef XBRZ_CXX11 -#undef dist -#endif // XBRZ_CXX11 - #undef a #undef b #undef c @@ -779,9 +716,7 @@ void scaleImage(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const int bufferSize = srcWidth; unsigned char* preProcBuffer = reinterpret_cast(trg + yLast * Scaler::scale * trgWidth) - bufferSize; std::fill(preProcBuffer, preProcBuffer + bufferSize, 0); -#ifdef XBRZ_CXX11 static_assert(BLEND_NONE == 0, ""); -#endif // XBRZ_CXX11 //initialize preprocessing buffer for first row: detect upper left and right corner blending //this cannot be optimized for adjacent processing stripes; we must not allow for a memory race condition! diff --git a/src/textures/hires/xbr/xbrz_old.h b/src/textures/hires/xbr/xbrz_old.h index c93a1480a4..9a46f2a978 100644 --- a/src/textures/hires/xbr/xbrz_old.h +++ b/src/textures/hires/xbr/xbrz_old.h @@ -11,18 +11,13 @@ // * If you modify this file, you may extend this exception to your version * // * of the file, but you are not obligated to do so. If you do not wish to * // * do so, delete this exception statement from your version. * -// * * -// * An explicit permission was granted to use xBRZ in combination with ZDoom * -// * and derived projects as long as it is used for non-commercial purposes. * -// * * -// * Backported to C++98 by Alexey Lysiuk * // **************************************************************************** #ifndef __XBRZ_OLD_HEADER_INCLUDED__ #define __XBRZ_OLD_HEADER_INCLUDED__ #include //size_t -#include //uint32_t +#include //uint32_t #include #include "xbrz_config_old.h"