Doxygen Source Code Documentation
jdatasrc.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
#include "jerror.h"
Go to the source code of this file.
Data Structures | |
struct | my_source_mgr |
Defines | |
#define | INPUT_BUF_SIZE 4096 |
Typedefs | |
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, FILE *infile) |
Define Documentation
|
Definition at line 35 of file jdatasrc.c. Referenced by fill_input_buffer(), and jpeg_stdio_src(). |
Typedef Documentation
|
Definition at line 33 of file jdatasrc.c. |
Function Documentation
|
Definition at line 90 of file jdatasrc.c. References my_source_mgr::buffer, jpeg_source_mgr::bytes_in_buffer, ERREXIT, my_source_mgr::infile, INPUT_BUF_SIZE, JFREAD, JPEG_EOI, jpeg_source_mgr::next_input_byte, my_source_mgr::pub, jpeg_decompress_struct::src, my_source_mgr::start_of_file, and WARNMS. Referenced by jpeg_stdio_src(), and skip_input_data().
00091 { 00092 my_src_ptr src = (my_src_ptr) cinfo->src; 00093 size_t nbytes; 00094 00095 nbytes = JFREAD(src->infile, src->buffer, INPUT_BUF_SIZE); 00096 00097 if (nbytes <= 0) { 00098 if (src->start_of_file) /* Treat empty input file as fatal error */ 00099 ERREXIT(cinfo, JERR_INPUT_EMPTY); 00100 WARNMS(cinfo, JWRN_JPEG_EOF); 00101 /* Insert a fake EOI marker */ 00102 src->buffer[0] = (JOCTET) 0xFF; 00103 src->buffer[1] = (JOCTET) JPEG_EOI; 00104 nbytes = 2; 00105 } 00106 00107 src->pub.next_input_byte = src->buffer; 00108 src->pub.bytes_in_buffer = nbytes; 00109 src->start_of_file = FALSE; 00110 00111 return TRUE; 00112 } |
|
Definition at line 44 of file jdatasrc.c. References jpeg_decompress_struct::src, and my_source_mgr::start_of_file. Referenced by jpeg_stdio_src().
00045 { 00046 my_src_ptr src = (my_src_ptr) cinfo->src; 00047 00048 /* We reset the empty-input-file flag for each image, 00049 * but we don't clear the input buffer. 00050 * This is correct behavior for reading a series of images from one source. 00051 */ 00052 src->start_of_file = TRUE; 00053 } |
|
Definition at line 182 of file jdatasrc.c. References my_source_mgr::buffer, jpeg_source_mgr::bytes_in_buffer, fill_input_buffer(), my_source_mgr::infile, init_source(), INPUT_BUF_SIZE, JOCTET, jpeg_resync_to_restart(), jpeg_source_mgr::next_input_byte, my_source_mgr::pub, SIZEOF, skip_input_data(), jpeg_decompress_struct::src, and term_source(). Referenced by main(), and read_JPEG_file().
00183 { 00184 my_src_ptr src; 00185 00186 /* The source object and input buffer are made permanent so that a series 00187 * of JPEG images can be read from the same file by calling jpeg_stdio_src 00188 * only before the first one. (If we discarded the buffer at the end of 00189 * one image, we'd likely lose the start of the next one.) 00190 * This makes it unsafe to use this manager and a different source 00191 * manager serially with the same JPEG object. Caveat programmer. 00192 */ 00193 if (cinfo->src == NULL) { /* first time for this JPEG object? */ 00194 cinfo->src = (struct jpeg_source_mgr *) 00195 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, 00196 SIZEOF(my_source_mgr)); 00197 src = (my_src_ptr) cinfo->src; 00198 src->buffer = (JOCTET *) 00199 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, 00200 INPUT_BUF_SIZE * SIZEOF(JOCTET)); 00201 } 00202 00203 src = (my_src_ptr) cinfo->src; 00204 src->pub.init_source = init_source; 00205 src->pub.fill_input_buffer = fill_input_buffer; 00206 src->pub.skip_input_data = skip_input_data; 00207 src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ 00208 src->pub.term_source = term_source; 00209 src->infile = infile; 00210 src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ 00211 src->pub.next_input_byte = NULL; /* until buffer loaded */ 00212 } |
|
Definition at line 128 of file jdatasrc.c. References jpeg_source_mgr::bytes_in_buffer, fill_input_buffer(), jpeg_source_mgr::next_input_byte, my_source_mgr::pub, and jpeg_decompress_struct::src. Referenced by jpeg_stdio_src().
00129 { 00130 my_src_ptr src = (my_src_ptr) cinfo->src; 00131 00132 /* Just a dumb implementation for now. Could use fseek() except 00133 * it doesn't work on pipes. Not clear that being smart is worth 00134 * any trouble anyway --- large skips are infrequent. 00135 */ 00136 if (num_bytes > 0) { 00137 while (num_bytes > (long) src->pub.bytes_in_buffer) { 00138 num_bytes -= (long) src->pub.bytes_in_buffer; 00139 (void) fill_input_buffer(cinfo); 00140 /* note we assume that fill_input_buffer will never return FALSE, 00141 * so suspension need not be handled. 00142 */ 00143 } 00144 src->pub.next_input_byte += (size_t) num_bytes; 00145 src->pub.bytes_in_buffer -= (size_t) num_bytes; 00146 } 00147 } |
|
Definition at line 169 of file jdatasrc.c. Referenced by jpeg_stdio_src().
00170 {
00171 /* no work necessary here */
00172 }
|