1 #ifndef STB_ZLIB_H 2 #define STB_ZLIB_H 3 4 // ZLIB client - used by PNG, available for other purposes 5 #include <stdio.h> 6 7 typedef unsigned char uint8; 8 typedef unsigned short uint16; 9 typedef signed short int16; 10 typedef unsigned int uint32; 11 typedef signed int int32; 12 typedef unsigned int uint; 13 14 15 // fast-way is faster to check than jpeg huffman, but slow way is slower 16 #define ZFAST_BITS 9 // accelerate all cases in default tables 17 #define ZFAST_MASK ((1 << ZFAST_BITS) - 1) 18 19 // zlib-style huffman encoding 20 // (jpegs packs from left, zlib from right, so can't share code) 21 typedef struct 22 { 23 uint16 fast[1 << ZFAST_BITS]; 24 uint16 firstcode[16]; 25 int maxcode[17]; 26 uint16 firstsymbol[16]; 27 uint8 size[288]; 28 uint16 value[288]; 29 } zhuffman; 30 31 typedef struct 32 { 33 uint8 *zbuffer, *zbuffer_end; 34 FILE *zf; 35 int totread,totsize; 36 int num_bits; 37 uint32 code_buffer; 38 39 char *zout; 40 char *zout_start; 41 char *zout_end; 42 int z_expandable; 43 44 uint8 *cbuf; 45 uint32 cb_pos; 46 int final,left,type,dist; 47 48 zhuffman z_length, z_distance; 49 } zbuf; 50 51 52 53 54 char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); 55 56 zbuf *stbi_zlib_create_zbuf(const char *ibuffer,FILE *f, int ilen); 57 int stbi_zlib_decode_noheader_stream(zbuf *a,char *obuffer, int olen); 58 59 60 61 #endif 62