Changeset 846 for trunk/src/3rdparty/libjpeg/jdatasrc.c
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/3rdparty/libjpeg/jdatasrc.c
r2 r846 3 3 * 4 4 * Copyright (C) 1994-1996, Thomas G. Lane. 5 * Modified 2009 by Guido Vollbeding. 5 6 * This file is part of the Independent JPEG Group's software. 6 7 * For conditions of distribution and use, see the accompanying README file. 7 8 * 8 9 * This file contains decompression data source routines for the case of 9 * reading JPEG data from a file (or any stdio stream). While these routines10 * are sufficient for most applications, some will want to use a different11 * so urce manager.10 * reading JPEG data from memory or from a file (or any stdio stream). 11 * While these routines are sufficient for most applications, 12 * some will want to use a different source manager. 12 13 * IMPORTANT: we assume that fread() will correctly transcribe an array of 13 14 * JOCTETs from 8-bit-wide elements on external storage. If char is wider … … 51 52 */ 52 53 src->start_of_file = TRUE; 54 } 55 56 METHODDEF(void) 57 init_mem_source (j_decompress_ptr cinfo) 58 { 59 /* no work necessary here */ 53 60 } 54 61 … … 112 119 } 113 120 121 METHODDEF(boolean) 122 fill_mem_input_buffer (j_decompress_ptr cinfo) 123 { 124 static JOCTET mybuffer[4]; 125 126 /* The whole JPEG data is expected to reside in the supplied memory 127 * buffer, so any request for more data beyond the given buffer size 128 * is treated as an error. 129 */ 130 WARNMS(cinfo, JWRN_JPEG_EOF); 131 /* Insert a fake EOI marker */ 132 mybuffer[0] = (JOCTET) 0xFF; 133 mybuffer[1] = (JOCTET) JPEG_EOI; 134 135 cinfo->src->next_input_byte = mybuffer; 136 cinfo->src->bytes_in_buffer = 2; 137 138 return TRUE; 139 } 140 114 141 115 142 /* … … 128 155 skip_input_data (j_decompress_ptr cinfo, long num_bytes) 129 156 { 130 my_src_ptr src = (my_src_ptr)cinfo->src;157 struct jpeg_source_mgr * src = cinfo->src; 131 158 132 159 /* Just a dumb implementation for now. Could use fseek() except … … 135 162 */ 136 163 if (num_bytes > 0) { 137 while (num_bytes > (long) src-> pub.bytes_in_buffer) {138 num_bytes -= (long) src-> pub.bytes_in_buffer;164 while (num_bytes > (long) src->bytes_in_buffer) { 165 num_bytes -= (long) src->bytes_in_buffer; 139 166 (void) fill_input_buffer(cinfo); 140 167 /* note we assume that fill_input_buffer will never return FALSE, … … 142 169 */ 143 170 } 144 src-> pub.next_input_byte += (size_t) num_bytes;145 src-> pub.bytes_in_buffer -= (size_t) num_bytes;171 src->next_input_byte += (size_t) num_bytes; 172 src->bytes_in_buffer -= (size_t) num_bytes; 146 173 } 147 174 } … … 211 238 src->pub.next_input_byte = NULL; /* until buffer loaded */ 212 239 } 240 241 242 /* 243 * Prepare for input from a supplied memory buffer. 244 * The buffer must contain the whole JPEG data. 245 */ 246 247 GLOBAL(void) 248 jpeg_mem_src (j_decompress_ptr cinfo, 249 unsigned char * inbuffer, unsigned long insize) 250 { 251 struct jpeg_source_mgr * src; 252 253 if (inbuffer == NULL || insize == 0) /* Treat empty input as fatal error */ 254 ERREXIT(cinfo, JERR_INPUT_EMPTY); 255 256 /* The source object is made permanent so that a series of JPEG images 257 * can be read from the same buffer by calling jpeg_mem_src only before 258 * the first one. 259 */ 260 if (cinfo->src == NULL) { /* first time for this JPEG object? */ 261 cinfo->src = (struct jpeg_source_mgr *) 262 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, 263 SIZEOF(struct jpeg_source_mgr)); 264 } 265 266 src = cinfo->src; 267 src->init_source = init_mem_source; 268 src->fill_input_buffer = fill_mem_input_buffer; 269 src->skip_input_data = skip_input_data; 270 src->resync_to_restart = jpeg_resync_to_restart; /* use default method */ 271 src->term_source = term_source; 272 src->bytes_in_buffer = (size_t) insize; 273 src->next_input_byte = (JOCTET *) inbuffer; 274 }
Note:
See TracChangeset
for help on using the changeset viewer.