21 #ifndef CVD_SCALAR_CONVERT_H
22 #define CVD_SCALAR_CONVERT_H
51 template<
class To,
class From>
struct int_info {
64 static const int shift_dir = (diff == 0)?0:((diff > 0)?1:-1);
67 template<
class To,
int num,
int shift,
int bits,
int r_shift>
struct upshift
74 template<
class To,
int shift,
int bits,
int r_shift>
struct upshift<To,0,shift,bits,r_shift>
82 template<class To, class From, int i=int_info<To,From>::shift_dir>
struct shift_convert {
83 template <
class D>
static To
from(D f) {
84 return static_cast<To
>(f);
91 template <
class D>
static To
from(D f) {
98 template <
class D>
static To
from(D f) {
108 for (
int i=0; i<=511; i++)
109 table[i] = (S)((i-255)/255.0);
123 return static_cast<To
>(from*factor);
129 template <
class From,
class To,
class D>
struct ScalarConvert<From,To,D,true, true> {
130 static inline To
from(
const D& f) {
138 template<
class From,
class D>
struct ScalarConvert<From, bool, D, true, true>
145 template<
class From,
class D>
struct ScalarConvert<From, bool, D, true, false>
164 return static_cast<float>(from * (1.0/255.0));
175 return from * (1.0/255.0);
static To from(const D &f)
static double double_for_byte[512]
static To aggregate(To i)
float byte_to_float(int b)
double byte_float_to_float(double d)
bool buildLookupTable(S table[])
static const int extra_bits
static To aggregate(To i)
static bool from(const D &from)
static float from(const D &from)
static const int shift_dir
To scalar_convert(const D &d)
static const bool init_double_for_byte
static float from(const D &from)
static double from(const D &from)
static const int final_rshift
static const bool init_float_for_byte
static To from(const D &from)
int_info< To, From > info
static double from(const D &from)
double byte_to_double(int b)
static bool from(const D &from)
static float float_for_byte[512]