| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#ifndef APDK_FILTERHPA_H |
| 33 |
#define APDK_FILTERHPA_H |
| 34 |
|
| 35 |
#if defined(APDK_DJ9xxVIP) && defined(APDK_VIP_COLORFILTERING) |
| 36 |
|
| 37 |
APDK_BEGIN_NAMESPACE |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
enum eBlockType |
| 47 |
{ |
| 48 |
eDone = 0x0, |
| 49 |
e11n = 0x00000001, |
| 50 |
e11s = 0x00000002, |
| 51 |
e12 = 0x00000004, |
| 52 |
e14n = 0x00000008, |
| 53 |
e14s = 0x00000010, |
| 54 |
e21nw = 0x00000020, |
| 55 |
e21ne = 0x00000040, |
| 56 |
e21sw = 0x00000080, |
| 57 |
e21se = 0x00000100, |
| 58 |
e22w = 0x00000200, |
| 59 |
e22e = 0x00000400, |
| 60 |
e24nw = 0x00000800, |
| 61 |
e24ne = 0x00001000, |
| 62 |
e24sw = 0x00002000, |
| 63 |
e24se = 0x00004000, |
| 64 |
e41ni = 0x00008000, |
| 65 |
e41n = 0x00010000, |
| 66 |
e41si = 0x00020000, |
| 67 |
e41s = 0x00040000, |
| 68 |
e42i = 0x00080000, |
| 69 |
e42 = 0x00100000, |
| 70 |
e44ni = 0x00200000, |
| 71 |
e44n = 0x00400000, |
| 72 |
e44si = 0x00800000, |
| 73 |
e44s = 0x01000000, |
| 74 |
e84ni = 0x02000000, |
| 75 |
e84n = 0x04000000, |
| 76 |
e84si = 0x08000000, |
| 77 |
e84s = 0x10000000, |
| 78 |
|
| 79 |
eNorths = e11n | e21nw | e21ne | e41ni | e41n, |
| 80 |
eSouths = e11s | e21sw | e21se | e41si | e41s, |
| 81 |
eTheRest = ~(eNorths|eSouths), |
| 82 |
|
| 83 |
eTopLeftOfBlocks = e12 | e14n | e21nw | e21sw | e22w | e24nw | e41ni | e41si | e42i | e44ni | e84ni |
| 84 |
}; |
| 85 |
|
| 86 |
#define isOdd(x) (x & 0x01) |
| 87 |
#define isWhite(x) (((x) & kWhite) == kWhite) |
| 88 |
|
| 89 |
#define kMemWritesOptimize 0 // disables mem write optimizations. |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
#if kGatherStats == 1 |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
enum StatisticBlocks |
| 102 |
{ |
| 103 |
es11n = 0, |
| 104 |
es11s, |
| 105 |
es12, |
| 106 |
es14n, |
| 107 |
es14s, |
| 108 |
es21nw, |
| 109 |
es21ne, |
| 110 |
es21sw, |
| 111 |
es21se, |
| 112 |
es22w, |
| 113 |
es22e, |
| 114 |
es24nw, |
| 115 |
es24ne, |
| 116 |
es24sw, |
| 117 |
es24se, |
| 118 |
es41ni, |
| 119 |
es41n, |
| 120 |
es41si, |
| 121 |
es41s, |
| 122 |
es42i, |
| 123 |
es42, |
| 124 |
es44ni, |
| 125 |
es44n, |
| 126 |
es44si, |
| 127 |
es44s, |
| 128 |
es84ni, |
| 129 |
es84n, |
| 130 |
es84si, |
| 131 |
es84s, |
| 132 |
|
| 133 |
esDoneStat, |
| 134 |
esWhiteFound, |
| 135 |
|
| 136 |
eLastAveragingFlagPosition |
| 137 |
}; |
| 138 |
|
| 139 |
#endif |
| 140 |
|
| 141 |
enum pixelTypes |
| 142 |
{ |
| 143 |
eBGRPixelData = 0 |
| 144 |
}; |
| 145 |
|
| 146 |
class TErnieFilter : public Processor |
| 147 |
{ |
| 148 |
public: |
| 149 |
TErnieFilter(int rowWidthInPixels, pixelTypes pixelType, unsigned int maxErrorForTwoPixels, int bytesPerPixel = 3); |
| 150 |
virtual ~TErnieFilter(); |
| 151 |
|
| 152 |
void submitRowToFilter(unsigned char *rowPtr); |
| 153 |
void writeBufferedRows(); |
| 154 |
|
| 155 |
|
| 156 |
BOOL Process(RASTERDATA* InputRaster=NULL); |
| 157 |
void Flush(); |
| 158 |
unsigned int GetOutputWidth(COLORTYPE rastercolor); |
| 159 |
unsigned int GetInputWidth(); |
| 160 |
BYTE* NextOutputRaster(COLORTYPE rastercolor); |
| 161 |
|
| 162 |
|
| 163 |
private: |
| 164 |
uint32_t *fRowBuf[4]; |
| 165 |
unsigned char *fRowPtr[4]; |
| 166 |
BYTE *fBlackRowPtr[4]; |
| 167 |
unsigned int BlackRasterSize[4]; |
| 168 |
unsigned char *fCompressionOutBuf; |
| 169 |
unsigned int *fPixelFilteredFlags[2]; |
| 170 |
|
| 171 |
int fNumberOfBufferedRows; |
| 172 |
int fPixelOffset[8]; |
| 173 |
int fPixelOffsetIndex; |
| 174 |
int fRowWidthInPixels; |
| 175 |
int fRowWidthInBytes; |
| 176 |
int fInternalBufferPixelSize; |
| 177 |
int fOriginalPixelSize; |
| 178 |
unsigned int fMaxErrorForTwoPixels; |
| 179 |
|
| 180 |
int RowIndex; |
| 181 |
|
| 182 |
void Filter1RawRow(unsigned char *currPtr, int rowWidthInPixels, unsigned int *flagsPtr); |
| 183 |
void Filter2RawRows(unsigned char *currPtr, unsigned char *upPtr, int rowWidthInPixels, unsigned int *flagsPtr); |
| 184 |
void Filter2PairsOfFilteredRows(unsigned char *row1Ptr, unsigned char *row2Ptr, unsigned char *row3Ptr, unsigned char *row4Ptr); |
| 185 |
void Filter3FilteredRows(unsigned char *row1Ptr, unsigned char *row2Ptr, unsigned char *row3Ptr); |
| 186 |
inline unsigned int DeltaE(int dr0, int dr1, int dg0, int dg1, int db0, int db1); |
| 187 |
inline bool NewDeltaE(int dr0, int dr1, int dg0, int dg1, int db0, int db1, int tolerance); |
| 188 |
inline unsigned int GradDeltaE(int dr, int dg, int db); |
| 189 |
|
| 190 |
#if kMemWritesOptimize == 1 |
| 191 |
void WriteBlockPixels(); |
| 192 |
#endif |
| 193 |
|
| 194 |
enum |
| 195 |
{ |
| 196 |
eBufferedPixelWidthInBytes = 4 |
| 197 |
}; |
| 198 |
}; |
| 199 |
|
| 200 |
APDK_END_NAMESPACE |
| 201 |
|
| 202 |
#endif |
| 203 |
#endif |