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

Unified Diff: rdswitch.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, 8 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 side-by-side diff with in-line comments
Download patch
Index: rdswitch.c
diff --git a/rdswitch.c b/rdswitch.c
index fc0727a5552fec59f0a15e5400e4f912844e4876..7d870c309d4f6db1ae04ed70ba080d796b5b63e9 100644
--- a/rdswitch.c
+++ b/rdswitch.c
@@ -5,28 +5,29 @@
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2010, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README file.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
*
* This file contains routines to process some of cjpeg's more complicated
* command-line switches. Switches processed here are:
- * -qtables file Read quantization tables from text file
- * -scans file Read scan script from text file
- * -quality N[,N,...] Set quality ratings
- * -qslots N[,N,...] Set component quantization table selectors
- * -sample HxV[,HxV,...] Set component sampling factors
+ * -qtables file Read quantization tables from text file
+ * -scans file Read scan script from text file
+ * -quality N[,N,...] Set quality ratings
+ * -qslots N[,N,...] Set component quantization table selectors
+ * -sample HxV[,HxV,...] Set component sampling factors
*/
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-#include <ctype.h> /* to declare isdigit(), isspace() */
+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
+#include <ctype.h> /* to declare isdigit(), isspace() */
LOCAL(int)
-text_getc (FILE * file)
+text_getc (FILE *file)
/* Read next char, skipping over any comments (# to end of line) */
/* A comment/newline sequence is returned as a newline */
{
register int ch;
-
+
ch = getc(file);
if (ch == '#') {
do {
@@ -38,13 +39,13 @@ text_getc (FILE * file)
LOCAL(boolean)
-read_text_integer (FILE * file, long * result, int * termchar)
+read_text_integer (FILE *file, long *result, int *termchar)
/* Read an unsigned decimal integer from a file, store it in result */
/* Reads one trailing character after the integer; returns it in termchar */
{
register int ch;
register long val;
-
+
/* Skip any leading whitespace, detect EOF */
do {
ch = text_getc(file);
@@ -53,7 +54,7 @@ read_text_integer (FILE * file, long * result, int * termchar)
return FALSE;
}
} while (isspace(ch));
-
+
if (! isdigit(ch)) {
*termchar = ch;
return FALSE;
@@ -77,7 +78,8 @@ static int q_scale_factor[NUM_QUANT_TBLS] = {100, 100, 100, 100};
#endif
GLOBAL(boolean)
-read_quant_tables (j_compress_ptr cinfo, char * filename, boolean force_baseline)
+read_quant_tables (j_compress_ptr cinfo, char *filename,
+ boolean force_baseline)
/* Read a set of quantization tables from the specified file.
* The file is plain ASCII text: decimal numbers with whitespace between.
* Comments preceded by '#' may be included in the file.
@@ -88,7 +90,7 @@ read_quant_tables (j_compress_ptr cinfo, char * filename, boolean force_baseline
* You must use -qslots if you want a different component->table mapping.
*/
{
- FILE * fp;
+ FILE *fp;
int tblno, i, termchar;
long val;
unsigned int table[DCTSIZE2];
@@ -108,15 +110,15 @@ read_quant_tables (j_compress_ptr cinfo, char * filename, boolean force_baseline
table[0] = (unsigned int) val;
for (i = 1; i < DCTSIZE2; i++) {
if (! read_text_integer(fp, &val, &termchar)) {
- fprintf(stderr, "Invalid table data in file %s\n", filename);
- fclose(fp);
- return FALSE;
+ fprintf(stderr, "Invalid table data in file %s\n", filename);
+ fclose(fp);
+ return FALSE;
}
table[i] = (unsigned int) val;
}
#if JPEG_LIB_VERSION >= 70
jpeg_add_quant_table(cinfo, tblno, table, cinfo->q_scale_factor[tblno],
- force_baseline);
+ force_baseline);
#else
jpeg_add_quant_table(cinfo, tblno, table, q_scale_factor[tblno],
force_baseline);
@@ -138,7 +140,7 @@ read_quant_tables (j_compress_ptr cinfo, char * filename, boolean force_baseline
#ifdef C_MULTISCAN_FILES_SUPPORTED
LOCAL(boolean)
-read_scan_integer (FILE * file, long * result, int * termchar)
+read_scan_integer (FILE *file, long *result, int *termchar)
/* Variant of read_text_integer that always looks for a non-space termchar;
* this simplifies parsing of punctuation in scan scripts.
*/
@@ -150,7 +152,7 @@ read_scan_integer (FILE * file, long * result, int * termchar)
ch = *termchar;
while (ch != EOF && isspace(ch))
ch = text_getc(file);
- if (isdigit(ch)) { /* oops, put it back */
+ if (isdigit(ch)) { /* oops, put it back */
if (ungetc(ch, file) == EOF)
return FALSE;
ch = ' ';
@@ -167,7 +169,7 @@ read_scan_integer (FILE * file, long * result, int * termchar)
GLOBAL(boolean)
-read_scan_script (j_compress_ptr cinfo, char * filename)
+read_scan_script (j_compress_ptr cinfo, char *filename)
/* Read a scan script from the specified text file.
* Each entry in the file defines one scan to be emitted.
* Entries are separated by semicolons ';'.
@@ -184,11 +186,11 @@ read_scan_script (j_compress_ptr cinfo, char * filename)
* jcmaster.c will validate the script parameters.
*/
{
- FILE * fp;
+ FILE *fp;
int scanno, ncomps, termchar;
long val;
- jpeg_scan_info * scanptr;
-#define MAX_SCANS 100 /* quite arbitrary limit */
+ jpeg_scan_info *scanptr;
+#define MAX_SCANS 100 /* quite arbitrary limit */
jpeg_scan_info scans[MAX_SCANS];
if ((fp = fopen(filename, "r")) == NULL) {
@@ -208,29 +210,29 @@ read_scan_script (j_compress_ptr cinfo, char * filename)
ncomps = 1;
while (termchar == ' ') {
if (ncomps >= MAX_COMPS_IN_SCAN) {
- fprintf(stderr, "Too many components in one scan in file %s\n",
- filename);
- fclose(fp);
- return FALSE;
+ fprintf(stderr, "Too many components in one scan in file %s\n",
+ filename);
+ fclose(fp);
+ return FALSE;
}
if (! read_scan_integer(fp, &val, &termchar))
- goto bogus;
+ goto bogus;
scanptr->component_index[ncomps] = (int) val;
ncomps++;
}
scanptr->comps_in_scan = ncomps;
if (termchar == ':') {
if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
- goto bogus;
+ goto bogus;
scanptr->Ss = (int) val;
if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
- goto bogus;
+ goto bogus;
scanptr->Se = (int) val;
if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
- goto bogus;
+ goto bogus;
scanptr->Ah = (int) val;
if (! read_scan_integer(fp, &val, &termchar))
- goto bogus;
+ goto bogus;
scanptr->Al = (int) val;
} else {
/* set non-progressive parameters */
@@ -261,8 +263,8 @@ bogus:
*/
scanptr = (jpeg_scan_info *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- scanno * SIZEOF(jpeg_scan_info));
- MEMCOPY(scanptr, scans, scanno * SIZEOF(jpeg_scan_info));
+ scanno * sizeof(jpeg_scan_info));
+ MEMCOPY(scanptr, scans, scanno * sizeof(jpeg_scan_info));
cinfo->scan_info = scanptr;
cinfo->num_scans = scanno;
}
@@ -305,9 +307,9 @@ LOCAL(void)
jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
{
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
- q_scale_factor[0], force_baseline);
+ q_scale_factor[0], force_baseline);
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
- q_scale_factor[1], force_baseline);
+ q_scale_factor[1], force_baseline);
}
#endif
@@ -319,17 +321,17 @@ set_quality_ratings (j_compress_ptr cinfo, char *arg, boolean force_baseline)
* If there are more q-table slots than parameters, the last value is replicated.
*/
{
- int val = 75; /* default value */
+ int val = 75; /* default value */
int tblno;
char ch;
for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
if (*arg) {
- ch = ','; /* if not set by sscanf, will be ',' */
+ ch = ','; /* if not set by sscanf, will be ',' */
if (sscanf(arg, "%d%c", &val, &ch) < 1)
- return FALSE;
- if (ch != ',') /* syntax check */
- return FALSE;
+ return FALSE;
+ if (ch != ',') /* syntax check */
+ return FALSE;
/* Convert user 0-100 rating to percentage scaling */
#if JPEG_LIB_VERSION >= 70
cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val);
@@ -337,7 +339,7 @@ set_quality_ratings (j_compress_ptr cinfo, char *arg, boolean force_baseline)
q_scale_factor[tblno] = jpeg_quality_scaling(val);
#endif
while (*arg && *arg++ != ',') /* advance to next segment of arg string */
- ;
+ ;
} else {
/* reached end of parameter, set remaining factors to last value */
#if JPEG_LIB_VERSION >= 70
@@ -359,25 +361,25 @@ set_quant_slots (j_compress_ptr cinfo, char *arg)
* If there are more components than parameters, the last value is replicated.
*/
{
- int val = 0; /* default table # */
+ int val = 0; /* default table # */
int ci;
char ch;
for (ci = 0; ci < MAX_COMPONENTS; ci++) {
if (*arg) {
- ch = ','; /* if not set by sscanf, will be ',' */
+ ch = ','; /* if not set by sscanf, will be ',' */
if (sscanf(arg, "%d%c", &val, &ch) < 1)
- return FALSE;
- if (ch != ',') /* syntax check */
- return FALSE;
+ return FALSE;
+ if (ch != ',') /* syntax check */
+ return FALSE;
if (val < 0 || val >= NUM_QUANT_TBLS) {
- fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n",
- NUM_QUANT_TBLS-1);
- return FALSE;
+ fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n",
+ NUM_QUANT_TBLS-1);
+ return FALSE;
}
cinfo->comp_info[ci].quant_tbl_no = val;
while (*arg && *arg++ != ',') /* advance to next segment of arg string */
- ;
+ ;
} else {
/* reached end of parameter, set remaining components to last table */
cinfo->comp_info[ci].quant_tbl_no = val;
@@ -399,19 +401,19 @@ set_sample_factors (j_compress_ptr cinfo, char *arg)
for (ci = 0; ci < MAX_COMPONENTS; ci++) {
if (*arg) {
- ch2 = ','; /* if not set by sscanf, will be ',' */
+ ch2 = ','; /* if not set by sscanf, will be ',' */
if (sscanf(arg, "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3)
- return FALSE;
+ return FALSE;
if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */
- return FALSE;
+ return FALSE;
if (val1 <= 0 || val1 > 4 || val2 <= 0 || val2 > 4) {
- fprintf(stderr, "JPEG sampling factors must be 1..4\n");
- return FALSE;
+ fprintf(stderr, "JPEG sampling factors must be 1..4\n");
+ return FALSE;
}
cinfo->comp_info[ci].h_samp_factor = val1;
cinfo->comp_info[ci].v_samp_factor = val2;
while (*arg && *arg++ != ',') /* advance to next segment of arg string */
- ;
+ ;
} else {
/* reached end of parameter, set remaining components to 1x1 sampling */
cinfo->comp_info[ci].h_samp_factor = 1;

Powered by Google App Engine
This is Rietveld 408576698