45#define THUNDER_DATA 0x3f
46#define THUNDER_CODE 0xc0
48#define THUNDER_RUN 0x00
49#define THUNDER_2BITDELTAS 0x40
51#define THUNDER_3BITDELTAS 0x80
53#define THUNDER_RAW 0xc0
55static const int twobitdeltas[4] = { 0, 1, 0, -1 };
56static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 };
58#define SETPIXEL(op, v) { \
59 lastpixel = (v) & 0xf; \
60 if ( npixels < maxpixels ) \
65 op[0] = (uint8) (lastpixel << 4); \
70ThunderSetupDecode(
TIFF* tif)
72 static const char module[] =
"ThunderSetupDecode";
77 "Wrong bitspersample value (%d), Thunder decoder only supports 4bits per sample.",
89 static const char module[] =
"ThunderDecode";
90 register unsigned char *bp;
92 unsigned int lastpixel;
99 while (
cc > 0 && npixels < maxpixels) {
104 switch (
n & THUNDER_CODE) {
112 lastpixel = *
op++; npixels++;
n--;
114 lastpixel |= lastpixel << 4;
116 if (npixels < maxpixels) {
117 for (;
n > 0;
n -= 2)
124 case THUNDER_2BITDELTAS:
125 if ((delta = ((
n >> 4) & 3)) != DELTA2_SKIP)
126 SETPIXEL(
op, (
unsigned)((
int)lastpixel + twobitdeltas[delta]));
127 if ((delta = ((
n >> 2) & 3)) != DELTA2_SKIP)
128 SETPIXEL(
op, (
unsigned)((
int)lastpixel + twobitdeltas[delta]));
129 if ((delta = (
n & 3)) != DELTA2_SKIP)
130 SETPIXEL(
op, (
unsigned)((
int)lastpixel + twobitdeltas[delta]));
132 case THUNDER_3BITDELTAS:
133 if ((delta = ((
n >> 3) & 7)) != DELTA3_SKIP)
134 SETPIXEL(
op, (
unsigned)((
int)lastpixel + threebitdeltas[delta]));
135 if ((delta = (
n & 7)) != DELTA3_SKIP)
136 SETPIXEL(
op, (
unsigned)((
int)lastpixel + threebitdeltas[delta]));
145 if (npixels != maxpixels) {
146#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
148 "%s data at scanline %lu (%I64u != %I64u)",
149 npixels < maxpixels ?
"Not enough" :
"Too much",
155 "%s data at scanline %lu (%llu != %llu)",
156 npixels < maxpixels ?
"Not enough" :
"Too much",
158 (
unsigned long long) npixels,
159 (
unsigned long long) maxpixels);
170 static const char module[] =
"ThunderDecodeRow";
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLenum GLuint GLenum GLsizei const GLchar * buf
tmsize_t tif_scanlinesize
TIFFCodeMethod tif_decodestrip
TIFFCodeMethod tif_decoderow
TIFFBoolMethod tif_setupdecode
#define TIFFInitThunderScan
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
#define SETPIXEL(buf, x, y, p)