44#define THUNDER_DATA 0x3f
45#define THUNDER_CODE 0xc0
47#define THUNDER_RUN 0x00
48#define THUNDER_2BITDELTAS 0x40
50#define THUNDER_3BITDELTAS 0x80
52#define THUNDER_RAW 0xc0
54static const int twobitdeltas[4] = {0, 1, 0, -1};
55static const int threebitdeltas[8] = {0, 1, 2, 3, 0, -3, -2, -1};
57#define SETPIXEL(op, v) \
59 lastpixel = (v)&0xf; \
60 if (npixels < maxpixels) \
65 op[0] = (uint8_t)(lastpixel << 4); \
69static int ThunderSetupDecode(
TIFF *tif)
71 static const char module[] =
"ThunderSetupDecode";
76 "Wrong bitspersample value (%d), Thunder decoder only "
77 "supports 4bits per sample.",
87 static const char module[] =
"ThunderDecode";
88 register unsigned char *bp;
90 unsigned int lastpixel;
98 while (
cc > 0 && npixels < maxpixels)
104 switch (
n & THUNDER_CODE)
121 lastpixel |= lastpixel << 4;
123 if (npixels > maxpixels)
125 for (;
n > 0;
n -= 2)
131 case THUNDER_2BITDELTAS:
132 if ((delta = ((
n >> 4) & 3)) != DELTA2_SKIP)
134 (
unsigned)((
int)lastpixel + twobitdeltas[delta]));
135 if ((delta = ((
n >> 2) & 3)) != DELTA2_SKIP)
137 (
unsigned)((
int)lastpixel + twobitdeltas[delta]));
138 if ((delta = (
n & 3)) != DELTA2_SKIP)
140 (
unsigned)((
int)lastpixel + twobitdeltas[delta]));
142 case THUNDER_3BITDELTAS:
143 if ((delta = ((
n >> 3) & 7)) != DELTA3_SKIP)
145 op, (
unsigned)((
int)lastpixel + threebitdeltas[delta]));
146 if ((delta = (
n & 7)) != DELTA3_SKIP)
148 op, (
unsigned)((
int)lastpixel + threebitdeltas[delta]));
157 if (npixels != maxpixels)
159 uint8_t *op_end = op0 + (maxpixels + 1) / 2;
163 npixels < maxpixels ?
"Not enough" :
"Too much",
174 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
uint16_t td_bitspersample
tmsize_t tif_scanlinesize
TIFFCodeMethod tif_decodestrip
TIFFCodeMethod tif_decoderow
TIFFBoolMethod tif_setupdecode
#define TIFFInitThunderScan
void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt,...)
#define SETPIXEL(buf, x, y, p)