⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commondecls.h

📁 关于JPEG和PDCM压缩算法的文章和算法程序代码
💻 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;typedef struct _j_compress_struct{/*for quantity*/UINT16 *quant_tbl_ptrs;DCTELEM *divisors;/*prepare for huffman coding*/JHUFF_TBL *dc_huff_tbl_ptrs;JHUFF_TBL *ac_huff_tbl_ptrs;c_derived_tbl *d_dc_huff_tbl_ptr;c_derived_tbl *d_ac_huff_tbl_ptr;_savable_state saved;/*for input*/FILE *inputfile;JSAMPARRAY inbuffer;/*measure of the image*/UINT16 image_height;UINT16 image_width;UINT16 block_height;               /*measure in 8*8 block*/UINT16 block_width;  UINT16 height_blank;               /*it is used to create exact dump line*/ UINT16 width_blank;                /*  and dump column*/                /*for output*/FILE *outputfile;jpeg_destination_mgr *dest;      /*in the main function we shoud create a dest structure*/JOCTET *outbuffer;/*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 + -