Changeset 283 for trunk/libjpeg/cjpeg.c


Ignore:
Timestamp:
Jan 4, 2010, 8:20:18 PM (12 years ago)
Author:
rbri
Message:

JPEG plugin: libjpeg updated to version 7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libjpeg/cjpeg.c

    r15 r283  
    33 *
    44 * Copyright (C) 1991-1998, Thomas G. Lane.
     5 * Modified 2003-2008 by Guido Vollbeding.
    56 * This file is part of the Independent JPEG Group's software.
    67 * For conditions of distribution and use, see the accompanying README file.
     
    150151
    151152  fprintf(stderr, "Switches (names may be abbreviated):\n");
    152   fprintf(stderr, "  -quality N     Compression quality (0..100; 5-95 is useful range)\n");
     153  fprintf(stderr, "  -quality N[,...]   Compression quality (0..100; 5-95 is useful range)\n");
    153154  fprintf(stderr, "  -grayscale     Create monochrome JPEG file\n");
    154155#ifdef ENTROPY_OPT_SUPPORTED
     
    157158#ifdef C_PROGRESSIVE_SUPPORTED
    158159  fprintf(stderr, "  -progressive   Create progressive JPEG file\n");
     160#endif
     161#ifdef DCT_SCALING_SUPPORTED
     162  fprintf(stderr, "  -scale M/N     Scale image by fraction M/N, eg, 1/2\n");
    159163#endif
    160164#ifdef TARGA_SUPPORTED
     
    174178          (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : ""));
    175179#endif
     180  fprintf(stderr, "  -nosmooth      Don't use high-quality downsampling\n");
    176181  fprintf(stderr, "  -restart N     Set restart interval in rows, or in blocks with B\n");
    177182#ifdef INPUT_SMOOTHING_SUPPORTED
     
    210215  int argn;
    211216  char * arg;
    212   int quality;                  /* -quality parameter */
    213   int q_scale_factor;           /* scaling percentage for -qtables */
    214217  boolean force_baseline;
    215218  boolean simple_progressive;
     219  char * qualityarg = NULL;     /* saves -quality parm if any */
    216220  char * qtablefile = NULL;     /* saves -qtables filename if any */
    217221  char * qslotsarg = NULL;      /* saves -qslots parm if any */
     
    220224
    221225  /* Set up default JPEG parameters. */
    222   /* Note that default -quality level need not, and does not,
    223    * match the default scaling for an explicit -qtables argument.
    224    */
    225   quality = 75;                 /* default -quality value */
    226   q_scale_factor = 100;         /* default to no scaling for -qtables */
     226
    227227  force_baseline = FALSE;       /* by default, allow 16-bit quantizers */
    228228  simple_progressive = FALSE;
     
    301301      cinfo->mem->max_memory_to_use = lval * 1000L;
    302302
     303    } else if (keymatch(arg, "nosmooth", 3)) {
     304      /* Suppress fancy downsampling */
     305      cinfo->do_fancy_downsampling = FALSE;
     306
    303307    } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) {
    304308      /* Enable entropy parm optimization. */
     
    329333
    330334    } else if (keymatch(arg, "quality", 1)) {
    331       /* Quality factor (quantization table scaling factor). */
    332       if (++argn >= argc)       /* advance to next argument */
    333         usage();
    334       if (sscanf(argv[argn], "%d", &quality) != 1)
    335         usage();
    336       /* Change scale factor in case -qtables is present. */
    337       q_scale_factor = jpeg_quality_scaling(quality);
     335      /* Quality ratings (quantization table scaling factors). */
     336      if (++argn >= argc)       /* advance to next argument */
     337        usage();
     338      qualityarg = argv[argn];
    338339
    339340    } else if (keymatch(arg, "qslots", 2)) {
     
    383384       */
    384385
    385     } else if (keymatch(arg, "scans", 2)) {
     386    } else if (keymatch(arg, "scale", 4)) {
     387      /* Scale the image by a fraction M/N. */
     388      if (++argn >= argc)       /* advance to next argument */
     389        usage();
     390      if (sscanf(argv[argn], "%d/%d",
     391                 &cinfo->scale_num, &cinfo->scale_denom) != 2)
     392        usage();
     393
     394    } else if (keymatch(arg, "scans", 4)) {
    386395      /* Set scan script. */
    387396#ifdef C_MULTISCAN_FILES_SUPPORTED
     
    423432    /* Set quantization tables for selected quality. */
    424433    /* Some or all may be overridden if -qtables is present. */
    425     jpeg_set_quality(cinfo, quality, force_baseline);
     434    if (qualityarg != NULL)     /* process -quality if it was present */
     435      if (! set_quality_ratings(cinfo, qualityarg, force_baseline))
     436        usage();
    426437
    427438    if (qtablefile != NULL)     /* process -qtables if it was present */
    428       if (! read_quant_tables(cinfo, qtablefile,
    429                               q_scale_factor, force_baseline))
     439      if (! read_quant_tables(cinfo, qtablefile, force_baseline))
    430440        usage();
    431441
Note: See TracChangeset for help on using the changeset viewer.