diff options
author | 2017-01-25 17:49:53 +0100 | |
---|---|---|
committer | 2017-01-25 17:49:53 +0100 | |
commit | 78a7342750182687a08060c5e060cb897800e9f6 (patch) | |
tree | 73ab5b3a3b09c56a73a74950a71701adf7a22cc7 /3rdparty/libjpeg/cjpeg.c | |
parent | 93c92be81517a982ef9b47eed610a3e42ed244bc (diff) |
updated libjpeg to 9c (nw)
Diffstat (limited to '3rdparty/libjpeg/cjpeg.c')
-rw-r--r-- | 3rdparty/libjpeg/cjpeg.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/3rdparty/libjpeg/cjpeg.c b/3rdparty/libjpeg/cjpeg.c index 40d25215d1c..3cb07fa4ba7 100644 --- a/3rdparty/libjpeg/cjpeg.c +++ b/3rdparty/libjpeg/cjpeg.c @@ -2,7 +2,7 @@ * cjpeg.c * * Copyright (C) 1991-1998, Thomas G. Lane. - * Modified 2003-2010 by Guido Vollbeding. + * Modified 2003-2013 by Guido Vollbeding. * This file is part of the Independent JPEG Group's software. * For conditions of distribution and use, see the accompanying README file. * @@ -152,6 +152,7 @@ usage (void) fprintf(stderr, "Switches (names may be abbreviated):\n"); fprintf(stderr, " -quality N[,...] Compression quality (0..100; 5-95 is useful range)\n"); fprintf(stderr, " -grayscale Create monochrome JPEG file\n"); + fprintf(stderr, " -rgb Create RGB JPEG file\n"); #ifdef ENTROPY_OPT_SUPPORTED fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); #endif @@ -165,9 +166,16 @@ usage (void) fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n"); #endif fprintf(stderr, "Switches for advanced users:\n"); +#ifdef C_ARITH_CODING_SUPPORTED + fprintf(stderr, " -arithmetic Use arithmetic coding\n"); +#endif #ifdef DCT_SCALING_SUPPORTED fprintf(stderr, " -block N DCT block size (1..16; default is 8)\n"); #endif +#if JPEG_LIB_VERSION_MAJOR >= 9 + fprintf(stderr, " -rgb1 Create RGB JPEG file with reversible color transform\n"); + fprintf(stderr, " -bgycc Create big gamut YCC JPEG file\n"); +#endif #ifdef DCT_ISLOW_SUPPORTED fprintf(stderr, " -dct int Use integer DCT method%s\n", (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); @@ -189,9 +197,6 @@ usage (void) fprintf(stderr, " -outfile name Specify name for output file\n"); fprintf(stderr, " -verbose or -debug Emit debug output\n"); fprintf(stderr, "Switches for wizards:\n"); -#ifdef C_ARITH_CODING_SUPPORTED - fprintf(stderr, " -arithmetic Use arithmetic coding\n"); -#endif fprintf(stderr, " -baseline Force baseline quantization tables\n"); fprintf(stderr, " -qtables file Use quantization tables given in file\n"); fprintf(stderr, " -qslots N[,...] Set component quantization tables\n"); @@ -263,9 +268,8 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv, } else if (keymatch(arg, "block", 2)) { /* Set DCT block size. */ -#if defined(DCT_SCALING_SUPPORTED) && defined(JPEG_LIB_VERSION_MAJOR) && \ - (JPEG_LIB_VERSION_MAJOR > 8 || (JPEG_LIB_VERSION_MAJOR == 8 && \ - defined(JPEG_LIB_VERSION_MINOR) && JPEG_LIB_VERSION_MINOR >= 3)) +#if defined DCT_SCALING_SUPPORTED && JPEG_LIB_VERSION_MAJOR >= 8 && \ + (JPEG_LIB_VERSION_MAJOR > 8 || JPEG_LIB_VERSION_MINOR >= 3) int val; if (++argn >= argc) /* advance to next argument */ @@ -310,6 +314,27 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv, /* Force a monochrome JPEG file to be generated. */ jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); + } else if (keymatch(arg, "rgb", 3) || keymatch(arg, "rgb1", 4)) { + /* Force an RGB JPEG file to be generated. */ +#if JPEG_LIB_VERSION_MAJOR >= 9 + /* Note: Entropy table assignment in jpeg_set_colorspace depends + * on color_transform. + */ + cinfo->color_transform = arg[3] ? JCT_SUBTRACT_GREEN : JCT_NONE; +#endif + jpeg_set_colorspace(cinfo, JCS_RGB); + + } else if (keymatch(arg, "bgycc", 5)) { + /* Force a big gamut YCC JPEG file to be generated. */ +#if JPEG_LIB_VERSION_MAJOR >= 9 && \ + (JPEG_LIB_VERSION_MAJOR > 9 || JPEG_LIB_VERSION_MINOR >= 1) + jpeg_set_colorspace(cinfo, JCS_BG_YCC); +#else + fprintf(stderr, "%s: sorry, BG_YCC colorspace not supported\n", + progname); + exit(EXIT_FAILURE); +#endif + } else if (keymatch(arg, "maxmemory", 3)) { /* Maximum memory in Kb (or Mb with 'm'). */ long lval; @@ -324,7 +349,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv, cinfo->mem->max_memory_to_use = lval * 1000L; } else if (keymatch(arg, "nosmooth", 3)) { - /* Suppress fancy downsampling */ + /* Suppress fancy downsampling. */ cinfo->do_fancy_downsampling = FALSE; } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { @@ -410,7 +435,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv, /* Scale the image by a fraction M/N. */ if (++argn >= argc) /* advance to next argument */ usage(); - if (sscanf(argv[argn], "%d/%d", + if (sscanf(argv[argn], "%u/%u", &cinfo->scale_num, &cinfo->scale_denom) != 2) usage(); |