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

Side by Side Diff: third_party/libjpeg_turbo/rdswitch.c

Issue 7554002: Updates libjpeg-turbo to 1.1.90 (r677) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: '' Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « third_party/libjpeg_turbo/rdppm.c ('k') | third_party/libjpeg_turbo/simd/jcclrmmx.asm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * rdswitch.c 2 * rdswitch.c
3 * 3 *
4 * Copyright (C) 1991-1996, Thomas G. Lane. 4 * Copyright (C) 1991-1996, Thomas G. Lane.
5 * Copyright (C) 2010, D. R. Commander.
5 * This file is part of the Independent JPEG Group's software. 6 * This file is part of the Independent JPEG Group's software.
6 * For conditions of distribution and use, see the accompanying README file. 7 * For conditions of distribution and use, see the accompanying README file.
7 * 8 *
8 * This file contains routines to process some of cjpeg's more complicated 9 * This file contains routines to process some of cjpeg's more complicated
9 * command-line switches. Switches processed here are: 10 * command-line switches. Switches processed here are:
10 * -qtables file Read quantization tables from text file 11 * -qtables file Read quantization tables from text file
11 * -scans file Read scan script from text file 12 * -scans file Read scan script from text file
13 * -quality N[,N,...] Set quality ratings
12 * -qslots N[,N,...] Set component quantization table selectors 14 * -qslots N[,N,...] Set component quantization table selectors
13 * -sample HxV[,HxV,...] Set component sampling factors 15 * -sample HxV[,HxV,...] Set component sampling factors
14 */ 16 */
15 17
16 #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ 18 #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
17 #include <ctype.h> /* to declare isdigit(), isspace() */ 19 #include <ctype.h> /* to declare isdigit(), isspace() */
18 20
19 21
20 LOCAL(int) 22 LOCAL(int)
21 text_getc (FILE * file) 23 text_getc (FILE * file)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 break; 64 break;
63 val *= 10; 65 val *= 10;
64 val += ch - '0'; 66 val += ch - '0';
65 } 67 }
66 *result = val; 68 *result = val;
67 *termchar = ch; 69 *termchar = ch;
68 return TRUE; 70 return TRUE;
69 } 71 }
70 72
71 73
74 #if JPEG_LIB_VERSION < 70
75 static int q_scale_factor[NUM_QUANT_TBLS] = {100, 100, 100, 100};
76 #endif
77
72 GLOBAL(boolean) 78 GLOBAL(boolean)
73 read_quant_tables (j_compress_ptr cinfo, char * filename, 79 read_quant_tables (j_compress_ptr cinfo, char * filename, boolean force_baseline )
74 » » int scale_factor, boolean force_baseline)
75 /* Read a set of quantization tables from the specified file. 80 /* Read a set of quantization tables from the specified file.
76 * The file is plain ASCII text: decimal numbers with whitespace between. 81 * The file is plain ASCII text: decimal numbers with whitespace between.
77 * Comments preceded by '#' may be included in the file. 82 * Comments preceded by '#' may be included in the file.
78 * There may be one to NUM_QUANT_TBLS tables in the file, each of 64 values. 83 * There may be one to NUM_QUANT_TBLS tables in the file, each of 64 values.
79 * The tables are implicitly numbered 0,1,etc. 84 * The tables are implicitly numbered 0,1,etc.
80 * NOTE: does not affect the qslots mapping, which will default to selecting 85 * NOTE: does not affect the qslots mapping, which will default to selecting
81 * table 0 for luminance (or primary) components, 1 for chrominance components. 86 * table 0 for luminance (or primary) components, 1 for chrominance components.
82 * You must use -qslots if you want a different component->table mapping. 87 * You must use -qslots if you want a different component->table mapping.
83 */ 88 */
84 { 89 {
(...skipping 16 matching lines...) Expand all
101 } 106 }
102 table[0] = (unsigned int) val; 107 table[0] = (unsigned int) val;
103 for (i = 1; i < DCTSIZE2; i++) { 108 for (i = 1; i < DCTSIZE2; i++) {
104 if (! read_text_integer(fp, &val, &termchar)) { 109 if (! read_text_integer(fp, &val, &termchar)) {
105 fprintf(stderr, "Invalid table data in file %s\n", filename); 110 fprintf(stderr, "Invalid table data in file %s\n", filename);
106 fclose(fp); 111 fclose(fp);
107 return FALSE; 112 return FALSE;
108 } 113 }
109 table[i] = (unsigned int) val; 114 table[i] = (unsigned int) val;
110 } 115 }
111 jpeg_add_quant_table(cinfo, tblno, table, scale_factor, force_baseline); 116 #if JPEG_LIB_VERSION >= 70
117 jpeg_add_quant_table(cinfo, tblno, table, cinfo->q_scale_factor[tblno],
118 » » » force_baseline);
119 #else
120 jpeg_add_quant_table(cinfo, tblno, table, q_scale_factor[tblno],
121 force_baseline);
122 #endif
112 tblno++; 123 tblno++;
113 } 124 }
114 125
115 if (termchar != EOF) { 126 if (termchar != EOF) {
116 fprintf(stderr, "Non-numeric data in file %s\n", filename); 127 fprintf(stderr, "Non-numeric data in file %s\n", filename);
117 fclose(fp); 128 fclose(fp);
118 return FALSE; 129 return FALSE;
119 } 130 }
120 131
121 fclose(fp); 132 fclose(fp);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 cinfo->num_scans = scanno; 266 cinfo->num_scans = scanno;
256 } 267 }
257 268
258 fclose(fp); 269 fclose(fp);
259 return TRUE; 270 return TRUE;
260 } 271 }
261 272
262 #endif /* C_MULTISCAN_FILES_SUPPORTED */ 273 #endif /* C_MULTISCAN_FILES_SUPPORTED */
263 274
264 275
276 #if JPEG_LIB_VERSION < 70
277 /* These are the sample quantization tables given in JPEG spec section K.1.
278 * The spec says that the values given produce "good" quality, and
279 * when divided by 2, "very good" quality.
280 */
281 static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
282 16, 11, 10, 16, 24, 40, 51, 61,
283 12, 12, 14, 19, 26, 58, 60, 55,
284 14, 13, 16, 24, 40, 57, 69, 56,
285 14, 17, 22, 29, 51, 87, 80, 62,
286 18, 22, 37, 56, 68, 109, 103, 77,
287 24, 35, 55, 64, 81, 104, 113, 92,
288 49, 64, 78, 87, 103, 121, 120, 101,
289 72, 92, 95, 98, 112, 100, 103, 99
290 };
291 static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
292 17, 18, 24, 47, 99, 99, 99, 99,
293 18, 21, 26, 66, 99, 99, 99, 99,
294 24, 26, 56, 99, 99, 99, 99, 99,
295 47, 66, 99, 99, 99, 99, 99, 99,
296 99, 99, 99, 99, 99, 99, 99, 99,
297 99, 99, 99, 99, 99, 99, 99, 99,
298 99, 99, 99, 99, 99, 99, 99, 99,
299 99, 99, 99, 99, 99, 99, 99, 99
300 };
301
302
303 LOCAL(void)
304 jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
305 {
306 jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
307 q_scale_factor[0], force_baseline);
308 jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
309 q_scale_factor[1], force_baseline);
310 }
311 #endif
312
313
314 GLOBAL(boolean)
315 set_quality_ratings (j_compress_ptr cinfo, char *arg, boolean force_baseline)
316 /* Process a quality-ratings parameter string, of the form
317 * N[,N,...]
318 * If there are more q-table slots than parameters, the last value is replicated .
319 */
320 {
321 int val = 75; /* default value */
322 int tblno;
323 char ch;
324
325 for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
326 if (*arg) {
327 ch = ','; /* if not set by sscanf, will be ',' */
328 if (sscanf(arg, "%d%c", &val, &ch) < 1)
329 return FALSE;
330 if (ch != ',') /* syntax check */
331 return FALSE;
332 /* Convert user 0-100 rating to percentage scaling */
333 #if JPEG_LIB_VERSION >= 70
334 cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val);
335 #else
336 q_scale_factor[tblno] = jpeg_quality_scaling(val);
337 #endif
338 while (*arg && *arg++ != ',') /* advance to next segment of arg string */
339 ;
340 } else {
341 /* reached end of parameter, set remaining factors to last value */
342 #if JPEG_LIB_VERSION >= 70
343 cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val);
344 #else
345 q_scale_factor[tblno] = jpeg_quality_scaling(val);
346 #endif
347 }
348 }
349 jpeg_default_qtables(cinfo, force_baseline);
350 return TRUE;
351 }
352
353
265 GLOBAL(boolean) 354 GLOBAL(boolean)
266 set_quant_slots (j_compress_ptr cinfo, char *arg) 355 set_quant_slots (j_compress_ptr cinfo, char *arg)
267 /* Process a quantization-table-selectors parameter string, of the form 356 /* Process a quantization-table-selectors parameter string, of the form
268 * N[,N,...] 357 * N[,N,...]
269 * If there are more components than parameters, the last value is replicated. 358 * If there are more components than parameters, the last value is replicated.
270 */ 359 */
271 { 360 {
272 int val = 0; /* default table # */ 361 int val = 0; /* default table # */
273 int ci; 362 int ci;
274 char ch; 363 char ch;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 while (*arg && *arg++ != ',') /* advance to next segment of arg string */ 412 while (*arg && *arg++ != ',') /* advance to next segment of arg string */
324 ; 413 ;
325 } else { 414 } else {
326 /* reached end of parameter, set remaining components to 1x1 sampling */ 415 /* reached end of parameter, set remaining components to 1x1 sampling */
327 cinfo->comp_info[ci].h_samp_factor = 1; 416 cinfo->comp_info[ci].h_samp_factor = 1;
328 cinfo->comp_info[ci].v_samp_factor = 1; 417 cinfo->comp_info[ci].v_samp_factor = 1;
329 } 418 }
330 } 419 }
331 return TRUE; 420 return TRUE;
332 } 421 }
OLDNEW
« no previous file with comments | « third_party/libjpeg_turbo/rdppm.c ('k') | third_party/libjpeg_turbo/simd/jcclrmmx.asm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698