Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: jdatasrc-tj.c

Issue 1934113002: Update libjpeg_turbo to 1.4.90 from https://github.com/libjpeg-turbo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * jdatasrc-tj.c 2 * jdatasrc-tj.c
3 * 3 *
4 * This file was part of the Independent JPEG Group's software: 4 * This file was part of the Independent JPEG Group's software:
5 * Copyright (C) 1994-1996, Thomas G. Lane. 5 * Copyright (C) 1994-1996, Thomas G. Lane.
6 * Modified 2009-2011 by Guido Vollbeding. 6 * Modified 2009-2011 by Guido Vollbeding.
7 * libjpeg-turbo Modifications: 7 * libjpeg-turbo Modifications:
8 * Copyright (C) 2011, D. R. Commander. 8 * Copyright (C) 2011, D. R. Commander.
9 * For conditions of distribution and use, see the accompanying README file. 9 * For conditions of distribution and use, see the accompanying README.ijg
10 * file.
10 * 11 *
11 * This file contains decompression data source routines for the case of 12 * This file contains decompression data source routines for the case of
12 * reading JPEG data from memory or from a file (or any stdio stream). 13 * reading JPEG data from memory or from a file (or any stdio stream).
13 * While these routines are sufficient for most applications, 14 * While these routines are sufficient for most applications,
14 * some will want to use a different source manager. 15 * some will want to use a different source manager.
15 * IMPORTANT: we assume that fread() will correctly transcribe an array of 16 * IMPORTANT: we assume that fread() will correctly transcribe an array of
16 * JOCTETs from 8-bit-wide elements on external storage. If char is wider 17 * JOCTETs from 8-bit-wide elements on external storage. If char is wider
17 * than 8 bits on your machine, you may need to do some tweaking. 18 * than 8 bits on your machine, you may need to do some tweaking.
18 */ 19 */
19 20
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 * is not granted the right to give a suspension return. If the skip extends 99 * is not granted the right to give a suspension return. If the skip extends
99 * beyond the data currently in the buffer, the buffer can be marked empty so 100 * beyond the data currently in the buffer, the buffer can be marked empty so
100 * that the next read will cause a fill_input_buffer call that can suspend. 101 * that the next read will cause a fill_input_buffer call that can suspend.
101 * Arranging for additional bytes to be discarded before reloading the input 102 * Arranging for additional bytes to be discarded before reloading the input
102 * buffer is the application writer's problem. 103 * buffer is the application writer's problem.
103 */ 104 */
104 105
105 METHODDEF(void) 106 METHODDEF(void)
106 skip_input_data (j_decompress_ptr cinfo, long num_bytes) 107 skip_input_data (j_decompress_ptr cinfo, long num_bytes)
107 { 108 {
108 struct jpeg_source_mgr * src = cinfo->src; 109 struct jpeg_source_mgr *src = cinfo->src;
109 110
110 /* Just a dumb implementation for now. Could use fseek() except 111 /* Just a dumb implementation for now. Could use fseek() except
111 * it doesn't work on pipes. Not clear that being smart is worth 112 * it doesn't work on pipes. Not clear that being smart is worth
112 * any trouble anyway --- large skips are infrequent. 113 * any trouble anyway --- large skips are infrequent.
113 */ 114 */
114 if (num_bytes > 0) { 115 if (num_bytes > 0) {
115 while (num_bytes > (long) src->bytes_in_buffer) { 116 while (num_bytes > (long) src->bytes_in_buffer) {
116 num_bytes -= (long) src->bytes_in_buffer; 117 num_bytes -= (long) src->bytes_in_buffer;
117 (void) (*src->fill_input_buffer) (cinfo); 118 (void) (*src->fill_input_buffer) (cinfo);
118 /* note we assume that fill_input_buffer will never return FALSE, 119 /* note we assume that fill_input_buffer will never return FALSE,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 151 }
151 152
152 153
153 /* 154 /*
154 * Prepare for input from a supplied memory buffer. 155 * Prepare for input from a supplied memory buffer.
155 * The buffer must contain the whole JPEG data. 156 * The buffer must contain the whole JPEG data.
156 */ 157 */
157 158
158 GLOBAL(void) 159 GLOBAL(void)
159 jpeg_mem_src_tj (j_decompress_ptr cinfo, 160 jpeg_mem_src_tj (j_decompress_ptr cinfo,
160 » unsigned char * inbuffer, unsigned long insize) 161 const unsigned char *inbuffer, unsigned long insize)
161 { 162 {
162 struct jpeg_source_mgr * src; 163 struct jpeg_source_mgr *src;
163 164
164 if (inbuffer == NULL || insize == 0)» /* Treat empty input as fatal error */ 165 if (inbuffer == NULL || insize == 0) /* Treat empty input as fatal error */
165 ERREXIT(cinfo, JERR_INPUT_EMPTY); 166 ERREXIT(cinfo, JERR_INPUT_EMPTY);
166 167
167 /* The source object is made permanent so that a series of JPEG images 168 /* The source object is made permanent so that a series of JPEG images
168 * can be read from the same buffer by calling jpeg_mem_src only before 169 * can be read from the same buffer by calling jpeg_mem_src only before
169 * the first one. 170 * the first one.
170 */ 171 */
171 if (cinfo->src == NULL) {» /* first time for this JPEG object? */ 172 if (cinfo->src == NULL) { /* first time for this JPEG object? */
172 cinfo->src = (struct jpeg_source_mgr *) 173 cinfo->src = (struct jpeg_source_mgr *)
173 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, 174 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
174 » » » » SIZEOF(struct jpeg_source_mgr)); 175 sizeof(struct jpeg_source_mgr));
175 } 176 }
176 177
177 src = cinfo->src; 178 src = cinfo->src;
178 src->init_source = init_mem_source; 179 src->init_source = init_mem_source;
179 src->fill_input_buffer = fill_mem_input_buffer; 180 src->fill_input_buffer = fill_mem_input_buffer;
180 src->skip_input_data = skip_input_data; 181 src->skip_input_data = skip_input_data;
181 src->resync_to_restart = jpeg_resync_to_restart; /* use default method */ 182 src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
182 src->term_source = term_source; 183 src->term_source = term_source;
183 src->bytes_in_buffer = (size_t) insize; 184 src->bytes_in_buffer = (size_t) insize;
184 src->next_input_byte = (JOCTET *) inbuffer; 185 src->next_input_byte = (const JOCTET *) inbuffer;
185 } 186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698