OLD | NEW |
1 /* | 1 /* |
2 * jpegtran.c | 2 * jpegtran.c |
3 * | 3 * |
4 * Copyright (C) 1995-1997, Thomas G. Lane. | 4 * Copyright (C) 1995-2010, Thomas G. Lane, Guido Vollbeding. |
| 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 a command-line user interface for JPEG transcoding. | 9 * This file contains a command-line user interface for JPEG transcoding. |
9 * It is very similar to cjpeg.c, but provides lossless transcoding between | 10 * It is very similar to cjpeg.c, and partly to djpeg.c, but provides |
10 * different JPEG file formats. It also provides some lossless and sort-of- | 11 * lossless transcoding between different JPEG file formats. It also |
11 * lossless transformations of JPEG data. | 12 * provides some lossless and sort-of-lossless transformations of JPEG data. |
12 */ | 13 */ |
13 | 14 |
14 #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ | 15 #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ |
15 #include "transupp.h" /* Support routines for jpegtran */ | 16 #include "transupp.h" /* Support routines for jpegtran */ |
16 #include "jversion.h" /* for version message */ | 17 #include "jversion.h" /* for version message */ |
| 18 #include "config.h" |
17 | 19 |
18 #ifdef USE_CCOMMAND /* command-line reader for Macintosh */ | 20 #ifdef USE_CCOMMAND /* command-line reader for Macintosh */ |
19 #ifdef __MWERKS__ | 21 #ifdef __MWERKS__ |
20 #include <SIOUX.h> /* Metrowerks needs this */ | 22 #include <SIOUX.h> /* Metrowerks needs this */ |
21 #include <console.h> /* ... and this */ | 23 #include <console.h> /* ... and this */ |
22 #endif | 24 #endif |
23 #ifdef THINK_C | 25 #ifdef THINK_C |
24 #include <console.h> /* Think declares it here */ | 26 #include <console.h> /* Think declares it here */ |
25 #endif | 27 #endif |
26 #endif | 28 #endif |
(...skipping 28 matching lines...) Expand all Loading... |
55 fprintf(stderr, "Switches (names may be abbreviated):\n"); | 57 fprintf(stderr, "Switches (names may be abbreviated):\n"); |
56 fprintf(stderr, " -copy none Copy no extra markers from source file\n"); | 58 fprintf(stderr, " -copy none Copy no extra markers from source file\n"); |
57 fprintf(stderr, " -copy comments Copy only comment markers (default)\n"); | 59 fprintf(stderr, " -copy comments Copy only comment markers (default)\n"); |
58 fprintf(stderr, " -copy all Copy all extra markers\n"); | 60 fprintf(stderr, " -copy all Copy all extra markers\n"); |
59 #ifdef ENTROPY_OPT_SUPPORTED | 61 #ifdef ENTROPY_OPT_SUPPORTED |
60 fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but sl
ow compression)\n"); | 62 fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but sl
ow compression)\n"); |
61 #endif | 63 #endif |
62 #ifdef C_PROGRESSIVE_SUPPORTED | 64 #ifdef C_PROGRESSIVE_SUPPORTED |
63 fprintf(stderr, " -progressive Create progressive JPEG file\n"); | 65 fprintf(stderr, " -progressive Create progressive JPEG file\n"); |
64 #endif | 66 #endif |
| 67 fprintf(stderr, "Switches for modifying the image:\n"); |
65 #if TRANSFORMS_SUPPORTED | 68 #if TRANSFORMS_SUPPORTED |
66 fprintf(stderr, "Switches for modifying the image:\n"); | 69 fprintf(stderr, " -crop WxH+X+Y Crop to a rectangular subarea\n"); |
67 fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n"); | 70 fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n"); |
68 fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or to
p-bottom)\n"); | 71 fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or to
p-bottom)\n"); |
| 72 fprintf(stderr, " -perfect Fail if there is non-transformable edge bloc
ks\n"); |
69 fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwis
e)\n"); | 73 fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwis
e)\n"); |
| 74 #endif |
| 75 #if TRANSFORMS_SUPPORTED |
70 fprintf(stderr, " -transpose Transpose image\n"); | 76 fprintf(stderr, " -transpose Transpose image\n"); |
71 fprintf(stderr, " -transverse Transverse transpose image\n"); | 77 fprintf(stderr, " -transverse Transverse transpose image\n"); |
72 fprintf(stderr, " -trim Drop non-transformable edge blocks\n"); | 78 fprintf(stderr, " -trim Drop non-transformable edge blocks\n"); |
73 #endif /* TRANSFORMS_SUPPORTED */ | 79 #endif |
74 fprintf(stderr, "Switches for advanced users:\n"); | 80 fprintf(stderr, "Switches for advanced users:\n"); |
75 fprintf(stderr, " -restart N Set restart interval in rows, or in blocks w
ith B\n"); | 81 fprintf(stderr, " -restart N Set restart interval in rows, or in blocks w
ith B\n"); |
76 fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); | 82 fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); |
77 fprintf(stderr, " -outfile name Specify name for output file\n"); | 83 fprintf(stderr, " -outfile name Specify name for output file\n"); |
78 fprintf(stderr, " -verbose or -debug Emit debug output\n"); | 84 fprintf(stderr, " -verbose or -debug Emit debug output\n"); |
79 fprintf(stderr, "Switches for wizards:\n"); | 85 fprintf(stderr, "Switches for wizards:\n"); |
80 #ifdef C_ARITH_CODING_SUPPORTED | 86 #ifdef C_ARITH_CODING_SUPPORTED |
81 fprintf(stderr, " -arithmetic Use arithmetic coding\n"); | 87 fprintf(stderr, " -arithmetic Use arithmetic coding\n"); |
82 #endif | 88 #endif |
83 #ifdef C_MULTISCAN_FILES_SUPPORTED | 89 #ifdef C_MULTISCAN_FILES_SUPPORTED |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 int argn; | 131 int argn; |
126 char * arg; | 132 char * arg; |
127 boolean simple_progressive; | 133 boolean simple_progressive; |
128 char * scansarg = NULL; /* saves -scans parm if any */ | 134 char * scansarg = NULL; /* saves -scans parm if any */ |
129 | 135 |
130 /* Set up default JPEG parameters. */ | 136 /* Set up default JPEG parameters. */ |
131 simple_progressive = FALSE; | 137 simple_progressive = FALSE; |
132 outfilename = NULL; | 138 outfilename = NULL; |
133 copyoption = JCOPYOPT_DEFAULT; | 139 copyoption = JCOPYOPT_DEFAULT; |
134 transformoption.transform = JXFORM_NONE; | 140 transformoption.transform = JXFORM_NONE; |
| 141 transformoption.perfect = FALSE; |
135 transformoption.trim = FALSE; | 142 transformoption.trim = FALSE; |
136 transformoption.force_grayscale = FALSE; | 143 transformoption.force_grayscale = FALSE; |
| 144 transformoption.crop = FALSE; |
| 145 transformoption.slow_hflip = FALSE; |
137 cinfo->err->trace_level = 0; | 146 cinfo->err->trace_level = 0; |
138 | 147 |
139 /* Scan command line options, adjust parameters */ | 148 /* Scan command line options, adjust parameters */ |
140 | 149 |
141 for (argn = 1; argn < argc; argn++) { | 150 for (argn = 1; argn < argc; argn++) { |
142 arg = argv[argn]; | 151 arg = argv[argn]; |
143 if (*arg != '-') { | 152 if (*arg != '-') { |
144 /* Not a switch, must be a file name argument */ | 153 /* Not a switch, must be a file name argument */ |
145 if (argn <= last_file_arg_seen) { | 154 if (argn <= last_file_arg_seen) { |
146 outfilename = NULL; /* -outfile applies to just one input file */ | 155 outfilename = NULL; /* -outfile applies to just one input file */ |
147 continue; /* ignore this name if previously processed */ | 156 continue; /* ignore this name if previously processed */ |
148 } | 157 } |
149 break; /* else done parsing switches */ | 158 break; /* else done parsing switches */ |
150 } | 159 } |
151 arg++; /* advance past switch marker character */ | 160 arg++; /* advance past switch marker character */ |
152 | 161 |
153 if (keymatch(arg, "arithmetic", 1)) { | 162 if (keymatch(arg, "arithmetic", 1)) { |
154 /* Use arithmetic coding. */ | 163 /* Use arithmetic coding. */ |
155 #ifdef C_ARITH_CODING_SUPPORTED | 164 #ifdef C_ARITH_CODING_SUPPORTED |
156 cinfo->arith_code = TRUE; | 165 cinfo->arith_code = TRUE; |
157 #else | 166 #else |
158 fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", | 167 fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", |
159 progname); | 168 progname); |
160 exit(EXIT_FAILURE); | 169 exit(EXIT_FAILURE); |
161 #endif | 170 #endif |
162 | 171 |
163 } else if (keymatch(arg, "copy", 1)) { | 172 } else if (keymatch(arg, "copy", 2)) { |
164 /* Select which extra markers to copy. */ | 173 /* Select which extra markers to copy. */ |
165 if (++argn >= argc) /* advance to next argument */ | 174 if (++argn >= argc) /* advance to next argument */ |
166 usage(); | 175 usage(); |
167 if (keymatch(argv[argn], "none", 1)) { | 176 if (keymatch(argv[argn], "none", 1)) { |
168 copyoption = JCOPYOPT_NONE; | 177 copyoption = JCOPYOPT_NONE; |
169 } else if (keymatch(argv[argn], "comments", 1)) { | 178 } else if (keymatch(argv[argn], "comments", 1)) { |
170 copyoption = JCOPYOPT_COMMENTS; | 179 copyoption = JCOPYOPT_COMMENTS; |
171 } else if (keymatch(argv[argn], "all", 1)) { | 180 } else if (keymatch(argv[argn], "all", 1)) { |
172 copyoption = JCOPYOPT_ALL; | 181 copyoption = JCOPYOPT_ALL; |
173 } else | 182 } else |
174 usage(); | 183 usage(); |
175 | 184 |
| 185 } else if (keymatch(arg, "crop", 2)) { |
| 186 /* Perform lossless cropping. */ |
| 187 #if TRANSFORMS_SUPPORTED |
| 188 if (++argn >= argc) /* advance to next argument */ |
| 189 usage(); |
| 190 if (! jtransform_parse_crop_spec(&transformoption, argv[argn])) { |
| 191 fprintf(stderr, "%s: bogus -crop argument '%s'\n", |
| 192 progname, argv[argn]); |
| 193 exit(EXIT_FAILURE); |
| 194 } |
| 195 #else |
| 196 select_transform(JXFORM_NONE); /* force an error */ |
| 197 #endif |
| 198 |
176 } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { | 199 } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { |
177 /* Enable debug printouts. */ | 200 /* Enable debug printouts. */ |
178 /* On first -d, print version identification */ | 201 /* On first -d, print version identification */ |
179 static boolean printed_version = FALSE; | 202 static boolean printed_version = FALSE; |
180 | 203 |
181 if (! printed_version) { | 204 if (! printed_version) { |
182 » fprintf(stderr, "Independent JPEG Group's JPEGTRAN, version %s\n%s\n", | 205 » fprintf(stderr, "%s version %s (build %s)\n", |
| 206 » » PACKAGE_NAME, VERSION, BUILD); |
| 207 » fprintf(stderr, "%s\n\n", LJTCOPYRIGHT); |
| 208 » fprintf(stderr, "Based on Independent JPEG Group's libjpeg, version %s\n
%s\n\n", |
183 JVERSION, JCOPYRIGHT); | 209 JVERSION, JCOPYRIGHT); |
184 printed_version = TRUE; | 210 printed_version = TRUE; |
185 } | 211 } |
186 cinfo->err->trace_level++; | 212 cinfo->err->trace_level++; |
187 | 213 |
188 } else if (keymatch(arg, "flip", 1)) { | 214 } else if (keymatch(arg, "flip", 1)) { |
189 /* Mirror left-right or top-bottom. */ | 215 /* Mirror left-right or top-bottom. */ |
190 if (++argn >= argc) /* advance to next argument */ | 216 if (++argn >= argc) /* advance to next argument */ |
191 usage(); | 217 usage(); |
192 if (keymatch(argv[argn], "horizontal", 1)) | 218 if (keymatch(argv[argn], "horizontal", 1)) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 progname); | 252 progname); |
227 exit(EXIT_FAILURE); | 253 exit(EXIT_FAILURE); |
228 #endif | 254 #endif |
229 | 255 |
230 } else if (keymatch(arg, "outfile", 4)) { | 256 } else if (keymatch(arg, "outfile", 4)) { |
231 /* Set output file name. */ | 257 /* Set output file name. */ |
232 if (++argn >= argc) /* advance to next argument */ | 258 if (++argn >= argc) /* advance to next argument */ |
233 usage(); | 259 usage(); |
234 outfilename = argv[argn]; /* save it away for later use */ | 260 outfilename = argv[argn]; /* save it away for later use */ |
235 | 261 |
236 } else if (keymatch(arg, "progressive", 1)) { | 262 } else if (keymatch(arg, "perfect", 2)) { |
| 263 /* Fail if there is any partial edge MCUs that the transform can't |
| 264 * handle. */ |
| 265 transformoption.perfect = TRUE; |
| 266 |
| 267 } else if (keymatch(arg, "progressive", 2)) { |
237 /* Select simple progressive mode. */ | 268 /* Select simple progressive mode. */ |
238 #ifdef C_PROGRESSIVE_SUPPORTED | 269 #ifdef C_PROGRESSIVE_SUPPORTED |
239 simple_progressive = TRUE; | 270 simple_progressive = TRUE; |
240 /* We must postpone execution until num_components is known. */ | 271 /* We must postpone execution until num_components is known. */ |
241 #else | 272 #else |
242 fprintf(stderr, "%s: sorry, progressive output was not compiled\n", | 273 fprintf(stderr, "%s: sorry, progressive output was not compiled\n", |
243 progname); | 274 progname); |
244 exit(EXIT_FAILURE); | 275 exit(EXIT_FAILURE); |
245 #endif | 276 #endif |
246 | 277 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 { | 366 { |
336 struct jpeg_decompress_struct srcinfo; | 367 struct jpeg_decompress_struct srcinfo; |
337 struct jpeg_compress_struct dstinfo; | 368 struct jpeg_compress_struct dstinfo; |
338 struct jpeg_error_mgr jsrcerr, jdsterr; | 369 struct jpeg_error_mgr jsrcerr, jdsterr; |
339 #ifdef PROGRESS_REPORT | 370 #ifdef PROGRESS_REPORT |
340 struct cdjpeg_progress_mgr progress; | 371 struct cdjpeg_progress_mgr progress; |
341 #endif | 372 #endif |
342 jvirt_barray_ptr * src_coef_arrays; | 373 jvirt_barray_ptr * src_coef_arrays; |
343 jvirt_barray_ptr * dst_coef_arrays; | 374 jvirt_barray_ptr * dst_coef_arrays; |
344 int file_index; | 375 int file_index; |
345 FILE * input_file; | 376 /* We assume all-in-memory processing and can therefore use only a |
346 FILE * output_file; | 377 * single file pointer for sequential input and output operation. |
| 378 */ |
| 379 FILE * fp; |
347 | 380 |
348 /* On Mac, fetch a command line. */ | 381 /* On Mac, fetch a command line. */ |
349 #ifdef USE_CCOMMAND | 382 #ifdef USE_CCOMMAND |
350 argc = ccommand(&argv); | 383 argc = ccommand(&argv); |
351 #endif | 384 #endif |
352 | 385 |
353 progname = argv[0]; | 386 progname = argv[0]; |
354 if (progname == NULL || progname[0] == 0) | 387 if (progname == NULL || progname[0] == 0) |
355 progname = "jpegtran"; /* in case C library doesn't provide it */ | 388 progname = "jpegtran"; /* in case C library doesn't provide it */ |
356 | 389 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 #else | 432 #else |
400 /* Unix style: expect zero or one file name */ | 433 /* Unix style: expect zero or one file name */ |
401 if (file_index < argc-1) { | 434 if (file_index < argc-1) { |
402 fprintf(stderr, "%s: only one input file\n", progname); | 435 fprintf(stderr, "%s: only one input file\n", progname); |
403 usage(); | 436 usage(); |
404 } | 437 } |
405 #endif /* TWO_FILE_COMMANDLINE */ | 438 #endif /* TWO_FILE_COMMANDLINE */ |
406 | 439 |
407 /* Open the input file. */ | 440 /* Open the input file. */ |
408 if (file_index < argc) { | 441 if (file_index < argc) { |
409 if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { | 442 if ((fp = fopen(argv[file_index], READ_BINARY)) == NULL) { |
410 fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); | 443 fprintf(stderr, "%s: can't open %s for reading\n", progname, argv[file_ind
ex]); |
411 exit(EXIT_FAILURE); | 444 exit(EXIT_FAILURE); |
412 } | 445 } |
413 } else { | 446 } else { |
414 /* default input file is stdin */ | 447 /* default input file is stdin */ |
415 input_file = read_stdin(); | 448 fp = read_stdin(); |
416 } | |
417 | |
418 /* Open the output file. */ | |
419 if (outfilename != NULL) { | |
420 if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { | |
421 fprintf(stderr, "%s: can't open %s\n", progname, outfilename); | |
422 exit(EXIT_FAILURE); | |
423 } | |
424 } else { | |
425 /* default output file is stdout */ | |
426 output_file = write_stdout(); | |
427 } | 449 } |
428 | 450 |
429 #ifdef PROGRESS_REPORT | 451 #ifdef PROGRESS_REPORT |
430 start_progress_monitor((j_common_ptr) &dstinfo, &progress); | 452 start_progress_monitor((j_common_ptr) &dstinfo, &progress); |
431 #endif | 453 #endif |
432 | 454 |
433 /* Specify data source for decompression */ | 455 /* Specify data source for decompression */ |
434 jpeg_stdio_src(&srcinfo, input_file); | 456 jpeg_stdio_src(&srcinfo, fp); |
435 | 457 |
436 /* Enable saving of extra markers that we want to copy */ | 458 /* Enable saving of extra markers that we want to copy */ |
437 jcopy_markers_setup(&srcinfo, copyoption); | 459 jcopy_markers_setup(&srcinfo, copyoption); |
438 | 460 |
439 /* Read file header */ | 461 /* Read file header */ |
440 (void) jpeg_read_header(&srcinfo, TRUE); | 462 (void) jpeg_read_header(&srcinfo, TRUE); |
441 | 463 |
442 /* Any space needed by a transform option must be requested before | 464 /* Any space needed by a transform option must be requested before |
443 * jpeg_read_coefficients so that memory allocation will be done right. | 465 * jpeg_read_coefficients so that memory allocation will be done right. |
444 */ | 466 */ |
445 #if TRANSFORMS_SUPPORTED | 467 #if TRANSFORMS_SUPPORTED |
446 jtransform_request_workspace(&srcinfo, &transformoption); | 468 /* Fail right away if -perfect is given and transformation is not perfect. |
| 469 */ |
| 470 if (!jtransform_request_workspace(&srcinfo, &transformoption)) { |
| 471 fprintf(stderr, "%s: transformation is not perfect\n", progname); |
| 472 exit(EXIT_FAILURE); |
| 473 } |
447 #endif | 474 #endif |
448 | 475 |
449 /* Read source file as DCT coefficients */ | 476 /* Read source file as DCT coefficients */ |
450 src_coef_arrays = jpeg_read_coefficients(&srcinfo); | 477 src_coef_arrays = jpeg_read_coefficients(&srcinfo); |
451 | 478 |
452 /* Initialize destination compression parameters from source values */ | 479 /* Initialize destination compression parameters from source values */ |
453 jpeg_copy_critical_parameters(&srcinfo, &dstinfo); | 480 jpeg_copy_critical_parameters(&srcinfo, &dstinfo); |
454 | 481 |
455 /* Adjust destination parameters if required by transform options; | 482 /* Adjust destination parameters if required by transform options; |
456 * also find out which set of coefficient arrays will hold the output. | 483 * also find out which set of coefficient arrays will hold the output. |
457 */ | 484 */ |
458 #if TRANSFORMS_SUPPORTED | 485 #if TRANSFORMS_SUPPORTED |
459 dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo, | 486 dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo, |
460 src_coef_arrays, | 487 src_coef_arrays, |
461 &transformoption); | 488 &transformoption); |
462 #else | 489 #else |
463 dst_coef_arrays = src_coef_arrays; | 490 dst_coef_arrays = src_coef_arrays; |
464 #endif | 491 #endif |
465 | 492 |
| 493 /* Close input file, if we opened it. |
| 494 * Note: we assume that jpeg_read_coefficients consumed all input |
| 495 * until JPEG_REACHED_EOI, and that jpeg_finish_decompress will |
| 496 * only consume more while (! cinfo->inputctl->eoi_reached). |
| 497 * We cannot call jpeg_finish_decompress here since we still need the |
| 498 * virtual arrays allocated from the source object for processing. |
| 499 */ |
| 500 if (fp != stdin) |
| 501 fclose(fp); |
| 502 |
| 503 /* Open the output file. */ |
| 504 if (outfilename != NULL) { |
| 505 if ((fp = fopen(outfilename, WRITE_BINARY)) == NULL) { |
| 506 fprintf(stderr, "%s: can't open %s for writing\n", progname, outfilename); |
| 507 exit(EXIT_FAILURE); |
| 508 } |
| 509 } else { |
| 510 /* default output file is stdout */ |
| 511 fp = write_stdout(); |
| 512 } |
| 513 |
466 /* Adjust default compression parameters by re-parsing the options */ | 514 /* Adjust default compression parameters by re-parsing the options */ |
467 file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); | 515 file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); |
468 | 516 |
469 /* Specify data destination for compression */ | 517 /* Specify data destination for compression */ |
470 jpeg_stdio_dest(&dstinfo, output_file); | 518 jpeg_stdio_dest(&dstinfo, fp); |
471 | 519 |
472 /* Start compressor (note no image data is actually written here) */ | 520 /* Start compressor (note no image data is actually written here) */ |
473 jpeg_write_coefficients(&dstinfo, dst_coef_arrays); | 521 jpeg_write_coefficients(&dstinfo, dst_coef_arrays); |
474 | 522 |
475 /* Copy to the output file any extra markers that we want to preserve */ | 523 /* Copy to the output file any extra markers that we want to preserve */ |
476 jcopy_markers_execute(&srcinfo, &dstinfo, copyoption); | 524 jcopy_markers_execute(&srcinfo, &dstinfo, copyoption); |
477 | 525 |
478 /* Execute image transformation, if any */ | 526 /* Execute image transformation, if any */ |
479 #if TRANSFORMS_SUPPORTED | 527 #if TRANSFORMS_SUPPORTED |
480 jtransform_execute_transformation(&srcinfo, &dstinfo, | 528 jtransform_execute_transformation(&srcinfo, &dstinfo, |
481 src_coef_arrays, | 529 src_coef_arrays, |
482 &transformoption); | 530 &transformoption); |
483 #endif | 531 #endif |
484 | 532 |
485 /* Finish compression and release memory */ | 533 /* Finish compression and release memory */ |
486 jpeg_finish_compress(&dstinfo); | 534 jpeg_finish_compress(&dstinfo); |
487 jpeg_destroy_compress(&dstinfo); | 535 jpeg_destroy_compress(&dstinfo); |
488 (void) jpeg_finish_decompress(&srcinfo); | 536 (void) jpeg_finish_decompress(&srcinfo); |
489 jpeg_destroy_decompress(&srcinfo); | 537 jpeg_destroy_decompress(&srcinfo); |
490 | 538 |
491 /* Close files, if we opened them */ | 539 /* Close output file, if we opened it */ |
492 if (input_file != stdin) | 540 if (fp != stdout) |
493 fclose(input_file); | 541 fclose(fp); |
494 if (output_file != stdout) | |
495 fclose(output_file); | |
496 | 542 |
497 #ifdef PROGRESS_REPORT | 543 #ifdef PROGRESS_REPORT |
498 end_progress_monitor((j_common_ptr) &dstinfo); | 544 end_progress_monitor((j_common_ptr) &dstinfo); |
499 #endif | 545 #endif |
500 | 546 |
501 /* All done. */ | 547 /* All done. */ |
502 exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS); | 548 exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS); |
503 return 0; /* suppress no-return-value warnings */ | 549 return 0; /* suppress no-return-value warnings */ |
504 } | 550 } |
OLD | NEW |