Use BABL method for 16-to-8 bit conversion (#3429)
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
#ifndef _MYMATH_
|
||||
#define _MYMATH_
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
namespace rtengine
|
||||
{
|
||||
static const int MAXVAL = 0xffff;
|
||||
static const float MAXVALF = float(MAXVAL); // float version of MAXVAL
|
||||
static const double MAXVALD = double(MAXVAL); // double version of MAXVAL
|
||||
|
||||
constexpr int MAXVAL = 0xffff;
|
||||
constexpr float MAXVALF = static_cast<float>(MAXVAL); // float version of MAXVAL
|
||||
constexpr double MAXVALD = static_cast<double>(MAXVAL); // double version of MAXVAL
|
||||
|
||||
template <typename _Tp>
|
||||
inline _Tp SQR (_Tp x)
|
||||
@@ -107,6 +108,9 @@ inline int float2uint16range(float d) // clips input to [0;65535] and rounds
|
||||
return d + 0.5f;
|
||||
}
|
||||
|
||||
constexpr std::uint8_t uint16ToUint8Rounded(std::uint16_t i)
|
||||
{
|
||||
return ((i + 128) - ((i + 128) >> 8)) >> 8;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user