6 #ifndef CHARLS_DEFAULTTRAITS
7 #define CHARLS_DEFAULTTRAITS
16 template <
class sample,
class pixel>
20 typedef sample SAMPLE;
46 RANGE = (MAXVAL + 2 * NEAR )/(2 * NEAR + 1) + 1;
48 LIMIT = 2 * (bpp + MAX(8,bpp));
54 inlinehint LONG ComputeErrVal(LONG e)
const
60 inlinehint SAMPLE ComputeReconstructedSample(LONG Px, LONG ErrVal)
62 return FixReconstructedValue(Px + DeQuantize(ErrVal));
65 inlinehint
bool IsNear(LONG lhs, LONG rhs)
const
66 {
return ABS(lhs-rhs) <=NEAR; }
70 return ABS(lhs.v1-rhs.v1) <=NEAR &&
71 ABS(lhs.v2-rhs.v2) <=NEAR &&
72 ABS(lhs.v3-rhs.v3) <=NEAR;
75 inlinehint LONG CorrectPrediction(LONG Pxc)
const
77 if ((Pxc & MAXVAL) == Pxc)
80 return (~(Pxc >> (LONG_BITCOUNT-1))) & MAXVAL;
83 inlinehint LONG ModRange(LONG Errval)
const
85 ASSERT(ABS(Errval) <= RANGE);
87 Errval = Errval + RANGE;
89 if (Errval >= ((RANGE + 1) / 2))
90 Errval = Errval - RANGE;
92 ASSERT(ABS(Errval) <= RANGE/2);
99 LONG Quantize(LONG Errval)
const
102 return (Errval + NEAR) / (2 * NEAR + 1);
104 return - (NEAR - Errval) / (2 * NEAR + 1);
108 inlinehint LONG DeQuantize(LONG Errval)
const
110 return Errval * (2 * NEAR + 1);
113 inlinehint SAMPLE FixReconstructedValue(LONG val)
const
116 val = val + RANGE*(2*NEAR+1);
117 else if (val > MAXVAL + NEAR)
118 val = val - RANGE*(2*NEAR+1);
120 return SAMPLE(CorrectPrediction(val));