~ubuntu-branches/ubuntu/quantal/libjpeg6b/quantal-security

« back to all changes in this revision

Viewing changes to jpegtran.c

  • Committer: Bazaar Package Importer
  • Author(s): Bill Allombert
  • Date: 2010-06-29 13:55:42 UTC
  • mfrom: (4.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100629135542-u2ux634ovmawtrog
Tags: 6b1-1
* New upstream release
  - libjpeg62 has now versionned symbols.
  - Updated build system that use current libtool.
  - Full source code for the build system.
* debian/copyright: add 6b1 upstream download URL.
* debian/control:
  - libjpeg62-dev: Provides libjpeg-dev since the transition has been
    postponed.
  - Remove now useless dependency on libtool and sharutils
  - Bump Standards-Version to 3.9.0.
* Get rid of dpatch system. Patches were only relevant to libjpeg-progs
  which is not build from this package anymore.
* Move to new source format 3.0 (quilt). Patches applied:
  - use-autotools-dev: Use autotools-dev version of config.sub/.guess.
  - extern_C-jpeglib.h: Wrap jpeglib.h with extern "C" {} if __cplusplus 
    is defined.
* debian/rules:
  - Adjust for new build system and new patch system.
* debian/shlibs: add (>=6b1) to avoid linker warnings with libjpeg6b.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * jpegtran.c
3
3
 *
4
 
 * Copyright (C) 1995-2001, Thomas G. Lane.
 
4
 * Copyright (C) 1995-1997, Thomas G. Lane.
5
5
 * This file is part of the Independent JPEG Group's software.
6
6
 * For conditions of distribution and use, see the accompanying README file.
7
7
 *
64
64
#endif
65
65
#if TRANSFORMS_SUPPORTED
66
66
  fprintf(stderr, "Switches for modifying the image:\n");
67
 
  fprintf(stderr, "  -crop WxH+X+Y  Crop to a rectangular subarea\n");
68
67
  fprintf(stderr, "  -grayscale     Reduce to grayscale (omit color data)\n");
69
68
  fprintf(stderr, "  -flip [horizontal|vertical]  Mirror image (left-right or top-bottom)\n");
70
 
  fprintf(stderr, "  -perfect       Fail if there is non-transformable edge blocks\n");
71
69
  fprintf(stderr, "  -rotate [90|180|270]         Rotate image (degrees clockwise)\n");
72
70
  fprintf(stderr, "  -transpose     Transpose image\n");
73
71
  fprintf(stderr, "  -transverse    Transverse transpose image\n");
135
133
  copyoption = JCOPYOPT_DEFAULT;
136
134
  transformoption.transform = JXFORM_NONE;
137
135
  transformoption.trim = FALSE;
138
 
  transformoption.perfect = FALSE;
139
136
  transformoption.force_grayscale = FALSE;
140
 
  transformoption.crop = FALSE;
141
137
  cinfo->err->trace_level = 0;
142
138
 
143
139
  /* Scan command line options, adjust parameters */
164
160
      exit(EXIT_FAILURE);
165
161
#endif
166
162
 
167
 
    } else if (keymatch(arg, "copy", 2)) {
 
163
    } else if (keymatch(arg, "copy", 1)) {
168
164
      /* Select which extra markers to copy. */
169
165
      if (++argn >= argc)       /* advance to next argument */
170
166
        usage();
177
173
      } else
178
174
        usage();
179
175
 
180
 
    } else if (keymatch(arg, "crop", 2)) {
181
 
      /* Perform lossless cropping. */
182
 
#if TRANSFORMS_SUPPORTED
183
 
      if (++argn >= argc)       /* advance to next argument */
184
 
        usage();
185
 
      if (! jtransform_parse_crop_spec(&transformoption, argv[argn])) {
186
 
        fprintf(stderr, "%s: bogus -crop argument '%s'\n",
187
 
                progname, argv[argn]);
188
 
        exit(EXIT_FAILURE);
189
 
      }
190
 
#else
191
 
      select_transform(JXFORM_NONE);    /* force an error */
192
 
#endif
193
 
 
194
176
    } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
195
177
      /* Enable debug printouts. */
196
178
      /* On first -d, print version identification */
251
233
        usage();
252
234
      outfilename = argv[argn]; /* save it away for later use */
253
235
 
254
 
    } else if (keymatch(arg, "perfect", 2)) {
255
 
      /* Fail if there is any partial edge MCUs that the transform can't
256
 
       * handle. */
257
 
      transformoption.perfect = TRUE;
258
 
 
259
 
    } else if (keymatch(arg, "progressive", 2)) {
 
236
    } else if (keymatch(arg, "progressive", 1)) {
260
237
      /* Select simple progressive mode. */
261
238
#ifdef C_PROGRESSIVE_SUPPORTED
262
239
      simple_progressive = TRUE;
365
342
  jvirt_barray_ptr * src_coef_arrays;
366
343
  jvirt_barray_ptr * dst_coef_arrays;
367
344
  int file_index;
368
 
  /* We assume all-in-memory processing and can therefore use only a
369
 
   * single file pointer for sequential input and output operation. 
370
 
   */
371
 
  FILE * fp;
 
345
  FILE * input_file;
 
346
  FILE * output_file;
372
347
 
373
348
  /* On Mac, fetch a command line. */
374
349
#ifdef USE_CCOMMAND
431
406
 
432
407
  /* Open the input file. */
433
408
  if (file_index < argc) {
434
 
    if ((fp = fopen(argv[file_index], READ_BINARY)) == NULL) {
435
 
      fprintf(stderr, "%s: can't open %s for reading\n", progname, argv[file_index]);
 
409
    if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {
 
410
      fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]);
436
411
      exit(EXIT_FAILURE);
437
412
    }
438
413
  } else {
439
414
    /* default input file is stdin */
440
 
    fp = read_stdin();
 
415
    input_file = 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();
441
427
  }
442
428
 
443
429
#ifdef PROGRESS_REPORT
445
431
#endif
446
432
 
447
433
  /* Specify data source for decompression */
448
 
  jpeg_stdio_src(&srcinfo, fp);
 
434
  jpeg_stdio_src(&srcinfo, input_file);
449
435
 
450
436
  /* Enable saving of extra markers that we want to copy */
451
437
  jcopy_markers_setup(&srcinfo, copyoption);
457
443
   * jpeg_read_coefficients so that memory allocation will be done right.
458
444
   */
459
445
#if TRANSFORMS_SUPPORTED
460
 
  /* Fails right away if -perfect is given and transformation is not perfect.
461
 
   */
462
 
  if (transformoption.perfect &&
463
 
      !jtransform_perfect_transform(srcinfo.image_width, srcinfo.image_height,
464
 
      srcinfo.max_h_samp_factor * DCTSIZE, srcinfo.max_v_samp_factor * DCTSIZE,
465
 
      transformoption.transform)) {
466
 
    fprintf(stderr, "%s: transformation is not perfect\n", progname);
467
 
    exit(EXIT_FAILURE);
468
 
  }
469
446
  jtransform_request_workspace(&srcinfo, &transformoption);
470
447
#endif
471
448
 
486
463
  dst_coef_arrays = src_coef_arrays;
487
464
#endif
488
465
 
489
 
  /* Close input file, if we opened it.
490
 
   * Note: we assume that jpeg_read_coefficients consumed all input
491
 
   * until JPEG_REACHED_EOI, and that jpeg_finish_decompress will
492
 
   * only consume more while (! cinfo->inputctl->eoi_reached).
493
 
   * We cannot call jpeg_finish_decompress here since we still need the
494
 
   * virtual arrays allocated from the source object for processing.
495
 
   */
496
 
  if (fp != stdin)
497
 
    fclose(fp);
498
 
 
499
 
  /* Open the output file. */
500
 
  if (outfilename != NULL) {
501
 
    if ((fp = fopen(outfilename, WRITE_BINARY)) == NULL) {
502
 
      fprintf(stderr, "%s: can't open %s for writing\n", progname, outfilename);
503
 
      exit(EXIT_FAILURE);
504
 
    }
505
 
  } else {
506
 
    /* default output file is stdout */
507
 
    fp = write_stdout();
508
 
  }
509
 
 
510
466
  /* Adjust default compression parameters by re-parsing the options */
511
467
  file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE);
512
468
 
513
469
  /* Specify data destination for compression */
514
 
  jpeg_stdio_dest(&dstinfo, fp);
 
470
  jpeg_stdio_dest(&dstinfo, output_file);
515
471
 
516
472
  /* Start compressor (note no image data is actually written here) */
517
473
  jpeg_write_coefficients(&dstinfo, dst_coef_arrays);
532
488
  (void) jpeg_finish_decompress(&srcinfo);
533
489
  jpeg_destroy_decompress(&srcinfo);
534
490
 
535
 
  /* Close output file, if we opened it */
536
 
  if (fp != stdout)
537
 
    fclose(fp);
 
491
  /* Close files, if we opened them */
 
492
  if (input_file != stdin)
 
493
    fclose(input_file);
 
494
  if (output_file != stdout)
 
495
    fclose(output_file);
538
496
 
539
497
#ifdef PROGRESS_REPORT
540
498
  end_progress_monitor((j_common_ptr) &dstinfo);