Doxygen Source Code Documentation
jcapimin.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
Go to the source code of this file.
Defines | |
#define | JPEG_INTERNALS |
Functions | |
jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize) | |
jpeg_destroy_compress (j_compress_ptr cinfo) | |
jpeg_abort_compress (j_compress_ptr cinfo) | |
jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress) | |
jpeg_finish_compress (j_compress_ptr cinfo) | |
jpeg_write_marker (j_compress_ptr cinfo, int marker, const JOCTET *dataptr, unsigned int datalen) | |
jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen) | |
jpeg_write_m_byte (j_compress_ptr cinfo, int val) | |
jpeg_write_tables (j_compress_ptr cinfo) |
Define Documentation
|
Definition at line 19 of file jcapimin.c. |
Function Documentation
|
Definition at line 100 of file jcapimin.c. References jpeg_abort().
00101 { 00102 jpeg_abort((j_common_ptr) cinfo); /* use common routine */ 00103 } |
|
Definition at line 30 of file jcapimin.c. References jpeg_compress_struct::ac_huff_tbl_ptrs, client_data, jpeg_compress_struct::comp_info, CSTATE_START, jpeg_compress_struct::dc_huff_tbl_ptrs, jpeg_compress_struct::dest, ERREXIT2, i, jpeg_compress_struct::input_gamma, JERR_BAD_LIB_VERSION, jinit_memory_mgr(), JPEG_LIB_VERSION, MEMZERO, NUM_HUFF_TBLS, NUM_QUANT_TBLS, jpeg_compress_struct::quant_tbl_ptrs, jpeg_compress_struct::script_space, SIZEOF, and structsize.
00031 { 00032 int i; 00033 00034 /* Guard against version mismatches between library and caller. */ 00035 cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ 00036 if (version != JPEG_LIB_VERSION) 00037 ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); 00038 if (structsize != SIZEOF(struct jpeg_compress_struct)) 00039 ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, 00040 (int) SIZEOF(struct jpeg_compress_struct), (int) structsize); 00041 00042 /* For debugging purposes, we zero the whole master structure. 00043 * But the application has already set the err pointer, and may have set 00044 * client_data, so we have to save and restore those fields. 00045 * Note: if application hasn't set client_data, tools like Purify may 00046 * complain here. 00047 */ 00048 { 00049 struct jpeg_error_mgr * err = cinfo->err; 00050 void * client_data = cinfo->client_data; /* ignore Purify complaint here */ 00051 MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct)); 00052 cinfo->err = err; 00053 cinfo->client_data = client_data; 00054 } 00055 cinfo->is_decompressor = FALSE; 00056 00057 /* Initialize a memory manager instance for this object */ 00058 jinit_memory_mgr((j_common_ptr) cinfo); 00059 00060 /* Zero out pointers to permanent structures. */ 00061 cinfo->progress = NULL; 00062 cinfo->dest = NULL; 00063 00064 cinfo->comp_info = NULL; 00065 00066 for (i = 0; i < NUM_QUANT_TBLS; i++) 00067 cinfo->quant_tbl_ptrs[i] = NULL; 00068 00069 for (i = 0; i < NUM_HUFF_TBLS; i++) { 00070 cinfo->dc_huff_tbl_ptrs[i] = NULL; 00071 cinfo->ac_huff_tbl_ptrs[i] = NULL; 00072 } 00073 00074 cinfo->script_space = NULL; 00075 00076 cinfo->input_gamma = 1.0; /* in case application forgets */ 00077 00078 /* OK, I'm ready */ 00079 cinfo->global_state = CSTATE_START; 00080 } |
|
Definition at line 88 of file jcapimin.c. References jpeg_destroy(). Referenced by main(), and write_JPEG_file().
00089 { 00090 jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ 00091 } |
|
Definition at line 147 of file jcapimin.c. References jpeg_compress_struct::coef, CSTATE_RAW_OK, CSTATE_SCANNING, CSTATE_WRCOEFS, jpeg_compress_struct::dest, ERREXIT, ERREXIT1, jpeg_compress_struct::image_height, jpeg_comp_master::is_last_pass, JDIMENSION, jpeg_abort(), jpeg_compress_struct::marker, jpeg_compress_struct::master, jpeg_compress_struct::next_scanline, and jpeg_compress_struct::total_iMCU_rows. Referenced by main(), and write_JPEG_file().
00148 { 00149 JDIMENSION iMCU_row; 00150 00151 if (cinfo->global_state == CSTATE_SCANNING || 00152 cinfo->global_state == CSTATE_RAW_OK) { 00153 /* Terminate first pass */ 00154 if (cinfo->next_scanline < cinfo->image_height) 00155 ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); 00156 (*cinfo->master->finish_pass) (cinfo); 00157 } else if (cinfo->global_state != CSTATE_WRCOEFS) 00158 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); 00159 /* Perform any remaining passes */ 00160 while (! cinfo->master->is_last_pass) { 00161 (*cinfo->master->prepare_for_pass) (cinfo); 00162 for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) { 00163 if (cinfo->progress != NULL) { 00164 cinfo->progress->pass_counter = (long) iMCU_row; 00165 cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows; 00166 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); 00167 } 00168 /* We bypass the main controller and invoke coef controller directly; 00169 * all work is being done from the coefficient buffer. 00170 */ 00171 if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL)) 00172 ERREXIT(cinfo, JERR_CANT_SUSPEND); 00173 } 00174 (*cinfo->master->finish_pass) (cinfo); 00175 } 00176 /* Write EOI, do final cleanup */ 00177 (*cinfo->marker->write_file_trailer) (cinfo); 00178 (*cinfo->dest->term_destination) (cinfo); 00179 /* We can use jpeg_abort to release memory and reset global_state */ 00180 jpeg_abort((j_common_ptr) cinfo); 00181 } |
|
Definition at line 119 of file jcapimin.c. References jpeg_compress_struct::ac_huff_tbl_ptrs, jpeg_compress_struct::dc_huff_tbl_ptrs, i, NUM_HUFF_TBLS, NUM_QUANT_TBLS, jpeg_compress_struct::quant_tbl_ptrs, JHUFF_TBL::sent_table, JQUANT_TBL::sent_table, and suppress. Referenced by jpeg_start_compress(), and jpeg_write_coefficients().
00120 { 00121 int i; 00122 JQUANT_TBL * qtbl; 00123 JHUFF_TBL * htbl; 00124 00125 for (i = 0; i < NUM_QUANT_TBLS; i++) { 00126 if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL) 00127 qtbl->sent_table = suppress; 00128 } 00129 00130 for (i = 0; i < NUM_HUFF_TBLS; i++) { 00131 if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL) 00132 htbl->sent_table = suppress; 00133 if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL) 00134 htbl->sent_table = suppress; 00135 } 00136 } |
|
Definition at line 226 of file jcapimin.c. References jpeg_compress_struct::marker. Referenced by jcopy_markers_execute().
00227 { 00228 (*cinfo->marker->write_marker_byte) (cinfo, val); 00229 } |
|
Definition at line 214 of file jcapimin.c. References CSTATE_RAW_OK, CSTATE_SCANNING, CSTATE_WRCOEFS, datalen, ERREXIT1, jpeg_compress_struct::marker, marker, and jpeg_compress_struct::next_scanline. Referenced by jcopy_markers_execute().
00215 { 00216 if (cinfo->next_scanline != 0 || 00217 (cinfo->global_state != CSTATE_SCANNING && 00218 cinfo->global_state != CSTATE_RAW_OK && 00219 cinfo->global_state != CSTATE_WRCOEFS)) 00220 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); 00221 00222 (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); 00223 } |
|
Definition at line 192 of file jcapimin.c. References CSTATE_RAW_OK, CSTATE_SCANNING, CSTATE_WRCOEFS, datalen, dataptr, ERREXIT1, JMETHOD, JOCTET, jpeg_compress_struct::marker, marker, jpeg_compress_struct::next_scanline, and write_marker_byte(). Referenced by jcopy_markers_execute().
00194 { 00195 JMETHOD(void, write_marker_byte, (j_compress_ptr info, int val)); 00196 00197 if (cinfo->next_scanline != 0 || 00198 (cinfo->global_state != CSTATE_SCANNING && 00199 cinfo->global_state != CSTATE_RAW_OK && 00200 cinfo->global_state != CSTATE_WRCOEFS)) 00201 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); 00202 00203 (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); 00204 write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */ 00205 while (datalen--) { 00206 (*write_marker_byte) (cinfo, *dataptr); 00207 dataptr++; 00208 } 00209 } |
|
Definition at line 254 of file jcapimin.c. References CSTATE_START, jpeg_compress_struct::dest, ERREXIT1, jinit_marker_writer(), and jpeg_compress_struct::marker.
00255 { 00256 if (cinfo->global_state != CSTATE_START) 00257 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); 00258 00259 /* (Re)initialize error mgr and destination modules */ 00260 (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); 00261 (*cinfo->dest->init_destination) (cinfo); 00262 /* Initialize the marker writer ... bit of a crock to do it here. */ 00263 jinit_marker_writer(cinfo); 00264 /* Write them tables! */ 00265 (*cinfo->marker->write_tables_only) (cinfo); 00266 /* And clean up. */ 00267 (*cinfo->dest->term_destination) (cinfo); 00268 /* 00269 * In library releases up through v6a, we called jpeg_abort() here to free 00270 * any working memory allocated by the destination manager and marker 00271 * writer. Some applications had a problem with that: they allocated space 00272 * of their own from the library memory manager, and didn't want it to go 00273 * away during write_tables. So now we do nothing. This will cause a 00274 * memory leak if an app calls write_tables repeatedly without doing a full 00275 * compression cycle or otherwise resetting the JPEG object. However, that 00276 * seems less bad than unexpectedly freeing memory in the normal case. 00277 * An app that prefers the old behavior can call jpeg_abort for itself after 00278 * each call to jpeg_write_tables(). 00279 */ 00280 } |