📄 commondecls.h
字号:
#include <stdio.h>#include <stddef.h>#include <stdlib.h>#include <string.h>#define SIZEOF(object) ((size_t) sizeof(object))typedef unsigned char JSAMPLE;typedef JSAMPLE *JSAMPROW; /* ptr to one image row of pixel samples. */typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */typedef long INT32;/* Datatype used for image dimensions. The JPEG standard only supports * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore * "unsigned int" is sufficient on all machines. However, if you need to * handle larger images and you don't mind deviating from the spec, you * can change this datatype. */typedef int DCTELEM; typedef unsigned int JDIMENSION; /*usigned int is 32 bits*/typedef unsigned char UINT8;typedef unsigned char JOCTET; /*output data*/typedef short JCOEF; /*data after quantitify*/typedef JCOEF *JCOEFPTR; /* UINT16 must hold at least the values 0..65535. */typedef unsigned short UINT16;extern const int jpeg_natural_order[];#define DCTSIZE2 64#define DCTSIZE 8#define OUTPUT_BUF_SIZE 4096#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size))#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size))#define JFREAD(file,buf,sizeofbuf) \ ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))#define JFWRITE(file,buf,sizeofbuf) \ ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len)))#define WriteOK(file,buffer,len) (JFWRITE(file,buffer,len)==((size_t) (len)))#define LOCAL(type) static type#define GETJSAMPLE(value) ((int) (value))#define CENTERJSAMPLE 128#define ONE ((INT32) 1)#define SHIFT_TEMPS#define RIGHT_SHIFT(x,shft) ((x) >> (shft))#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)/* Huffman coding tables. */typedef struct { /* These two fields directly represent the contents of a JPEG DHT marker */ UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ /* length k bits; bits[0] is unused */ UINT8 huffval[256]; /* The symbols, in order of incr code length */ } JHUFF_TBL;typedef struct { unsigned int ehufco[256]; /* code for each symbol */ char ehufsi[256]; /* length of code for each symbol */ /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */} c_derived_tbl;typedef struct { INT32 put_buffer; /* current bit-accumulation buffer */ int put_bits; /* # of bits now in it */ int last_dc_val; /* last DC coef for the component */} _savable_state;typedef struct _jpeg_destination_mgr { JOCTET * next_output_byte; /* => next byte to write in buffer */ size_t free_in_buffer; /* # of byte spaces remaining in buffer */} jpeg_destination_mgr;/* Expanded entropy encoder object for arithmetic encoding. */typedef struct { INT32 c; /* C register, base of coding interval, layout as in sec. D.1.3 */ INT32 a; /* A register, normalized size of coding interval */ INT32 sc; /* counter for stacked 0xFF values which might overflow */ INT32 zc; /* counter for pending 0x00 output values which might * * be discarded at the end ("Pacman" termination) */ int buffer; int ct; /* bit shift counter, determines when next byte will be written */ unsigned char context_b[1000]; /* B pixel context conditioning */ unsigned char val_b[1000]; /* The pixel each line must be less than 1000*/ unsigned char dc_stats[160]; /* statictic model*/ int last_val; int context; } arith_entropy_encoder;typedef arith_entropy_encoder * arith_entropy_ptr; typedef struct _jpeg_source_mgr { const JOCTET * next_input_byte; /* => next byte to read from buffer */ size_t bytes_in_buffer; /* # of bytes remaining in buffer */}jpeg_source_mgr; typedef struct { int B[365]; int C[365]; int N[365]; int reset; int near;} predic_structure;typedef predic_structure *predic_structure_ptr; typedef struct _j_compress_struct{arith_entropy_ptr entropy;int arith_dc_L;int arith_dc_U;unsigned char first_line;/*for input*/FILE *inputfile;JSAMPARRAY inbuffer;jpeg_source_mgr *src; predic_structure pre;/*measure of the image*/UINT16 image_height;UINT16 image_width; /*for output*/FILE *outputfile;jpeg_destination_mgr *dest; /*in the main function we shoud create a dest structure*/JOCTET *outbuffer;int unread_marker;/*buffer management*/int buffer_count;void *buffer[200];}j_compress_struct;typedef j_compress_struct * j_compress_ptr;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -