40#ifdef HAVE_UNSIGNED_CHAR
41typedef unsigned char U_CHAR;
42#define UCH(x) ((int) (x))
45#ifdef CHAR_IS_UNSIGNED
46#define UCH(x) ((int) (x))
48#define UCH(x) ((int) (x) & 0xFF)
53#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len)))
56#define MAXCOLORMAPSIZE 256
62#define MAX_LZW_BITS 12
63#define LZW_TABLE_SIZE (1<<MAX_LZW_BITS)
67#define LM_to_uint(array, offset) ((unsigned int) UCH(array[offset]) + \
68 (((unsigned int) UCH(array[offset+1])) << 8))
70#define BitSet(byte, bit) ((byte) & (bit))
72#define COLORMAPFLAG 0x80
102 U_CHAR code_buf[256+4];
107 boolean out_of_blocks;
110 int clear_code, end_code;
127 boolean is_interlaced;
135typedef gif_source_struct * gif_source_ptr;
161GetDataBlock (gif_source_ptr
sinfo, U_CHAR *
buf)
177SkipDataBlocks (gif_source_ptr
sinfo)
182 while (GetDataBlock(
sinfo,
buf) > 0)
188ReInitLZW (gif_source_ptr
sinfo)
191 sinfo->code_size =
sinfo->input_code_size + 1;
199InitLZWCode (gif_source_ptr
sinfo)
203 sinfo->last_byte = 2;
204 sinfo->code_buf[0] = 0;
205 sinfo->code_buf[1] = 0;
213 sinfo->clear_code = 1 <<
sinfo->input_code_size;
224 register INT32 accum;
230 if (
sinfo->first_time) {
232 return sinfo->clear_code;
234 if (
sinfo->out_of_blocks) {
236 return sinfo->end_code;
245 return sinfo->end_code;
254 offs =
sinfo->cur_bit >> 3;
257 accum |= (
INT32) UCH(
sinfo->code_buf[offs+1]);
262 accum >>= (
sinfo->cur_bit & 7);
264 return ((
int) accum) & ((1 <<
sinfo->code_size) - 1);
269LZWReadByte (gif_source_ptr
sinfo)
277 return (
int) *(--
sinfo->sp);
300 if (!
sinfo->out_of_blocks) {
301 SkipDataBlocks(
sinfo);
333 if ((
code =
sinfo->max_code) < LZW_TABLE_SIZE) {
340 sinfo->code_size < MAX_LZW_BITS) {
342 sinfo->limit_code <<= 1;
346 sinfo->oldcode = incode;
347 return sinfo->firstcode;
357 for (
i = 0;
i < cmaplen;
i++) {
358#if BITS_IN_JSAMPLE == 8
359#define UPSCALE(x) (x)
361#define UPSCALE(x) ((x) << (BITS_IN_JSAMPLE-8))
371DoExtension (gif_source_ptr
sinfo)
381 SkipDataBlocks(
sinfo);
395 int colormaplen, aspectRatio;
401 if (hdrbuf[0] !=
'G' || hdrbuf[1] !=
'I' || hdrbuf[2] !=
'F')
407 if ((hdrbuf[3] !=
'8' || hdrbuf[4] !=
'7' || hdrbuf[5] !=
'a') &&
408 (hdrbuf[3] !=
'8' || hdrbuf[4] !=
'9' || hdrbuf[5] !=
'a'))
409 TRACEMS3(cinfo, 1, JTRC_GIF_BADVERSION, hdrbuf[3], hdrbuf[4], hdrbuf[5]);
413 ERREXIT(cinfo, JERR_INPUT_EOF);
414 width = LM_to_uint(hdrbuf, 0);
415 height = LM_to_uint(hdrbuf, 2);
417 aspectRatio = UCH(hdrbuf[6]);
418 if (aspectRatio != 0 && aspectRatio != 49)
419 TRACEMS(cinfo, 1, JTRC_GIF_NONSQUARE);
427 if (BitSet(hdrbuf[4], COLORMAPFLAG)) {
428 colormaplen = 2 << (hdrbuf[4] & 0x07);
439 ERREXIT(cinfo, JERR_GIF_IMAGENOTFOUND);
453 ERREXIT(cinfo, JERR_INPUT_EOF);
455 width = LM_to_uint(hdrbuf, 4);
456 height = LM_to_uint(hdrbuf, 6);
457 source->is_interlaced = (BitSet(hdrbuf[8], INTERLACE) != 0);
462 if (BitSet(hdrbuf[8], COLORMAPFLAG)) {
463 colormaplen = 2 << (hdrbuf[8] & 0x07);
468 if (
source->input_code_size < 2 ||
source->input_code_size > 8)
491 if (
source->is_interlaced) {
496 source->interlaced_image = (*cinfo->mem->request_virt_sarray)
499 if (cinfo->progress !=
NULL) {
503 source->pub.get_pixel_rows = load_interlaced_image;
505 source->pub.get_pixel_rows = get_pixel_rows;
511 source->pub.buffer_height = 1;
514 for (
c = colormaplen;
c <
source->clear_code;
c++) {
516 source->colormap[CM_GREEN][
c] =
549 *
ptr++ = colormap[CM_RED ][
c];
550 *
ptr++ = colormap[CM_GREEN][
c];
551 *
ptr++ = colormap[CM_BLUE ][
c];
579 sptr = * (*cinfo->mem->access_virt_sarray) ((
j_common_ptr) cinfo,
589 source->pub.get_pixel_rows = get_interlaced_row;
591 source->cur_row_number = 0;
596 return get_interlaced_row(cinfo,
sinfo);
617 switch ((
int) (
source->cur_row_number & 7)) {
619 irow =
source->cur_row_number >> 3;
622 irow = (
source->cur_row_number >> 3) +
source->pass2_offset;
626 irow = (
source->cur_row_number >> 2) +
source->pass3_offset;
629 irow = (
source->cur_row_number >> 1) +
source->pass4_offset;
631 sptr = * (*cinfo->mem->access_virt_sarray) ((
j_common_ptr) cinfo,
637 *
ptr++ = colormap[CM_RED ][
c];
638 *
ptr++ = colormap[CM_GREEN][
c];
639 *
ptr++ = colormap[CM_BLUE ][
c];
667 source = (gif_source_ptr) (*cinfo->mem->alloc_small)
671 source->pub.start_input = start_input_gif;
672 source->pub.finish_input = finish_input_gif;
struct cdjpeg_progress_mgr * cd_progress_ptr
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
GLuint GLuint GLsizei count
GLint GLint GLsizei GLsizei height
GLint GLint GLsizei width
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE *_File)
#define TRACEMS1(cinfo, lvl, code, p1)
#define TRACEMS(cinfo, lvl, code)
#define WARNMS1(cinfo, code, p1)
#define ERREXIT1(cinfo, code, p1)
#define WARNMS(cinfo, code)
#define TRACEMS3(cinfo, lvl, code, p1, p2, p3)
#define GETJSAMPLE(value)
struct jpeg_common_struct * j_common_ptr
BYTE ReadByte(PSAFE_READ pRead)
struct jpeg_progress_mgr pub
int completed_extra_passes
J_COLOR_SPACE in_color_space
#define ReadOK(tif, buf, size)