Go to the source code of this file.
Classes | |
struct | my_source_mgr |
Defines | |
#define | INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */ |
Typedefs | |
typedef boolean(* | boolean_jpeg_decompress_struct )(jpeg_decompress_struct *) |
typedef void(* | void_jpeg_decompress_struct )(jpeg_decompress_struct *) |
typedef void(* | void_jpeg_decompress_struct_long )(jpeg_decompress_struct *, long) |
typedef my_source_mgr * | my_src_ptr |
Functions | |
init_source (j_decompress_ptr cinfo) | |
fill_input_buffer (j_decompress_ptr cinfo) | |
skip_input_data (j_decompress_ptr cinfo, long num_bytes) | |
term_source (j_decompress_ptr cinfo) | |
jpeg_stdio_src (j_decompress_ptr cinfo, std::ifstream *infile, gdcm::JPEGFragment *frag, int flag) |
|
Definition at line 40 of file jdatasrc.cxx. Referenced by fill_input_buffer(), and jpeg_stdio_src(). |
|
Definition at line 22 of file jdatasrc.cxx. |
|
Definition at line 38 of file jdatasrc.cxx. Referenced by fill_input_buffer(), init_source(), jpeg_stdio_src(), and skip_input_data(). |
|
Definition at line 23 of file jdatasrc.cxx. |
|
Definition at line 24 of file jdatasrc.cxx. |
|
Definition at line 96 of file jdatasrc.cxx. References my_source_mgr::buffer, my_source_mgr::bytes_read, my_source_mgr::frag, gdcm::JPEGFragment::GetLength(), my_source_mgr::infile, INPUT_BUF_SIZE, my_src_ptr, my_source_mgr::pub, and my_source_mgr::start_of_file. Referenced by jpeg_stdio_src(), and skip_input_data().
00096 { 00097 my_src_ptr src = (my_src_ptr) cinfo->src; 00098 00099 if( src->bytes_read == src->frag->GetLength() ) 00100 { 00101 // Start the I/O suspension simply by returning false here: 00102 return FALSE; 00103 } 00104 00105 size_t input_buf_size = INPUT_BUF_SIZE; 00106 if( (src->bytes_read + INPUT_BUF_SIZE) > src->frag->GetLength() ) 00107 { 00108 input_buf_size = src->frag->GetLength() - src->bytes_read; 00109 } 00110 00111 src->infile->read( (char*)src->buffer, input_buf_size); 00112 size_t nbytes = src->infile->gcount(); 00113 00114 if (nbytes <= 0) { 00115 if (src->start_of_file) /* Treat empty input file as fatal error */ 00116 ERREXIT(cinfo, JERR_INPUT_EMPTY); 00117 WARNMS(cinfo, JWRN_JPEG_EOF); 00118 /* Insert a fake EOI marker */ 00119 src->buffer[0] = (JOCTET) 0xFF; 00120 src->buffer[1] = (JOCTET) JPEG_EOI; 00121 nbytes = 2; 00122 } 00123 00124 src->pub.next_input_byte = src->buffer; 00125 src->pub.bytes_in_buffer = nbytes; 00126 src->start_of_file = FALSE; 00127 src->bytes_read += nbytes; 00128 00129 return TRUE; 00130 } 00131 |
|
Definition at line 50 of file jdatasrc.cxx. References my_src_ptr, and my_source_mgr::start_of_file. Referenced by jpeg_stdio_src().
00050 { 00051 my_src_ptr src = (my_src_ptr) cinfo->src; 00052 00053 /* We reset the empty-input-file flag for each image, 00054 * but we don't clear the input buffer. 00055 * This is correct behavior for reading a series of images from one source. 00056 */ 00057 src->start_of_file = TRUE; 00058 } 00059 |
|
Definition at line 202 of file jdatasrc.cxx. References my_source_mgr::buffer, my_source_mgr::bytes_read, fill_input_buffer(), my_source_mgr::frag, my_source_mgr::infile, init_source(), INPUT_BUF_SIZE, my_src_ptr, my_source_mgr::pub, skip_input_data(), and term_source().
00202 { 00203 my_src_ptr src; 00204 00205 /* The source object and input buffer are made permanent so that a series 00206 * of JPEG images can be read from the same file by calling jpeg_stdio_src 00207 * only before the first one. (If we discarded the buffer at the end of 00208 * one image, we'd likely lose the start of the next one.) 00209 * This makes it unsafe to use this manager and a different source 00210 * manager serially with the same JPEG object. Caveat programmer. 00211 */ 00212 if (cinfo->src == NULL) { /* first time for this JPEG object? */ 00213 cinfo->src = (struct jpeg_source_mgr *) 00214 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, 00215 SIZEOF(my_source_mgr)); 00216 src = (my_src_ptr) cinfo->src; 00217 src->buffer = (JOCTET *) 00218 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, 00219 INPUT_BUF_SIZE * SIZEOF(JOCTET)); 00220 } 00221 00222 src = (my_src_ptr) cinfo->src; 00223 src->pub.init_source = reinterpret_cast<void_jpeg_decompress_struct>(init_source); 00224 src->pub.fill_input_buffer = reinterpret_cast<boolean_jpeg_decompress_struct>(fill_input_buffer); 00225 src->pub.skip_input_data = reinterpret_cast<void_jpeg_decompress_struct_long>(skip_input_data); 00226 src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ 00227 src->pub.term_source = reinterpret_cast<void_jpeg_decompress_struct>(term_source); 00228 src->infile = infile; 00229 00230 // Need to setup a new buffer, clean bytes_in_buffer and next_input_byte 00231 if( flag ) 00232 { 00233 src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ 00234 src->pub.next_input_byte = NULL; /* until buffer loaded */ 00235 } 00236 //only upate the new fragment, valid for both 'flag' value 00237 src->frag = frag; 00238 src->bytes_read = 0; 00239 } 00240 } |
|
Definition at line 147 of file jdatasrc.cxx. References fill_input_buffer(), my_src_ptr, and my_source_mgr::pub. Referenced by jpeg_stdio_src().
00147 { 00148 my_src_ptr src = (my_src_ptr) cinfo->src; 00149 00150 /* Just a dumb implementation for now. Could use fseek() except 00151 * it doesn't work on pipes. Not clear that being smart is worth 00152 * any trouble anyway --- large skips are infrequent. 00153 */ 00154 if (num_bytes > 0) { 00155 while (num_bytes > (long) src->pub.bytes_in_buffer) { 00156 num_bytes -= (long) src->pub.bytes_in_buffer; 00157 (void) fill_input_buffer(cinfo); 00158 /* note we assume that fill_input_buffer will never return FALSE, 00159 * so suspension need not be handled. 00160 */ 00161 } 00162 src->pub.next_input_byte += (size_t) num_bytes; 00163 src->pub.bytes_in_buffer -= (size_t) num_bytes; 00164 } 00165 } 00166 |
|
Definition at line 188 of file jdatasrc.cxx. Referenced by jpeg_stdio_src().
00188 {
00189 cinfo=cinfo;
00190 /* no work necessary here */
00191 }
00192
|