Updated libjpeg to preliminary version 9b.

It is currently in development and is planned for release in January 2016.
This commit is contained in:
Crayon2000 2015-11-01 23:56:53 -05:00
parent fce350b9a2
commit 5b61d78f59
18 changed files with 739 additions and 317 deletions

375
GRRLIB/lib/jpeg/README Normal file
View file

@ -0,0 +1,375 @@
The Independent JPEG Group's JPEG software
==========================================
README for release 9b of 10-Jan-2016
====================================
This distribution contains the ninth public release of the Independent JPEG
Group's free JPEG software. You are welcome to redistribute this software and
to use it for any purpose, subject to the conditions under LEGAL ISSUES, below.
This software is the work of Tom Lane, Guido Vollbeding, Philip Gladstone,
Bill Allombert, Jim Boucher, Lee Crocker, Bob Friesenhahn, Ben Jackson,
Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, Ge' Weijers,
and other members of the Independent JPEG Group.
IJG is not affiliated with the ISO/IEC JTC1/SC29/WG1 standards committee
(previously known as JPEG, together with ITU-T SG16).
DOCUMENTATION ROADMAP
=====================
This file contains the following sections:
OVERVIEW General description of JPEG and the IJG software.
LEGAL ISSUES Copyright, lack of warranty, terms of distribution.
REFERENCES Where to learn more about JPEG.
ARCHIVE LOCATIONS Where to find newer versions of this software.
ACKNOWLEDGMENTS Special thanks.
FILE FORMAT WARS Software *not* to get.
TO DO Plans for future IJG releases.
Other documentation files in the distribution are:
User documentation:
install.txt How to configure and install the IJG software.
usage.txt Usage instructions for cjpeg, djpeg, jpegtran,
rdjpgcom, and wrjpgcom.
*.1 Unix-style man pages for programs (same info as usage.txt).
wizard.txt Advanced usage instructions for JPEG wizards only.
change.log Version-to-version change highlights.
Programmer and internal documentation:
libjpeg.txt How to use the JPEG library in your own programs.
example.c Sample code for calling the JPEG library.
structure.txt Overview of the JPEG library's internal structure.
filelist.txt Road map of IJG files.
coderules.txt Coding style rules --- please read if you contribute code.
Please read at least the files install.txt and usage.txt. Some information
can also be found in the JPEG FAQ (Frequently Asked Questions) article. See
ARCHIVE LOCATIONS below to find out where to obtain the FAQ article.
If you want to understand how the JPEG code works, we suggest reading one or
more of the REFERENCES, then looking at the documentation files (in roughly
the order listed) before diving into the code.
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 grayscale images.
This software implements JPEG baseline, extended-sequential, and progressive
compression processes. Provision is made for supporting all variants of these
processes, although some uncommon parameter settings aren't implemented yet.
We have made no provision for supporting the hierarchical or lossless
processes defined in the standard.
We provide a set of library routines for reading and writing JPEG image files,
plus two sample applications "cjpeg" and "djpeg", which use the library to
perform conversion between JPEG and some other popular image file formats.
The library is intended to be reused in other applications.
In order to support file conversion and viewing software, we have included
considerable functionality beyond the bare JPEG coding/decoding capability;
for example, the color quantization modules are not strictly part of JPEG
decoding, but they are essential for output to colormapped file formats or
colormapped displays. These extra functions can be compiled out of the
library if not required for a particular application.
We have also included "jpegtran", a utility for lossless transcoding between
different JPEG processes, and "rdjpgcom" and "wrjpgcom", two simple
applications for inserting and extracting textual comments in JFIF files.
The emphasis in designing this software has been on achieving portability and
flexibility, while also making it fast enough to be useful. In particular,
the software is not intended to be read as a tutorial on JPEG. (See the
REFERENCES section for introductory material.) Rather, it is intended to
be reliable, portable, industrial-strength code. We do not claim to have
achieved that goal in every aspect of the software, but we strive for it.
We welcome the use of this software as a component of commercial products.
No royalty is required, but we do ask for an acknowledgement in product
documentation, as described under LEGAL ISSUES.
LEGAL ISSUES
============
In plain English:
1. We don't promise that this software works. (But if you find any bugs,
please let us know!)
2. You can use this software for whatever you want. You don't have to pay us.
3. You may not pretend that you wrote this software. If you use it in a
program, you must acknowledge somewhere in your documentation that
you've used the IJG code.
In legalese:
The authors make NO WARRANTY or representation, either express or implied,
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-2016, Thomas G. Lane, Guido Vollbeding.
All Rights Reserved except as specified below.
Permission is hereby granted to use, copy, modify, and distribute this
software (or portions thereof) for any purpose, without fee, subject to these
conditions:
(1) If any part of the source code for this software is distributed, then this
README file must be included, with this copyright and no-warranty notice
unaltered; and any additions, deletions, or changes to the original files
must be clearly indicated in accompanying documentation.
(2) If only executable code is distributed, then the accompanying
documentation must state that "this software is based in part on the work of
the Independent JPEG Group".
(3) Permission for use of this software is granted only if the user accepts
full responsibility for any undesirable consequences; the authors accept
NO LIABILITY for damages of any kind.
These conditions apply to any software derived from or based on the IJG code,
not just to the unmodified library. If you use our work, you ought to
acknowledge us.
Permission is NOT granted for the use of any IJG author's name or company name
in advertising or publicity relating to this software or products derived from
it. This software may be referred to only as "the Independent JPEG Group's
software".
We specifically permit and encourage the use of this software as the basis of
commercial products, provided that all warranty or liability claims are
assumed by the product vendor.
The Unix configuration script "configure" was produced with GNU Autoconf.
It is copyright by the Free Software Foundation but is freely distributable.
The same holds for its supporting scripts (config.guess, config.sub,
ltmain.sh). Another support script, install-sh, is copyright by X Consortium
but is also freely distributable.
The IJG distribution formerly included code to read and write GIF files.
To avoid entanglement with the Unisys LZW patent (now expired), GIF reading
support has been removed altogether, and the GIF writer has been simplified
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.
REFERENCES
==========
We recommend reading one or more of these references before trying to
understand the innards of the JPEG software.
The best short technical introduction to the JPEG compression algorithm is
Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
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 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,
and it may not be used for commercial purposes.
A somewhat less technical, more leisurely introduction to JPEG can be found in
"The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by
M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides
good explanations and example C code for a multitude of compression methods
including JPEG. It is an excellent source if you are comfortable reading C
code but don't know much about data compression in general. The book's JPEG
sample code is far from industrial-strength, but when you are ready to look
at a full implementation, you've got one here...
The best currently available description of JPEG is the textbook "JPEG Still
Image Data Compression Standard" by William B. Pennebaker and Joan L.
Mitchell, published by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1.
Price US$59.95, 638 pp. The book includes the complete text of the ISO JPEG
standards (DIS 10918-1 and draft DIS 10918-2).
Although this is by far the most detailed and comprehensive exposition of
JPEG publicly available, we point out that it is still missing an explanation
of the most essential properties and algorithms of the underlying DCT
technology.
If you think that you know about DCT-based JPEG after reading this book,
then you are in delusion. The real fundamentals and corresponding potential
of DCT-based JPEG are not publicly known so far, and that is the reason for
all the mistaken developments taking place in the image coding domain.
The original JPEG standard is divided into two parts, Part 1 being the actual
specification, while Part 2 covers compliance testing methods. Part 1 is
titled "Digital Compression and Coding of Continuous-tone Still Images,
Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS
10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of
Continuous-tone Still Images, Part 2: Compliance testing" and has document
numbers ISO/IEC IS 10918-2, ITU-T T.83.
IJG JPEG 8 introduced an implementation of the JPEG SmartScale extension
which is specified in two documents: A contributed document at ITU and ISO
with title "ITU-T JPEG-Plus Proposal for Extending ITU-T T.81 for Advanced
Image Coding", April 2006, Geneva, Switzerland. The latest version of this
document is Revision 3. And a contributed document ISO/IEC JTC1/SC29/WG1 N
5799 with title "Evolution of JPEG", June/July 2011, Berlin, Germany.
IJG JPEG 9 introduces a reversible color transform for improved lossless
compression which is described in a contributed document ISO/IEC JTC1/SC29/
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, 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
found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems.
IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6).
Instead, we recommend the JPEG design proposed by TIFF Technical Note #2
(Compression tag 7). Copies of this Note can be obtained from
http://www.ijg.org/files/. It is expected that the next revision
of the TIFF spec will replace the 6.0 JPEG design with the Note's design.
Although IJG's own code does not support TIFF/JPEG, the free libtiff library
uses our library to implement TIFF/JPEG per the Note.
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.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.
It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/
and other news.answers archive sites, including the official news.answers
archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/.
If you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu
with body
send usenet/news.answers/jpeg-faq/part1
send usenet/news.answers/jpeg-faq/part2
ACKNOWLEDGMENTS
===============
Thank to Juergen Bruder for providing me with a copy of the common DCT
algorithm article, only to find out that I had come to the same result
in a more direct and comprehensible way with a more generative approach.
Thank to Istvan Sebestyen and Joan L. Mitchell for inviting me to the
ITU JPEG (Study Group 16) meeting in Geneva, Switzerland.
Thank to Thomas Wiegand and Gary Sullivan for inviting me to the
Joint Video Team (MPEG & ITU) meeting in Geneva, Switzerland.
Thank to Thomas Richter and Daniel Lee for inviting me to the
ISO/IEC JTC1/SC29/WG1 (previously known as JPEG, together with ITU-T SG16)
meeting in Berlin, Germany.
Thank to John Korejwa and Massimo Ballerini for inviting me to
fruitful consultations in Boston, MA and Milan, Italy.
Thank to Hendrik Elstner, Roland Fassauer, Simone Zuck, Guenther
Maier-Gerber, Walter Stoeber, Fred Schmitz, and Norbert Braunagel
for corresponding business development.
Thank to Nico Zschach and Dirk Stelling of the technical support team
at the Digital Images company in Halle for providing me with extra
equipment for configuration tests.
Thank to Richard F. Lyon (then of Foveon Inc.) for fruitful
communication about JPEG configuration in Sigma Photo Pro software.
Thank to Andrew Finkenstadt for hosting the ijg.org site.
Last but not least special thank to Thomas G. Lane for the original
design and development of this singular software package.
FILE FORMAT WARS
================
The ISO/IEC JTC1/SC29/WG1 standards committee (previously known as JPEG,
together with ITU-T SG16) currently promotes different formats containing
the name "JPEG" which is misleading because these formats are incompatible
with original DCT-based JPEG and are based on faulty technologies.
IJG therefore does not and will not support such momentary mistakes
(see REFERENCES).
There exist also distributions under the name "OpenJPEG" promoting such
kind of formats which is misleading because they don't support original
JPEG images.
We have no sympathy for the promotion of inferior formats. Indeed, one of
the original reasons for developing this free software was to help force
convergence on common, interoperable format standards for JPEG files.
Don't use an incompatible file format!
(In any case, our decoder will remain capable of reading existing JPEG
image files indefinitely.)
The ISO committee pretends to be "responsible for the popular JPEG" in their
public reports which is not true because they don't respond to actual
requirements for the maintenance of the original JPEG specification.
Furthermore, the ISO committee pretends to "ensure interoperability" with
their standards which is not true because their "standards" support only
application-specific and proprietary use cases and contain mathematically
incorrect code.
There are currently different distributions in circulation containing the
name "libjpeg" which is misleading because they don't have the features and
are incompatible with formats supported by actual IJG libjpeg distributions.
One of those fakes is released by members of the ISO committee and just uses
the name of libjpeg for misdirection of people, similar to the abuse of the
name JPEG as described above, while having nothing in common with actual IJG
libjpeg distributions and containing mathematically incorrect code.
The other one claims to be a "derivative" or "fork" of the original libjpeg,
but violates the license conditions as described under LEGAL ISSUES above
and violates basic C programming properties.
We have no sympathy for the release of misleading, incorrect and illegal
distributions derived from obsolete code bases.
Don't use an obsolete code base!
According to the UCC (Uniform Commercial Code) law, IJG has the lawful and
legal right to foreclose on certain standardization bodies and other
institutions or corporations that knowingly perform substantial and
systematic deceptive acts and practices, fraud, theft, and damaging of the
value of the people of this planet without their knowing, willing and
intentional consent.
The titles, ownership, and rights of these institutions and all their assets
are now duly secured and held in trust for the free people of this planet.
People of the planet, on every country, may have a financial interest in
the assets of these former principals, agents, and beneficiaries of the
foreclosed institutions and corporations.
IJG asserts what is: that each man, woman, and child has unalienable value
and rights granted and deposited in them by the Creator and not any one of
the people is subordinate to any artificial principality, corporate fiction
or the special interest of another without their appropriate knowing,
willing and intentional consent made by contract or accommodation agreement.
IJG expresses that which already was.
The people have already determined and demanded that public administration
entities, national governments, and their supporting judicial systems must
be fully transparent, accountable, and liable.
IJG has secured the value for all concerned free people of the planet.
A partial list of foreclosed institutions and corporations ("Hall of Shame")
is currently prepared and will be published later.
TO DO
=====
Version 9 is the second release of a new generation JPEG standard
to overcome the limitations of the original JPEG specification,
and is the first true source reference JPEG codec.
More features are being prepared for coming releases...
Please send bug reports, offers of help, etc. to jpeg-info@jpegclub.org.

View file

@ -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 */

View file

@ -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;
}

View file

@ -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;

View file

@ -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

View file

@ -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.
*
@ -199,30 +199,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 +227,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));
}

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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 */

View file

@ -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 */
}
}

View file

@ -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 */

View file

@ -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);
output_buf[0][output_col] = range_limit[dcval & RANGE_MASK];
quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
dcval = DEQUANTIZE(coef_block[0], quantptr[0]);
/* 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[(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 */

View file

@ -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 */

View file

@ -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 10-Jan-2016"
#define JCOPYRIGHT "Copyright (C) 2014, Thomas G. Lane, Guido Vollbeding"
#define JCOPYRIGHT "Copyright (C) 2016, Thomas G. Lane, Guido Vollbeding"

View file

@ -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;

View file

@ -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 */

View file

@ -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 */