📄 jpeglib.h
字号:
/* Standard state variables for error facility */ int trace_level; /* max msg_level that will be displayed */ /* For recoverable corrupt-data errors, we emit a warning message, * but keep going unless emit_message chooses to abort. emit_message * should count warnings in num_warnings. The 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 */ /* These fields point to the table(s) of error message strings. * An application can change the table pointer to switch to a different * message list (typically, to change the language in which errors are * reported). Some applications may wish to add additional error codes * that will be handled by the JPEG library error mechanism; the second * table pointer is used for this purpose. * * First table includes all errors generated by JPEG library itself. * Error code 0 is reserved for a "no such error string" message. */ const char * const * jpeg_message_table; /* Library errors */ int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ /* Second table can be added by application (see cjpeg/djpeg for example). * It contains strings numbered first_addon_message..last_addon_message. */ const char * const * addon_message_table; /* Non-library errors */ int first_addon_message; /* code for first string in addon table */ int last_addon_message; /* code for last string in addon table */};/* Progress monitor object */struct jpeg_progress_mgr { JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); long pass_counter; /* work units completed in this pass */ long pass_limit; /* total number of work units in this pass */ int completed_passes; /* passes completed so far */ int total_passes; /* total number of passes expected */};/* Data destination object for compression */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 */ JMETHOD(void, init_destination, (j_compress_ptr cinfo)); JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); JMETHOD(void, term_destination, (j_compress_ptr cinfo));};/* Data source object for decompression */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 */ JMETHOD(void, init_source, (j_decompress_ptr cinfo)); JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); JMETHOD(void, term_source, (j_decompress_ptr cinfo));};/* Memory manager object. * Allocates "small" objects (a few K total), "large" objects (tens of K), * and "really big" objects (virtual arrays with backing store if needed). * The memory manager does not allow individual objects to be freed; rather, * each created object is assigned to a pool, and whole pools can be freed * at once. This is faster and more convenient than remembering exactly what * to free, especially where malloc()/free() are not too speedy. * NB: alloc routines never return NULL. They exit to error_exit if not * successful. */#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */#define JPOOL_NUMPOOLS 2typedef struct jvirt_sarray_control * jvirt_sarray_ptr;typedef struct jvirt_barray_control * jvirt_barray_ptr;struct jpeg_memory_mgr { /* Method pointers */ JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, size_t sizeofobject)); JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, size_t sizeofobject)); JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow, JDIMENSION numrows)); JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, JDIMENSION blocksperrow, JDIMENSION numrows)); JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, int pool_id, boolean pre_zero, JDIMENSION samplesperrow, JDIMENSION numrows, JDIMENSION maxaccess)); JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, int pool_id, boolean pre_zero, JDIMENSION blocksperrow, JDIMENSION numrows, JDIMENSION maxaccess)); JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, jvirt_sarray_ptr ptr, JDIMENSION start_row, JDIMENSION num_rows, boolean writable)); JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, jvirt_barray_ptr ptr, JDIMENSION start_row, JDIMENSION num_rows, boolean writable)); JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); JMETHOD(void, self_destruct, (j_common_ptr cinfo)); /* Limit on memory allocation for this JPEG object. (Note that this is * merely advisory, not a guaranteed maximum; it only affects the space * used for virtual-array buffers.) May be changed by outer application * after creating the JPEG object. */ long max_memory_to_use; /* Maximum allocation request accepted by alloc_large. */ long max_alloc_chunk;};/* Routine signature for application-supplied marker processing methods. * Need not pass marker code since it is stored in cinfo->unread_marker. */typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));/* Declarations for routines called by application. * The JPP macro hides prototype parameters from compilers that can't cope. * Note JPP requires double parentheses. */#ifdef HAVE_PROTOTYPES#define JPP(arglist) arglist#else#define JPP(arglist) ()#endif/* Short forms of external names for systems with brain-damaged linkers. * We shorten external names to be unique in the first six letters, which * is good enough for all known systems. * (If your compiler itself needs names to be unique in less than 15 * characters, you are out of luck. Get a better compiler.) */#ifdef NEED_SHORT_EXTERNAL_NAMES#define jpeg_std_error jStdError#define jpeg_CreateCompress jCreaCompress#define jpeg_CreateDecompress jCreaDecompress#define jpeg_destroy_compress jDestCompress#define jpeg_destroy_decompress jDestDecompress#define jpeg_stdio_dest jStdDest#define jpeg_stdio_src jStdSrc#define jpeg_set_defaults jSetDefaults#define jpeg_set_colorspace jSetColorspace#define jpeg_default_colorspace jDefColorspace#define jpeg_set_quality jSetQuality#define jpeg_set_linear_quality jSetLQuality#define jpeg_add_quant_table jAddQuantTable#define jpeg_quality_scaling jQualityScaling#define jpeg_simple_progression jSimProgress#define jpeg_suppress_tables jSuppressTables#define jpeg_alloc_quant_table jAlcQTable#define jpeg_alloc_huff_table jAlcHTable#define jpeg_start_compress jStrtCompress#define jpeg_write_scanlines jWrtScanlines#define jpeg_finish_compress jFinCompress#define jpeg_write_raw_data jWrtRawData#define jpeg_write_marker jWrtMarker#define jpeg_write_m_header jWrtMHeader#define jpeg_write_m_byte jWrtMByte#define jpeg_write_tables jWrtTables#define jpeg_read_header jReadHeader#define jpeg_start_decompress jStrtDecompress#define jpeg_read_scanlines jReadScanlines#define jpeg_finish_decompress jFinDecompress#define jpeg_read_raw_data jReadRawData#define jpeg_has_multiple_scans jHasMultScn#define jpeg_start_output jStrtOutput#define jpeg_finish_output jFinOutput#define jpeg_input_complete jInComplete#define jpeg_new_colormap jNewCMap#define jpeg_consume_input jConsumeInput#define jpeg_calc_output_dimensions jCalcDimensions#define jpeg_save_markers jSaveMarkers#define jpeg_set_marker_processor jSetMarker#define jpeg_read_coefficients jReadCoefs#define jpeg_write_coefficients jWrtCoefs#define jpeg_copy_critical_parameters jCopyCrit#define jpeg_abort_compress jAbrtCompress#define jpeg_abort_decompress jAbrtDecompress#define jpeg_abort jAbort#define jpeg_destroy jDestroy#define jpeg_resync_to_restart jResyncRestart#endif /* NEED_SHORT_EXTERNAL_NAMES */#ifdef USE_INTERNAL_CPU// This data structure is added especially for the parameters passing between// embedded CPU and external CPU.typedef struct { int component_index; /* its index in SOF or cinfo->comp_info[] */ int MCU_width; /* number of blocks per MCU, horizontally */ int MCU_height; /* number of blocks per MCU, vertically */ int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ } jpeg_embedded_component_info; struct jpeg_decompress_embedded_struct { //unsigned char *pCoreBaseAddr; /**** process_data_context_main() or process_data_simple_main () function's related variables ****/ JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */ /* (main->iMCU_row_ctr) directly copy and borrow from struct my_main_controller */ JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ /* (cinfo->total_iMCU_rows) directly copy and borrow from struct jpeg_compress_struct */ int max_v_samp_factor; /* largest v_samp_factor */ /* (cinfo->max_v_samp_factor) directly copy and borrow from struct jpeg_compress_struct */ /**** decompress_onepass() function's related variables ****/ JDIMENSION MCUs_per_row; /* # of MCUs across the image */ /* (cinfo->MCUs_per_row) directly copy and borrow from struct jpeg_decompress_struct */ JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ /* (coef->MCU_ctr) directly copy and borrow from struct my_coef_controller */ int blocks_in_MCU; /* # of DCT blocks per MCU */ /* directly copy and borrow from struct jpeg_decompress_struct */ boolean invalid_next_restart_marker; /* to indicate whehter we should stop the VLD engine in case there is invalid restart marker sequence */ /* directly copy and borrow from struct jpeg_decompress_struct */ /**** generate_dma_chain_table() function's related variables ****/ // for jpeg_component_info structure, we need to initialize those variables : // compptr->component_index // compptr->MCU_width // compptr->MCU_height // compptr->MCU_sample_width jpeg_embedded_component_info cur_comp_info[MAX_COMPS_IN_SCAN]; /* *cur_comp_info[i] describes component that appears i'th in SOS */ /* directly copy and borrow from struct jpeg_compress_struct */ int comps_in_scan; /* # of JPEG components in this scan */ /* (cinfo->comps_in_scan) directly copy and borrow from struct jpeg_decompress_struct */ //main->iMCU_row_ctr // already defined in process_data_context_main() or process_data_simple_main () function's related variables unsigned char* outdata[3]; /**** decrement_restart_interval() function's related variables ****/ unsigned int restarts_to_go; /* MCUs left in this restart interval */ /* (entropy->restarts_to_go) directly copy and borrow from struct huff_entropy_decoder */ /**** check_restart_marker() function's related variables ****/ unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ /* (cinfo->restart_interval) directly copy and borrow from struct jpeg_decompress_struct */ boolean restart_flag; /* indicate the restart interval has been met */ /* (entropy->restart_flag) directly copy and borrow from struct huff_entropy_decoder */ /**** get_restart_action() function's related variables ****/ int next_restart_num; /* next restart number expected (0-7) */ /* (cinfo->marker->next_restart_num) directly copy and borrow from struct jpeg_marker_reader */ /**** update_next_restart_number() function's related variables ****/ // no related variables /**** processing_restart_marker() function's related variables ****/ // no related variables /**** decompress_noninterleaved_data() function's related variables ****/ JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ /* (cinfo->input_iMCU_row) directly copy and borrow from struct jpeg_decompress_struct */ /**** start_iMCU_row() function's related variables ****/ int MCU_rows_per_iMCU_row; /* number of such rows needed */ /* (coef->MCU_rows_per_iMCU_row) directly copy and borrow from struct my_coef_controller */ int cur_comp_info_0_v_samp_factor; /* vertical sampling factor (1..4) */ /* (cinfo->cur_comp_info[0]->v_samp_factor) directly copy and borrow from struct jpeg_component_info */ int cur_comp_info_0_last_row_height; /* # of non-dummy blocks down in last MCU */ /* (cinfo->cur_comp_info[0]->last_row_height) directly copy and borrow from struct jpeg_component_info */ int MCU_vert_offset; /* counts MCU rows within iMCU row */ /* (coef->MCU_vert_offset) directly copy and borrow from struct my_coef_controller */ // it's the command to instruct the internal CPU to do something useful for external CPU int internal_cpu_command; // 0 : to instruct internal CPU to stop and exit decoding // 1 : to instruct internal CPU to do interleaved decoding // 2 : to instruct internal CPU to do non-interleaved decoding for the very first time. // 3 : to instruct internal CPU to do next non-interleaved decoding. // it's the response from internal CPU after executing the command instructed by external CPU int external_cpu_response; // 0 : normal state , when internal_cpu_command was set to do decoding, the external_cpu_response will be reset to 0 // 1 : decoding done for interleaved decoding // 2 : decoding done for non-interleaved decoding };typedef struct jpeg_decompress_embedded_struct * j_decompress_embedded_ptr;#endif // end of #define USE_INTERNAL_CPU/** * @defgroup compression_functions_group Compression Handling Functions * */ /** * @defgroup decompression_functions_group Decompression Handling Functions * *//** * @defgroup error_handling_functions_group Error Handling Functions * *//* Default error-management setup *//** * @ingroup error_handling_functions_group * To setup default error-management object. * */EXTERN(struct jpeg_error_mgr *) jpeg_std_error JPP((struct jpeg_error_mgr * err));EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, int version, size_t structsize));EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, int version, size_t structsize));/* jpeg_read_header()'s return value is one of: */#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */#define JPEG_HEADER_OK 1 /* Found valid image datastream */#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream *//** * @ingroup compression_functions_group * @name helper routines for compression * *///@{/* Default parameter setup for compression */EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -