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

Side by Side Diff: cdjpeg.c

Issue 1953443002: Update to libjpeg_turbo 1.4.90 (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
« no previous file with comments | « cdjpeg.h ('k') | change.log » ('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 * cdjpeg.c 2 * cdjpeg.c
3 * 3 *
4 * This file was part of the Independent JPEG Group's software:
4 * Copyright (C) 1991-1997, Thomas G. Lane. 5 * Copyright (C) 1991-1997, Thomas G. Lane.
5 * This file is part of the Independent JPEG Group's software. 6 * It was modified by The libjpeg-turbo Project to include only code relevant
6 * For conditions of distribution and use, see the accompanying README file. 7 * to libjpeg-turbo.
8 * For conditions of distribution and use, see the accompanying README.ijg
9 * file.
7 * 10 *
8 * This file contains common support routines used by the IJG application 11 * This file contains common support routines used by the IJG application
9 * programs (cjpeg, djpeg, jpegtran). 12 * programs (cjpeg, djpeg, jpegtran).
10 */ 13 */
11 14
12 #include "cdjpeg.h"» » /* Common decls for cjpeg/djpeg applications */ 15 #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
13 #include <ctype.h>» » /* to declare isupper(), tolower() */ 16 #include <ctype.h> /* to declare isupper(), tolower() */
14 #ifdef NEED_SIGNAL_CATCHER
15 #include <signal.h>» » /* to declare signal() */
16 #endif
17 #ifdef USE_SETMODE 17 #ifdef USE_SETMODE
18 #include <fcntl.h>» » /* to declare setmode()'s parameter macros */ 18 #include <fcntl.h> /* to declare setmode()'s parameter macros */
19 /* If you have setmode() but not <io.h>, just delete this line: */ 19 /* If you have setmode() but not <io.h>, just delete this line: */
20 #include <io.h>»» » /* to declare setmode() */ 20 #include <io.h> /* to declare setmode() */
21 #endif 21 #endif
22 22
23 23
24 /*
25 * Signal catcher to ensure that temporary files are removed before aborting.
26 * NB: for Amiga Manx C this is actually a global routine named _abort();
27 * we put "#define signal_catcher _abort" in jconfig.h. Talk about bogus...
28 */
29
30 #ifdef NEED_SIGNAL_CATCHER
31
32 static j_common_ptr sig_cinfo;
33
34 void /* must be global for Manx C */
35 signal_catcher (int signum)
36 {
37 if (sig_cinfo != NULL) {
38 if (sig_cinfo->err != NULL) /* turn off trace output */
39 sig_cinfo->err->trace_level = 0;
40 jpeg_destroy(sig_cinfo); /* clean up memory allocation & temp files */
41 }
42 exit(EXIT_FAILURE);
43 }
44
45
46 GLOBAL(void)
47 enable_signal_catcher (j_common_ptr cinfo)
48 {
49 sig_cinfo = cinfo;
50 #ifdef SIGINT /* not all systems have SIGINT */
51 signal(SIGINT, signal_catcher);
52 #endif
53 #ifdef SIGTERM /* not all systems have SIGTERM */
54 signal(SIGTERM, signal_catcher);
55 #endif
56 }
57
58 #endif
59
60
61 /* 24 /*
62 * Optional progress monitor: display a percent-done figure on stderr. 25 * Optional progress monitor: display a percent-done figure on stderr.
63 */ 26 */
64 27
65 #ifdef PROGRESS_REPORT 28 #ifdef PROGRESS_REPORT
66 29
67 METHODDEF(void) 30 METHODDEF(void)
68 progress_monitor (j_common_ptr cinfo) 31 progress_monitor (j_common_ptr cinfo)
69 { 32 {
70 cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress; 33 cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress;
71 int total_passes = prog->pub.total_passes + prog->total_extra_passes; 34 int total_passes = prog->pub.total_passes + prog->total_extra_passes;
72 int percent_done = (int) (prog->pub.pass_counter*100L/prog->pub.pass_limit); 35 int percent_done = (int) (prog->pub.pass_counter*100L/prog->pub.pass_limit);
73 36
74 if (percent_done != prog->percent_done) { 37 if (percent_done != prog->percent_done) {
75 prog->percent_done = percent_done; 38 prog->percent_done = percent_done;
76 if (total_passes > 1) { 39 if (total_passes > 1) {
77 fprintf(stderr, "\rPass %d/%d: %3d%% ", 40 fprintf(stderr, "\rPass %d/%d: %3d%% ",
78 » prog->pub.completed_passes + prog->completed_extra_passes + 1, 41 prog->pub.completed_passes + prog->completed_extra_passes + 1,
79 » total_passes, percent_done); 42 total_passes, percent_done);
80 } else { 43 } else {
81 fprintf(stderr, "\r %3d%% ", percent_done); 44 fprintf(stderr, "\r %3d%% ", percent_done);
82 } 45 }
83 fflush(stderr); 46 fflush(stderr);
84 } 47 }
85 } 48 }
86 49
87 50
88 GLOBAL(void) 51 GLOBAL(void)
89 start_progress_monitor (j_common_ptr cinfo, cd_progress_ptr progress) 52 start_progress_monitor (j_common_ptr cinfo, cd_progress_ptr progress)
(...skipping 22 matching lines...) Expand all
112 #endif 75 #endif
113 76
114 77
115 /* 78 /*
116 * Case-insensitive matching of possibly-abbreviated keyword switches. 79 * Case-insensitive matching of possibly-abbreviated keyword switches.
117 * keyword is the constant keyword (must be lower case already), 80 * keyword is the constant keyword (must be lower case already),
118 * minchars is length of minimum legal abbreviation. 81 * minchars is length of minimum legal abbreviation.
119 */ 82 */
120 83
121 GLOBAL(boolean) 84 GLOBAL(boolean)
122 keymatch (char * arg, const char * keyword, int minchars) 85 keymatch (char *arg, const char *keyword, int minchars)
123 { 86 {
124 register int ca, ck; 87 register int ca, ck;
125 register int nmatched = 0; 88 register int nmatched = 0;
126 89
127 while ((ca = *arg++) != '\0') { 90 while ((ca = *arg++) != '\0') {
128 if ((ck = *keyword++) == '\0') 91 if ((ck = *keyword++) == '\0')
129 return FALSE;» » /* arg longer than keyword, no good */ 92 return FALSE; /* arg longer than keyword, no good */
130 if (isupper(ca))» » /* force arg to lcase (assume ck is already) */ 93 if (isupper(ca)) /* force arg to lcase (assume ck is already) */
131 ca = tolower(ca); 94 ca = tolower(ca);
132 if (ca != ck) 95 if (ca != ck)
133 return FALSE;» » /* no good */ 96 return FALSE; /* no good */
134 nmatched++;»» » /* count matched characters */ 97 nmatched++; /* count matched characters */
135 } 98 }
136 /* reached end of argument; fail if it's too short for unique abbrev */ 99 /* reached end of argument; fail if it's too short for unique abbrev */
137 if (nmatched < minchars) 100 if (nmatched < minchars)
138 return FALSE; 101 return FALSE;
139 return TRUE;» » » /* A-OK */ 102 return TRUE; /* A-OK */
140 } 103 }
141 104
142 105
143 /* 106 /*
144 * Routines to establish binary I/O mode for stdin and stdout. 107 * Routines to establish binary I/O mode for stdin and stdout.
145 * Non-Unix systems often require some hacking to get out of text mode. 108 * Non-Unix systems often require some hacking to get out of text mode.
146 */ 109 */
147 110
148 GLOBAL(FILE *) 111 GLOBAL(FILE *)
149 read_stdin (void) 112 read_stdin (void)
150 { 113 {
151 FILE * input_file = stdin; 114 FILE * input_file = stdin;
152 115
153 #ifdef USE_SETMODE» » /* need to hack file mode? */ 116 #ifdef USE_SETMODE /* need to hack file mode? */
154 setmode(fileno(stdin), O_BINARY); 117 setmode(fileno(stdin), O_BINARY);
155 #endif 118 #endif
156 #ifdef USE_FDOPEN» » /* need to re-open in binary mode? */ 119 #ifdef USE_FDOPEN /* need to re-open in binary mode? */
157 if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) { 120 if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) {
158 fprintf(stderr, "Cannot reopen stdin\n"); 121 fprintf(stderr, "Cannot reopen stdin\n");
159 exit(EXIT_FAILURE); 122 exit(EXIT_FAILURE);
160 } 123 }
161 #endif 124 #endif
162 return input_file; 125 return input_file;
163 } 126 }
164 127
165 128
166 GLOBAL(FILE *) 129 GLOBAL(FILE *)
167 write_stdout (void) 130 write_stdout (void)
168 { 131 {
169 FILE * output_file = stdout; 132 FILE * output_file = stdout;
170 133
171 #ifdef USE_SETMODE» » /* need to hack file mode? */ 134 #ifdef USE_SETMODE /* need to hack file mode? */
172 setmode(fileno(stdout), O_BINARY); 135 setmode(fileno(stdout), O_BINARY);
173 #endif 136 #endif
174 #ifdef USE_FDOPEN» » /* need to re-open in binary mode? */ 137 #ifdef USE_FDOPEN /* need to re-open in binary mode? */
175 if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { 138 if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) {
176 fprintf(stderr, "Cannot reopen stdout\n"); 139 fprintf(stderr, "Cannot reopen stdout\n");
177 exit(EXIT_FAILURE); 140 exit(EXIT_FAILURE);
178 } 141 }
179 #endif 142 #endif
180 return output_file; 143 return output_file;
181 } 144 }
OLDNEW
« no previous file with comments | « cdjpeg.h ('k') | change.log » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698