📄 jpegdata.h
字号:
/* MCU_membership[i] is index in cur_comp_info of component owning */
/* i'th block in an MCU */
/* these fields are private data for the entropy encoder */
JCOEF last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each comp */
JCOEF last_dc_diff[MAX_COMPS_IN_SCAN]; /* last DC diff for each comp */
UINT16 restarts_to_go; /* MCUs left in this restart interval */
short next_restart_num; /* # of next RSTn marker (0..7) */
};
typedef struct Compress_info_struct * compress_info_ptr;
/* Working data for decompression */
struct Decompress_info_struct {
/*
* These fields shall be established by the user interface before
* calling jpeg_decompress.
* Most parameters can be set to reasonable defaults by j_d_defaults.
* Note that the UI must supply the storage for the main methods struct,
* though it sets only a few of the methods there.
*/
decompress_methods_ptr methods; /* Points to list of methods to use */
external_methods_ptr emethods; /* Points to list of methods to use */
JFILEREF input_file; /* tells input routines where to read JPEG */
IFILEREF output_file; /* tells output routines where to write image */
/* these can be set at d_ui_method_selection time: */
COLOR_SPACE out_color_space; /* colorspace of output */
double output_gamma; /* image gamma wanted in output */
boolean quantize_colors; /* T if output is a colormapped format */
/* the following are ignored if not quantize_colors: */
boolean two_pass_quantize; /* use two-pass color quantization? */
boolean use_dithering; /* want color dithering? */
int desired_number_of_colors; /* max number of colors to use */
boolean do_block_smoothing; /* T = apply cross-block smoothing */
boolean do_pixel_smoothing; /* T = apply post-upsampling smoothing */
/*
* These fields are used for efficient buffering of data between read_jpeg_data
* and the entropy decoding object. By using a shared buffer, we avoid copying
* data and eliminate the need for an "unget" operation at the end of a scan.
* The actual source of the data is known only to read_jpeg_data; see the
* JGETC macro, below.
* Note: the user interface is expected to allocate the input_buffer and
* initialize bytes_in_buffer to 0. Also, for JFIF/raw-JPEG input, the UI
* actually supplies the read_jpeg_data method. This is all handled by
* j_d_defaults in a typical implementation.
*/
char * input_buffer; /* start of buffer (private to input code) */
char * next_input_byte; /* => next byte to read from buffer */
int bytes_in_buffer; /* # of bytes remaining in buffer */
/*
* These fields are set by read_file_header or read_scan_header
*/
long image_width; /* overall image width */
long image_height; /* overall image height */
short data_precision; /* bits of precision in image data */
COLOR_SPACE jpeg_color_space; /* colorspace of JPEG file */
/* These three values are not used by the JPEG code, merely copied */
/* from the JFIF APP0 marker (if any). */
UINT8 density_unit; /* JFIF code for pixel size units */
UINT16 X_density; /* Horizontal pixel density */
UINT16 Y_density; /* Vertical pixel density */
short num_components; /* # of color components in JPEG image */
jpeg_component_info * comp_info;
/* comp_info[i] describes component that appears i'th in SOF */
QUANT_TBL_PTR quant_tbl_ptrs[NUM_QUANT_TBLS];
/* ptrs to coefficient quantization tables, or NULL if not defined */
HUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
HUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
/* ptrs to Huffman coding tables, or NULL if not defined */
UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
boolean CCIR601_sampling; /* TRUE=first samples are cosited */
UINT16 restart_interval;/* MCUs per restart interval, or 0 for no restart */
/*
* These fields are computed during jpeg_decompress startup
*/
short max_h_samp_factor; /* largest h_samp_factor */
short max_v_samp_factor; /* largest v_samp_factor */
short color_out_comps; /* # of color components output by color_convert */
/* (need not match num_components) */
short final_out_comps; /* # of color components sent to put_pixel_rows */
/* (1 when quantizing colors, else same as color_out_comps) */
JSAMPLE * sample_range_limit; /* table for fast range-limiting */
/*
* When quantizing colors, the color quantizer leaves a pointer to the output
* colormap in these fields. The colormap is valid from the time put_color_map
* is called (must be before any put_pixel_rows calls) until shutdown (more
* specifically, until free_all is called to release memory).
*/
int actual_number_of_colors; /* actual number of entries */
JSAMPARRAY colormap; /* NULL if not valid */
/* map has color_out_comps rows * actual_number_of_colors columns */
/*
* These fields may be useful for progress monitoring
*/
int total_passes; /* number of passes expected */
int completed_passes; /* number of passes completed so far */
/*
* These fields are valid during any one scan
*/
short comps_in_scan; /* # of JPEG components input this time */
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
/* *cur_comp_info[i] describes component that appears i'th in SOS */
long MCUs_per_row; /* # of MCUs across the image */
long MCU_rows_in_scan; /* # of MCU rows in the image */
short blocks_in_MCU; /* # of DCT blocks per MCU */
short MCU_membership[MAX_BLOCKS_IN_MCU];
/* MCU_membership[i] is index in cur_comp_info of component owning */
/* i'th block in an MCU */
/* these fields are private data for the entropy encoder */
JCOEF last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each comp */
JCOEF last_dc_diff[MAX_COMPS_IN_SCAN]; /* last DC diff for each comp */
UINT16 restarts_to_go; /* MCUs left in this restart interval */
short next_restart_num; /* # of next RSTn marker (0..7) */
};
typedef struct Decompress_info_struct * decompress_info_ptr;
/* Macros for reading data from the decompression input buffer */
#ifdef CHAR_IS_UNSIGNED
#define JGETC(cinfo) ( --(cinfo)->bytes_in_buffer < 0 ? \
(*(cinfo)->methods->read_jpeg_data) (cinfo) : \
(int) (*(cinfo)->next_input_byte++) )
#else
#define JGETC(cinfo) ( --(cinfo)->bytes_in_buffer < 0 ? \
(*(cinfo)->methods->read_jpeg_data) (cinfo) : \
(int) (*(cinfo)->next_input_byte++) & 0xFF )
#endif
#define JUNGETC(ch,cinfo) ((cinfo)->bytes_in_buffer++, \
*(--((cinfo)->next_input_byte)) = (char) (ch))
#define MIN_UNGET 4 /* may always do at least 4 JUNGETCs */
/* A virtual image has a control block whose contents are private to the
* memory manager module (and may differ between managers). The rest of the
* code only refers to virtual images by these pointer types, and never
* dereferences the pointer.
*/
typedef struct big_sarray_control * big_sarray_ptr;
typedef struct big_barray_control * big_barray_ptr;
/* Although a real ANSI C compiler can deal perfectly well with pointers to
* unspecified structures (see "incomplete types" in the spec), a few pre-ANSI
* and pseudo-ANSI compilers get confused. To keep one of these bozos happy,
* add -DINCOMPLETE_TYPES_BROKEN to CFLAGS in your Makefile. Then we will
* pseudo-define the structs as containing a single "dummy" field.
* The memory managers #define AM_MEMORY_MANAGER before including this file,
* so that they can make their own definitions of the structs.
*/
#ifdef INCOMPLETE_TYPES_BROKEN
#ifndef AM_MEMORY_MANAGER
struct big_sarray_control { long dummy; };
struct big_barray_control { long dummy; };
#endif
#endif
/* Method types that need typedefs */
typedef METHOD(void, MCU_output_method_ptr, (compress_info_ptr cinfo,
JBLOCK *MCU_data));
typedef METHOD(void, MCU_output_caller_ptr, (compress_info_ptr cinfo,
MCU_output_method_ptr output_method));
typedef METHOD(void, downsample_ptr, (compress_info_ptr cinfo,
int which_component,
long input_cols, int input_rows,
long output_cols, int output_rows,
JSAMPARRAY above,
JSAMPARRAY input_data,
JSAMPARRAY below,
JSAMPARRAY output_data));
typedef METHOD(void, upsample_ptr, (decompress_info_ptr cinfo,
int which_component,
long input_cols, int input_rows,
long output_cols, int output_rows,
JSAMPARRAY above,
JSAMPARRAY input_data,
JSAMPARRAY below,
JSAMPARRAY output_data));
typedef METHOD(void, quantize_method_ptr, (decompress_info_ptr cinfo,
int num_rows,
JSAMPIMAGE input_data,
JSAMPARRAY output_workspace));
typedef METHOD(void, quantize_caller_ptr, (decompress_info_ptr cinfo,
quantize_method_ptr quantize_method));
/* These structs contain function pointers for the various JPEG methods. */
/* Routines to be provided by the surrounding application, rather than the
* portable JPEG code proper. These are the same for compression and
* decompression.
*/
struct External_methods_struct {
/* User interface: error exit and trace message routines */
/* NOTE: the string msgtext parameters will eventually be replaced
* by an enumerated-type code so that non-English error messages
* can be substituted easily. This will not be done until all the
* code is in place, so that we know what messages are needed.
*/
METHOD(void, error_exit,());
METHOD(void, trace_message,());
/* Working data for error/trace facility */
/* See macros below for the usage of these variables */
int trace_level; /* level of detail of tracing messages */
/* Use level 0 for important warning messages (nonfatal errors) */
/* Use levels 1, 2, 3 for successively more detailed trace options */
/* For recoverable corrupt-data errors, we emit a warning message and
* keep going. A surrounding application can check for bad data by
* seeing if num_warnings is nonzero at the end of processing.
*/
long num_warnings; /* number of corrupt-data warnings */
int first_warning_level; /* trace level for first warning */
int more_warning_level; /* trace level for subsequent warnings */
int message_parm[8]; /* store numeric parms for messages here */
/* Memory management */
/* NB: alloc routines never return NULL. They exit to */
/* error_exit if not successful. */
METHOD(void *, alloc_small, (size_t sizeofobject));
METHOD(void, free_small, (void *ptr));
METHOD(void FAR *, alloc_medium, (size_t sizeofobject));
METHOD(void, free_medium, (void FAR *ptr));
METHOD(JSAMPARRAY, alloc_small_sarray, (long samplesperrow,
long numrows));
METHOD(void, free_small_sarray, (JSAMPARRAY ptr));
METHOD(JBLOCKARRAY, alloc_small_barray, (long blocksperrow,
long numrows));
METHOD(void, free_small_barray, (JBLOCKARRAY ptr));
METHOD(big_sarray_ptr, request_big_sarray, (long samplesperrow,
long numrows,
long unitheight));
METHOD(big_barray_ptr, request_big_barray, (long blocksperrow,
long numrows,
long unitheight));
METHOD(void, alloc_big_arrays, (long extra_small_samples,
long extra_small_blocks,
long extra_medium_space));
METHOD(JSAMPARRAY, access_big_sarray, (big_sarray_ptr ptr,
long start_row,
boolean writable));
METHOD(JBLOCKARRAY, access_big_barray, (big_barray_ptr ptr,
long start_row,
boolean writable));
METHOD(void, free_big_sarray, (big_sarray_ptr ptr));
METHOD(void, free_big_barray, (big_barray_ptr ptr));
METHOD(void, free_all, (void));
long max_memory_to_use; /* maximum amount of memory to use */
};
/* Macros to simplify using the error and trace message stuff */
/* The first parameter is generally cinfo->emethods */
/* Fatal errors (print message and exit) */
#define ERREXIT(emeth) ((*(emeth)->error_exit) ())
#define ERREXIT1(emeth,p1) ((emeth)->message_parm[0] = (p1), \
(*(emeth)->error_exit) ())
#define ERREXIT2(emeth,p1,p2) ((emeth)->message_parm[0] = (p1), \
(emeth)->message_parm[1] = (p2), \
(*(emeth)->error_exit) ())
#define ERREXIT3(emeth,p1,p2,p3) ((emeth)->message_parm[0] = (p1), \
(emeth)->message_parm[1] = (p2), \
(emeth)->message_parm[2] = (p3), \
(*(emeth)->error_exit) ())
#define ERREXIT4(emeth,p1,p2,p3,p4) ((emeth)->message_parm[0] = (p1), \
(emeth)->message_parm[1] = (p2), \
(emeth)->message_parm[2] = (p3), \
(emeth)->message_parm[3] = (p4), \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -