mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
- cleaned up old xBRZ 1.0 upscaler
Removed obsolete header comments and support for C++98 Disabled Windows only debug features
This commit is contained in:
parent
30c3f4f597
commit
e111e2251c
3 changed files with 13 additions and 88 deletions
|
@ -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__
|
||||
|
|
|
@ -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 <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
#if __cplusplus > 199711
|
||||
#define XBRZ_CXX11
|
||||
#endif // __cplusplus > 199711
|
||||
|
||||
namespace
|
||||
{
|
||||
template <uint32_t N> inline
|
||||
|
@ -40,9 +31,7 @@ inline unsigned char getBlue (uint32_t val) { return getByte<0>(val); }
|
|||
template <class T> inline
|
||||
T abs(T value)
|
||||
{
|
||||
#ifdef XBRZ_CXX11
|
||||
static_assert(std::numeric_limits<T>::is_signed, "");
|
||||
#endif // XBRZ_CXX11
|
||||
static_assert(std::is_signed<T>::value, "");
|
||||
return value < 0 ? -value : value;
|
||||
}
|
||||
|
||||
|
@ -53,11 +42,9 @@ const uint32_t blueMask = 0x0000ff;
|
|||
template <unsigned int N, unsigned int M> 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<rotDeg>(ker)
|
||||
#define b get_b<rotDeg>(ker)
|
||||
#define c get_c<rotDeg>(ker)
|
||||
#define d get_d<rotDeg>(ker)
|
||||
#define e get_e<rotDeg>(ker)
|
||||
#define f get_f<rotDeg>(ker)
|
||||
#define g get_g<rotDeg>(ker)
|
||||
#define h get_h<rotDeg>(ker)
|
||||
#define i get_i<rotDeg>(ker)
|
||||
|
||||
#ifndef XBRZ_CXX11
|
||||
|
||||
template <RotationDegree rotDeg>
|
||||
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<rotDeg>(ker)
|
||||
#define b get_b<rotDeg>(ker)
|
||||
#define c get_c<rotDeg>(ker)
|
||||
#define d get_d<rotDeg>(ker)
|
||||
#define e get_e<rotDeg>(ker)
|
||||
#define f get_f<rotDeg>(ker)
|
||||
#define g get_g<rotDeg>(ker)
|
||||
#define h get_h<rotDeg>(ker)
|
||||
#define i get_i<rotDeg>(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<rotDeg>(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<Scaler::scale, rotDeg> out(target, trgWidth);
|
||||
|
||||
#ifdef XBRZ_CXX11
|
||||
if (doLineBlend)
|
||||
#else // !XBRZ_CXX11
|
||||
if (doLineBlend<rotDeg>(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<unsigned char*>(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!
|
||||
|
|
|
@ -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 <cstddef> //size_t
|
||||
#include <stdint.h> //uint32_t
|
||||
#include <cstdint> //uint32_t
|
||||
#include <limits>
|
||||
#include "xbrz_config_old.h"
|
||||
|
||||
|
|
Loading…
Reference in a new issue