diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2017-05-28 20:21:59 +0300 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2017-05-28 20:21:59 +0300 |
commit | 46cb763bffdbd1d2feea6d27344c48d16a511745 (patch) | |
tree | 4eea9dd37e649dbfb3d24bbb1b03671db2f7ae0e /plugins/AdvaImg | |
parent | c9bffd4f4e69fb1f34781cdf138b8b17e96b835b (diff) |
AdvaImg: LibJPEG lib update to 9b
Diffstat (limited to 'plugins/AdvaImg')
30 files changed, 604 insertions, 1278 deletions
diff --git a/plugins/AdvaImg/src/LibJPEG/README b/plugins/AdvaImg/src/LibJPEG/README index a28ead34ee..0b5e097362 100644 --- a/plugins/AdvaImg/src/LibJPEG/README +++ b/plugins/AdvaImg/src/LibJPEG/README @@ -1,7 +1,7 @@ The Independent JPEG Group's JPEG software
==========================================
-README for release 9a of 19-Jan-2014
+README for release 9b of 17-Jan-2016
====================================
This distribution contains the ninth public release of the Independent JPEG
@@ -60,7 +60,7 @@ OVERVIEW This package contains C software to implement JPEG image encoding, decoding,
and transcoding. JPEG (pronounced "jay-peg") is a standardized compression
-method for full-color and gray-scale images.
+method for full-color and grayscale images.
This software implements JPEG baseline, extended-sequential, and progressive
compression processes. Provision is made for supporting all variants of these
@@ -115,7 +115,7 @@ with respect to this software, its quality, accuracy, merchantability, or fitness for a particular purpose. This software is provided "AS IS", and you,
its user, assume the entire risk as to its quality and accuracy.
-This software is copyright (C) 1991-2014, Thomas G. Lane, Guido Vollbeding.
+This software is copyright (C) 1991-2016, Thomas G. Lane, Guido Vollbeding.
All Rights Reserved except as specified below.
Permission is hereby granted to use, copy, modify, and distribute this
@@ -159,11 +159,6 @@ to produce "uncompressed GIFs". This technique does not use the LZW algorithm; the resulting GIF files are larger than usual, but are readable
by all standard GIF decoders.
-We are required to state that
- "The Graphics Interchange Format(c) is the Copyright property of
- CompuServe Incorporated. GIF(sm) is a Service Mark property of
- CompuServe Incorporated."
-
REFERENCES
==========
@@ -176,8 +171,8 @@ The best short technical introduction to the JPEG compression algorithm is Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44.
(Adjacent articles in that issue discuss MPEG motion picture compression,
applications of JPEG, and related topics.) If you don't have the CACM issue
-handy, a PostScript file containing a revised version of Wallace's article is
-available at http://www.ijg.org/files/wallace.ps.gz. The file (actually
+handy, a PDF file containing a revised version of Wallace's article is
+available at http://www.ijg.org/files/Wallace.JPEG.pdf. The file (actually
a preprint for an article that appeared in IEEE Trans. Consumer Electronics)
omits the sample images that appeared in CACM, but it includes corrections
and some added material. Note: the Wallace article is copyright ACM and IEEE,
@@ -225,14 +220,13 @@ WG1 N 6080 with title "JPEG 9 Lossless Coding", June/July 2012, Paris, France.
The JPEG standard does not specify all details of an interchangeable file
-format. For the omitted details we follow the "JFIF" conventions, revision
-1.02. JFIF 1.02 has been adopted as an Ecma International Technical Report
-and thus received a formal publication status. It is available as a free
-download in PDF format from
-http://www.ecma-international.org/publications/techreports/E-TR-098.htm.
-A PostScript version of the JFIF document is available at
-http://www.ijg.org/files/jfif.ps.gz. There is also a plain text version at
-http://www.ijg.org/files/jfif.txt.gz, but it is missing the figures.
+format. For the omitted details we follow the "JFIF" conventions, version 2.
+JFIF version 1 has been adopted as Recommendation ITU-T T.871 (05/2011) :
+Information technology - Digital compression and coding of continuous-tone
+still images: JPEG File Interchange Format (JFIF). It is available as a
+free download in PDF file format from http://www.itu.int/rec/T-REC-T.871.
+A PDF file of the older JFIF document is available at
+http://www.w3.org/Graphics/JPEG/jfif3.pdf.
The TIFF 6.0 file format specification can be obtained by FTP from
ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme
@@ -252,8 +246,8 @@ ARCHIVE LOCATIONS The "official" archive site for this software is www.ijg.org.
The most recent released version can always be found there in
directory "files". This particular version will be archived as
-http://www.ijg.org/files/jpegsrc.v9a.tar.gz, and in Windows-compatible
-"zip" archive format as http://www.ijg.org/files/jpegsr9a.zip.
+http://www.ijg.org/files/jpegsrc.v9b.tar.gz, and in Windows-compatible
+"zip" archive format as http://www.ijg.org/files/jpegsr9b.zip.
The JPEG FAQ (Frequently Asked Questions) article is a source of some
general information about JPEG.
diff --git a/plugins/AdvaImg/src/LibJPEG/ansi2knr.c b/plugins/AdvaImg/src/LibJPEG/ansi2knr.c deleted file mode 100644 index dcfb5d9255..0000000000 --- a/plugins/AdvaImg/src/LibJPEG/ansi2knr.c +++ /dev/null @@ -1,739 +0,0 @@ -/* Copyright (C) 1989, 2000 Aladdin Enterprises. All rights reserved. */
-
-/*$Id: ansi2knr.c,v 1.6 2012/01/29 12:23:24 drolon Exp $*/
-/* Convert ANSI C function definitions to K&R ("traditional C") syntax */
-
-/*
-ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY. No author or distributor accepts responsibility to anyone for the
-consequences of using it or for whether it serves any particular purpose or
-works at all, unless he says so in writing. Refer to the GNU General Public
-License (the "GPL") for full details.
-
-Everyone is granted permission to copy, modify and redistribute ansi2knr,
-but only under the conditions described in the GPL. A copy of this license
-is supposed to have been given to you along with ansi2knr so you can know
-your rights and responsibilities. It should be in a file named COPYLEFT,
-or, if there is no file named COPYLEFT, a file named COPYING. Among other
-things, the copyright notice and this notice must be preserved on all
-copies.
-
-We explicitly state here what we believe is already implied by the GPL: if
-the ansi2knr program is distributed as a separate set of sources and a
-separate executable file which are aggregated on a storage medium together
-with another program, this in itself does not bring the other program under
-the GPL, nor does the mere fact that such a program or the procedures for
-constructing it invoke the ansi2knr executable bring any other part of the
-program under the GPL.
-*/
-
-/*
- * Usage:
- ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]]
- * --filename provides the file name for the #line directive in the output,
- * overriding input_file (if present).
- * If no input_file is supplied, input is read from stdin.
- * If no output_file is supplied, output goes to stdout.
- * There are no error messages.
- *
- * ansi2knr recognizes function definitions by seeing a non-keyword
- * identifier at the left margin, followed by a left parenthesis, with a
- * right parenthesis as the last character on the line, and with a left
- * brace as the first token on the following line (ignoring possible
- * intervening comments and/or preprocessor directives), except that a line
- * consisting of only
- * identifier1(identifier2)
- * will not be considered a function definition unless identifier2 is
- * the word "void", and a line consisting of
- * identifier1(identifier2, <<arbitrary>>)
- * will not be considered a function definition.
- * ansi2knr will recognize a multi-line header provided that no intervening
- * line ends with a left or right brace or a semicolon. These algorithms
- * ignore whitespace, comments, and preprocessor directives, except that
- * the function name must be the first thing on the line. The following
- * constructs will confuse it:
- * - Any other construct that starts at the left margin and
- * follows the above syntax (such as a macro or function call).
- * - Some macros that tinker with the syntax of function headers.
- */
-
-/*
- * The original and principal author of ansi2knr is L. Peter Deutsch
- * <ghost@aladdin.com>. Other authors are noted in the change history
- * that follows (in reverse chronological order):
-
- lpd 2000-04-12 backs out Eggert's changes because of bugs:
- - concatlits didn't declare the type of its bufend argument;
- - concatlits didn't recognize when it was inside a comment;
- - scanstring could scan backward past the beginning of the string; when
- - the check for \ + newline in scanstring was unnecessary.
-
- 2000-03-05 Paul Eggert <eggert@twinsun.com>
-
- Add support for concatenated string literals.
- * ansi2knr.c (concatlits): New decl.
- (main): Invoke concatlits to concatenate string literals.
- (scanstring): Handle backslash-newline correctly. Work with
- character constants. Fix bug when scanning backwards through
- backslash-quote. Check for unterminated strings.
- (convert1): Parse character constants, too.
- (appendline, concatlits): New functions.
- * ansi2knr.1: Document this.
-
- lpd 1999-08-17 added code to allow preprocessor directives
- wherever comments are allowed
- lpd 1999-04-12 added minor fixes from Pavel Roskin
- <pavel_roskin@geocities.com> for clean compilation with
- gcc -W -Wall
- lpd 1999-03-22 added hack to recognize lines consisting of
- identifier1(identifier2, xxx) as *not* being procedures
- lpd 1999-02-03 made indentation of preprocessor commands consistent
- lpd 1999-01-28 fixed two bugs: a '/' in an argument list caused an
- endless loop; quoted strings within an argument list
- confused the parser
- lpd 1999-01-24 added a check for write errors on the output,
- suggested by Jim Meyering <meyering@ascend.com>
- lpd 1998-11-09 added further hack to recognize identifier(void)
- as being a procedure
- lpd 1998-10-23 added hack to recognize lines consisting of
- identifier1(identifier2) as *not* being procedures
- lpd 1997-12-08 made input_file optional; only closes input and/or
- output file if not stdin or stdout respectively; prints
- usage message on stderr rather than stdout; adds
- --filename switch (changes suggested by
- <ceder@lysator.liu.se>)
- lpd 1996-01-21 added code to cope with not HAVE_CONFIG_H and with
- compilers that don't understand void, as suggested by
- Tom Lane
- lpd 1996-01-15 changed to require that the first non-comment token
- on the line following a function header be a left brace,
- to reduce sensitivity to macros, as suggested by Tom Lane
- <tgl@sss.pgh.pa.us>
- lpd 1995-06-22 removed #ifndefs whose sole purpose was to define
- undefined preprocessor symbols as 0; changed all #ifdefs
- for configuration symbols to #ifs
- lpd 1995-04-05 changed copyright notice to make it clear that
- including ansi2knr in a program does not bring the entire
- program under the GPL
- lpd 1994-12-18 added conditionals for systems where ctype macros
- don't handle 8-bit characters properly, suggested by
- Francois Pinard <pinard@iro.umontreal.ca>;
- removed --varargs switch (this is now the default)
- lpd 1994-10-10 removed CONFIG_BROKETS conditional
- lpd 1994-07-16 added some conditionals to help GNU `configure',
- suggested by Francois Pinard <pinard@iro.umontreal.ca>;
- properly erase prototype args in function parameters,
- contributed by Jim Avera <jima@netcom.com>;
- correct error in writeblanks (it shouldn't erase EOLs)
- lpd 1989-xx-xx original version
- */
-
-/* Most of the conditionals here are to make ansi2knr work with */
-/* or without the GNU configure machinery. */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-
-#if HAVE_CONFIG_H
-
-/*
- For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h).
- This will define HAVE_CONFIG_H and so, activate the following lines.
- */
-
-# if STDC_HEADERS || HAVE_STRING_H
-# include <string.h>
-# else
-# include <strings.h>
-# endif
-
-#else /* not HAVE_CONFIG_H */
-
-/* Otherwise do it the hard way */
-
-# ifdef BSD
-# include <strings.h>
-# else
-# ifdef VMS
- extern int strlen(), strncmp();
-# else
-# include <string.h>
-# endif
-# endif
-
-#endif /* not HAVE_CONFIG_H */
-
-#if STDC_HEADERS
-# include <stdlib.h>
-#else
-/*
- malloc and free should be declared in stdlib.h,
- but if you've got a K&R compiler, they probably aren't.
- */
-# ifdef MSDOS
-# include <malloc.h>
-# else
-# ifdef VMS
- extern char *malloc();
- extern void free();
-# else
- extern char *malloc();
- extern int free();
-# endif
-# endif
-
-#endif
-
-/* Define NULL (for *very* old compilers). */
-#ifndef NULL
-# define NULL (0)
-#endif
-
-/*
- * The ctype macros don't always handle 8-bit characters correctly.
- * Compensate for this here.
- */
-#ifdef isascii
-# undef HAVE_ISASCII /* just in case */
-# define HAVE_ISASCII 1
-#else
-#endif
-#if STDC_HEADERS || !HAVE_ISASCII
-# define is_ascii(c) 1
-#else
-# define is_ascii(c) isascii(c)
-#endif
-
-#define is_space(c) (is_ascii(c) && isspace(c))
-#define is_alpha(c) (is_ascii(c) && isalpha(c))
-#define is_alnum(c) (is_ascii(c) && isalnum(c))
-
-/* Scanning macros */
-#define isidchar(ch) (is_alnum(ch) || (ch) == '_')
-#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_')
-
-/* Forward references */
-char *ppdirforward();
-char *ppdirbackward();
-char *skipspace();
-char *scanstring();
-int writeblanks();
-int test1();
-int convert1();
-
-/* The main program */
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{ FILE *in = stdin;
- FILE *out = stdout;
- char *filename = 0;
- char *program_name = argv[0];
- char *output_name = 0;
-#define bufsize 5000 /* arbitrary size */
- char *buf;
- char *line;
- char *more;
- char *usage =
- "Usage: ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]]\n";
- /*
- * In previous versions, ansi2knr recognized a --varargs switch.
- * If this switch was supplied, ansi2knr would attempt to convert
- * a ... argument to va_alist and va_dcl; if this switch was not
- * supplied, ansi2knr would simply drop any such arguments.
- * Now, ansi2knr always does this conversion, and we only
- * check for this switch for backward compatibility.
- */
- int convert_varargs = 1;
- int output_error;
-
- while ( argc > 1 && argv[1][0] == '-' ) {
- if ( !strcmp(argv[1], "--varargs") ) {
- convert_varargs = 1;
- argc--;
- argv++;
- continue;
- }
- if ( !strcmp(argv[1], "--filename") && argc > 2 ) {
- filename = argv[2];
- argc -= 2;
- argv += 2;
- continue;
- }
- fprintf(stderr, "%s: Unrecognized switch: %s\n", program_name,
- argv[1]);
- fprintf(stderr, usage);
- exit(1);
- }
- switch ( argc )
- {
- default:
- fprintf(stderr, usage);
- exit(0);
- case 3:
- output_name = argv[2];
- out = fopen(output_name, "w");
- if ( out == NULL ) {
- fprintf(stderr, "%s: Cannot open output file %s\n",
- program_name, output_name);
- exit(1);
- }
- /* falls through */
- case 2:
- in = fopen(argv[1], "r");
- if ( in == NULL ) {
- fprintf(stderr, "%s: Cannot open input file %s\n",
- program_name, argv[1]);
- exit(1);
- }
- if ( filename == 0 )
- filename = argv[1];
- /* falls through */
- case 1:
- break;
- }
- if ( filename )
- fprintf(out, "#line 1 \"%s\"\n", filename);
- buf = malloc(bufsize);
- if ( buf == NULL )
- {
- fprintf(stderr, "Unable to allocate read buffer!\n");
- exit(1);
- }
- line = buf;
- while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
- {
-test: line += strlen(line);
- switch ( test1(buf) )
- {
- case 2: /* a function header */
- convert1(buf, out, 1, convert_varargs);
- break;
- case 1: /* a function */
- /* Check for a { at the start of the next line. */
- more = ++line;
-f: if ( line >= buf + (bufsize - 1) ) /* overflow check */
- goto wl;
- if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL )
- goto wl;
- switch ( *skipspace(ppdirforward(more), 1) )
- {
- case '{':
- /* Definitely a function header. */
- convert1(buf, out, 0, convert_varargs);
- fputs(more, out);
- break;
- case 0:
- /* The next line was blank or a comment: */
- /* keep scanning for a non-comment. */
- line += strlen(line);
- goto f;
- default:
- /* buf isn't a function header, but */
- /* more might be. */
- fputs(buf, out);
- strcpy(buf, more);
- line = buf;
- goto test;
- }
- break;
- case -1: /* maybe the start of a function */
- if ( line != buf + (bufsize - 1) ) /* overflow check */
- continue;
- /* falls through */
- default: /* not a function */
-wl: fputs(buf, out);
- break;
- }
- line = buf;
- }
- if ( line != buf )
- fputs(buf, out);
- free(buf);
- if ( output_name ) {
- output_error = ferror(out);
- output_error |= fclose(out);
- } else { /* out == stdout */
- fflush(out);
- output_error = ferror(out);
- }
- if ( output_error ) {
- fprintf(stderr, "%s: error writing to %s\n", program_name,
- (output_name ? output_name : "stdout"));
- exit(1);
- }
- if ( in != stdin )
- fclose(in);
- return 0;
-}
-
-/*
- * Skip forward or backward over one or more preprocessor directives.
- */
-char *
-ppdirforward(p)
- char *p;
-{
- for (; *p == '#'; ++p) {
- for (; *p != '\r' && *p != '\n'; ++p)
- if (*p == 0)
- return p;
- if (*p == '\r' && p[1] == '\n')
- ++p;
- }
- return p;
-}
-char *
-ppdirbackward(p, limit)
- char *p;
- char *limit;
-{
- char *np = p;
-
- for (;; p = --np) {
- if (*np == '\n' && np[-1] == '\r')
- --np;
- for (; np > limit && np[-1] != '\r' && np[-1] != '\n'; --np)
- if (np[-1] == 0)
- return np;
- if (*np != '#')
- return p;
- }
-}
-
-/*
- * Skip over whitespace, comments, and preprocessor directives,
- * in either direction.
- */
-char *
-skipspace(p, dir)
- char *p;
- int dir; /* 1 for forward, -1 for backward */
-{
- for ( ; ; ) {
- while ( is_space(*p) )
- p += dir;
- if ( !(*p == '/' && p[dir] == '*') )
- break;
- p += dir; p += dir;
- while ( !(*p == '*' && p[dir] == '/') ) {
- if ( *p == 0 )
- return p; /* multi-line comment?? */
- p += dir;
- }
- p += dir; p += dir;
- }
- return p;
-}
-
-/* Scan over a quoted string, in either direction. */
-char *
-scanstring(p, dir)
- char *p;
- int dir;
-{
- for (p += dir; ; p += dir)
- if (*p == '"' && p[-dir] != '\\')
- return p + dir;
-}
-
-/*
- * Write blanks over part of a string.
- * Don't overwrite end-of-line characters.
- */
-int
-writeblanks(start, end)
- char *start;
- char *end;
-{ char *p;
- for ( p = start; p < end; p++ )
- if ( *p != '\r' && *p != '\n' )
- *p = ' ';
- return 0;
-}
-
-/*
- * Test whether the string in buf is a function definition.
- * The string may contain and/or end with a newline.
- * Return as follows:
- * 0 - definitely not a function definition;
- * 1 - definitely a function definition;
- * 2 - definitely a function prototype (NOT USED);
- * -1 - may be the beginning of a function definition,
- * append another line and look again.
- * The reason we don't attempt to convert function prototypes is that
- * Ghostscript's declaration-generating macros look too much like
- * prototypes, and confuse the algorithms.
- */
-int
-test1(buf)
- char *buf;
-{ char *p = buf;
- char *bend;
- char *endfn;
- int contin;
-
- if ( !isidfirstchar(*p) )
- return 0; /* no name at left margin */
- bend = skipspace(ppdirbackward(buf + strlen(buf) - 1, buf), -1);
- switch ( *bend )
- {
- case ';': contin = 0 /*2*/; break;
- case ')': contin = 1; break;
- case '{': return 0; /* not a function */
- case '}': return 0; /* not a function */
- default: contin = -1;
- }
- while ( isidchar(*p) )
- p++;
- endfn = p;
- p = skipspace(p, 1);
- if ( *p++ != '(' )
- return 0; /* not a function */
- p = skipspace(p, 1);
- if ( *p == ')' )
- return 0; /* no parameters */
- /* Check that the apparent function name isn't a keyword. */
- /* We only need to check for keywords that could be followed */
- /* by a left parenthesis (which, unfortunately, is most of them). */
- { static char *words[] =
- { "asm", "auto", "case", "char", "const", "double",
- "extern", "float", "for", "if", "int", "long",
- "register", "return", "short", "signed", "sizeof",
- "static", "switch", "typedef", "unsigned",
- "void", "volatile", "while", 0
- };
- char **key = words;
- char *kp;
- unsigned len = endfn - buf;
-
- while ( (kp = *key) != 0 )
- { if ( strlen(kp) == len && !strncmp(kp, buf, len) )
- return 0; /* name is a keyword */
- key++;
- }
- }
- {
- char *id = p;
- int len;
- /*
- * Check for identifier1(identifier2) and not
- * identifier1(void), or identifier1(identifier2, xxxx).
- */
-
- while ( isidchar(*p) )
- p++;
- len = p - id;
- p = skipspace(p, 1);
- if (*p == ',' ||
- (*p == ')' && (len != 4 || strncmp(id, "void", 4)))
- )
- return 0; /* not a function */
- }
- /*
- * If the last significant character was a ), we need to count
- * parentheses, because it might be part of a formal parameter
- * that is a procedure.
- */
- if (contin > 0) {
- int level = 0;
-
- for (p = skipspace(buf, 1); *p; p = skipspace(p + 1, 1))
- level += (*p == '(' ? 1 : *p == ')' ? -1 : 0);
- if (level > 0)
- contin = -1;
- }
- return contin;
-}
-
-/* Convert a recognized function definition or header to K&R syntax. */
-int
-convert1(buf, out, header, convert_varargs)
- char *buf;
- FILE *out;
- int header; /* Boolean */
- int convert_varargs; /* Boolean */
-{ char *endfn;
- char *p;
- /*
- * The breaks table contains pointers to the beginning and end
- * of each argument.
- */
- char **breaks;
- unsigned num_breaks = 2; /* for testing */
- char **btop;
- char **bp;
- char **ap;
- char *vararg = 0;
-
- /* Pre-ANSI implementations don't agree on whether strchr */
- /* is called strchr or index, so we open-code it here. */
- for ( endfn = buf; *(endfn++) != '('; )
- ;
-top: p = endfn;
- breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
- if ( breaks == NULL )
- { /* Couldn't allocate break table, give up */
- fprintf(stderr, "Unable to allocate break table!\n");
- fputs(buf, out);
- return -1;
- }
- btop = breaks + num_breaks * 2 - 2;
- bp = breaks;
- /* Parse the argument list */
- do
- { int level = 0;
- char *lp = NULL;
- char *rp = NULL;
- char *end = NULL;
-
- if ( bp >= btop )
- { /* Filled up break table. */
- /* Allocate a bigger one and start over. */
- free((char *)breaks);
- num_breaks <<= 1;
- goto top;
- }
- *bp++ = p;
- /* Find the end of the argument */
- for ( ; end == NULL; p++ )
- { switch(*p)
- {
- case ',':
- if ( !level ) end = p;
- break;
- case '(':
- if ( !level ) lp = p;
- level++;
- break;
- case ')':
- if ( --level < 0 ) end = p;
- else rp = p;
- break;
- case '/':
- if (p[1] == '*')
- p = skipspace(p, 1) - 1;
- break;
- case '"':
- p = scanstring(p, 1) - 1;
- break;
- default:
- ;
- }
- }
- /* Erase any embedded prototype parameters. */
- if ( lp && rp )
- writeblanks(lp + 1, rp);
- p--; /* back up over terminator */
- /* Find the name being declared. */
- /* This is complicated because of procedure and */
- /* array modifiers. */
- for ( ; ; )
- { p = skipspace(p - 1, -1);
- switch ( *p )
- {
- case ']': /* skip array dimension(s) */
- case ')': /* skip procedure args OR name */
- { int level = 1;
- while ( level )
- switch ( *--p )
- {
- case ']': case ')':
- level++;
- break;
- case '[': case '(':
- level--;
- break;
- case '/':
- if (p > buf && p[-1] == '*')
- p = skipspace(p, -1) + 1;
- break;
- case '"':
- p = scanstring(p, -1) + 1;
- break;
- default: ;
- }
- }
- if ( *p == '(' && *skipspace(p + 1, 1) == '*' )
- { /* We found the name being declared */
- while ( !isidfirstchar(*p) )
- p = skipspace(p, 1) + 1;
- goto found;
- }
- break;
- default:
- goto found;
- }
- }
-found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' )
- { if ( convert_varargs )
- { *bp++ = "va_alist";
- vararg = p-2;
- }
- else
- { p++;
- if ( bp == breaks + 1 ) /* sole argument */
- writeblanks(breaks[0], p);
- else
- writeblanks(bp[-1] - 1, p);
- bp--;
- }
- }
- else
- { while ( isidchar(*p) ) p--;
- *bp++ = p+1;
- }
- p = end;
- }
- while ( *p++ == ',' );
- *bp = p;
- /* Make a special check for 'void' arglist */
- if ( bp == breaks+2 )
- { p = skipspace(breaks[0], 1);
- if ( !strncmp(p, "void", 4) )
- { p = skipspace(p+4, 1);
- if ( p == breaks[2] - 1 )
- { bp = breaks; /* yup, pretend arglist is empty */
- writeblanks(breaks[0], p + 1);
- }
- }
- }
- /* Put out the function name and left parenthesis. */
- p = buf;
- while ( p != endfn ) putc(*p, out), p++;
- /* Put out the declaration. */
- if ( header )
- { fputs(");", out);
- for ( p = breaks[0]; *p; p++ )
- if ( *p == '\r' || *p == '\n' )
- putc(*p, out);
- }
- else
- { for ( ap = breaks+1; ap < bp; ap += 2 )
- { p = *ap;
- while ( isidchar(*p) )
- putc(*p, out), p++;
- if ( ap < bp - 1 )
- fputs(", ", out);
- }
- fputs(") ", out);
- /* Put out the argument declarations */
- for ( ap = breaks+2; ap <= bp; ap += 2 )
- (*ap)[-1] = ';';
- if ( vararg != 0 )
- { *vararg = 0;
- fputs(breaks[0], out); /* any prior args */
- fputs("va_dcl", out); /* the final arg */
- fputs(bp[0], out);
- }
- else
- fputs(breaks[0], out);
- }
- free((char *)breaks);
- return 0;
-}
diff --git a/plugins/AdvaImg/src/LibJPEG/change.log b/plugins/AdvaImg/src/LibJPEG/change.log index 26b628bb86..6d5786d500 100644 --- a/plugins/AdvaImg/src/LibJPEG/change.log +++ b/plugins/AdvaImg/src/LibJPEG/change.log @@ -1,6 +1,29 @@ CHANGE LOG for Independent JPEG Group's JPEG software
+Version 9b 17-Jan-2016
+-----------------------
+
+Improvements and optimizations in DCT and color calculations.
+Normalize range limit array composition and access pattern.
+Thank to Sia Furler and Maddie Ziegler for inspiration.
+
+Use merged upsample with scaled DCT sizes larger than 8.
+Thank to Taylor Hatala for inspiration.
+
+Check for excessive comment lengths in argument parsing in wrjpgcom.c.
+Thank to Julian Cohen for hint.
+
+Add makefile.b32 for use with Borland C++ 32-bit (bcc32).
+Thank to Joe Slater for contribution.
+
+Document 'f' specifier for jpegtran -crop specification.
+Thank to Michele Martone for suggestion.
+
+Use defined value from header instead of hardwired number in rdswitch.c.
+Thank to Robert Sprowson for hint.
+
+
Version 9a 19-Jan-2014
-----------------------
diff --git a/plugins/AdvaImg/src/LibJPEG/djpeg.c b/plugins/AdvaImg/src/LibJPEG/djpeg.c index 77718cefbe..2845f306c1 100644 --- a/plugins/AdvaImg/src/LibJPEG/djpeg.c +++ b/plugins/AdvaImg/src/LibJPEG/djpeg.c @@ -2,7 +2,7 @@ * djpeg.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2009-2013 by Guido Vollbeding.
+ * Modified 2009-2015 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.
*
@@ -102,6 +102,7 @@ usage (void) fprintf(stderr, " -colors N Reduce image to no more than N colors\n");
fprintf(stderr, " -fast Fast, low-quality processing\n");
fprintf(stderr, " -grayscale Force grayscale output\n");
+ fprintf(stderr, " -rgb Force RGB output\n");
#ifdef IDCT_SCALING_SUPPORTED
fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n");
#endif
@@ -264,6 +265,10 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv, /* Force monochrome output. */
cinfo->out_color_space = JCS_GRAYSCALE;
+ } else if (keymatch(arg, "rgb", 3)) {
+ /* Force RGB output. */
+ cinfo->out_color_space = JCS_RGB;
+
} else if (keymatch(arg, "map", 3)) {
/* Quantize to a color map taken from an input file. */
if (++argn >= argc) /* advance to next argument */
diff --git a/plugins/AdvaImg/src/LibJPEG/install.txt b/plugins/AdvaImg/src/LibJPEG/install.txt index 8e6b721ba5..44a14a28ff 100644 --- a/plugins/AdvaImg/src/LibJPEG/install.txt +++ b/plugins/AdvaImg/src/LibJPEG/install.txt @@ -1,6 +1,6 @@ INSTALLATION INSTRUCTIONS for the Independent JPEG Group's JPEG software
-Copyright (C) 1991-2013, Thomas G. Lane, Guido Vollbeding.
+Copyright (C) 1991-2015, Thomas G. Lane, Guido Vollbeding.
This file is part of the Independent JPEG Group's software.
For conditions of distribution and use, see the accompanying README file.
@@ -147,9 +147,10 @@ makefile.bcc jconfig.bcc MS-DOS or OS/2, Borland C makefile.dj jconfig.dj MS-DOS, DJGPP (Delorie's port of GNU C)
makefile.mc6 jconfig.mc6 MS-DOS, Microsoft C (16-bit only)
makefile.wat jconfig.wat MS-DOS, OS/2, or Windows NT, Watcom C
-makefile.vc jconfig.vc Windows NT/95, MS Visual C++
-make*.vc6 jconfig.vc Windows NT/95, MS Visual C++ 6
-make*.v10 jconfig.vc Windows NT/95, MS Visual C++ 2010 (v10)
+makefile.vc jconfig.vc Windows NT/9x, MS Visual C++
+make*.vc6 jconfig.vc Windows NT/9x, MS Visual C++ 6
+make*.v10 jconfig.vc Windows NT/9x, MS Visual C++ 2010 (v10)
+makefile.b32 jconfig.vc Windows NT/9x, Borland C++ 32-bit (bcc32)
makefile.mms jconfig.vms Digital VMS, with MMS software
makefile.vms jconfig.vms Digital VMS, without MMS software
diff --git a/plugins/AdvaImg/src/LibJPEG/jconfig.h b/plugins/AdvaImg/src/LibJPEG/jconfig.h index 3d952e2e72..9b71ed2db1 100644 --- a/plugins/AdvaImg/src/LibJPEG/jconfig.h +++ b/plugins/AdvaImg/src/LibJPEG/jconfig.h @@ -1,161 +1,52 @@ -/*
- * jconfig.txt
- *
- * Copyright (C) 1991-1994, Thomas G. Lane.
- * Modified 2009-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.
- *
- * This file documents the configuration options that are required to
- * customize the JPEG software for a particular system.
- *
- * The actual configuration options for a particular installation are stored
- * in jconfig.h. On many machines, jconfig.h can be generated automatically
- * or copied from one of the "canned" jconfig files that we supply. But if
- * you need to generate a jconfig.h file by hand, this file tells you how.
- *
- * DO NOT EDIT THIS FILE --- IT WON'T ACCOMPLISH ANYTHING.
- * EDIT A COPY NAMED JCONFIG.H.
- */
+/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 9x or NT. */
+/* This file also works for Borland C++ 32-bit (bcc32) on Windows 9x or NT. */
+/* see jconfig.txt for explanations */
-
-/*
- * These symbols indicate the properties of your machine or compiler.
- * #define the symbol if yes, #undef it if no.
- */
-
-/* Does your compiler support function prototypes?
- * (If not, you also need to use ansi2knr, see install.txt)
- */
#define HAVE_PROTOTYPES
-
-/* Does your compiler support the declaration "unsigned char" ?
- * How about "unsigned short" ?
- */
#define HAVE_UNSIGNED_CHAR
#define HAVE_UNSIGNED_SHORT
-
-/* Define "void" as "char" if your compiler doesn't know about type void.
- * NOTE: be sure to define void such that "void *" represents the most general
- * pointer type, e.g., that returned by malloc().
- */
/* #define void char */
-
-/* Define "const" as empty if your compiler doesn't know the "const" keyword.
- */
/* #define const */
-
-/* Define this if an ordinary "char" type is unsigned.
- * If you're not sure, leaving it undefined will work at some cost in speed.
- * If you defined HAVE_UNSIGNED_CHAR then the speed difference is minimal.
- */
#undef CHAR_IS_UNSIGNED
-
-/* Define this if your system has an ANSI-conforming <stddef.h> file.
- */
#define HAVE_STDDEF_H
-
-/* Define this if your system has an ANSI-conforming <stdlib.h> file.
- */
#define HAVE_STDLIB_H
-
-/* Define this if your system does not have an ANSI/SysV <string.h>,
- * but does have a BSD-style <strings.h>.
- */
#undef NEED_BSD_STRINGS
-
-/* Define this if your system does not provide typedef size_t in any of the
- * ANSI-standard places (stddef.h, stdlib.h, or stdio.h), but places it in
- * <sys/types.h> instead.
- */
#undef NEED_SYS_TYPES_H
-
-/* For 80x86 machines, you need to define NEED_FAR_POINTERS,
- * unless you are using a large-data memory model or 80386 flat-memory mode.
- * On less brain-damaged CPUs this symbol must not be defined.
- * (Defining this symbol causes large data structures to be referenced through
- * "far" pointers and to be allocated with a special version of malloc.)
- */
-#undef NEED_FAR_POINTERS
-
-/* Define this if your linker needs global names to be unique in less
- * than the first 15 characters.
- */
+#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */
#undef NEED_SHORT_EXTERNAL_NAMES
-
-/* Although a real ANSI C compiler can deal perfectly well with pointers to
- * unspecified structures (see "incomplete types" in the spec), a few pre-ANSI
- * and pseudo-ANSI compilers get confused. To keep one of these bozos happy,
- * define INCOMPLETE_TYPES_BROKEN. This is not recommended unless you
- * actually get "missing structure definition" warnings or errors while
- * compiling the JPEG code.
- */
#undef INCOMPLETE_TYPES_BROKEN
-/* Define "boolean" as unsigned char, not int, per Windows custom */
+/* Define "boolean" as unsigned char, not enum, per Windows custom */
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
typedef unsigned char boolean;
#endif
+#ifndef FALSE /* in case these macros already exist */
+#define FALSE 0 /* values of boolean */
+#endif
+#ifndef TRUE
+#define TRUE 1
+#endif
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
-/*
- * The following options affect code selection within the JPEG library,
- * but they don't need to be visible to applications using the library.
- * To minimize application namespace pollution, the symbols won't be
- * defined unless JPEG_INTERNALS has been defined.
- */
#ifdef JPEG_INTERNALS
-/* Define this if your compiler implements ">>" on signed values as a logical
- * (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift,
- * which is the normal and rational definition.
- */
#undef RIGHT_SHIFT_IS_UNSIGNED
-
#endif /* JPEG_INTERNALS */
-
-/*
- * The remaining options do not affect the JPEG library proper,
- * but only the sample applications cjpeg/djpeg (see cjpeg.c, djpeg.c).
- * Other applications can ignore these.
- */
-
#ifdef JPEG_CJPEG_DJPEG
-/* These defines indicate which image (non-JPEG) file formats are allowed. */
-
#define BMP_SUPPORTED /* BMP image file format */
#define GIF_SUPPORTED /* GIF image file format */
#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
#undef RLE_SUPPORTED /* Utah RLE image file format */
#define TARGA_SUPPORTED /* Targa image file format */
-/* Define this if you want to name both input and output files on the command
- * line, rather than using stdout and optionally stdin. You MUST do this if
- * your system can't cope with binary I/O to stdin/stdout. See comments at
- * head of cjpeg.c or djpeg.c.
- */
-#undef TWO_FILE_COMMANDLINE
-
-/* Define this if your system needs explicit cleanup of temporary files.
- * This is crucial under MS-DOS, where the temporary "files" may be areas
- * of extended memory; on most other systems it's not as important.
- */
+#define TWO_FILE_COMMANDLINE /* optional */
+#define USE_SETMODE /* Microsoft has setmode() */
#undef NEED_SIGNAL_CATCHER
-
-/* By default, we open image files with fopen(...,"rb") or fopen(...,"wb").
- * This is necessary on systems that distinguish text files from binary files,
- * and is harmless on most systems that don't. If you have one of the rare
- * systems that complains about the "b" spec, define this symbol.
- */
#undef DONT_USE_B_MODE
-
-/* Define this if you want percent-done progress reports from cjpeg/djpeg.
- */
-#undef PROGRESS_REPORT
-
+#undef PROGRESS_REPORT /* optional */
#endif /* JPEG_CJPEG_DJPEG */
diff --git a/plugins/AdvaImg/src/LibJPEG/jdarith.c b/plugins/AdvaImg/src/LibJPEG/jdarith.c index dac87a9948..14ca7fe133 100644 --- a/plugins/AdvaImg/src/LibJPEG/jdarith.c +++ b/plugins/AdvaImg/src/LibJPEG/jdarith.c @@ -1,7 +1,7 @@ /*
* jdarith.c
*
- * Developed 1997-2013 by Guido Vollbeding.
+ * Developed 1997-2015 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.
*
@@ -94,7 +94,7 @@ get_byte (j_decompress_ptr cinfo) * (instead of fixed) with the bit shift counter CT.
* Thus, we also need only one (variable instead of
* fixed size) shift for the LPS/MPS decision, and
- * we can get away with any renormalization update
+ * we can do away with any renormalization update
* of C (except for new data insertion, of course).
*
* I've also introduced a new scheme for accessing
diff --git a/plugins/AdvaImg/src/LibJPEG/jdatasrc.c b/plugins/AdvaImg/src/LibJPEG/jdatasrc.c index e8bca76cdb..c44d8d0ba7 100644 --- a/plugins/AdvaImg/src/LibJPEG/jdatasrc.c +++ b/plugins/AdvaImg/src/LibJPEG/jdatasrc.c @@ -2,7 +2,7 @@ * jdatasrc.c
*
* Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2009-2011 by Guido Vollbeding.
+ * Modified 2009-2015 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.
*
@@ -247,7 +247,7 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile) GLOBAL(void)
jpeg_mem_src (j_decompress_ptr cinfo,
- unsigned char * inbuffer, unsigned long insize)
+ const unsigned char * inbuffer, unsigned long insize)
{
struct jpeg_source_mgr * src;
@@ -271,5 +271,5 @@ jpeg_mem_src (j_decompress_ptr cinfo, src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
src->term_source = term_source;
src->bytes_in_buffer = (size_t) insize;
- src->next_input_byte = (JOCTET *) inbuffer;
+ src->next_input_byte = (const JOCTET *) inbuffer;
}
diff --git a/plugins/AdvaImg/src/LibJPEG/jdcolor.c b/plugins/AdvaImg/src/LibJPEG/jdcolor.c index b135776567..92d3c1a584 100644 --- a/plugins/AdvaImg/src/LibJPEG/jdcolor.c +++ b/plugins/AdvaImg/src/LibJPEG/jdcolor.c @@ -2,7 +2,7 @@ * jdcolor.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2011-2013 by Guido Vollbeding.
+ * Modified 2011-2015 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.
*
@@ -25,9 +25,6 @@ typedef struct { INT32 * Cr_g_tab; /* => table for Cr to G conversion */
INT32 * Cb_g_tab; /* => table for Cb to G conversion */
- JSAMPLE * range_limit; /* pointer to normal sample range limit table, */
- /* or extended sample range limit table for BG_YCC */
-
/* Private state for RGB->Y conversion */
INT32 * rgb_y_tab; /* => table for RGB to Y conversion */
} my_color_deconverter;
@@ -134,8 +131,6 @@ build_ycc_rgb_table (j_decompress_ptr cinfo) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32));
- cconvert->range_limit = cinfo->sample_range_limit;
-
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
@@ -176,10 +171,6 @@ build_bg_ycc_rgb_table (j_decompress_ptr cinfo) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32));
- cconvert->range_limit = (JSAMPLE *)
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- 5 * (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
-
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
@@ -195,20 +186,6 @@ build_bg_ycc_rgb_table (j_decompress_ptr cinfo) /* We also add in ONE_HALF so that need not do it in inner loop */
cconvert->Cb_g_tab[i] = (- FIX(0.688272572)) * x + ONE_HALF;
}
-
- /* Cb and Cr portions can extend to double range in wide gamut case,
- * so we prepare an appropriate extended range limit table.
- */
-
- /* First segment of range limit table: limit[x] = 0 for x < 0 */
- MEMZERO(cconvert->range_limit, 2 * (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
- cconvert->range_limit += 2 * (MAXJSAMPLE+1);
- /* Main part of range limit table: limit[x] = x */
- for (i = 0; i <= MAXJSAMPLE; i++)
- cconvert->range_limit[i] = (JSAMPLE) i;
- /* End of range limit table: limit[x] = MAXJSAMPLE for x > MAXJSAMPLE */
- for (; i < 3 * (MAXJSAMPLE+1); i++)
- cconvert->range_limit[i] = MAXJSAMPLE;
}
@@ -235,7 +212,7 @@ ycc_rgb_convert (j_decompress_ptr cinfo, register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
/* copy these pointers into registers if possible */
- register JSAMPLE * range_limit = cconvert->range_limit;
+ register JSAMPLE * range_limit = cinfo->sample_range_limit;
register int * Crrtab = cconvert->Cr_r_tab;
register int * Cbbtab = cconvert->Cb_b_tab;
register INT32 * Crgtab = cconvert->Cr_g_tab;
diff --git a/plugins/AdvaImg/src/LibJPEG/jdct.h b/plugins/AdvaImg/src/LibJPEG/jdct.h index b1ff91250b..5f631f42e2 100644 --- a/plugins/AdvaImg/src/LibJPEG/jdct.h +++ b/plugins/AdvaImg/src/LibJPEG/jdct.h @@ -2,6 +2,7 @@ * jdct.h
*
* Copyright (C) 1994-1996, Thomas G. Lane.
+ * Modified 2002-2015 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.
*
@@ -78,13 +79,16 @@ typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */ * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could
* be quite far out of range if the input data is corrupt, so a bulletproof
* range-limiting step is required. We use a mask-and-table-lookup method
- * to do the combined operations quickly. See the comments with
- * prepare_range_limit_table (in jdmaster.c) for more info.
+ * to do the combined operations quickly, assuming that MAXJSAMPLE+1
+ * is a power of 2. See the comments with prepare_range_limit_table
+ * (in jdmaster.c) for more info.
*/
-#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE)
-
#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */
+#define RANGE_CENTER (MAXJSAMPLE * 2 + 2)
+#define RANGE_SUBSET (RANGE_CENTER - CENTERJSAMPLE)
+
+#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit - RANGE_SUBSET)
/* Short forms of external names for systems with brain-damaged linkers. */
@@ -391,3 +395,23 @@ EXTERN(void) jpeg_idct_1x2 #ifndef MULTIPLY16V16 /* default definition */
#define MULTIPLY16V16(var1,var2) ((var1) * (var2))
#endif
+
+/* Like RIGHT_SHIFT, but applies to a DCTELEM.
+ * We assume that int right shift is unsigned if INT32 right shift is.
+ */
+
+#ifdef RIGHT_SHIFT_IS_UNSIGNED
+#define ISHIFT_TEMPS DCTELEM ishift_temp;
+#if BITS_IN_JSAMPLE == 8
+#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */
+#else
+#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */
+#endif
+#define IRIGHT_SHIFT(x,shft) \
+ ((ishift_temp = (x)) < 0 ? \
+ (ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \
+ (ishift_temp >> (shft)))
+#else
+#define ISHIFT_TEMPS
+#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
+#endif
diff --git a/plugins/AdvaImg/src/LibJPEG/jdmaster.c b/plugins/AdvaImg/src/LibJPEG/jdmaster.c index ed6b499607..0ece558cb2 100644 --- a/plugins/AdvaImg/src/LibJPEG/jdmaster.c +++ b/plugins/AdvaImg/src/LibJPEG/jdmaster.c @@ -2,7 +2,7 @@ * jdmaster.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2002-2013 by Guido Vollbeding.
+ * Modified 2002-2015 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.
*
@@ -45,11 +45,23 @@ LOCAL(boolean) use_merged_upsample (j_decompress_ptr cinfo)
{
#ifdef UPSAMPLE_MERGING_SUPPORTED
- /* Merging is the equivalent of plain box-filter upsampling */
- if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
+ /* Merging is the equivalent of plain box-filter upsampling. */
+ /* The following condition is only needed if fancy shall select
+ * a different upsampling method. In our current implementation
+ * fancy only affects the DCT scaling, thus we can use fancy
+ * upsampling and merged upsample simultaneously, in particular
+ * with scaled DCT sizes larger than the default DCTSIZE.
+ */
+#if 0
+ if (cinfo->do_fancy_upsampling)
+ return FALSE;
+#endif
+ if (cinfo->CCIR601_sampling)
return FALSE;
/* jdmerge.c only supports YCC=>RGB color conversion */
- if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
+ if ((cinfo->jpeg_color_space != JCS_YCbCr &&
+ cinfo->jpeg_color_space != JCS_BG_YCC) ||
+ cinfo->num_components != 3 ||
cinfo->out_color_space != JCS_RGB ||
cinfo->out_color_components != RGB_PIXELSIZE ||
cinfo->color_transform)
@@ -199,30 +211,20 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo) * These processes all use a common table prepared by the routine below.
*
* For most steps we can mathematically guarantee that the initial value
- * of x is within MAXJSAMPLE+1 of the legal range, so a table running from
- * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial
- * limiting step (just after the IDCT), a wildly out-of-range value is
- * possible if the input data is corrupt. To avoid any chance of indexing
+ * of x is within 2*(MAXJSAMPLE+1) of the legal range, so a table running
+ * from -2*(MAXJSAMPLE+1) to 3*MAXJSAMPLE+2 is sufficient. But for the
+ * initial limiting step (just after the IDCT), a wildly out-of-range value
+ * is possible if the input data is corrupt. To avoid any chance of indexing
* off the end of memory and getting a bad-pointer trap, we perform the
* post-IDCT limiting thus:
- * x = range_limit[x & MASK];
+ * x = (sample_range_limit - SUBSET)[(x + CENTER) & MASK];
* where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit
* samples. Under normal circumstances this is more than enough range and
* a correct output will be generated; with bogus input data the mask will
* cause wraparound, and we will safely generate a bogus-but-in-range output.
* For the post-IDCT step, we want to convert the data from signed to unsigned
* representation by adding CENTERJSAMPLE at the same time that we limit it.
- * So the post-IDCT limiting table ends up looking like this:
- * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE,
- * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
- * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
- * 0,1,...,CENTERJSAMPLE-1
- * Negative inputs select values from the upper half of the table after
- * masking.
- *
- * We can save some space by overlapping the start of the post-IDCT table
- * with the simpler range limiting table. The post-IDCT table begins at
- * sample_range_limit + CENTERJSAMPLE.
+ * This is accomplished with SUBSET = CENTER - CENTERJSAMPLE.
*
* Note that the table is allocated in near data space on PCs; it's small
* enough and used often enough to justify this.
@@ -237,23 +239,17 @@ prepare_range_limit_table (j_decompress_ptr cinfo) table = (JSAMPLE *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE));
- table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
+ 5 * (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
+ /* First segment of range limit table: limit[x] = 0 for x < 0 */
+ MEMZERO(table, 2 * (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
+ table += 2 * (MAXJSAMPLE+1); /* allow negative subscripts of table */
cinfo->sample_range_limit = table;
- /* First segment of "simple" table: limit[x] = 0 for x < 0 */
- MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
- /* Main part of "simple" table: limit[x] = x */
+ /* Main part of range limit table: limit[x] = x */
for (i = 0; i <= MAXJSAMPLE; i++)
table[i] = (JSAMPLE) i;
- table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
- /* End of simple table, rest of first half of post-IDCT table */
- for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
+ /* End of range limit table: limit[x] = MAXJSAMPLE for x > MAXJSAMPLE */
+ for (; i < 3 * (MAXJSAMPLE+1); i++)
table[i] = MAXJSAMPLE;
- /* Second half of post-IDCT table */
- MEMZERO(table + (2 * (MAXJSAMPLE+1)),
- (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));
- MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
- cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));
}
diff --git a/plugins/AdvaImg/src/LibJPEG/jdmerge.c b/plugins/AdvaImg/src/LibJPEG/jdmerge.c index 605e858cbd..368fa703aa 100644 --- a/plugins/AdvaImg/src/LibJPEG/jdmerge.c +++ b/plugins/AdvaImg/src/LibJPEG/jdmerge.c @@ -2,7 +2,7 @@ * jdmerge.c
*
* Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2013 by Guido Vollbeding.
+ * Modified 2013-2015 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.
*
@@ -24,7 +24,7 @@ * multiplications needed for color conversion.
*
* This file currently provides implementations for the following cases:
- * YCbCr => RGB color conversion only.
+ * YCC => RGB color conversion only (YCbCr or BG_YCC).
* Sampling ratios of 2h1v or 2h2v.
* No scaling needed at upsample time.
* Corner-aligned (non-CCIR601) sampling alignment.
@@ -76,12 +76,13 @@ typedef my_upsampler * my_upsample_ptr; /*
- * Initialize tables for YCC->RGB colorspace conversion.
+ * Initialize tables for YCbCr->RGB and BG_YCC->RGB colorspace conversion.
* This is taken directly from jdcolor.c; see that file for more info.
*/
LOCAL(void)
build_ycc_rgb_table (j_decompress_ptr cinfo)
+/* Normal case, sYCC */
{
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
int i;
@@ -119,6 +120,46 @@ build_ycc_rgb_table (j_decompress_ptr cinfo) }
+LOCAL(void)
+build_bg_ycc_rgb_table (j_decompress_ptr cinfo)
+/* Wide gamut case, bg-sYCC */
+{
+ my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
+ int i;
+ INT32 x;
+ SHIFT_TEMPS
+
+ upsample->Cr_r_tab = (int *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
+ (MAXJSAMPLE+1) * SIZEOF(int));
+ upsample->Cb_b_tab = (int *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
+ (MAXJSAMPLE+1) * SIZEOF(int));
+ upsample->Cr_g_tab = (INT32 *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
+ (MAXJSAMPLE+1) * SIZEOF(INT32));
+ upsample->Cb_g_tab = (INT32 *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
+ (MAXJSAMPLE+1) * SIZEOF(INT32));
+
+ for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
+ /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
+ /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
+ /* Cr=>R value is nearest int to 2.804 * x */
+ upsample->Cr_r_tab[i] = (int)
+ RIGHT_SHIFT(FIX(2.804) * x + ONE_HALF, SCALEBITS);
+ /* Cb=>B value is nearest int to 3.544 * x */
+ upsample->Cb_b_tab[i] = (int)
+ RIGHT_SHIFT(FIX(3.544) * x + ONE_HALF, SCALEBITS);
+ /* Cr=>G value is scaled-up -1.428272572 * x */
+ upsample->Cr_g_tab[i] = (- FIX(1.428272572)) * x;
+ /* Cb=>G value is scaled-up -0.688272572 * x */
+ /* We also add in ONE_HALF so that need not do it in inner loop */
+ upsample->Cb_g_tab[i] = (- FIX(0.688272572)) * x + ONE_HALF;
+ }
+}
+
+
/*
* Initialize for an upsampling pass.
*/
@@ -251,32 +292,32 @@ h2v1_merged_upsample (j_decompress_ptr cinfo, /* Do the chroma part of the calculation */
cb = GETJSAMPLE(*inptr1++);
cr = GETJSAMPLE(*inptr2++);
- cred = Crrtab[cr];
+ cred = Crrtab[cr];
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
+ cblue = Cbbtab[cb];
/* Fetch 2 Y values and emit 2 pixels */
y = GETJSAMPLE(*inptr0++);
- outptr[RGB_RED] = range_limit[y + cred];
+ outptr[RGB_RED] = range_limit[y + cred];
outptr[RGB_GREEN] = range_limit[y + cgreen];
- outptr[RGB_BLUE] = range_limit[y + cblue];
+ outptr[RGB_BLUE] = range_limit[y + cblue];
outptr += RGB_PIXELSIZE;
y = GETJSAMPLE(*inptr0++);
- outptr[RGB_RED] = range_limit[y + cred];
+ outptr[RGB_RED] = range_limit[y + cred];
outptr[RGB_GREEN] = range_limit[y + cgreen];
- outptr[RGB_BLUE] = range_limit[y + cblue];
+ outptr[RGB_BLUE] = range_limit[y + cblue];
outptr += RGB_PIXELSIZE;
}
/* If image width is odd, do the last output column separately */
if (cinfo->output_width & 1) {
cb = GETJSAMPLE(*inptr1);
cr = GETJSAMPLE(*inptr2);
- cred = Crrtab[cr];
+ cred = Crrtab[cr];
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
+ cblue = Cbbtab[cb];
y = GETJSAMPLE(*inptr0);
- outptr[RGB_RED] = range_limit[y + cred];
+ outptr[RGB_RED] = range_limit[y + cred];
outptr[RGB_GREEN] = range_limit[y + cgreen];
- outptr[RGB_BLUE] = range_limit[y + cblue];
+ outptr[RGB_BLUE] = range_limit[y + cblue];
}
}
@@ -315,46 +356,46 @@ h2v2_merged_upsample (j_decompress_ptr cinfo, /* Do the chroma part of the calculation */
cb = GETJSAMPLE(*inptr1++);
cr = GETJSAMPLE(*inptr2++);
- cred = Crrtab[cr];
+ cred = Crrtab[cr];
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
+ cblue = Cbbtab[cb];
/* Fetch 4 Y values and emit 4 pixels */
y = GETJSAMPLE(*inptr00++);
- outptr0[RGB_RED] = range_limit[y + cred];
+ outptr0[RGB_RED] = range_limit[y + cred];
outptr0[RGB_GREEN] = range_limit[y + cgreen];
- outptr0[RGB_BLUE] = range_limit[y + cblue];
+ outptr0[RGB_BLUE] = range_limit[y + cblue];
outptr0 += RGB_PIXELSIZE;
y = GETJSAMPLE(*inptr00++);
- outptr0[RGB_RED] = range_limit[y + cred];
+ outptr0[RGB_RED] = range_limit[y + cred];
outptr0[RGB_GREEN] = range_limit[y + cgreen];
- outptr0[RGB_BLUE] = range_limit[y + cblue];
+ outptr0[RGB_BLUE] = range_limit[y + cblue];
outptr0 += RGB_PIXELSIZE;
y = GETJSAMPLE(*inptr01++);
- outptr1[RGB_RED] = range_limit[y + cred];
+ outptr1[RGB_RED] = range_limit[y + cred];
outptr1[RGB_GREEN] = range_limit[y + cgreen];
- outptr1[RGB_BLUE] = range_limit[y + cblue];
+ outptr1[RGB_BLUE] = range_limit[y + cblue];
outptr1 += RGB_PIXELSIZE;
y = GETJSAMPLE(*inptr01++);
- outptr1[RGB_RED] = range_limit[y + cred];
+ outptr1[RGB_RED] = range_limit[y + cred];
outptr1[RGB_GREEN] = range_limit[y + cgreen];
- outptr1[RGB_BLUE] = range_limit[y + cblue];
+ outptr1[RGB_BLUE] = range_limit[y + cblue];
outptr1 += RGB_PIXELSIZE;
}
/* If image width is odd, do the last output column separately */
if (cinfo->output_width & 1) {
cb = GETJSAMPLE(*inptr1);
cr = GETJSAMPLE(*inptr2);
- cred = Crrtab[cr];
+ cred = Crrtab[cr];
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
- cblue = Cbbtab[cb];
+ cblue = Cbbtab[cb];
y = GETJSAMPLE(*inptr00);
- outptr0[RGB_RED] = range_limit[y + cred];
+ outptr0[RGB_RED] = range_limit[y + cred];
outptr0[RGB_GREEN] = range_limit[y + cgreen];
- outptr0[RGB_BLUE] = range_limit[y + cblue];
+ outptr0[RGB_BLUE] = range_limit[y + cblue];
y = GETJSAMPLE(*inptr01);
- outptr1[RGB_RED] = range_limit[y + cred];
+ outptr1[RGB_RED] = range_limit[y + cred];
outptr1[RGB_GREEN] = range_limit[y + cgreen];
- outptr1[RGB_BLUE] = range_limit[y + cblue];
+ outptr1[RGB_BLUE] = range_limit[y + cblue];
}
}
@@ -375,7 +416,7 @@ jinit_merged_upsampler (j_decompress_ptr cinfo) upsample = (my_upsample_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_upsampler));
- cinfo->upsample = (struct jpeg_upsampler *) upsample;
+ cinfo->upsample = &upsample->pub;
upsample->pub.start_pass = start_pass_merged_upsample;
upsample->pub.need_context_rows = FALSE;
@@ -395,7 +436,10 @@ jinit_merged_upsampler (j_decompress_ptr cinfo) upsample->spare_row = NULL;
}
- build_ycc_rgb_table(cinfo);
+ if (cinfo->jpeg_color_space == JCS_BG_YCC)
+ build_bg_ycc_rgb_table(cinfo);
+ else
+ build_ycc_rgb_table(cinfo);
}
#endif /* UPSAMPLE_MERGING_SUPPORTED */
diff --git a/plugins/AdvaImg/src/LibJPEG/jdosaobj.txt b/plugins/AdvaImg/src/LibJPEG/jdosaobj.txt new file mode 100644 index 0000000000..4318362ec4 --- /dev/null +++ b/plugins/AdvaImg/src/LibJPEG/jdosaobj.txt @@ -0,0 +1,16 @@ +This archive contains already-assembled object files for JMEMDOSA.ASM +of the Independent JPEG Group's JPEG package. These files will be helpful +if you want to compile the IJG code for DOS, but don't have an assembler. + +These files were prepared from the 3/13/1992 version of JMEMDOSA.ASM, +which is still unchanged as of mid-1998. You can use these files with +releases 3 through 6 of the IJG code, and probably future releases too. + +To use these files, copy the proper version to JMEMDOSA.OBJ. Make sure +this file has a newer date than JMEMDOSA.ASM. Then compile the code as +usual. + +Object files included: + +JDOSAMSC.OBJ For Microsoft C version 5 or later. +JDOSABCC.OBJ For Borland C version 3.0 or later. diff --git a/plugins/AdvaImg/src/LibJPEG/jdsample.c b/plugins/AdvaImg/src/LibJPEG/jdsample.c index 94f9599f04..83d6332c3b 100644 --- a/plugins/AdvaImg/src/LibJPEG/jdsample.c +++ b/plugins/AdvaImg/src/LibJPEG/jdsample.c @@ -2,7 +2,7 @@ * jdsample.c
*
* Copyright (C) 1991-1996, Thomas G. Lane.
- * Modified 2002-2008 by Guido Vollbeding.
+ * Modified 2002-2015 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.
*
@@ -296,13 +296,12 @@ jinit_upsampler (j_decompress_ptr cinfo) my_upsample_ptr upsample;
int ci;
jpeg_component_info * compptr;
- boolean need_buffer;
int h_in_group, v_in_group, h_out_group, v_out_group;
upsample = (my_upsample_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_upsampler));
- cinfo->upsample = (struct jpeg_upsampler *) upsample;
+ cinfo->upsample = &upsample->pub;
upsample->pub.start_pass = start_pass_upsample;
upsample->pub.upsample = sep_upsample;
upsample->pub.need_context_rows = FALSE; /* until we find out differently */
@@ -325,17 +324,17 @@ jinit_upsampler (j_decompress_ptr cinfo) h_out_group = cinfo->max_h_samp_factor;
v_out_group = cinfo->max_v_samp_factor;
upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
- need_buffer = TRUE;
if (! compptr->component_needed) {
/* Don't bother to upsample an uninteresting component. */
upsample->methods[ci] = noop_upsample;
- need_buffer = FALSE;
- } else if (h_in_group == h_out_group && v_in_group == v_out_group) {
+ continue; /* don't need to allocate buffer */
+ }
+ if (h_in_group == h_out_group && v_in_group == v_out_group) {
/* Fullsize components can be processed without any work. */
upsample->methods[ci] = fullsize_upsample;
- need_buffer = FALSE;
- } else if (h_in_group * 2 == h_out_group &&
- v_in_group == v_out_group) {
+ continue; /* don't need to allocate buffer */
+ }
+ if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) {
/* Special case for 2h1v upsampling */
upsample->methods[ci] = h2v1_upsample;
} else if (h_in_group * 2 == h_out_group &&
@@ -350,12 +349,10 @@ jinit_upsampler (j_decompress_ptr cinfo) upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group);
} else
ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
- if (need_buffer) {
- upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr) cinfo, JPOOL_IMAGE,
- (JDIMENSION) jround_up((long) cinfo->output_width,
- (long) cinfo->max_h_samp_factor),
- (JDIMENSION) cinfo->max_v_samp_factor);
- }
+ upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)
+ ((j_common_ptr) cinfo, JPOOL_IMAGE,
+ (JDIMENSION) jround_up((long) cinfo->output_width,
+ (long) cinfo->max_h_samp_factor),
+ (JDIMENSION) cinfo->max_v_samp_factor);
}
}
diff --git a/plugins/AdvaImg/src/LibJPEG/jerror.c b/plugins/AdvaImg/src/LibJPEG/jerror.c index dcba3980e3..cfaf083a39 100644 --- a/plugins/AdvaImg/src/LibJPEG/jerror.c +++ b/plugins/AdvaImg/src/LibJPEG/jerror.c @@ -2,7 +2,7 @@ * jerror.c
*
* Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2012 by Guido Vollbeding.
+ * Modified 2012-2015 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.
*
@@ -19,16 +19,16 @@ * These routines are used by both the compression and decompression code.
*/
+#ifdef USE_WINDOWS_MESSAGEBOX
+#include <windows.h>
+#endif
+
/* this is not a core library module, so it doesn't define JPEG_INTERNALS */
#include "jinclude.h"
#include "jpeglib.h"
#include "jversion.h"
#include "jerror.h"
-#ifdef USE_WINDOWS_MESSAGEBOX
-#include <windows.h>
-#endif
-
#ifndef EXIT_FAILURE /* define exit() codes if not provided */
#define EXIT_FAILURE 1
#endif
diff --git a/plugins/AdvaImg/src/LibJPEG/jfdctflt.c b/plugins/AdvaImg/src/LibJPEG/jfdctflt.c index 3c1b174801..0cc054074f 100644 --- a/plugins/AdvaImg/src/LibJPEG/jfdctflt.c +++ b/plugins/AdvaImg/src/LibJPEG/jfdctflt.c @@ -2,7 +2,7 @@ * jfdctflt.c
*
* Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2003-2009 by Guido Vollbeding.
+ * Modified 2003-2015 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.
*
@@ -54,6 +54,8 @@ /*
* Perform the forward DCT on one block of samples.
+ *
+ * cK represents cos(K*pi/16).
*/
GLOBAL(void)
@@ -89,7 +91,7 @@ jpeg_fdct_float (FAST_FLOAT * data, JSAMPARRAY sample_data, JDIMENSION start_col tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2;
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = tmp10 + tmp11 - 8 * CENTERJSAMPLE; /* phase 3 */
dataptr[4] = tmp10 - tmp11;
diff --git a/plugins/AdvaImg/src/LibJPEG/jfdctfst.c b/plugins/AdvaImg/src/LibJPEG/jfdctfst.c index 82b92317b0..173d0d6fce 100644 --- a/plugins/AdvaImg/src/LibJPEG/jfdctfst.c +++ b/plugins/AdvaImg/src/LibJPEG/jfdctfst.c @@ -2,7 +2,7 @@ * jfdctfst.c
*
* Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2003-2009 by Guido Vollbeding.
+ * Modified 2003-2015 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.
*
@@ -109,6 +109,8 @@ /*
* Perform the forward DCT on one block of samples.
+ *
+ * cK represents cos(K*pi/16).
*/
GLOBAL(void)
@@ -145,7 +147,7 @@ jpeg_fdct_ifast (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2;
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = tmp10 + tmp11 - 8 * CENTERJSAMPLE; /* phase 3 */
dataptr[4] = tmp10 - tmp11;
diff --git a/plugins/AdvaImg/src/LibJPEG/jfdctint.c b/plugins/AdvaImg/src/LibJPEG/jfdctint.c index 4dd7cb9e6c..6700fdde2f 100644 --- a/plugins/AdvaImg/src/LibJPEG/jfdctint.c +++ b/plugins/AdvaImg/src/LibJPEG/jfdctint.c @@ -2,7 +2,7 @@ * jfdctint.c
*
* Copyright (C) 1991-1996, Thomas G. Lane.
- * Modification developed 2003-2013 by Guido Vollbeding.
+ * Modification developed 2003-2015 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.
*
@@ -194,7 +194,7 @@ jpeg_fdct_islow (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[5]);
tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[4]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM) ((tmp10 + tmp11 - 8 * CENTERJSAMPLE) << PASS1_BITS);
dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);
@@ -367,7 +367,7 @@ jpeg_fdct_7x7 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp12 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[4]);
z1 = tmp0 + tmp2;
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((z1 + tmp1 + tmp3 - 7 * CENTERJSAMPLE) << PASS1_BITS);
tmp3 += tmp3;
@@ -503,7 +503,7 @@ jpeg_fdct_6x6 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[4]);
tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[3]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp10 + tmp11 - 6 * CENTERJSAMPLE) << PASS1_BITS);
dataptr[2] = (DCTELEM)
@@ -618,7 +618,7 @@ jpeg_fdct_5x5 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[4]);
tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[3]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp10 + tmp2 - 5 * CENTERJSAMPLE) << (PASS1_BITS+1));
tmp11 = MULTIPLY(tmp11, FIX(0.790569415)); /* (c2+c4)/2 */
@@ -724,7 +724,7 @@ jpeg_fdct_4x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]);
tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp0 + tmp1 - 4 * CENTERJSAMPLE) << (PASS1_BITS+2));
dataptr[2] = (DCTELEM) ((tmp0 - tmp1) << (PASS1_BITS+2));
@@ -818,7 +818,7 @@ jpeg_fdct_3x3 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp2 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[2]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp0 + tmp1 - 3 * CENTERJSAMPLE) << (PASS1_BITS+2));
dataptr[2] = (DCTELEM)
@@ -876,7 +876,7 @@ jpeg_fdct_3x3 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) GLOBAL(void)
jpeg_fdct_2x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
{
- INT32 tmp0, tmp1, tmp2, tmp3;
+ DCTELEM tmp0, tmp1, tmp2, tmp3;
JSAMPROW elemptr;
/* Pre-zero output coefficient block. */
@@ -904,13 +904,13 @@ jpeg_fdct_2x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) */
/* Column 0 */
- /* Apply unsigned->signed conversion */
- data[DCTSIZE*0] = (DCTELEM) ((tmp0 + tmp2 - 4 * CENTERJSAMPLE) << 4);
- data[DCTSIZE*1] = (DCTELEM) ((tmp0 - tmp2) << 4);
+ /* Apply unsigned->signed conversion. */
+ data[DCTSIZE*0] = (tmp0 + tmp2 - 4 * CENTERJSAMPLE) << 4;
+ data[DCTSIZE*1] = (tmp0 - tmp2) << 4;
/* Column 1 */
- data[DCTSIZE*0+1] = (DCTELEM) ((tmp1 + tmp3) << 4);
- data[DCTSIZE*1+1] = (DCTELEM) ((tmp1 - tmp3) << 4);
+ data[DCTSIZE*0+1] = (tmp1 + tmp3) << 4;
+ data[DCTSIZE*1+1] = (tmp1 - tmp3) << 4;
}
@@ -921,14 +921,17 @@ jpeg_fdct_2x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) GLOBAL(void)
jpeg_fdct_1x1 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
{
+ DCTELEM dcval;
+
/* Pre-zero output coefficient block. */
MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
+ dcval = GETJSAMPLE(sample_data[0][start_col]);
+
/* We leave the result scaled up by an overall factor of 8. */
/* We must also scale the output by (8/1)**2 = 2**6. */
- /* Apply unsigned->signed conversion */
- data[0] = (DCTELEM)
- ((GETJSAMPLE(sample_data[0][start_col]) - CENTERJSAMPLE) << 6);
+ /* Apply unsigned->signed conversion. */
+ data[0] = (dcval - CENTERJSAMPLE) << 6;
}
@@ -976,7 +979,7 @@ jpeg_fdct_9x9 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) z1 = tmp0 + tmp2 + tmp3;
z2 = tmp1 + tmp4;
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM) ((z1 + z2 - 9 * CENTERJSAMPLE) << 1);
dataptr[6] = (DCTELEM)
DESCALE(MULTIPLY(z1 - z2 - z2, FIX(0.707106781)), /* c6 */
@@ -1130,7 +1133,7 @@ jpeg_fdct_10x10 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[6]);
tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[5]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp10 + tmp11 + tmp12 - 10 * CENTERJSAMPLE) << 1);
tmp12 += tmp12;
@@ -1291,7 +1294,7 @@ jpeg_fdct_11x11 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp13 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[7]);
tmp14 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[6]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp0 + tmp1 + tmp2 + tmp3 + tmp4 + tmp5 - 11 * CENTERJSAMPLE) << 1);
tmp5 += tmp5;
@@ -1480,7 +1483,7 @@ jpeg_fdct_12x12 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[7]);
tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[6]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM) (tmp10 + tmp11 + tmp12 - 12 * CENTERJSAMPLE);
dataptr[6] = (DCTELEM) (tmp13 - tmp14 - tmp15);
dataptr[4] = (DCTELEM)
@@ -1641,7 +1644,7 @@ jpeg_fdct_13x13 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp14 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[8]);
tmp15 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[7]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
(tmp0 + tmp1 + tmp2 + tmp3 + tmp4 + tmp5 + tmp6 - 13 * CENTERJSAMPLE);
tmp6 += tmp6;
@@ -1848,7 +1851,7 @@ jpeg_fdct_14x14 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[8]);
tmp6 = GETJSAMPLE(elemptr[6]) - GETJSAMPLE(elemptr[7]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
(tmp10 + tmp11 + tmp12 + tmp13 - 14 * CENTERJSAMPLE);
tmp13 += tmp13;
@@ -2047,7 +2050,7 @@ jpeg_fdct_15x15 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) z1 = tmp0 + tmp4 + tmp5;
z2 = tmp1 + tmp3 + tmp6;
z3 = tmp2 + tmp7;
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM) (z1 + z2 + z3 - 15 * CENTERJSAMPLE);
z3 += z3;
dataptr[6] = (DCTELEM)
@@ -2234,7 +2237,7 @@ jpeg_fdct_16x16 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp6 = GETJSAMPLE(elemptr[6]) - GETJSAMPLE(elemptr[9]);
tmp7 = GETJSAMPLE(elemptr[7]) - GETJSAMPLE(elemptr[8]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp10 + tmp11 + tmp12 + tmp13 - 16 * CENTERJSAMPLE) << PASS1_BITS);
dataptr[4] = (DCTELEM)
@@ -2443,7 +2446,7 @@ jpeg_fdct_16x8 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp6 = GETJSAMPLE(elemptr[6]) - GETJSAMPLE(elemptr[9]);
tmp7 = GETJSAMPLE(elemptr[7]) - GETJSAMPLE(elemptr[8]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp10 + tmp11 + tmp12 + tmp13 - 16 * CENTERJSAMPLE) << PASS1_BITS);
dataptr[4] = (DCTELEM)
@@ -2624,7 +2627,7 @@ jpeg_fdct_14x7 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[8]);
tmp6 = GETJSAMPLE(elemptr[6]) - GETJSAMPLE(elemptr[7]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp10 + tmp11 + tmp12 + tmp13 - 14 * CENTERJSAMPLE) << PASS1_BITS);
tmp13 += tmp13;
@@ -2786,7 +2789,7 @@ jpeg_fdct_12x6 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[7]);
tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[6]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp10 + tmp11 + tmp12 - 12 * CENTERJSAMPLE) << PASS1_BITS);
dataptr[6] = (DCTELEM) ((tmp13 - tmp14 - tmp15) << PASS1_BITS);
@@ -2922,7 +2925,7 @@ jpeg_fdct_10x5 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[6]);
tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[5]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp10 + tmp11 + tmp12 - 10 * CENTERJSAMPLE) << PASS1_BITS);
tmp12 += tmp12;
@@ -3057,7 +3060,7 @@ jpeg_fdct_8x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[5]);
tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[4]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp10 + tmp11 - 8 * CENTERJSAMPLE) << (PASS1_BITS+1));
dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << (PASS1_BITS+1));
@@ -3192,7 +3195,7 @@ jpeg_fdct_6x3 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[4]);
tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[3]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp10 + tmp11 - 6 * CENTERJSAMPLE) << (PASS1_BITS+1));
dataptr[2] = (DCTELEM)
@@ -3288,7 +3291,7 @@ jpeg_fdct_4x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]);
tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp0 + tmp1 - 4 * CENTERJSAMPLE) << (PASS1_BITS+3));
dataptr[2] = (DCTELEM) ((tmp0 - tmp1) << (PASS1_BITS+3));
@@ -3342,7 +3345,7 @@ jpeg_fdct_4x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) GLOBAL(void)
jpeg_fdct_2x1 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
{
- INT32 tmp0, tmp1;
+ DCTELEM tmp0, tmp1;
JSAMPROW elemptr;
/* Pre-zero output coefficient block. */
@@ -3359,12 +3362,12 @@ jpeg_fdct_2x1 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) /* Even part */
- /* Apply unsigned->signed conversion */
- data[0] = (DCTELEM) ((tmp0 + tmp1 - 2 * CENTERJSAMPLE) << 5);
+ /* Apply unsigned->signed conversion. */
+ data[0] = (tmp0 + tmp1 - 2 * CENTERJSAMPLE) << 5;
/* Odd part */
- data[1] = (DCTELEM) ((tmp0 - tmp1) << 5);
+ data[1] = (tmp0 - tmp1) << 5;
}
@@ -3417,7 +3420,7 @@ jpeg_fdct_8x16 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[5]);
tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[4]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM) ((tmp10 + tmp11 - 8 * CENTERJSAMPLE) << PASS1_BITS);
dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);
@@ -3607,7 +3610,7 @@ jpeg_fdct_7x14 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp12 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[4]);
z1 = tmp0 + tmp2;
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((z1 + tmp1 + tmp3 - 7 * CENTERJSAMPLE) << PASS1_BITS);
tmp3 += tmp3;
@@ -3789,7 +3792,7 @@ jpeg_fdct_6x12 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[4]);
tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[3]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp10 + tmp11 - 6 * CENTERJSAMPLE) << PASS1_BITS);
dataptr[2] = (DCTELEM)
@@ -3938,7 +3941,7 @@ jpeg_fdct_5x10 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[4]);
tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[3]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp10 + tmp2 - 5 * CENTERJSAMPLE) << PASS1_BITS);
tmp11 = MULTIPLY(tmp11, FIX(0.790569415)); /* (c2+c4)/2 */
@@ -4081,7 +4084,7 @@ jpeg_fdct_4x8 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]);
tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp0 + tmp1 - 4 * CENTERJSAMPLE) << (PASS1_BITS+1));
dataptr[2] = (DCTELEM) ((tmp0 - tmp1) << (PASS1_BITS+1));
@@ -4220,7 +4223,7 @@ jpeg_fdct_3x6 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp2 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[2]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp0 + tmp1 - 3 * CENTERJSAMPLE) << (PASS1_BITS+1));
dataptr[2] = (DCTELEM)
@@ -4321,7 +4324,7 @@ jpeg_fdct_2x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp0 = GETJSAMPLE(elemptr[0]);
tmp1 = GETJSAMPLE(elemptr[1]);
- /* Apply unsigned->signed conversion */
+ /* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM) ((tmp0 + tmp1 - 2 * CENTERJSAMPLE) << 3);
/* Odd part */
@@ -4377,7 +4380,7 @@ jpeg_fdct_2x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) GLOBAL(void)
jpeg_fdct_1x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
{
- INT32 tmp0, tmp1;
+ DCTELEM tmp0, tmp1;
/* Pre-zero output coefficient block. */
MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
@@ -4394,12 +4397,12 @@ jpeg_fdct_1x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col) tmp0 = GETJSAMPLE(sample_data[0][start_col]);
tmp1 = GETJSAMPLE(sample_data[1][start_col]);
- /* Apply unsigned->signed conversion */
- data[DCTSIZE*0] = (DCTELEM) ((tmp0 + tmp1 - 2 * CENTERJSAMPLE) << 5);
+ /* Apply unsigned->signed conversion. */
+ data[DCTSIZE*0] = (tmp0 + tmp1 - 2 * CENTERJSAMPLE) << 5;
/* Odd part */
- data[DCTSIZE*1] = (DCTELEM) ((tmp0 - tmp1) << 5);
+ data[DCTSIZE*1] = (tmp0 - tmp1) << 5;
}
#endif /* DCT_SCALING_SUPPORTED */
diff --git a/plugins/AdvaImg/src/LibJPEG/jidctflt.c b/plugins/AdvaImg/src/LibJPEG/jidctflt.c index f399600c89..ce2499f299 100644 --- a/plugins/AdvaImg/src/LibJPEG/jidctflt.c +++ b/plugins/AdvaImg/src/LibJPEG/jidctflt.c @@ -2,7 +2,7 @@ * jidctflt.c
*
* Copyright (C) 1994-1998, Thomas G. Lane.
- * Modified 2010 by Guido Vollbeding.
+ * Modified 2010-2015 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.
*
@@ -63,6 +63,8 @@ /*
* Perform dequantization and inverse DCT on one block of coefficients.
+ *
+ * cK represents cos(K*pi/16).
*/
GLOBAL(void)
@@ -77,7 +79,7 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, FLOAT_MULT_TYPE * quantptr;
FAST_FLOAT * wsptr;
JSAMPROW outptr;
- JSAMPLE *range_limit = cinfo->sample_range_limit;
+ JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */
@@ -95,14 +97,14 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, * With typical images and quantization tables, half or more of the
* column DCT calculations can be simplified this way.
*/
-
+
if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
inptr[DCTSIZE*7] == 0) {
/* AC terms all zero */
FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
-
+
wsptr[DCTSIZE*0] = dcval;
wsptr[DCTSIZE*1] = dcval;
wsptr[DCTSIZE*2] = dcval;
@@ -111,13 +113,13 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, wsptr[DCTSIZE*5] = dcval;
wsptr[DCTSIZE*6] = dcval;
wsptr[DCTSIZE*7] = dcval;
-
+
inptr++; /* advance pointers to next column */
quantptr++;
wsptr++;
continue;
}
-
+
/* Even part */
tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
@@ -135,7 +137,7 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, tmp3 = tmp10 - tmp13;
tmp1 = tmp11 + tmp12;
tmp2 = tmp11 - tmp12;
-
+
/* Odd part */
tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
@@ -172,7 +174,7 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, quantptr++;
wsptr++;
}
-
+
/* Pass 2: process rows from work array, store into output array. */
wsptr = workspace;
@@ -183,16 +185,17 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, * the simplification applies less often (typically 5% to 10% of the time).
* And testing floats for zero is relatively expensive, so we don't bother.
*/
-
+
/* Even part */
- /* Apply signed->unsigned and prepare float->int conversion */
- z5 = wsptr[0] + ((FAST_FLOAT) CENTERJSAMPLE + (FAST_FLOAT) 0.5);
+ /* Prepare range-limit and float->int conversion */
+ z5 = wsptr[0] + (((FAST_FLOAT) RANGE_CENTER) + ((FAST_FLOAT) 0.5));
tmp10 = z5 + wsptr[4];
tmp11 = z5 - wsptr[4];
tmp13 = wsptr[2] + wsptr[6];
- tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13;
+ tmp12 = (wsptr[2] - wsptr[6]) *
+ ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */
tmp0 = tmp10 + tmp13;
tmp3 = tmp10 - tmp13;
@@ -206,28 +209,28 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, z11 = wsptr[1] + wsptr[7];
z12 = wsptr[1] - wsptr[7];
- tmp7 = z11 + z13;
- tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562);
+ tmp7 = z11 + z13; /* phase 5 */
+ tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */
z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */
tmp10 = z5 - z12 * ((FAST_FLOAT) 1.082392200); /* 2*(c2-c6) */
tmp12 = z5 - z10 * ((FAST_FLOAT) 2.613125930); /* 2*(c2+c6) */
- tmp6 = tmp12 - tmp7;
+ tmp6 = tmp12 - tmp7; /* phase 2 */
tmp5 = tmp11 - tmp6;
tmp4 = tmp10 - tmp5;
/* Final output stage: float->int conversion and range-limit */
- outptr[0] = range_limit[((int) (tmp0 + tmp7)) & RANGE_MASK];
- outptr[7] = range_limit[((int) (tmp0 - tmp7)) & RANGE_MASK];
- outptr[1] = range_limit[((int) (tmp1 + tmp6)) & RANGE_MASK];
- outptr[6] = range_limit[((int) (tmp1 - tmp6)) & RANGE_MASK];
- outptr[2] = range_limit[((int) (tmp2 + tmp5)) & RANGE_MASK];
- outptr[5] = range_limit[((int) (tmp2 - tmp5)) & RANGE_MASK];
- outptr[3] = range_limit[((int) (tmp3 + tmp4)) & RANGE_MASK];
- outptr[4] = range_limit[((int) (tmp3 - tmp4)) & RANGE_MASK];
-
+ outptr[0] = range_limit[(int) (tmp0 + tmp7) & RANGE_MASK];
+ outptr[7] = range_limit[(int) (tmp0 - tmp7) & RANGE_MASK];
+ outptr[1] = range_limit[(int) (tmp1 + tmp6) & RANGE_MASK];
+ outptr[6] = range_limit[(int) (tmp1 - tmp6) & RANGE_MASK];
+ outptr[2] = range_limit[(int) (tmp2 + tmp5) & RANGE_MASK];
+ outptr[5] = range_limit[(int) (tmp2 - tmp5) & RANGE_MASK];
+ outptr[3] = range_limit[(int) (tmp3 + tmp4) & RANGE_MASK];
+ outptr[4] = range_limit[(int) (tmp3 - tmp4) & RANGE_MASK];
+
wsptr += DCTSIZE; /* advance pointer to next row */
}
}
diff --git a/plugins/AdvaImg/src/LibJPEG/jidctfst.c b/plugins/AdvaImg/src/LibJPEG/jidctfst.c index 078b8c444e..0c197ced77 100644 --- a/plugins/AdvaImg/src/LibJPEG/jidctfst.c +++ b/plugins/AdvaImg/src/LibJPEG/jidctfst.c @@ -2,6 +2,7 @@ * jidctfst.c
*
* Copyright (C) 1994-1998, Thomas G. Lane.
+ * Modified 2015 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.
*
@@ -133,35 +134,10 @@ #endif
-/* Like DESCALE, but applies to a DCTELEM and produces an int.
- * We assume that int right shift is unsigned if INT32 right shift is.
- */
-
-#ifdef RIGHT_SHIFT_IS_UNSIGNED
-#define ISHIFT_TEMPS DCTELEM ishift_temp;
-#if BITS_IN_JSAMPLE == 8
-#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */
-#else
-#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */
-#endif
-#define IRIGHT_SHIFT(x,shft) \
- ((ishift_temp = (x)) < 0 ? \
- (ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \
- (ishift_temp >> (shft)))
-#else
-#define ISHIFT_TEMPS
-#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
-#endif
-
-#ifdef USE_ACCURATE_ROUNDING
-#define IDESCALE(x,n) ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n))
-#else
-#define IDESCALE(x,n) ((int) IRIGHT_SHIFT(x, n))
-#endif
-
-
/*
* Perform dequantization and inverse DCT on one block of coefficients.
+ *
+ * cK represents cos(K*pi/16).
*/
GLOBAL(void)
@@ -180,7 +156,7 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, int ctr;
int workspace[DCTSIZE2]; /* buffers data between passes */
SHIFT_TEMPS /* for DESCALE */
- ISHIFT_TEMPS /* for IDESCALE */
+ ISHIFT_TEMPS /* for IRIGHT_SHIFT */
/* Pass 1: process columns from input, store into work array. */
@@ -253,12 +229,12 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
- tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
- tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */
+ tmp10 = z5 - MULTIPLY(z12, FIX_1_082392200); /* 2*(c2-c6) */
+ tmp12 = z5 - MULTIPLY(z10, FIX_2_613125930); /* 2*(c2+c6) */
tmp6 = tmp12 - tmp7; /* phase 2 */
tmp5 = tmp11 - tmp6;
- tmp4 = tmp10 + tmp5;
+ tmp4 = tmp10 - tmp5;
wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7);
wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7);
@@ -266,21 +242,28 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6);
wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5);
wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5);
- wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4);
- wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4);
+ wsptr[DCTSIZE*3] = (int) (tmp3 + tmp4);
+ wsptr[DCTSIZE*4] = (int) (tmp3 - tmp4);
inptr++; /* advance pointers to next column */
quantptr++;
wsptr++;
}
- /* Pass 2: process rows from work array, store into output array. */
- /* Note that we must descale the results by a factor of 8 == 2**3, */
- /* and also undo the PASS1_BITS scaling. */
+ /* Pass 2: process rows from work array, store into output array.
+ * Note that we must descale the results by a factor of 8 == 2**3,
+ * and also undo the PASS1_BITS scaling.
+ */
wsptr = workspace;
for (ctr = 0; ctr < DCTSIZE; ctr++) {
outptr = output_buf[ctr] + output_col;
+
+ /* Add range center and fudge factor for final descale and range-limit. */
+ z5 = (DCTELEM) wsptr[0] +
+ ((((DCTELEM) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (1 << (PASS1_BITS+2)));
+
/* Rows of zeroes can be exploited in the same way as we did with columns.
* However, the column calculation has created many nonzero AC terms, so
* the simplification applies less often (typically 5% to 10% of the time).
@@ -293,7 +276,7 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
/* AC terms all zero */
- JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3)
+ JSAMPLE dcval = range_limit[(int) IRIGHT_SHIFT(z5, PASS1_BITS+3)
& RANGE_MASK];
outptr[0] = dcval;
@@ -312,12 +295,12 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]);
- tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]);
+ tmp10 = z5 + (DCTELEM) wsptr[4];
+ tmp11 = z5 - (DCTELEM) wsptr[4];
- tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]);
- tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562)
- - tmp13;
+ tmp13 = (DCTELEM) wsptr[2] + (DCTELEM) wsptr[6];
+ tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6],
+ FIX_1_414213562) - tmp13; /* 2*c4 */
tmp0 = tmp10 + tmp13;
tmp3 = tmp10 - tmp13;
@@ -335,30 +318,30 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
- tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
- tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */
+ tmp10 = z5 - MULTIPLY(z12, FIX_1_082392200); /* 2*(c2-c6) */
+ tmp12 = z5 - MULTIPLY(z10, FIX_2_613125930); /* 2*(c2+c6) */
tmp6 = tmp12 - tmp7; /* phase 2 */
tmp5 = tmp11 - tmp6;
- tmp4 = tmp10 + tmp5;
+ tmp4 = tmp10 - tmp5;
/* Final output stage: scale down by a factor of 8 and range-limit */
- outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3)
+ outptr[0] = range_limit[(int) IRIGHT_SHIFT(tmp0 + tmp7, PASS1_BITS+3)
& RANGE_MASK];
- outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3)
+ outptr[7] = range_limit[(int) IRIGHT_SHIFT(tmp0 - tmp7, PASS1_BITS+3)
& RANGE_MASK];
- outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3)
+ outptr[1] = range_limit[(int) IRIGHT_SHIFT(tmp1 + tmp6, PASS1_BITS+3)
& RANGE_MASK];
- outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3)
+ outptr[6] = range_limit[(int) IRIGHT_SHIFT(tmp1 - tmp6, PASS1_BITS+3)
& RANGE_MASK];
- outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3)
+ outptr[2] = range_limit[(int) IRIGHT_SHIFT(tmp2 + tmp5, PASS1_BITS+3)
& RANGE_MASK];
- outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3)
+ outptr[5] = range_limit[(int) IRIGHT_SHIFT(tmp2 - tmp5, PASS1_BITS+3)
& RANGE_MASK];
- outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3)
+ outptr[3] = range_limit[(int) IRIGHT_SHIFT(tmp3 + tmp4, PASS1_BITS+3)
& RANGE_MASK];
- outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3)
+ outptr[4] = range_limit[(int) IRIGHT_SHIFT(tmp3 - tmp4, PASS1_BITS+3)
& RANGE_MASK];
wsptr += DCTSIZE; /* advance pointer to next row */
diff --git a/plugins/AdvaImg/src/LibJPEG/jidctint.c b/plugins/AdvaImg/src/LibJPEG/jidctint.c index 6be271c6e7..2d7ecdae91 100644 --- a/plugins/AdvaImg/src/LibJPEG/jidctint.c +++ b/plugins/AdvaImg/src/LibJPEG/jidctint.c @@ -2,7 +2,7 @@ * jidctint.c
*
* Copyright (C) 1991-1998, Thomas G. Lane.
- * Modification developed 2002-2013 by Guido Vollbeding.
+ * Modification developed 2002-2015 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.
*
@@ -230,13 +230,6 @@ jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, * The rotator is c(-6).
*/
- z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
- z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
-
- z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */
- tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */
- tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */
-
z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
z2 <<= CONST_BITS;
@@ -247,6 +240,13 @@ jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, tmp0 = z2 + z3;
tmp1 = z2 - z3;
+ z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
+ z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
+
+ z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */
+ tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */
+ tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */
+
tmp10 = tmp0 + tmp2;
tmp13 = tmp0 - tmp2;
tmp11 = tmp1 + tmp3;
@@ -306,6 +306,12 @@ jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, wsptr = workspace;
for (ctr = 0; ctr < DCTSIZE; ctr++) {
outptr = output_buf[ctr] + output_col;
+
+ /* Add range center and fudge factor for final descale and range-limit. */
+ z2 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
+
/* Rows of zeroes can be exploited in the same way as we did with columns.
* However, the column calculation has created many nonzero AC terms, so
* the simplification applies less often (typically 5% to 10% of the time).
@@ -318,7 +324,7 @@ jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
/* AC terms all zero */
- JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3)
+ JSAMPLE dcval = range_limit[(int) RIGHT_SHIFT(z2, PASS1_BITS+3)
& RANGE_MASK];
outptr[0] = dcval;
@@ -339,6 +345,11 @@ jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, * The rotator is c(-6).
*/
+ z3 = (INT32) wsptr[4];
+
+ tmp0 = (z2 + z3) << CONST_BITS;
+ tmp1 = (z2 - z3) << CONST_BITS;
+
z2 = (INT32) wsptr[2];
z3 = (INT32) wsptr[6];
@@ -346,13 +357,6 @@ jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */
tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */
- /* Add fudge factor here for final descale. */
- z2 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
- z3 = (INT32) wsptr[4];
-
- tmp0 = (z2 + z3) << CONST_BITS;
- tmp1 = (z2 - z3) << CONST_BITS;
-
tmp10 = tmp0 + tmp2;
tmp13 = tmp0 - tmp2;
tmp11 = tmp1 + tmp3;
@@ -508,8 +512,10 @@ jpeg_idct_7x7 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp13 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp13 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp13 <<= CONST_BITS;
z1 = (INT32) wsptr[2];
@@ -644,8 +650,10 @@ jpeg_idct_6x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp0 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp0 <<= CONST_BITS;
tmp2 = (INT32) wsptr[4];
tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */
@@ -763,8 +771,10 @@ jpeg_idct_5x5 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp12 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp12 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp12 <<= CONST_BITS;
tmp0 = (INT32) wsptr[2];
tmp1 = (INT32) wsptr[4];
@@ -875,8 +885,10 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp0 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp2 = (INT32) wsptr[2];
tmp10 = (tmp0 + tmp2) << CONST_BITS;
@@ -972,8 +984,10 @@ jpeg_idct_3x3 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp0 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp0 <<= CONST_BITS;
tmp2 = (INT32) wsptr[2];
tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */
@@ -1014,11 +1028,11 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
{
- INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
+ DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
ISLOW_MULT_TYPE * quantptr;
JSAMPROW outptr;
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- SHIFT_TEMPS
+ ISHIFT_TEMPS
/* Pass 1: process columns from input. */
@@ -1027,8 +1041,8 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Column 0 */
tmp4 = DEQUANTIZE(coef_block[DCTSIZE*0], quantptr[DCTSIZE*0]);
tmp5 = DEQUANTIZE(coef_block[DCTSIZE*1], quantptr[DCTSIZE*1]);
- /* Add fudge factor here for final descale. */
- tmp4 += ONE << 2;
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp4 += (((DCTELEM) RANGE_CENTER) << 3) + (1 << 2);
tmp0 = tmp4 + tmp5;
tmp2 = tmp4 - tmp5;
@@ -1045,14 +1059,14 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Row 0 */
outptr = output_buf[0] + output_col;
- outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp0 + tmp1, 3) & RANGE_MASK];
- outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp0 - tmp1, 3) & RANGE_MASK];
+ outptr[0] = range_limit[(int) IRIGHT_SHIFT(tmp0 + tmp1, 3) & RANGE_MASK];
+ outptr[1] = range_limit[(int) IRIGHT_SHIFT(tmp0 - tmp1, 3) & RANGE_MASK];
/* Row 1 */
outptr = output_buf[1] + output_col;
- outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp2 + tmp3, 3) & RANGE_MASK];
- outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp2 - tmp3, 3) & RANGE_MASK];
+ outptr[0] = range_limit[(int) IRIGHT_SHIFT(tmp2 + tmp3, 3) & RANGE_MASK];
+ outptr[1] = range_limit[(int) IRIGHT_SHIFT(tmp2 - tmp3, 3) & RANGE_MASK];
}
@@ -1069,17 +1083,21 @@ jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
{
- int dcval;
+ DCTELEM dcval;
ISLOW_MULT_TYPE * quantptr;
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- SHIFT_TEMPS
+ ISHIFT_TEMPS
/* 1x1 is trivial: just take the DC coefficient divided by 8. */
+
quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
+
dcval = DEQUANTIZE(coef_block[0], quantptr[0]);
- dcval = (int) DESCALE((INT32) dcval, 3);
+ /* Add range center and fudge factor for descale and range-limit. */
+ dcval += (((DCTELEM) RANGE_CENTER) << 3) + (1 << 2);
- output_buf[0][output_col] = range_limit[dcval & RANGE_MASK];
+ output_buf[0][output_col] =
+ range_limit[(int) IRIGHT_SHIFT(dcval, 3) & RANGE_MASK];
}
@@ -1178,8 +1196,10 @@ jpeg_idct_9x9 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp0 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp0 <<= CONST_BITS;
z1 = (INT32) wsptr[2];
@@ -1361,8 +1381,10 @@ jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- z3 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ z3 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
z3 <<= CONST_BITS;
z4 = (INT32) wsptr[4];
z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */
@@ -1554,8 +1576,10 @@ jpeg_idct_11x11 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp10 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp10 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp10 <<= CONST_BITS;
z1 = (INT32) wsptr[2];
@@ -1758,8 +1782,10 @@ jpeg_idct_12x12 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- z3 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ z3 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
z3 <<= CONST_BITS;
z4 = (INT32) wsptr[4];
@@ -1979,8 +2005,10 @@ jpeg_idct_13x13 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- z1 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ z1 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
z1 <<= CONST_BITS;
z2 = (INT32) wsptr[2];
@@ -2206,8 +2234,10 @@ jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- z1 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ z1 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
z1 <<= CONST_BITS;
z4 = (INT32) wsptr[4];
z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */
@@ -2438,8 +2468,10 @@ jpeg_idct_15x15 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- z1 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ z1 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
z1 <<= CONST_BITS;
z2 = (INT32) wsptr[2];
@@ -2689,8 +2721,10 @@ jpeg_idct_16x16 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp0 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp0 <<= CONST_BITS;
z1 = (INT32) wsptr[4];
@@ -2964,8 +2998,10 @@ jpeg_idct_16x8 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp0 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp0 <<= CONST_BITS;
z1 = (INT32) wsptr[4];
@@ -3182,8 +3218,10 @@ jpeg_idct_14x7 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- z1 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ z1 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
z1 <<= CONST_BITS;
z4 = (INT32) wsptr[4];
z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */
@@ -3366,8 +3404,10 @@ jpeg_idct_12x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- z3 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ z3 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
z3 <<= CONST_BITS;
z4 = (INT32) wsptr[4];
@@ -3542,8 +3582,10 @@ jpeg_idct_10x5 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- z3 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ z3 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
z3 <<= CONST_BITS;
z4 = (INT32) wsptr[4];
z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */
@@ -3707,6 +3749,15 @@ jpeg_idct_8x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, * The rotator is c(-6).
*/
+ /* Add range center and fudge factor for final descale and range-limit. */
+ z2 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
+ z3 = (INT32) wsptr[4];
+
+ tmp0 = (z2 + z3) << CONST_BITS;
+ tmp1 = (z2 - z3) << CONST_BITS;
+
z2 = (INT32) wsptr[2];
z3 = (INT32) wsptr[6];
@@ -3714,13 +3765,6 @@ jpeg_idct_8x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */
tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */
- /* Add fudge factor here for final descale. */
- z2 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
- z3 = (INT32) wsptr[4];
-
- tmp0 = (z2 + z3) << CONST_BITS;
- tmp1 = (z2 - z3) << CONST_BITS;
-
tmp10 = tmp0 + tmp2;
tmp13 = tmp0 - tmp2;
tmp11 = tmp1 + tmp3;
@@ -3852,8 +3896,10 @@ jpeg_idct_6x3 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp0 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp0 <<= CONST_BITS;
tmp2 = (INT32) wsptr[4];
tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */
@@ -3954,8 +4000,8 @@ jpeg_idct_4x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp0 = wsptr[0] + (ONE << 2);
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp0 = wsptr[0] + ((((INT32) RANGE_CENTER) << 3) + (ONE << 2));
tmp2 = wsptr[2];
tmp10 = (tmp0 + tmp2) << CONST_BITS;
@@ -4003,11 +4049,11 @@ jpeg_idct_2x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
{
- INT32 tmp0, tmp1;
+ DCTELEM tmp0, tmp1;
ISLOW_MULT_TYPE * quantptr;
JSAMPROW outptr;
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- SHIFT_TEMPS
+ ISHIFT_TEMPS
/* Pass 1: empty. */
@@ -4019,8 +4065,8 @@ jpeg_idct_2x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
tmp0 = DEQUANTIZE(coef_block[0], quantptr[0]);
- /* Add fudge factor here for final descale. */
- tmp0 += ONE << 2;
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp0 += (((DCTELEM) RANGE_CENTER) << 3) + (1 << 2);
/* Odd part */
@@ -4028,8 +4074,8 @@ jpeg_idct_2x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Final output stage */
- outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp0 + tmp1, 3) & RANGE_MASK];
- outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp0 - tmp1, 3) & RANGE_MASK];
+ outptr[0] = range_limit[(int) IRIGHT_SHIFT(tmp0 + tmp1, 3) & RANGE_MASK];
+ outptr[1] = range_limit[(int) IRIGHT_SHIFT(tmp0 - tmp1, 3) & RANGE_MASK];
}
@@ -4174,6 +4220,15 @@ jpeg_idct_8x16 (j_decompress_ptr cinfo, jpeg_component_info * compptr, * The rotator is c(-6).
*/
+ /* Add range center and fudge factor for final descale and range-limit. */
+ z2 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
+ z3 = (INT32) wsptr[4];
+
+ tmp0 = (z2 + z3) << CONST_BITS;
+ tmp1 = (z2 - z3) << CONST_BITS;
+
z2 = (INT32) wsptr[2];
z3 = (INT32) wsptr[6];
@@ -4181,13 +4236,6 @@ jpeg_idct_8x16 (j_decompress_ptr cinfo, jpeg_component_info * compptr, tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */
tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */
- /* Add fudge factor here for final descale. */
- z2 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
- z3 = (INT32) wsptr[4];
-
- tmp0 = (z2 + z3) << CONST_BITS;
- tmp1 = (z2 - z3) << CONST_BITS;
-
tmp10 = tmp0 + tmp2;
tmp13 = tmp0 - tmp2;
tmp11 = tmp1 + tmp3;
@@ -4377,8 +4425,10 @@ jpeg_idct_7x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp23 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp23 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp23 <<= CONST_BITS;
z1 = (INT32) wsptr[2];
@@ -4558,8 +4608,10 @@ jpeg_idct_6x12 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp10 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp10 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp10 <<= CONST_BITS;
tmp12 = (INT32) wsptr[4];
tmp20 = MULTIPLY(tmp12, FIX(0.707106781)); /* c4 */
@@ -4716,8 +4768,10 @@ jpeg_idct_5x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp12 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp12 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp12 <<= CONST_BITS;
tmp13 = (INT32) wsptr[2];
tmp14 = (INT32) wsptr[4];
@@ -4908,8 +4962,10 @@ jpeg_idct_4x8 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp0 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp2 = (INT32) wsptr[2];
tmp10 = (tmp0 + tmp2) << CONST_BITS;
@@ -5021,8 +5077,10 @@ jpeg_idct_3x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp0 = (INT32) wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) +
+ (ONE << (PASS1_BITS+2)));
tmp0 <<= CONST_BITS;
tmp2 = (INT32) wsptr[2];
tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */
@@ -5117,8 +5175,10 @@ jpeg_idct_2x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Even part */
- /* Add fudge factor here for final descale. */
- tmp10 = wsptr[0] + (ONE << (CONST_BITS+2));
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp10 = wsptr[0] +
+ ((((INT32) RANGE_CENTER) << (CONST_BITS+3)) +
+ (ONE << (CONST_BITS+2)));
/* Odd part */
@@ -5148,20 +5208,20 @@ jpeg_idct_1x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
{
- INT32 tmp0, tmp1;
+ DCTELEM tmp0, tmp1;
ISLOW_MULT_TYPE * quantptr;
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
- SHIFT_TEMPS
+ ISHIFT_TEMPS
/* Process 1 column from input, store into output array. */
quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
/* Even part */
-
+
tmp0 = DEQUANTIZE(coef_block[DCTSIZE*0], quantptr[DCTSIZE*0]);
- /* Add fudge factor here for final descale. */
- tmp0 += ONE << 2;
+ /* Add range center and fudge factor for final descale and range-limit. */
+ tmp0 += (((DCTELEM) RANGE_CENTER) << 3) + (1 << 2);
/* Odd part */
@@ -5169,10 +5229,10 @@ jpeg_idct_1x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, /* Final output stage */
- output_buf[0][output_col] = range_limit[(int) RIGHT_SHIFT(tmp0 + tmp1, 3)
- & RANGE_MASK];
- output_buf[1][output_col] = range_limit[(int) RIGHT_SHIFT(tmp0 - tmp1, 3)
- & RANGE_MASK];
+ output_buf[0][output_col] =
+ range_limit[(int) IRIGHT_SHIFT(tmp0 + tmp1, 3) & RANGE_MASK];
+ output_buf[1][output_col] =
+ range_limit[(int) IRIGHT_SHIFT(tmp0 - tmp1, 3) & RANGE_MASK];
}
#endif /* IDCT_SCALING_SUPPORTED */
diff --git a/plugins/AdvaImg/src/LibJPEG/jmorecfg.h b/plugins/AdvaImg/src/LibJPEG/jmorecfg.h index 1f645d7ff4..7407ac79b1 100644 --- a/plugins/AdvaImg/src/LibJPEG/jmorecfg.h +++ b/plugins/AdvaImg/src/LibJPEG/jmorecfg.h @@ -303,7 +303,10 @@ typedef void noreturn_t; * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
*/
-#ifdef HAVE_BOOLEAN
+#ifndef HAVE_BOOLEAN
+#if defined FALSE || defined TRUE || defined QGLOBAL_H
+/* Qt3 defines FALSE and TRUE as "const" variables in qglobal.h */
+typedef int boolean;
#ifndef FALSE /* in case these macros already exist */
#define FALSE 0 /* values of boolean */
#endif
@@ -313,6 +316,7 @@ typedef void noreturn_t; #else
typedef enum { FALSE = 0, TRUE = 1 } boolean;
#endif
+#endif
/*
diff --git a/plugins/AdvaImg/src/LibJPEG/jpeglib.h b/plugins/AdvaImg/src/LibJPEG/jpeglib.h index 8eb0085e9a..20ef353d8a 100644 --- a/plugins/AdvaImg/src/LibJPEG/jpeglib.h +++ b/plugins/AdvaImg/src/LibJPEG/jpeglib.h @@ -2,7 +2,7 @@ * jpeglib.h
*
* Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2002-2013 by Guido Vollbeding.
+ * Modified 2002-2015 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.
*
@@ -39,7 +39,7 @@ extern "C" { #define JPEG_LIB_VERSION 90 /* Compatibility version 9.0 */
#define JPEG_LIB_VERSION_MAJOR 9
-#define JPEG_LIB_VERSION_MINOR 1
+#define JPEG_LIB_VERSION_MINOR 2
/* Various constants determining the sizes of things.
@@ -979,7 +979,7 @@ EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo, unsigned char ** outbuffer,
unsigned long * outsize));
EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo,
- unsigned char * inbuffer,
+ const unsigned char * inbuffer,
unsigned long insize));
/* Default parameter setup for compression */
diff --git a/plugins/AdvaImg/src/LibJPEG/jversion.h b/plugins/AdvaImg/src/LibJPEG/jversion.h index 8bd2b522ce..bb53ffe712 100644 --- a/plugins/AdvaImg/src/LibJPEG/jversion.h +++ b/plugins/AdvaImg/src/LibJPEG/jversion.h @@ -1,7 +1,7 @@ /*
* jversion.h
*
- * Copyright (C) 1991-2014, Thomas G. Lane, Guido Vollbeding.
+ * Copyright (C) 1991-2016, Thomas G. Lane, Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -9,6 +9,6 @@ */
-#define JVERSION "9a 19-Jan-2014"
+#define JVERSION "9b 17-Jan-2016"
-#define JCOPYRIGHT "Copyright (C) 2014, Thomas G. Lane, Guido Vollbeding"
+#define JCOPYRIGHT "Copyright (C) 2016, Thomas G. Lane, Guido Vollbeding"
diff --git a/plugins/AdvaImg/src/LibJPEG/rdjpgcom.c b/plugins/AdvaImg/src/LibJPEG/rdjpgcom.c index 3d72e38142..ab09b443ff 100644 --- a/plugins/AdvaImg/src/LibJPEG/rdjpgcom.c +++ b/plugins/AdvaImg/src/LibJPEG/rdjpgcom.c @@ -228,6 +228,11 @@ process_COM (int raw) int ch;
int lastch = 0;
+ /* Bill Allombert: set locale properly for isprint */
+#ifdef HAVE_LOCALE_H
+ setlocale(LC_CTYPE, "");
+#endif
+
/* Get the marker parameter length count */
length = read_2_bytes();
/* Length includes itself, so must be at least 2 */
@@ -260,6 +265,11 @@ process_COM (int raw) length--;
}
printf("\n");
+
+ /* Bill Allombert: revert to C locale */
+#ifdef HAVE_LOCALE_H
+ setlocale(LC_CTYPE, "C");
+#endif
}
diff --git a/plugins/AdvaImg/src/LibJPEG/rdswitch.c b/plugins/AdvaImg/src/LibJPEG/rdswitch.c index 5eebcc1e5c..05753a3020 100644 --- a/plugins/AdvaImg/src/LibJPEG/rdswitch.c +++ b/plugins/AdvaImg/src/LibJPEG/rdswitch.c @@ -2,6 +2,7 @@ * rdswitch.c
*
* Copyright (C) 1991-1996, Thomas G. Lane.
+ * Modified 2003-2015 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.
*
@@ -347,8 +348,9 @@ set_sample_factors (j_compress_ptr cinfo, char *arg) return FALSE;
if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */
return FALSE;
- if (val1 <= 0 || val1 > 4 || val2 <= 0 || val2 > 4) {
- fprintf(stderr, "JPEG sampling factors must be 1..4\n");
+ if (val1 <= 0 || val1 > MAX_SAMP_FACTOR ||
+ val2 <= 0 || val2 > MAX_SAMP_FACTOR) {
+ fprintf(stderr, "JPEG sampling factors must be 1..%d\n", MAX_SAMP_FACTOR);
return FALSE;
}
cinfo->comp_info[ci].h_samp_factor = val1;
diff --git a/plugins/AdvaImg/src/LibJPEG/usage.txt b/plugins/AdvaImg/src/LibJPEG/usage.txt index ca9f7d74a4..fc3aafb3f3 100644 --- a/plugins/AdvaImg/src/LibJPEG/usage.txt +++ b/plugins/AdvaImg/src/LibJPEG/usage.txt @@ -14,7 +14,7 @@ INTRODUCTION These programs implement JPEG image encoding, decoding, and transcoding.
JPEG (pronounced "jay-peg") is a standardized compression method for
-full-color and gray-scale images.
+full-color and grayscale images.
GENERAL USAGE
@@ -47,12 +47,13 @@ or This syntax works on all systems, so it is useful for scripts.
The currently supported image file formats are: PPM (PBMPLUS color format),
-PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster Toolkit
-format). (RLE is supported only if the URT library is available.)
-cjpeg recognizes the input image format automatically, with the exception
-of some Targa-format files. You have to tell djpeg which format to generate.
+PGM (PBMPLUS grayscale format), BMP, Targa, and RLE (Utah Raster Toolkit
+format). (RLE is supported only if the URT library is available, which it
+isn't on most non-Unix systems.) cjpeg recognizes the input image format
+automatically, with the exception of some Targa-format files. You have to
+tell djpeg which format to generate.
-JPEG files are in the defacto standard JFIF file format. There are other,
+JPEG files are in the standard JFIF file format. There are other,
less widely used JPEG-based file formats, but we don't support them.
All switch names may be abbreviated; for example, -grayscale may be written
@@ -292,10 +293,14 @@ The basic command line switches for djpeg are: highest quality output.) Currently, this is equivalent
to "-dct fast -nosmooth -onepass -dither ordered".
- -grayscale Force gray-scale output even if JPEG file is color.
+ -grayscale Force grayscale output even if JPEG file is color.
Useful for viewing on monochrome displays; also,
djpeg runs noticeably faster in this mode.
+ -rgb Force RGB output even if JPEG file is grayscale.
+ This is provided to support applications that don't
+ want to cope with grayscale as a separate case.
+
-scale M/N Scale the output image by a factor M/N. Currently
supported scale factors are M/N with all M from 1 to
16, where N is the source DCT size, which is 8 for
@@ -309,7 +314,7 @@ The basic command line switches for djpeg are: -bmp Select BMP output format (Windows flavor). 8-bit
colormapped format is emitted if -colors or -grayscale
- is specified, or if the JPEG file is gray-scale;
+ is specified, or if the JPEG file is grayscale;
otherwise, 24-bit full-color format is emitted.
-gif Select GIF output format. Since GIF does not support
@@ -319,18 +324,18 @@ The basic command line switches for djpeg are: -os2 Select BMP output format (OS/2 1.x flavor). 8-bit
colormapped format is emitted if -colors or -grayscale
- is specified, or if the JPEG file is gray-scale;
+ is specified, or if the JPEG file is grayscale;
otherwise, 24-bit full-color format is emitted.
-pnm Select PBMPLUS (PPM/PGM) output format (this is the
default format). PGM is emitted if the JPEG file is
- gray-scale or if -grayscale is specified; otherwise
+ grayscale or if -grayscale is specified; otherwise
PPM is emitted.
-rle Select RLE output format. (Requires URT library.)
- -targa Select Targa output format. Gray-scale format is
- emitted if the JPEG file is gray-scale or if
+ -targa Select Targa output format. Grayscale format is
+ emitted if the JPEG file is grayscale or if
-grayscale is specified; otherwise, colormapped format
is emitted if -colors is specified; otherwise, 24-bit
full-color format is emitted.
@@ -372,7 +377,7 @@ Switches for advanced users: The one-pass method is faster and needs less memory,
but it produces a lower-quality image. -onepass is
ignored unless you also say -colors N. Also,
- the one-pass method is always used for gray-scale
+ the one-pass method is always used for grayscale
output (the two-pass method is no improvement then).
-maxmemory N Set limit for amount of memory to use in processing
@@ -479,14 +484,16 @@ jpegtran performs various useful transformations of JPEG files. It can translate the coded representation from one variant of JPEG to another,
for example from baseline JPEG to progressive JPEG or vice versa. It can also
perform some rearrangements of the image data, for example turning an image
-from landscape to portrait format by rotation.
+from landscape to portrait format by rotation. For EXIF files and JPEG files
+containing Exif data, you may prefer to use exiftran instead.
jpegtran works by rearranging the compressed data (DCT coefficients), without
ever fully decoding the image. Therefore, its transformations are lossless:
there is no image degradation at all, which would not be true if you used
djpeg followed by cjpeg to accomplish the same conversion. But by the same
token, jpegtran cannot perform lossy operations such as changing the image
-quality.
+quality. However, while the image data is losslessly transformed, metadata
+can be removed. See the -copy option for specifics.
jpegtran uses a command line syntax similar to cjpeg or djpeg.
On Unix-like systems, you say:
@@ -557,7 +564,8 @@ this does not hold for the given crop parameters, we silently move the upper left corner up and/or left to make it so, simultaneously increasing the
region dimensions to keep the lower right crop corner unchanged. (Thus, the
output image covers at least the requested region, but may cover more.)
-The adjustment of the region dimensions may be optionally disabled.
+The adjustment of the region dimensions may be optionally disabled by
+attaching an 'f' character ("force") to the width or height number.
The image can be losslessly cropped by giving the switch:
-crop WxH+X+Y Crop to a rectangular subarea of width W, height H
@@ -592,16 +600,18 @@ extended JPEG file at all. jpegtran also recognizes these switches that control what to do with "extra"
markers, such as comment blocks:
- -copy none Copy no extra markers from source file. This setting
- suppresses all comments and other excess baggage
- present in the source file.
- -copy comments Copy only comment markers. This setting copies
- comments from the source file, but discards
- any other inessential (for image display) data.
+ -copy none Copy no extra markers from source file.
+ This setting suppresses all comments
+ and other metadata in the source file.
+ -copy comments Copy only comment markers.
+ This setting copies comments from the source file,
+ but discards any other metadata.
-copy all Copy all extra markers. This setting preserves
- miscellaneous markers found in the source file, such
- as JFIF thumbnails, Exif data, and Photoshop settings.
+ metadata found in the source file, such as JFIF
+ thumbnails, Exif data, and Photoshop settings.
In some files these extra markers can be sizable.
+ Note that this option will copy thumbnails as-is;
+ they will not be transformed.
The default behavior is -copy comments. (Note: in IJG releases v6 and v6a,
jpegtran always did the equivalent of -copy none.)
diff --git a/plugins/AdvaImg/src/LibJPEG/wrgif.c b/plugins/AdvaImg/src/LibJPEG/wrgif.c index 13f953b567..d38a42bf40 100644 --- a/plugins/AdvaImg/src/LibJPEG/wrgif.c +++ b/plugins/AdvaImg/src/LibJPEG/wrgif.c @@ -2,6 +2,7 @@ * wrgif.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
+ * Modified 2015 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.
*
@@ -218,7 +219,7 @@ put_3bytes (gif_dest_ptr dinfo, int val) LOCAL(void)
emit_header (gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap)
/* Output the GIF file header, including color map */
-/* If colormap==NULL, synthesize a gray-scale colormap */
+/* If colormap==NULL, synthesize a grayscale colormap */
{
int BitsPerPixel, ColorMapSize, InitCodeSize, FlagByte;
int cshift = dinfo->cinfo->data_precision - 8;
@@ -270,7 +271,7 @@ emit_header (gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap) put_3bytes(dinfo, GETJSAMPLE(colormap[0][i]) >> cshift);
}
} else {
- /* Create a gray-scale map of num_colors values, range 0..255 */
+ /* Create a grayscale map of num_colors values, range 0..255 */
put_3bytes(dinfo, (i * 255 + (num_colors-1)/2) / (num_colors-1));
}
} else {
@@ -393,7 +394,7 @@ jinit_write_gif (j_decompress_ptr cinfo) ((j_common_ptr) cinfo, JPOOL_IMAGE, cinfo->output_width, (JDIMENSION) 1);
dest->pub.buffer_height = 1;
- return (djpeg_dest_ptr) dest;
+ return &dest->pub;
}
#endif /* GIF_SUPPORTED */
diff --git a/plugins/AdvaImg/src/LibJPEG/wrjpgcom.c b/plugins/AdvaImg/src/LibJPEG/wrjpgcom.c index 7d10ee66e8..66dccee636 100644 --- a/plugins/AdvaImg/src/LibJPEG/wrjpgcom.c +++ b/plugins/AdvaImg/src/LibJPEG/wrjpgcom.c @@ -2,6 +2,7 @@ * wrjpgcom.c
*
* Copyright (C) 1994-1997, Thomas G. Lane.
+ * Modified 2015 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.
*
@@ -453,6 +454,11 @@ main (int argc, char **argv) comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH);
if (comment_arg == NULL)
ERREXIT("Insufficient memory");
+ if (strlen(argv[argn]+1) >= (size_t) MAX_COM_LENGTH) {
+ fprintf(stderr, "Comment text may not exceed %u bytes\n",
+ (unsigned int) MAX_COM_LENGTH);
+ exit(EXIT_FAILURE);
+ }
strcpy(comment_arg, argv[argn]+1);
for (;;) {
comment_length = (unsigned int) strlen(comment_arg);
@@ -462,9 +468,19 @@ main (int argc, char **argv) }
if (++argn >= argc)
ERREXIT("Missing ending quote mark");
+ if (strlen(comment_arg) + 1 + strlen(argv[argn]) >=
+ (size_t) MAX_COM_LENGTH) {
+ fprintf(stderr, "Comment text may not exceed %u bytes\n",
+ (unsigned int) MAX_COM_LENGTH);
+ exit(EXIT_FAILURE);
+ }
strcat(comment_arg, " ");
strcat(comment_arg, argv[argn]);
}
+ } else if (strlen(comment_arg) >= (size_t) MAX_COM_LENGTH) {
+ fprintf(stderr, "Comment text may not exceed %u bytes\n",
+ (unsigned int) MAX_COM_LENGTH);
+ exit(EXIT_FAILURE);
}
comment_length = (unsigned int) strlen(comment_arg);
} else
diff --git a/plugins/AdvaImg/src/LibJPEG/wrtarga.c b/plugins/AdvaImg/src/LibJPEG/wrtarga.c index 65662738d9..a3b7475cf8 100644 --- a/plugins/AdvaImg/src/LibJPEG/wrtarga.c +++ b/plugins/AdvaImg/src/LibJPEG/wrtarga.c @@ -2,6 +2,7 @@ * wrtarga.c
*
* Copyright (C) 1991-1996, Thomas G. Lane.
+ * Modified 2015 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.
*
@@ -73,7 +74,7 @@ write_header (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors) targaheader[17] = 0x20; /* Top-down, non-interlaced */
if (cinfo->out_color_space == JCS_GRAYSCALE) {
- targaheader[2] = 3; /* image type = uncompressed gray-scale */
+ targaheader[2] = 3; /* image type = uncompressed grayscale */
targaheader[16] = 8; /* bits per pixel */
} else { /* must be RGB */
if (num_colors > 0) {
@@ -247,7 +248,7 @@ jinit_write_targa (j_decompress_ptr cinfo) ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width, (JDIMENSION) 1);
dest->pub.buffer_height = 1;
- return (djpeg_dest_ptr) dest;
+ return &dest->pub;
}
#endif /* TARGA_SUPPORTED */
|