7 #ifndef CHARLS_LOSSLESSTRAITS
8 #define CHARLS_LOSSLESSTRAITS
15 template <
class sample, LONG bitsperpixel>
18 typedef sample SAMPLE;
24 MAXVAL= (1 << bpp) - 1,
25 LIMIT = 2 * (bitsperpixel + MAX(8,bitsperpixel)),
29 static inlinehint LONG ComputeErrVal(LONG d)
30 {
return ModRange(d); }
32 static inlinehint
bool IsNear(LONG lhs, LONG rhs)
33 {
return lhs == rhs; }
35 static inlinehint LONG ModRange(LONG Errval)
37 return LONG(Errval << (LONG_BITCOUNT - bpp)) >> (LONG_BITCOUNT - bpp);
40 static inlinehint SAMPLE ComputeReconstructedSample(LONG Px, LONG ErrVal)
42 return SAMPLE(MAXVAL & (Px + ErrVal));
45 static inlinehint LONG CorrectPrediction(LONG Pxc)
47 if ((Pxc & MAXVAL) == Pxc)
50 return (~(Pxc >> (LONG_BITCOUNT-1))) & MAXVAL;
56 #if defined(_MSC_VER) && _MSC_VER <= 1200
57 # define DISABLE_SPECIALIZATIONS
60 template <
class SAMPLE, LONG bpp>
73 static inlinehint
signed char ModRange(LONG Errval)
74 {
return (
signed char)Errval; }
76 static inlinehint LONG ComputeErrVal(LONG d)
77 {
return (
signed char)(d); }
79 static inlinehint BYTE ComputeReconstructedSample(LONG Px, LONG ErrVal)
80 {
return BYTE(Px + ErrVal); }
91 static inlinehint
short ModRange(LONG Errval)
92 {
return short(Errval); }
94 static inlinehint LONG ComputeErrVal(LONG d)
97 static inlinehint SAMPLE ComputeReconstructedSample(LONG Px, LONG ErrVal)
98 {
return SAMPLE(Px + ErrVal); }
105 template<
class SAMPLE, LONG bpp>
110 static inlinehint
bool IsNear(LONG lhs, LONG rhs)
111 {
return lhs == rhs; }
113 static inlinehint
bool IsNear(
PIXEL lhs,
PIXEL rhs)
114 {
return lhs == rhs; }
117 static inlinehint SAMPLE ComputeReconstructedSample(LONG Px, LONG ErrVal)
118 {
return SAMPLE(Px + ErrVal); }