Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fc018fd1a | ||
|
|
96e4e7eb60 | ||
|
|
a560e4b423 | ||
|
|
fc11193e7a | ||
|
|
e7f88aec23 | ||
|
|
5829cb2398 | ||
|
|
c39ec149e8 | ||
|
|
a4ecaacde6 | ||
|
|
f18f81b7e2 |
43
Makefile.am
43
Makefile.am
@@ -33,16 +33,17 @@ DOCS= README install.txt usage.txt wizard.txt example.c libjpeg.txt \
|
||||
structure.txt coderules.txt filelist.txt change.log
|
||||
|
||||
# Makefiles for various systems
|
||||
MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.bcc \
|
||||
makefile.mc6 makefile.dj makefile.wat makefile.vc makejdsw.vc6 \
|
||||
makeadsw.vc6 makejdep.vc6 makejdsp.vc6 makejmak.vc6 makecdep.vc6 \
|
||||
makecdsp.vc6 makecmak.vc6 makeddep.vc6 makeddsp.vc6 makedmak.vc6 \
|
||||
maketdep.vc6 maketdsp.vc6 maketmak.vc6 makerdep.vc6 makerdsp.vc6 \
|
||||
makermak.vc6 makewdep.vc6 makewdsp.vc6 makewmak.vc6 makejsln.vc9 \
|
||||
makeasln.vc9 makejvcp.vc9 makecvcp.vc9 makedvcp.vc9 maketvcp.vc9 \
|
||||
makervcp.vc9 makewvcp.vc9 makeproj.mac makcjpeg.st makdjpeg.st \
|
||||
makljpeg.st maktjpeg.st makefile.manx makefile.sas makefile.mms \
|
||||
makefile.vms makvms.opt
|
||||
MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.b32 \
|
||||
makefile.bcc makefile.mc6 makefile.dj makefile.wat makefile.vc \
|
||||
makefile.vs makejdsw.vc6 makeadsw.vc6 makejdep.vc6 makejdsp.vc6 \
|
||||
makejmak.vc6 makecdep.vc6 makecdsp.vc6 makecmak.vc6 makeddep.vc6 \
|
||||
makeddsp.vc6 makedmak.vc6 maketdep.vc6 maketdsp.vc6 maketmak.vc6 \
|
||||
makerdep.vc6 makerdsp.vc6 makermak.vc6 makewdep.vc6 makewdsp.vc6 \
|
||||
makewmak.vc6 makejsln.v16 makeasln.v16 makejvcx.v16 makejfil.v16 \
|
||||
makecvcx.v16 makecfil.v16 makedvcx.v16 makedfil.v16 maketvcx.v16 \
|
||||
maketfil.v16 makervcx.v16 makerfil.v16 makewvcx.v16 makewfil.v16 \
|
||||
makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st maktjpeg.st \
|
||||
makefile.manx makefile.sas makefile.mms makefile.vms makvms.opt
|
||||
|
||||
# Configuration files
|
||||
CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \
|
||||
@@ -50,15 +51,15 @@ CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \
|
||||
jconfig.vms
|
||||
|
||||
# Support scripts for configure
|
||||
CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp missing
|
||||
CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp \
|
||||
missing ar-lib
|
||||
|
||||
# Miscellaneous support files
|
||||
OTHERFILES= jconfig.txt ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm \
|
||||
libjpeg.map
|
||||
OTHERFILES= jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map libjpeg.pc.in
|
||||
|
||||
# Test support files
|
||||
TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \
|
||||
testimgp.jpg
|
||||
TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.bmp testimg.jpg \
|
||||
testprog.jpg testimgp.jpg
|
||||
|
||||
# libtool libraries to build
|
||||
lib_LTLIBRARIES = libjpeg.la
|
||||
@@ -102,9 +103,13 @@ noinst_HEADERS = $(OTHERINCLUDES)
|
||||
EXTRA_DIST = $(DOCS) $(DISTMANS) $(MKFILES) $(CONFIGFILES) $(SYSDEPSOURCES) \
|
||||
$(OTHERFILES) $(TESTFILES)
|
||||
|
||||
# pkg-config file
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
nodist_pkgconfig_DATA = libjpeg.pc
|
||||
|
||||
# Files to be cleaned
|
||||
CLEANFILES = testout.ppm testout.bmp testout.jpg testoutp.ppm testoutp.jpg \
|
||||
testoutt.jpg
|
||||
CLEANFILES = testout.ppm testout.gif testout.bmp testout.jpg testoutp.ppm \
|
||||
testoutp.jpg testoutt.jpg
|
||||
|
||||
# Install jconfig.h
|
||||
install-data-local:
|
||||
@@ -118,14 +123,16 @@ uninstall-local:
|
||||
# Run tests
|
||||
test: check-local
|
||||
check-local:
|
||||
$(RM) testout*
|
||||
rm -f testout*
|
||||
./djpeg -dct int -ppm -outfile testout.ppm $(srcdir)/testorig.jpg
|
||||
./djpeg -dct int -gif -outfile testout.gif $(srcdir)/testorig.jpg
|
||||
./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg
|
||||
./cjpeg -dct int -outfile testout.jpg $(srcdir)/testimg.ppm
|
||||
./djpeg -dct int -ppm -outfile testoutp.ppm $(srcdir)/testprog.jpg
|
||||
./cjpeg -dct int -progressive -opt -outfile testoutp.jpg $(srcdir)/testimg.ppm
|
||||
./jpegtran -outfile testoutt.jpg $(srcdir)/testprog.jpg
|
||||
cmp $(srcdir)/testimg.ppm testout.ppm
|
||||
cmp $(srcdir)/testimg.gif testout.gif
|
||||
cmp $(srcdir)/testimg.bmp testout.bmp
|
||||
cmp $(srcdir)/testimg.jpg testout.jpg
|
||||
cmp $(srcdir)/testimg.ppm testoutp.ppm
|
||||
|
||||
1014
Makefile.in
1014
Makefile.in
File diff suppressed because it is too large
Load Diff
162
README
162
README
@@ -1,19 +1,20 @@
|
||||
The Independent JPEG Group's JPEG software
|
||||
==========================================
|
||||
|
||||
README for release 8 of 10-Jan-2010
|
||||
===================================
|
||||
README for release 9d of 12-Jan-2020
|
||||
====================================
|
||||
|
||||
This distribution contains the eighth public release of the Independent JPEG
|
||||
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.
|
||||
John Korejwa, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi,
|
||||
Ge' Weijers, and other members of the Independent JPEG Group.
|
||||
|
||||
IJG is not affiliated with the official ISO JPEG standards committee.
|
||||
IJG is not affiliated with the ISO/IEC JTC1/SC29/WG1 standards committee
|
||||
(previously known as JPEG, together with ITU-T SG16).
|
||||
|
||||
|
||||
DOCUMENTATION ROADMAP
|
||||
@@ -59,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
|
||||
@@ -114,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-2010, Thomas G. Lane, Guido Vollbeding.
|
||||
This software is copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
|
||||
All Rights Reserved except as specified below.
|
||||
|
||||
Permission is hereby granted to use, copy, modify, and distribute this
|
||||
@@ -145,33 +146,12 @@ commercial products, provided that all warranty or liability claims are
|
||||
assumed by the product vendor.
|
||||
|
||||
|
||||
ansi2knr.c is included in this distribution by permission of L. Peter Deutsch,
|
||||
sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA.
|
||||
ansi2knr.c is NOT covered by the above copyright and conditions, but instead
|
||||
by the usual distribution terms of the Free Software Foundation; principally,
|
||||
that you must include source code if you redistribute it. (See the file
|
||||
ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part
|
||||
of any program generated from the IJG code, this does not limit you more than
|
||||
the foregoing paragraphs do.
|
||||
|
||||
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, 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.
|
||||
|
||||
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
|
||||
==========
|
||||
@@ -184,8 +164,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,
|
||||
@@ -221,20 +201,25 @@ 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 introduces an implementation of the JPEG SmartScale extension
|
||||
which is specified in 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 the document is Revision 3.
|
||||
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, 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
|
||||
@@ -254,8 +239,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.v8.tar.gz, and in Windows-compatible
|
||||
"zip" archive format as http://www.ijg.org/files/jpegsr8.zip.
|
||||
http://www.ijg.org/files/jpegsrc.v9d.tar.gz, and in Windows-compatible
|
||||
"zip" archive format as http://www.ijg.org/files/jpegsr9d.zip.
|
||||
|
||||
The JPEG FAQ (Frequently Asked Questions) article is a source of some
|
||||
general information about JPEG.
|
||||
@@ -281,11 +266,16 @@ 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, and Walter Stoeber for corresponding business development.
|
||||
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
|
||||
@@ -296,30 +286,86 @@ 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.
|
||||
Thank to Thomas G. Lane for the original design and development of
|
||||
this singular software package.
|
||||
|
||||
Thank to Lars Goehler, Andreas Heinecke, Sebastian Fuss, Yvonne Roebert,
|
||||
Andrej Werner, and Ulf-Dietrich Braumann for support and public relations.
|
||||
|
||||
|
||||
FILE FORMAT WARS
|
||||
================
|
||||
|
||||
The ISO JPEG standards committee actually promotes different formats like
|
||||
"JPEG 2000" or "JPEG XR" which are incompatible with original DCT-based
|
||||
JPEG and which are based on faulty technologies. IJG therefore does not
|
||||
and will not support such momentary mistakes (see REFERENCES).
|
||||
We have little or no sympathy for the promotion of these 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.
|
||||
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 8.0 is the first release of a new generation JPEG standard
|
||||
to overcome the limitations of the original JPEG specification.
|
||||
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@uc.ag.
|
||||
Please send bug reports, offers of help, etc. to jpeg-info@jpegclub.org.
|
||||
|
||||
4950
aclocal.m4
vendored
4950
aclocal.m4
vendored
File diff suppressed because it is too large
Load Diff
36
ansi2knr.1
36
ansi2knr.1
@@ -1,36 +0,0 @@
|
||||
.TH ANSI2KNR 1 "19 Jan 1996"
|
||||
.SH NAME
|
||||
ansi2knr \- convert ANSI C to Kernighan & Ritchie C
|
||||
.SH SYNOPSIS
|
||||
.I ansi2knr
|
||||
[--varargs] input_file [output_file]
|
||||
.SH DESCRIPTION
|
||||
If no output_file is supplied, output goes to stdout.
|
||||
.br
|
||||
There are no error messages.
|
||||
.sp
|
||||
.I 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). It 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 and comments, except
|
||||
that the function name must be the first thing on the line.
|
||||
.sp
|
||||
The following constructs will confuse it:
|
||||
.br
|
||||
- Any other construct that starts at the left margin and follows the
|
||||
above syntax (such as a macro or function call).
|
||||
.br
|
||||
- Some macros that tinker with the syntax of the function header.
|
||||
.sp
|
||||
The --varargs switch is obsolete, and is recognized only for
|
||||
backwards compatibility. The present version of
|
||||
.I ansi2knr
|
||||
will always attempt to convert a ... argument to va_alist and va_dcl.
|
||||
.SH AUTHOR
|
||||
L. Peter Deutsch <ghost@aladdin.com> wrote the original ansi2knr and
|
||||
continues to maintain the current version; most of the code in the current
|
||||
version is his work. ansi2knr also includes contributions by Francois
|
||||
Pinard <pinard@iro.umontreal.ca> and Jim Avera <jima@netcom.com>.
|
||||
739
ansi2knr.c
739
ansi2knr.c
@@ -1,739 +0,0 @@
|
||||
/* Copyright (C) 1989, 2000 Aladdin Enterprises. All rights reserved. */
|
||||
|
||||
/*$Id: ansi2knr.c,v 1.14 2003/09/06 05:36:56 eggert 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;
|
||||
}
|
||||
270
ar-lib
Executable file
270
ar-lib
Executable file
@@ -0,0 +1,270 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for Microsoft lib.exe
|
||||
|
||||
me=ar-lib
|
||||
scriptversion=2012-03-01.08; # UTC
|
||||
|
||||
# Copyright (C) 2010-2018 Free Software Foundation, Inc.
|
||||
# Written by Peter Rosin <peda@lysator.liu.se>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
|
||||
# func_error message
|
||||
func_error ()
|
||||
{
|
||||
echo "$me: $1" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv in
|
||||
mingw)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_at_file at_file operation archive
|
||||
# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
|
||||
# for each of them.
|
||||
# When interpreting the content of the @FILE, do NOT use func_file_conv,
|
||||
# since the user would need to supply preconverted file names to
|
||||
# binutils ar, at least for MinGW.
|
||||
func_at_file ()
|
||||
{
|
||||
operation=$2
|
||||
archive=$3
|
||||
at_file_contents=`cat "$1"`
|
||||
eval set x "$at_file_contents"
|
||||
shift
|
||||
|
||||
for member
|
||||
do
|
||||
$AR -NOLOGO $operation:"$member" "$archive" || exit $?
|
||||
done
|
||||
}
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
func_error "no command. Try '$0 --help' for more information."
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<EOF
|
||||
Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
|
||||
|
||||
Members may be specified in a file named with @FILE.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "$me, version $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
if test $# -lt 3; then
|
||||
func_error "you must specify a program, an action and an archive"
|
||||
fi
|
||||
|
||||
AR=$1
|
||||
shift
|
||||
while :
|
||||
do
|
||||
if test $# -lt 2; then
|
||||
func_error "you must specify a program, an action and an archive"
|
||||
fi
|
||||
case $1 in
|
||||
-lib | -LIB \
|
||||
| -ltcg | -LTCG \
|
||||
| -machine* | -MACHINE* \
|
||||
| -subsystem* | -SUBSYSTEM* \
|
||||
| -verbose | -VERBOSE \
|
||||
| -wx* | -WX* )
|
||||
AR="$AR $1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
action=$1
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
orig_archive=$1
|
||||
shift
|
||||
func_file_conv "$orig_archive"
|
||||
archive=$file
|
||||
|
||||
# strip leading dash in $action
|
||||
action=${action#-}
|
||||
|
||||
delete=
|
||||
extract=
|
||||
list=
|
||||
quick=
|
||||
replace=
|
||||
index=
|
||||
create=
|
||||
|
||||
while test -n "$action"
|
||||
do
|
||||
case $action in
|
||||
d*) delete=yes ;;
|
||||
x*) extract=yes ;;
|
||||
t*) list=yes ;;
|
||||
q*) quick=yes ;;
|
||||
r*) replace=yes ;;
|
||||
s*) index=yes ;;
|
||||
S*) ;; # the index is always updated implicitly
|
||||
c*) create=yes ;;
|
||||
u*) ;; # TODO: don't ignore the update modifier
|
||||
v*) ;; # TODO: don't ignore the verbose modifier
|
||||
*)
|
||||
func_error "unknown action specified"
|
||||
;;
|
||||
esac
|
||||
action=${action#?}
|
||||
done
|
||||
|
||||
case $delete$extract$list$quick$replace,$index in
|
||||
yes,* | ,yes)
|
||||
;;
|
||||
yesyes*)
|
||||
func_error "more than one action specified"
|
||||
;;
|
||||
*)
|
||||
func_error "no action specified"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -n "$delete"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_at_file "${1#@}" -REMOVE "$archive"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
$AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
elif test -n "$extract"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
if test $# -gt 0; then
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_at_file "${1#@}" -EXTRACT "$archive"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
$AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
$AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member
|
||||
do
|
||||
$AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
|
||||
done
|
||||
fi
|
||||
|
||||
elif test -n "$quick$replace"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
if test -z "$create"; then
|
||||
echo "$me: creating $orig_archive"
|
||||
fi
|
||||
orig_archive=
|
||||
else
|
||||
orig_archive=$archive
|
||||
fi
|
||||
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_file_conv "${1#@}"
|
||||
set x "$@" "@$file"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
set x "$@" "$file"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
shift
|
||||
done
|
||||
|
||||
if test -n "$orig_archive"; then
|
||||
$AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
|
||||
else
|
||||
$AR -NOLOGO -OUT:"$archive" "$@" || exit $?
|
||||
fi
|
||||
|
||||
elif test -n "$list"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
$AR -NOLOGO -LIST "$archive" || exit $?
|
||||
fi
|
||||
11
cderror.h
11
cderror.h
@@ -2,7 +2,7 @@
|
||||
* cderror.h
|
||||
*
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* Modified 2009 by Guido Vollbeding.
|
||||
* Modified 2009-2017 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.
|
||||
*
|
||||
@@ -41,16 +41,16 @@ JMESSAGE(JMSG_FIRSTADDONCODE=1000, NULL) /* Must be first entry! */
|
||||
|
||||
#ifdef BMP_SUPPORTED
|
||||
JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format")
|
||||
JMESSAGE(JERR_BMP_BADDEPTH, "Only 8- and 24-bit BMP files are supported")
|
||||
JMESSAGE(JERR_BMP_BADDEPTH, "Only 8-, 24-, and 32-bit BMP files are supported")
|
||||
JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length")
|
||||
JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1")
|
||||
JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB")
|
||||
JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported")
|
||||
JMESSAGE(JERR_BMP_EMPTY, "Empty BMP image")
|
||||
JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM")
|
||||
JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image")
|
||||
JMESSAGE(JERR_BMP_OUTOFRANGE, "Numeric value out of range in BMP file")
|
||||
JMESSAGE(JTRC_BMP, "%ux%u %d-bit BMP image")
|
||||
JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image")
|
||||
JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image")
|
||||
JMESSAGE(JTRC_BMP_OS2, "%ux%u %d-bit OS2 BMP image")
|
||||
JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image")
|
||||
#endif /* BMP_SUPPORTED */
|
||||
|
||||
@@ -75,6 +75,7 @@ JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits")
|
||||
JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB")
|
||||
JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file")
|
||||
JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file")
|
||||
JMESSAGE(JERR_PPM_OUTOFRANGE, "Numeric value out of range in PPM file")
|
||||
JMESSAGE(JTRC_PGM, "%ux%u PGM image")
|
||||
JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image")
|
||||
JMESSAGE(JTRC_PPM, "%ux%u PPM image")
|
||||
|
||||
4
cdjpeg.h
4
cdjpeg.h
@@ -2,6 +2,7 @@
|
||||
* cdjpeg.h
|
||||
*
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* Modified 2019 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.
|
||||
*
|
||||
@@ -121,7 +122,8 @@ EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo));
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo,
|
||||
boolean is_os2));
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo));
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo,
|
||||
boolean is_lzw));
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo));
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo));
|
||||
|
||||
212
change.log
212
change.log
@@ -1,6 +1,218 @@
|
||||
CHANGE LOG for Independent JPEG Group's JPEG software
|
||||
|
||||
|
||||
Version 9d 12-Jan-2020
|
||||
-----------------------
|
||||
|
||||
Optimize the optimal Huffman code table generation to produce
|
||||
slightly smaller files. Thank to John Korejwa for suggestion.
|
||||
Note: Requires rebuild of testimgp.jpg.
|
||||
|
||||
Decoding Huffman: Use default tables if tables are not defined.
|
||||
Thank to Simone Azzalin for report (Motion JPEG),
|
||||
and to Martin Strunz for hint.
|
||||
|
||||
Add sanity check in optimal Huffman code table generation.
|
||||
Thank to Adam Farley for suggestion.
|
||||
|
||||
rdtarga.c: use read_byte(), with EOF check, instead of getc()
|
||||
in read_*_pixel().
|
||||
Thank to Chijin Zhou for cjpeg potential vulnerability report.
|
||||
|
||||
jmemnobs.c: respect the max_memory_to_use setting in
|
||||
jpeg_mem_available() computation. Thank to Sheng Shu and
|
||||
Dongdong She for djpeg potential vulnerability report.
|
||||
|
||||
jdarith.c, jdhuff.c: avoid left shift of negative value
|
||||
compiler warning in decode_mcu_AC_refine().
|
||||
Thank to Indu Bhagat for suggestion.
|
||||
|
||||
Add x64 (64-bit) platform support, avoid compiler warnings.
|
||||
Thank to Jonathan Potter, Feiyun Wang, and Sheng Shu for suggestion.
|
||||
|
||||
Adjust libjpeg version specification for pkg-config file.
|
||||
Thank to Chen Chen for suggestion.
|
||||
|
||||
Restore GIF read and write support from libjpeg version 6a.
|
||||
Thank to Wolfgang Werner (W.W.) Heinz for suggestion.
|
||||
|
||||
Improve consistency in raw (downsampled) image data processing mode.
|
||||
Thank to Zhongyuan Zhou for hint.
|
||||
|
||||
Avoid out of bounds array read (AC derived table pointers)
|
||||
in start pass in jdhuff.c. Thank to Peng Li for report.
|
||||
|
||||
Improve code sanity (jdhuff.c).
|
||||
Thank to Reza Mirzazade farkhani for reports.
|
||||
|
||||
Add jpegtran -drop option; add options to the crop extension and wipe
|
||||
to fill the extra area with content from the source image region,
|
||||
instead of gray out.
|
||||
|
||||
|
||||
Version 9c 14-Jan-2018
|
||||
-----------------------
|
||||
|
||||
jpegtran: add an option to the -wipe switch to fill the region
|
||||
with the average of adjacent blocks, instead of gray out.
|
||||
Thank to Caitlyn Feddock and Maddie Ziegler for inspiration.
|
||||
|
||||
Make range extension bits adjustable (in jpegint.h).
|
||||
Thank to Robin Watts for suggestion.
|
||||
|
||||
Provide macros for fflush() and ferror() in jinclude.h in order
|
||||
to facilitate adaption by applications using an own FILE class.
|
||||
Thank to Gerhard Huber for suggestion.
|
||||
|
||||
Add libjpeg pkg-config file. Thank to Mark Lavi, Vincent Torri,
|
||||
Patrick McMunn, and Huw Davies for suggestion.
|
||||
|
||||
Add sanity checks in cjpeg image reader modules.
|
||||
Thank to Bingchang, Liu for reports.
|
||||
|
||||
|
||||
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
|
||||
-----------------------
|
||||
|
||||
Add support for wide gamut color spaces (JFIF version 2).
|
||||
Improve clarity and accuracy in color conversion modules.
|
||||
Note: Requires rebuild of test images.
|
||||
|
||||
Extend the bit depth support to all values from 8 to 12
|
||||
(BITS_IN_JSAMPLE configuration option in jmorecfg.h).
|
||||
jpegtran now supports N bits sample data precision with all N from 8 to 12
|
||||
in a single instance. Thank to Roland Fassauer for inspiration.
|
||||
|
||||
Try to resolve issues with new boolean type definition.
|
||||
Thank also to v4hn for suggestion.
|
||||
|
||||
Enable option to use default Huffman tables for lossless compression
|
||||
(for hardware solution), and in this case improve lossless RGB compression
|
||||
with reversible color transform. Thank to Benny Alexandar for hint.
|
||||
|
||||
Extend the entropy decoding structure, so that extraneous bytes between
|
||||
compressed scan data and following marker can be reported correctly.
|
||||
Thank to Nigel Tao for hint.
|
||||
|
||||
Add jpegtran -wipe option and extension for -crop.
|
||||
Thank to Andrew Senior, David Clunie, and Josef Schmid for suggestion.
|
||||
|
||||
|
||||
Version 9 13-Jan-2013
|
||||
----------------------
|
||||
|
||||
Add cjpeg -rgb1 option to create an RGB JPEG file, and insert
|
||||
a simple reversible color transform into the processing which
|
||||
significantly improves the compression.
|
||||
The recommended command for lossless coding of RGB images is now
|
||||
cjpeg -rgb1 -block 1 -arithmetic.
|
||||
As said, this option improves the compression significantly, but
|
||||
the files are not compatible with JPEG decoders prior to IJG v9
|
||||
due to the included color transform.
|
||||
The used color transform and marker signaling is compatible with
|
||||
other JPEG standards (e.g., JPEG-LS part 2).
|
||||
|
||||
Remove the automatic de-ANSI-fication support (Automake 1.12).
|
||||
Thank also to Nitin A Kamble for suggestion.
|
||||
|
||||
Add remark for jpeg_mem_dest() in jdatadst.c.
|
||||
Thank to Elie-Gregoire Khoury for the hint.
|
||||
|
||||
Support files with invalid component identifiers (created
|
||||
by Adobe PDF). Thank to Robin Watts for the suggestion.
|
||||
|
||||
Adapt full buffer case in jcmainct.c for use with scaled DCT.
|
||||
Thank to Sergii Biloshytskyi for the suggestion.
|
||||
|
||||
Add type identifier for declaration of noreturn functions.
|
||||
Thank to Brett L. Moore for the suggestion.
|
||||
|
||||
Correct argument type in format string, avoid compiler warnings.
|
||||
Thank to Vincent Torri for hint.
|
||||
|
||||
Add missing #include directives in configuration checks, avoid
|
||||
configuration errors. Thank to John Spencer for the hint.
|
||||
|
||||
|
||||
Version 8d 15-Jan-2012
|
||||
-----------------------
|
||||
|
||||
Add cjpeg -rgb option to create RGB JPEG files.
|
||||
Using this switch suppresses the conversion from RGB
|
||||
colorspace input to the default YCbCr JPEG colorspace.
|
||||
This feature allows true lossless JPEG coding of RGB color images.
|
||||
The recommended command for this purpose is currently
|
||||
cjpeg -rgb -block 1 -arithmetic.
|
||||
SmartScale capable decoder (introduced with IJG JPEG 8) required.
|
||||
Thank to Michael Koch for the initial suggestion.
|
||||
|
||||
Add option to disable the region adjustment in the transupp crop code.
|
||||
Thank to Jeffrey Friedl for the suggestion.
|
||||
|
||||
Thank to Richard Jones and Edd Dawson for various minor corrections.
|
||||
|
||||
Thank to Akim Demaille for configure.ac cleanup.
|
||||
|
||||
|
||||
Version 8c 16-Jan-2011
|
||||
-----------------------
|
||||
|
||||
Add option to compression library and cjpeg (-block N) to use
|
||||
different DCT block size.
|
||||
All N from 1 to 16 are possible. Default is 8 (baseline format).
|
||||
Larger values produce higher compression,
|
||||
smaller values produce higher quality.
|
||||
SmartScale capable decoder (introduced with IJG JPEG 8) required.
|
||||
|
||||
|
||||
Version 8b 16-May-2010
|
||||
-----------------------
|
||||
|
||||
Repair problem in new memory source manager with corrupt JPEG data.
|
||||
Thank to Ted Campbell and Samuel Chun for the report.
|
||||
|
||||
Repair problem in Makefile.am test target.
|
||||
Thank to anonymous user for the report.
|
||||
|
||||
Support MinGW installation with automatic configure.
|
||||
Thank to Volker Grabsch for the suggestion.
|
||||
|
||||
|
||||
Version 8a 28-Feb-2010
|
||||
-----------------------
|
||||
|
||||
Writing tables-only datastreams via jpeg_write_tables works again.
|
||||
|
||||
Support 32-bit BMPs (RGB image with Alpha channel) for read in cjpeg.
|
||||
Thank to Brett Blackham for the suggestion.
|
||||
|
||||
Improve accuracy in floating point IDCT calculation.
|
||||
Thank to Robert Hooke for the hint.
|
||||
|
||||
|
||||
Version 8 10-Jan-2010
|
||||
----------------------
|
||||
|
||||
|
||||
91
cjpeg.1
91
cjpeg.1
@@ -1,4 +1,4 @@
|
||||
.TH CJPEG 1 "30 December 2009"
|
||||
.TH CJPEG 1 "28 April 2019"
|
||||
.SH NAME
|
||||
cjpeg \- compress an image file to a JPEG file
|
||||
.SH SYNOPSIS
|
||||
@@ -16,8 +16,9 @@ cjpeg \- compress an image file to a JPEG file
|
||||
compresses the named image file, or the standard input if no file is
|
||||
named, and produces a JPEG/JFIF file on the standard output.
|
||||
The currently supported input 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.)
|
||||
format), PGM (PBMPLUS grayscale format), BMP, GIF, 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.)
|
||||
.SH OPTIONS
|
||||
All switch names may be abbreviated; for example,
|
||||
.B \-grayscale
|
||||
@@ -42,13 +43,24 @@ Scale quantization tables to adjust image quality. Quality is 0 (worst) to
|
||||
.TP
|
||||
.B \-grayscale
|
||||
Create monochrome JPEG file from color input. Be sure to use this switch when
|
||||
compressing a grayscale BMP file, because
|
||||
compressing a grayscale BMP or GIF file, because
|
||||
.B cjpeg
|
||||
isn't bright enough to notice whether a BMP file uses only shades of gray.
|
||||
By saying
|
||||
isn't bright enough to notice whether a BMP or GIF file uses only shades of
|
||||
gray. By saying
|
||||
.BR \-grayscale ,
|
||||
you'll get a smaller JPEG file that takes less time to process.
|
||||
.TP
|
||||
.B \-rgb
|
||||
Create RGB JPEG file.
|
||||
Using this switch suppresses the conversion from RGB
|
||||
colorspace input to the default YCbCr JPEG colorspace.
|
||||
You can use this switch in combination with the
|
||||
.BI \-block " N"
|
||||
switch (see below) for lossless JPEG coding.
|
||||
See also the
|
||||
.B \-rgb1
|
||||
switch below.
|
||||
.TP
|
||||
.B \-optimize
|
||||
Perform optimization of entropy encoding parameters. Without this, default
|
||||
encoding parameters are used.
|
||||
@@ -64,7 +76,10 @@ Create progressive JPEG file (see below).
|
||||
.TP
|
||||
.BI \-scale " M/N"
|
||||
Scale the output image by a factor M/N. Currently supported scale factors are
|
||||
8/N with all N from 1 to 16.
|
||||
M/N with all N from 1 to 16, where M is the destination DCT size, which is 8
|
||||
by default (see
|
||||
.BI \-block " N"
|
||||
switch below).
|
||||
.TP
|
||||
.B \-targa
|
||||
Input file is Targa format. Targa files that contain an "identification"
|
||||
@@ -152,6 +167,59 @@ about the same --- often a little smaller.
|
||||
.PP
|
||||
Switches for advanced users:
|
||||
.TP
|
||||
.B \-arithmetic
|
||||
Use arithmetic coding.
|
||||
.B Caution:
|
||||
arithmetic coded JPEG is not yet widely implemented, so many decoders will
|
||||
be unable to view an arithmetic coded JPEG file at all.
|
||||
.TP
|
||||
.BI \-block " N"
|
||||
Set DCT block size. All N from 1 to 16 are possible.
|
||||
Default is 8 (baseline format).
|
||||
Larger values produce higher compression,
|
||||
smaller values produce higher quality
|
||||
(exact DCT stage possible with 1 or 2; with the default quality of 75 and
|
||||
default Luminance qtable the DCT+Quantization stage is lossless for N=1).
|
||||
.B Caution:
|
||||
An implementation of the JPEG SmartScale extension is required for this
|
||||
feature. SmartScale enabled JPEG is not yet widely implemented, so many
|
||||
decoders will be unable to view a SmartScale extended JPEG file at all.
|
||||
.TP
|
||||
.B \-rgb1
|
||||
Create RGB JPEG file with reversible color transform.
|
||||
Works like the
|
||||
.B \-rgb
|
||||
switch (see above) and inserts a simple reversible color transform
|
||||
into the processing which significantly improves the compression.
|
||||
Use this switch in combination with the
|
||||
.BI \-block " N"
|
||||
switch (see above) for lossless JPEG coding.
|
||||
.B Caution:
|
||||
A decoder with inverse color transform support is required for
|
||||
this feature. Reversible color transform support is not yet
|
||||
widely implemented, so many decoders will be unable to view
|
||||
a reversible color transformed JPEG file at all.
|
||||
.TP
|
||||
.B \-bgycc
|
||||
Create big gamut YCC JPEG file.
|
||||
In this type of encoding the color difference components are quantized
|
||||
further by a factor of 2 compared to the normal Cb/Cr values, thus creating
|
||||
space to allow larger color values with higher saturation than the normal
|
||||
gamut limits to be encoded. In order to compensate for the loss of color
|
||||
fidelity compared to a normal YCC encoded file, the color quantization
|
||||
tables can be adjusted accordingly. For example,
|
||||
.B cjpeg \-bgycc \-quality
|
||||
80,90 will give similar results as
|
||||
.B cjpeg \-quality
|
||||
80.
|
||||
.B Caution:
|
||||
For correct decompression a decoder with big gamut YCC support (JFIF
|
||||
version 2) is required. An old decoder may or may not display a big
|
||||
gamut YCC encoded JPEG file, depending on JFIF version check and
|
||||
corresponding warning/error configuration. In case of a granted
|
||||
decompression the old decoder will display the image with half
|
||||
saturated colors.
|
||||
.TP
|
||||
.B \-dct int
|
||||
Use integer DCT method (default).
|
||||
.TP
|
||||
@@ -219,12 +287,6 @@ visibly blur the image, however.
|
||||
.PP
|
||||
Switches for wizards:
|
||||
.TP
|
||||
.B \-arithmetic
|
||||
Use arithmetic coding.
|
||||
.B Caution:
|
||||
arithmetic coded JPEG is not yet widely implemented, so many decoders will be
|
||||
unable to view an arithmetic coded JPEG file at all.
|
||||
.TP
|
||||
.B \-baseline
|
||||
Force baseline-compatible quantization tables to be generated. This clamps
|
||||
quantization values to 8 bits even at low quality settings. (This switch is
|
||||
@@ -314,9 +376,6 @@ Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
|
||||
.SH AUTHOR
|
||||
Independent JPEG Group
|
||||
.SH BUGS
|
||||
GIF input files are no longer supported, to avoid the Unisys LZW patent.
|
||||
(Conversion of GIF files to JPEG is usually a bad idea anyway.)
|
||||
.PP
|
||||
Not all variants of BMP and Targa file formats are supported.
|
||||
.PP
|
||||
The
|
||||
|
||||
62
cjpeg.c
62
cjpeg.c
@@ -2,7 +2,7 @@
|
||||
* cjpeg.c
|
||||
*
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2003-2008 by Guido Vollbeding.
|
||||
* Modified 2003-2013 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -152,6 +152,7 @@ usage (void)
|
||||
fprintf(stderr, "Switches (names may be abbreviated):\n");
|
||||
fprintf(stderr, " -quality N[,...] Compression quality (0..100; 5-95 is useful range)\n");
|
||||
fprintf(stderr, " -grayscale Create monochrome JPEG file\n");
|
||||
fprintf(stderr, " -rgb Create RGB JPEG file\n");
|
||||
#ifdef ENTROPY_OPT_SUPPORTED
|
||||
fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n");
|
||||
#endif
|
||||
@@ -165,6 +166,16 @@ usage (void)
|
||||
fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n");
|
||||
#endif
|
||||
fprintf(stderr, "Switches for advanced users:\n");
|
||||
#ifdef C_ARITH_CODING_SUPPORTED
|
||||
fprintf(stderr, " -arithmetic Use arithmetic coding\n");
|
||||
#endif
|
||||
#ifdef DCT_SCALING_SUPPORTED
|
||||
fprintf(stderr, " -block N DCT block size (1..16; default is 8)\n");
|
||||
#endif
|
||||
#if JPEG_LIB_VERSION_MAJOR >= 9
|
||||
fprintf(stderr, " -rgb1 Create RGB JPEG file with reversible color transform\n");
|
||||
fprintf(stderr, " -bgycc Create big gamut YCC JPEG file\n");
|
||||
#endif
|
||||
#ifdef DCT_ISLOW_SUPPORTED
|
||||
fprintf(stderr, " -dct int Use integer DCT method%s\n",
|
||||
(JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : ""));
|
||||
@@ -186,9 +197,6 @@ usage (void)
|
||||
fprintf(stderr, " -outfile name Specify name for output file\n");
|
||||
fprintf(stderr, " -verbose or -debug Emit debug output\n");
|
||||
fprintf(stderr, "Switches for wizards:\n");
|
||||
#ifdef C_ARITH_CODING_SUPPORTED
|
||||
fprintf(stderr, " -arithmetic Use arithmetic coding\n");
|
||||
#endif
|
||||
fprintf(stderr, " -baseline Force baseline quantization tables\n");
|
||||
fprintf(stderr, " -qtables file Use quantization tables given in file\n");
|
||||
fprintf(stderr, " -qslots N[,...] Set component quantization tables\n");
|
||||
@@ -254,10 +262,29 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
|
||||
} else if (keymatch(arg, "baseline", 1)) {
|
||||
} else if (keymatch(arg, "baseline", 2)) {
|
||||
/* Force baseline-compatible output (8-bit quantizer values). */
|
||||
force_baseline = TRUE;
|
||||
|
||||
} else if (keymatch(arg, "block", 2)) {
|
||||
/* Set DCT block size. */
|
||||
#if defined DCT_SCALING_SUPPORTED && JPEG_LIB_VERSION_MAJOR >= 8 && \
|
||||
(JPEG_LIB_VERSION_MAJOR > 8 || JPEG_LIB_VERSION_MINOR >= 3)
|
||||
int val;
|
||||
|
||||
if (++argn >= argc) /* advance to next argument */
|
||||
usage();
|
||||
if (sscanf(argv[argn], "%d", &val) != 1)
|
||||
usage();
|
||||
if (val < 1 || val > 16)
|
||||
usage();
|
||||
cinfo->block_size = val;
|
||||
#else
|
||||
fprintf(stderr, "%s: sorry, block size setting not supported\n",
|
||||
progname);
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
|
||||
} else if (keymatch(arg, "dct", 2)) {
|
||||
/* Select DCT algorithm. */
|
||||
if (++argn >= argc) /* advance to next argument */
|
||||
@@ -287,6 +314,27 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
/* Force a monochrome JPEG file to be generated. */
|
||||
jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
|
||||
|
||||
} else if (keymatch(arg, "rgb", 3) || keymatch(arg, "rgb1", 4)) {
|
||||
/* Force an RGB JPEG file to be generated. */
|
||||
#if JPEG_LIB_VERSION_MAJOR >= 9
|
||||
/* Note: Entropy table assignment in jpeg_set_colorspace depends
|
||||
* on color_transform.
|
||||
*/
|
||||
cinfo->color_transform = arg[3] ? JCT_SUBTRACT_GREEN : JCT_NONE;
|
||||
#endif
|
||||
jpeg_set_colorspace(cinfo, JCS_RGB);
|
||||
|
||||
} else if (keymatch(arg, "bgycc", 5)) {
|
||||
/* Force a big gamut YCC JPEG file to be generated. */
|
||||
#if JPEG_LIB_VERSION_MAJOR >= 9 && \
|
||||
(JPEG_LIB_VERSION_MAJOR > 9 || JPEG_LIB_VERSION_MINOR >= 1)
|
||||
jpeg_set_colorspace(cinfo, JCS_BG_YCC);
|
||||
#else
|
||||
fprintf(stderr, "%s: sorry, BG_YCC colorspace not supported\n",
|
||||
progname);
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
|
||||
} else if (keymatch(arg, "maxmemory", 3)) {
|
||||
/* Maximum memory in Kb (or Mb with 'm'). */
|
||||
long lval;
|
||||
@@ -301,7 +349,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
cinfo->mem->max_memory_to_use = lval * 1000L;
|
||||
|
||||
} else if (keymatch(arg, "nosmooth", 3)) {
|
||||
/* Suppress fancy downsampling */
|
||||
/* Suppress fancy downsampling. */
|
||||
cinfo->do_fancy_downsampling = FALSE;
|
||||
|
||||
} else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) {
|
||||
@@ -387,7 +435,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
/* Scale the image by a fraction M/N. */
|
||||
if (++argn >= argc) /* advance to next argument */
|
||||
usage();
|
||||
if (sscanf(argv[argn], "%d/%d",
|
||||
if (sscanf(argv[argn], "%u/%u",
|
||||
&cinfo->scale_num, &cinfo->scale_denom) != 2)
|
||||
usage();
|
||||
|
||||
|
||||
348
compile
Executable file
348
compile
Executable file
@@ -0,0 +1,348 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2018-03-07.03; # UTC
|
||||
|
||||
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
|
||||
# We need space, tab and new line, in precisely that order. Quoting is
|
||||
# there to prevent tools from complaining about whitespace usage.
|
||||
IFS=" "" $nl"
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file lazy
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts. If the determined conversion
|
||||
# type is listed in (the comma separated) LAZY, no conversion will
|
||||
# take place.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv/,$2, in
|
||||
*,$file_conv,*)
|
||||
;;
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_cl_dashL linkdir
|
||||
# Make cl look for libraries in LINKDIR
|
||||
func_cl_dashL ()
|
||||
{
|
||||
func_file_conv "$1"
|
||||
if test -z "$lib_path"; then
|
||||
lib_path=$file
|
||||
else
|
||||
lib_path="$lib_path;$file"
|
||||
fi
|
||||
linker_opts="$linker_opts -LIBPATH:$file"
|
||||
}
|
||||
|
||||
# func_cl_dashl library
|
||||
# Do a library search-path lookup for cl
|
||||
func_cl_dashl ()
|
||||
{
|
||||
lib=$1
|
||||
found=no
|
||||
save_IFS=$IFS
|
||||
IFS=';'
|
||||
for dir in $lib_path $LIB
|
||||
do
|
||||
IFS=$save_IFS
|
||||
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.dll.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/$lib.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/lib$lib.a"; then
|
||||
found=yes
|
||||
lib=$dir/lib$lib.a
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
if test "$found" != yes; then
|
||||
lib=$lib.lib
|
||||
fi
|
||||
}
|
||||
|
||||
# func_cl_wrapper cl arg...
|
||||
# Adjust compile command to suit cl
|
||||
func_cl_wrapper ()
|
||||
{
|
||||
# Assume a capable shell
|
||||
lib_path=
|
||||
shared=:
|
||||
linker_opts=
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.[oO][bB][jJ])
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fo"$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fe"$file"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-I)
|
||||
eat=1
|
||||
func_file_conv "$2" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-I*)
|
||||
func_file_conv "${1#-I}" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-l)
|
||||
eat=1
|
||||
func_cl_dashl "$2"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
func_cl_dashl "${1#-l}"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-L)
|
||||
eat=1
|
||||
func_cl_dashL "$2"
|
||||
;;
|
||||
-L*)
|
||||
func_cl_dashL "${1#-L}"
|
||||
;;
|
||||
-static)
|
||||
shared=false
|
||||
;;
|
||||
-Wl,*)
|
||||
arg=${1#-Wl,}
|
||||
save_ifs="$IFS"; IFS=','
|
||||
for flag in $arg; do
|
||||
IFS="$save_ifs"
|
||||
linker_opts="$linker_opts $flag"
|
||||
done
|
||||
IFS="$save_ifs"
|
||||
;;
|
||||
-Xlinker)
|
||||
eat=1
|
||||
linker_opts="$linker_opts $2"
|
||||
;;
|
||||
-*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||
func_file_conv "$1"
|
||||
set x "$@" -Tp"$file"
|
||||
shift
|
||||
;;
|
||||
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||
func_file_conv "$1" mingw
|
||||
set x "$@" "$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if test -n "$linker_opts"; then
|
||||
linker_opts="-link$linker_opts"
|
||||
fi
|
||||
exec "$@" $linker_opts
|
||||
exit 1
|
||||
}
|
||||
|
||||
eat=
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand '-c -o'.
|
||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file 'INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
|
||||
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
# So we strip '-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no '-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# '.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
927
config.guess
vendored
927
config.guess
vendored
File diff suppressed because it is too large
Load Diff
536
config.sub
vendored
536
config.sub
vendored
File diff suppressed because it is too large
Load Diff
239
configure.ac
239
configure.ac
@@ -5,7 +5,7 @@
|
||||
# Configure script for IJG libjpeg
|
||||
#
|
||||
|
||||
AC_INIT([libjpeg], [8.0])
|
||||
AC_INIT([libjpeg], [9.4.0])
|
||||
|
||||
# Directory where autotools helper scripts lives.
|
||||
AC_CONFIG_AUX_DIR([.])
|
||||
@@ -21,16 +21,13 @@ AC_CANONICAL_TARGET
|
||||
|
||||
# Initialize Automake
|
||||
# Don't require all the GNU mandated files
|
||||
AM_INIT_AUTOMAKE([-Wall -Werror ansi2knr no-dist foreign])
|
||||
AM_INIT_AUTOMAKE([-Wall -Werror no-dist foreign])
|
||||
|
||||
# Make --enable-silent-rules the default.
|
||||
# To get verbose build output you may configure
|
||||
# with --disable-silent-rules or use "make V=1".
|
||||
AM_SILENT_RULES([yes])
|
||||
|
||||
# This is required when using the de-ANSI-fication feature.
|
||||
AM_C_PROTOTYPES
|
||||
|
||||
# Add configure option --enable-maintainer-mode which enables
|
||||
# dependency checking and generation useful to package maintainers.
|
||||
# This is made an option to avoid confusing end users.
|
||||
@@ -43,6 +40,7 @@ AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_LN_S
|
||||
AM_PROG_AR
|
||||
|
||||
# Check if LD supports linker scripts,
|
||||
# and define automake conditional HAVE_LD_VERSION_SCRIPT if so.
|
||||
@@ -63,7 +61,7 @@ VERS_2 {
|
||||
global: sym;
|
||||
} VERS_1;
|
||||
EOF
|
||||
AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
|
||||
[have_ld_version_script=yes], [have_ld_version_script=no])
|
||||
rm -f conftest.map
|
||||
LDFLAGS="$save_LDFLAGS"
|
||||
@@ -72,9 +70,9 @@ fi
|
||||
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
|
||||
|
||||
# See if compiler supports prototypes.
|
||||
AC_MSG_CHECKING(for function prototypes)
|
||||
AC_CACHE_VAL(ijg_cv_have_prototypes,
|
||||
[AC_TRY_COMPILE([
|
||||
AC_MSG_CHECKING([for function prototypes])
|
||||
AC_CACHE_VAL([ijg_cv_have_prototypes],
|
||||
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||
int testfunction (int arg1, int * arg2); /* check prototypes */
|
||||
struct methods_struct { /* check method-pointer declarations */
|
||||
int (*error_exit) (char *msgtext);
|
||||
@@ -85,25 +83,29 @@ int testfunction (int arg1, int * arg2) /* check definitions */
|
||||
{ return arg2[arg1]; }
|
||||
int test2function (void) /* check void arg list */
|
||||
{ return 0; }
|
||||
], [ ], ijg_cv_have_prototypes=yes, ijg_cv_have_prototypes=no)])
|
||||
AC_MSG_RESULT($ijg_cv_have_prototypes)
|
||||
]])],
|
||||
[ijg_cv_have_prototypes=yes],
|
||||
[ijg_cv_have_prototypes=no])])
|
||||
AC_MSG_RESULT([$ijg_cv_have_prototypes])
|
||||
if test $ijg_cv_have_prototypes = yes; then
|
||||
AC_DEFINE([HAVE_PROTOTYPES],[1],[Compiler supports function prototypes.])
|
||||
else
|
||||
echo Your compiler does not seem to know about function prototypes.
|
||||
echo Perhaps it needs a special switch to enable ANSI C mode.
|
||||
echo If so, we recommend running configure like this:
|
||||
echo " ./configure CC='cc -switch'"
|
||||
echo where -switch is the proper switch.
|
||||
AC_MSG_WARN([Your compiler does not seem to know about function prototypes.
|
||||
Perhaps it needs a special switch to enable ANSI C mode.
|
||||
If so, we recommend running configure like this:
|
||||
./configure CC='cc -switch'
|
||||
where -switch is the proper switch.])
|
||||
fi
|
||||
|
||||
# Check header files
|
||||
AC_CHECK_HEADERS(stddef.h stdlib.h locale.h)
|
||||
AC_CHECK_HEADER(string.h, , AC_DEFINE([NEED_BSD_STRINGS],[1],[Compiler has <strings.h> rather than standard <string.h>.]))
|
||||
AC_CHECK_HEADERS([stddef.h stdlib.h locale.h])
|
||||
AC_CHECK_HEADER([string.h], [],
|
||||
[AC_DEFINE([NEED_BSD_STRINGS], [1],
|
||||
[Compiler has <strings.h> rather than standard <string.h>.])])
|
||||
|
||||
# See whether type size_t is defined in any ANSI-standard places;
|
||||
# if not, perhaps it is defined in <sys/types.h>.
|
||||
AC_MSG_CHECKING(for size_t)
|
||||
AC_MSG_CHECKING([for size_t])
|
||||
AC_TRY_COMPILE([
|
||||
#ifdef HAVE_STDDEF_H
|
||||
#include <stddef.h>
|
||||
@@ -118,33 +120,42 @@ AC_TRY_COMPILE([
|
||||
#include <string.h>
|
||||
#endif
|
||||
typedef size_t my_size_t;
|
||||
], [ my_size_t foovar; ], ijg_size_t_ok=yes,
|
||||
[ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h"])
|
||||
AC_MSG_RESULT($ijg_size_t_ok)
|
||||
],
|
||||
[ my_size_t foovar; ],
|
||||
[ijg_size_t_ok=yes],
|
||||
[ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h"])
|
||||
AC_MSG_RESULT([$ijg_size_t_ok])
|
||||
if test "$ijg_size_t_ok" != yes; then
|
||||
AC_CHECK_HEADER(sys/types.h, [AC_DEFINE([NEED_SYS_TYPES_H],[1],[Need to include <sys/types.h> in order to obtain size_t.])
|
||||
AC_EGREP_CPP(size_t, [#include <sys/types.h>],
|
||||
[ijg_size_t_ok="size_t is in sys/types.h"], ijg_size_t_ok=no)],
|
||||
ijg_size_t_ok=no)
|
||||
AC_MSG_RESULT($ijg_size_t_ok)
|
||||
if test "$ijg_size_t_ok" = no; then
|
||||
echo Type size_t is not defined in any of the usual places.
|
||||
echo Try putting '"typedef unsigned int size_t;"' in jconfig.h.
|
||||
fi
|
||||
AC_CHECK_HEADER([sys/types.h],
|
||||
[AC_DEFINE([NEED_SYS_TYPES_H], [1],
|
||||
[Need to include <sys/types.h> in order to obtain size_t.])
|
||||
AC_EGREP_CPP([size_t], [#include <sys/types.h>],
|
||||
[ijg_size_t_ok="size_t is in sys/types.h"],
|
||||
[ijg_size_t_ok=no])],
|
||||
[ijg_size_t_ok=no])
|
||||
AC_MSG_RESULT([$ijg_size_t_ok])
|
||||
if test "$ijg_size_t_ok" = no; then
|
||||
AC_MSG_WARN([Type size_t is not defined in any of the usual places.
|
||||
Try putting '"typedef unsigned int size_t;"' in jconfig.h.])
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check compiler characteristics
|
||||
AC_MSG_CHECKING(for type unsigned char)
|
||||
AC_TRY_COMPILE(, [ unsigned char un_char; ],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_UNSIGNED_CHAR],[1],[Compiler supports 'unsigned char'.])], AC_MSG_RESULT(no))
|
||||
dnl
|
||||
AC_MSG_CHECKING(for type unsigned short)
|
||||
AC_TRY_COMPILE(, [ unsigned short un_short; ],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_UNSIGNED_SHORT],[1],[Compiler supports 'unsigned short'.])], AC_MSG_RESULT(no))
|
||||
dnl
|
||||
AC_MSG_CHECKING(for type void)
|
||||
AC_MSG_CHECKING([for type unsigned char])
|
||||
AC_TRY_COMPILE([], [ unsigned char un_char; ],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_UNSIGNED_CHAR], [1],
|
||||
[Compiler supports 'unsigned char'.])],
|
||||
[AC_MSG_RESULT(no)])
|
||||
|
||||
AC_MSG_CHECKING([for type unsigned short])
|
||||
AC_TRY_COMPILE([], [ unsigned short un_short; ],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_UNSIGNED_SHORT], [1],
|
||||
[Compiler supports 'unsigned short'.])],
|
||||
[AC_MSG_RESULT(no)])
|
||||
|
||||
AC_MSG_CHECKING([for type void])
|
||||
AC_TRY_COMPILE([
|
||||
/* Caution: a C++ compiler will insist on valid prototypes */
|
||||
typedef void * void_ptr; /* check void * */
|
||||
@@ -166,40 +177,56 @@ void test3function (arg1, arg2)
|
||||
arg1 = (void *) locptr;
|
||||
(*arg2) (1, 2); /* check call of fcn returning void */
|
||||
}
|
||||
], [ ], AC_MSG_RESULT(yes), [AC_MSG_RESULT(no)
|
||||
AC_DEFINE([void],[char],[Define 'void' as 'char' for archaic compilers that don't understand it.])])
|
||||
], [ ],
|
||||
[AC_MSG_RESULT(yes)],
|
||||
[AC_MSG_RESULT(no)
|
||||
AC_DEFINE([void], [char],
|
||||
[Define 'void' as 'char' for archaic compilers
|
||||
that don't understand it.])])
|
||||
AC_C_CONST
|
||||
|
||||
# Check for non-broken inline under various spellings
|
||||
AC_MSG_CHECKING(for inline)
|
||||
AC_MSG_CHECKING([for inline])
|
||||
ijg_cv_inline=""
|
||||
AC_TRY_COMPILE(, [} __inline__ int foo() { return 0; }
|
||||
AC_TRY_COMPILE([], [} __inline__ int foo() { return 0; }
|
||||
int bar() { return foo();], ijg_cv_inline="__inline__",
|
||||
AC_TRY_COMPILE(, [} __inline int foo() { return 0; }
|
||||
[AC_TRY_COMPILE(, [} __inline int foo() { return 0; }
|
||||
int bar() { return foo();], ijg_cv_inline="__inline",
|
||||
AC_TRY_COMPILE(, [} inline int foo() { return 0; }
|
||||
int bar() { return foo();], ijg_cv_inline="inline")))
|
||||
[AC_TRY_COMPILE(, [} inline int foo() { return 0; }
|
||||
int bar() { return foo();], ijg_cv_inline="inline")])])
|
||||
AC_MSG_RESULT($ijg_cv_inline)
|
||||
AC_DEFINE_UNQUOTED([INLINE],[$ijg_cv_inline],[How to obtain function inlining.])
|
||||
AC_DEFINE_UNQUOTED([INLINE], [$ijg_cv_inline],
|
||||
[How to obtain function inlining.])
|
||||
|
||||
# We cannot check for bogus warnings, but at least we can check for errors
|
||||
AC_MSG_CHECKING(for broken incomplete types)
|
||||
AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
|
||||
AC_MSG_RESULT(ok),
|
||||
[AC_MSG_RESULT(broken)
|
||||
AC_DEFINE([INCOMPLETE_TYPES_BROKEN],[1],[Compiler does not support pointers to unspecified structures.])])
|
||||
AC_MSG_CHECKING([for broken incomplete types])
|
||||
AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ],
|
||||
[],
|
||||
[AC_MSG_RESULT(ok)],
|
||||
[AC_MSG_RESULT(broken)
|
||||
AC_DEFINE([INCOMPLETE_TYPES_BROKEN], [1],
|
||||
[Compiler does not support pointers to unspecified
|
||||
structures.])])
|
||||
|
||||
# Test whether global names are unique to at least 15 chars
|
||||
AC_MSG_CHECKING(for short external names)
|
||||
AC_MSG_CHECKING([for short external names])
|
||||
AC_TRY_LINK([
|
||||
int possibly_duplicate_function () { return 0; }
|
||||
int possibly_dupli_function () { return 1; }
|
||||
], [ ], AC_MSG_RESULT(ok), [AC_MSG_RESULT(short)
|
||||
AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES],[1],[Linker requires that global names be unique in first 15 characters.])])
|
||||
], [],
|
||||
[AC_MSG_RESULT(ok)],
|
||||
[AC_MSG_RESULT(short)
|
||||
AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], [1],
|
||||
[Linker requires that global names be unique in
|
||||
first 15 characters.])])
|
||||
|
||||
# Run-time checks
|
||||
AC_MSG_CHECKING(to see if char is signed)
|
||||
AC_MSG_CHECKING([to see if char is signed])
|
||||
AC_TRY_RUN([
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
int is_char_signed (int arg)
|
||||
#else
|
||||
@@ -220,13 +247,19 @@ char signed_char_check = (char) (-67);
|
||||
int main() {
|
||||
exit(is_char_signed((int) signed_char_check));
|
||||
}], [AC_MSG_RESULT(no)
|
||||
AC_DEFINE([CHAR_IS_UNSIGNED],[1],[Characters are unsigned])], AC_MSG_RESULT(yes),
|
||||
[echo Assuming that char is signed on target machine.
|
||||
echo If it is unsigned, this will be a little bit inefficient.
|
||||
AC_DEFINE([CHAR_IS_UNSIGNED], [1],
|
||||
[Characters are unsigned])],
|
||||
[AC_MSG_RESULT(yes)],
|
||||
[AC_MSG_WARN([Assuming that char is signed on target machine.
|
||||
If it is unsigned, this will be a little bit inefficient.])
|
||||
])
|
||||
dnl
|
||||
AC_MSG_CHECKING(to see if right shift is signed)
|
||||
|
||||
AC_MSG_CHECKING([to see if right shift is signed])
|
||||
AC_TRY_RUN([
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
int is_shifting_signed (long arg)
|
||||
#else
|
||||
@@ -252,20 +285,29 @@ int is_shifting_signed (arg)
|
||||
}
|
||||
int main() {
|
||||
exit(is_shifting_signed(-0x7F7E80B1L));
|
||||
}], [AC_MSG_RESULT(no)
|
||||
AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED],[1],[Broken compiler shifts signed values as an unsigned shift.])], AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(Assuming that right shift is signed on target machine.))
|
||||
dnl
|
||||
AC_MSG_CHECKING(to see if fopen accepts b spec)
|
||||
}],
|
||||
[AC_MSG_RESULT(no)
|
||||
AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], [1],
|
||||
[Broken compiler shifts signed values as an unsigned shift.])],
|
||||
[AC_MSG_RESULT(yes)],
|
||||
[AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
|
||||
|
||||
AC_MSG_CHECKING([to see if fopen accepts b spec])
|
||||
AC_TRY_RUN([
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
if (fopen("conftestdata", "wb") != NULL)
|
||||
exit(0);
|
||||
exit(1);
|
||||
}], AC_MSG_RESULT(yes), [AC_MSG_RESULT(no)
|
||||
AC_DEFINE([DONT_USE_B_MODE],[1],[Don't open files in binary mode.])],
|
||||
AC_MSG_RESULT(Assuming that it does.))
|
||||
}],
|
||||
[AC_MSG_RESULT(yes)],
|
||||
[AC_MSG_RESULT(no)
|
||||
AC_DEFINE([DONT_USE_B_MODE], [1],
|
||||
[Don't open files in binary mode.])],
|
||||
[AC_MSG_RESULT(Assuming that it does.)])
|
||||
|
||||
# Configure libtool
|
||||
AC_LIBTOOL_WIN32_DLL
|
||||
@@ -275,9 +317,9 @@ AC_PROG_LIBTOOL
|
||||
# If no "-enable-maxmem", use jmemnobs
|
||||
MEMORYMGR='jmemnobs'
|
||||
MAXMEM="no"
|
||||
AC_ARG_ENABLE(maxmem,
|
||||
AC_ARG_ENABLE([maxmem],
|
||||
[ --enable-maxmem[=N] enable use of temp files, set max mem usage to N MB],
|
||||
MAXMEM="$enableval")
|
||||
[MAXMEM="$enableval"])
|
||||
dnl [# support --with-maxmem for backwards compatibility with IJG V5.]
|
||||
dnl AC_ARG_WITH(maxmem, , MAXMEM="$withval")
|
||||
if test "x$MAXMEM" = xyes; then
|
||||
@@ -288,30 +330,37 @@ if test "x$MAXMEM" != xno; then
|
||||
AC_MSG_ERROR(non-numeric argument to --enable-maxmem)
|
||||
fi
|
||||
DEFAULTMAXMEM=`expr $MAXMEM \* 1048576`
|
||||
AC_DEFINE_UNQUOTED([DEFAULT_MAX_MEM], [${DEFAULTMAXMEM}], [Maximum data space library will allocate.])
|
||||
AC_MSG_CHECKING([for 'tmpfile()'])
|
||||
AC_TRY_LINK([#include <stdio.h>], [ FILE * tfile = tmpfile(); ],
|
||||
[AC_MSG_RESULT(yes)
|
||||
MEMORYMGR='jmemansi'],
|
||||
[AC_MSG_RESULT(no)
|
||||
dnl if tmpfile is not present, must use jmemname.
|
||||
MEMORYMGR='jmemname'
|
||||
AC_DEFINE_UNQUOTED([DEFAULT_MAX_MEM], [${DEFAULTMAXMEM}],
|
||||
[Maximum data space library will allocate.])
|
||||
AC_MSG_CHECKING([for 'tmpfile()'])
|
||||
AC_TRY_LINK([#include <stdio.h>], [ FILE * tfile = tmpfile(); ],
|
||||
[AC_MSG_RESULT(yes)
|
||||
MEMORYMGR='jmemansi'],
|
||||
[AC_MSG_RESULT(no)
|
||||
dnl if tmpfile is not present, must use jmemname.
|
||||
MEMORYMGR='jmemname'
|
||||
|
||||
# Test for the need to remove temporary files using a signal handler (for cjpeg/djpeg)
|
||||
AC_DEFINE([NEED_SIGNAL_CATCHER],[1],[Need signal handler to clean up temporary files.])
|
||||
AC_MSG_CHECKING([for 'mktemp()'])
|
||||
AC_TRY_LINK(, [ char fname[80]; mktemp(fname); ], AC_MSG_RESULT(yes),
|
||||
[AC_MSG_RESULT(no)
|
||||
AC_DEFINE([NO_MKTEMP],[1],[The mktemp() function is not available.])])])
|
||||
# Test for the need to remove temporary files using a signal handler
|
||||
# (for cjpeg/djpeg)
|
||||
AC_DEFINE([NEED_SIGNAL_CATCHER], [1],
|
||||
[Need signal handler to clean up temporary files.])
|
||||
AC_MSG_CHECKING([for 'mktemp()'])
|
||||
AC_TRY_LINK([], [ char fname[80]; mktemp(fname); ],
|
||||
[AC_MSG_RESULT(yes)],
|
||||
[AC_MSG_RESULT(no)
|
||||
AC_DEFINE([NO_MKTEMP], [1],
|
||||
[The mktemp() function is not available.])])])
|
||||
fi
|
||||
AC_SUBST(MEMORYMGR)
|
||||
AC_SUBST([MEMORYMGR])
|
||||
|
||||
# Extract the library version ID from jpeglib.h.
|
||||
# Extract the library version IDs from jpeglib.h.
|
||||
AC_MSG_CHECKING([libjpeg version number])
|
||||
[JPEG_LIB_VERSION=`sed -e '/^#define JPEG_LIB_VERSION/!d' -e 's/^[^0-9]*\([0-9][0-9]*\).*$/\1/' $srcdir/jpeglib.h`]
|
||||
[JPEG_LIB_VERSION="`expr $JPEG_LIB_VERSION / 10`:`expr $JPEG_LIB_VERSION % 10`"]
|
||||
AC_MSG_RESULT([$JPEG_LIB_VERSION])
|
||||
AC_SUBST([JPEG_LIB_VERSION])
|
||||
[major=`sed -ne 's/^#define JPEG_LIB_VERSION_MAJOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h`
|
||||
minor=`sed -ne 's/^#define JPEG_LIB_VERSION_MINOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h`]
|
||||
AC_SUBST([JPEG_LIB_VERSION], [`expr $major + $minor`:0:$minor])
|
||||
AC_SUBST([JPEG_LIB_VERSION_MAJOR], [$major])
|
||||
AC_SUBST([JPEG_LIB_VERSION_MINOR], [$minor])
|
||||
AC_MSG_RESULT([$major.$minor.0])
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_CONFIG_FILES([Makefile libjpeg.pc])
|
||||
AC_OUTPUT
|
||||
|
||||
429
depcomp
429
depcomp
@@ -1,10 +1,9 @@
|
||||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
scriptversion=2018-03-07.03; # UTC
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
|
||||
# Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -17,7 +16,7 @@ scriptversion=2009-04-28.21; # UTC
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
@@ -28,7 +27,7 @@ scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
@@ -40,11 +39,11 @@ as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by `PROGRAMS ARGS'.
|
||||
object Object file output by `PROGRAMS ARGS'.
|
||||
source Source file read by 'PROGRAMS ARGS'.
|
||||
object Object file output by 'PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputing dependencies.
|
||||
tmpdepfile Temporary file to use when outputting dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
@@ -57,6 +56,66 @@ EOF
|
||||
;;
|
||||
esac
|
||||
|
||||
# Get the directory component of the given path, and save it in the
|
||||
# global variables '$dir'. Note that this directory component will
|
||||
# be either empty or ending with a '/' character. This is deliberate.
|
||||
set_dir_from ()
|
||||
{
|
||||
case $1 in
|
||||
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
|
||||
*) dir=;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Get the suffix-stripped basename of the given path, and save it the
|
||||
# global variable '$base'.
|
||||
set_base_from ()
|
||||
{
|
||||
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
|
||||
}
|
||||
|
||||
# If no dependency file was actually created by the compiler invocation,
|
||||
# we still have to create a dummy depfile, to avoid errors with the
|
||||
# Makefile "include basename.Plo" scheme.
|
||||
make_dummy_depfile ()
|
||||
{
|
||||
echo "#dummy" > "$depfile"
|
||||
}
|
||||
|
||||
# Factor out some common post-processing of the generated depfile.
|
||||
# Requires the auxiliary global variable '$tmpdepfile' to be set.
|
||||
aix_post_process_depfile ()
|
||||
{
|
||||
# If the compiler actually managed to produce a dependency file,
|
||||
# post-process it.
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form 'foo.o: dependency.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# $object: dependency.h
|
||||
# and one to simply output
|
||||
# dependency.h:
|
||||
# which is needed to avoid the deleted-header problem.
|
||||
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
|
||||
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
|
||||
} > "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
}
|
||||
|
||||
# A tabulation character.
|
||||
tab=' '
|
||||
# A newline character.
|
||||
nl='
|
||||
'
|
||||
# Character ranges might be problematic outside the C locale.
|
||||
# These definitions help.
|
||||
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
lower=abcdefghijklmnopqrstuvwxyz
|
||||
digits=0123456789
|
||||
alpha=${upper}${lower}
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
@@ -69,6 +128,9 @@ tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Avoid interferences from the environment.
|
||||
gccflag= dashmflag=
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
@@ -90,10 +152,24 @@ if test "$depmode" = msvcmsys; then
|
||||
# This is just like msvisualcpp but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u="sed s,\\\\\\\\,/,g"
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvisualcpp
|
||||
fi
|
||||
|
||||
if test "$depmode" = msvc7msys; then
|
||||
# This is just like msvc7 but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvc7
|
||||
fi
|
||||
|
||||
if test "$depmode" = xlc; then
|
||||
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
|
||||
gccflag=-qmakedep=gcc,-MF
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
@@ -114,8 +190,7 @@ gcc3)
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
@@ -123,13 +198,17 @@ gcc3)
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
|
||||
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
|
||||
## (see the conditional assignment to $gccflag above).
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say).
|
||||
## -MM, not -M (despite what the docs say). Also, it might not be
|
||||
## supported by the other compilers which use the 'gcc' depmode.
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
@@ -137,31 +216,31 @@ gcc)
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
## The second -e expression handles DOS-style file names with drive letters.
|
||||
# The second -e expression handles DOS-style file names with drive
|
||||
# letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the `deleted header file' problem.
|
||||
## This next piece of magic avoids the "deleted header file" problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" |
|
||||
## Some versions of gcc put a space before the `:'. On the theory
|
||||
## Some versions of gcc put a space before the ':'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well.
|
||||
## well. hp depmode also adds that space, but also prefixes the VPATH
|
||||
## to the object. Take care to not repeat it in the output.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
@@ -179,8 +258,7 @@ sgi)
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
@@ -188,43 +266,41 @@ sgi)
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like `#:fec' to the end of the
|
||||
# the IRIX cc adds comments like '#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||
tr '
|
||||
' ' ' >> "$depfile"
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
|
||||
| tr "$nl" ' ' >> "$depfile"
|
||||
echo >> "$depfile"
|
||||
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
xlc)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts `$object:' at the
|
||||
# current directory. Also, the AIX compiler puts '$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$base.u
|
||||
@@ -237,9 +313,7 @@ aix)
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
@@ -248,44 +322,100 @@ aix)
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form `foo.o: dependent.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
tcc)
|
||||
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
|
||||
# FIXME: That version still under development at the moment of writing.
|
||||
# Make that this statement remains true also for stable, released
|
||||
# versions.
|
||||
# It will wrap lines (doesn't matter whether long or short) with a
|
||||
# trailing '\', as in:
|
||||
#
|
||||
# foo.o : \
|
||||
# foo.c \
|
||||
# foo.h \
|
||||
#
|
||||
# It will put a trailing '\' even on the last line, and will use leading
|
||||
# spaces rather than leading tabs (at least since its commit 0394caf7
|
||||
# "Emit spaces for -MD").
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
|
||||
# We have to change lines of the first kind to '$object: \'.
|
||||
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
|
||||
# And for each line of the second kind, we have to emit a 'dep.h:'
|
||||
# dummy dependency, to avoid the deleted-header problem.
|
||||
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
icc)
|
||||
# Intel's C compiler understands `-MD -MF file'. However on
|
||||
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
|
||||
# ICC 7.0 will fill foo.d with something like
|
||||
# foo.o: sub/foo.c
|
||||
# foo.o: sub/foo.h
|
||||
# which is wrong. We want:
|
||||
# sub/foo.o: sub/foo.c
|
||||
# sub/foo.o: sub/foo.h
|
||||
# sub/foo.c:
|
||||
# sub/foo.h:
|
||||
# ICC 7.1 will output
|
||||
## The order of this option in the case statement is important, since the
|
||||
## shell code in configure will try each of these formats in the order
|
||||
## listed in this file. A plain '-MD' option would be understood by many
|
||||
## compilers, so we must ensure this comes after the gcc and icc options.
|
||||
pgcc)
|
||||
# Portland's C compiler understands '-MD'.
|
||||
# Will always output deps to 'file.d' where file is the root name of the
|
||||
# source file under compilation, even if file resides in a subdirectory.
|
||||
# The object file name does not affect the name of the '.d' file.
|
||||
# pgcc 10.2 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using \ :
|
||||
# and will wrap long lines using '\' :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
set_dir_from "$object"
|
||||
# Use the source, not the object, to determine the base name, since
|
||||
# that's sadly what pgcc will do too.
|
||||
set_base_from "$source"
|
||||
tmpdepfile=$base.d
|
||||
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
# For projects that build the same source file twice into different object
|
||||
# files, the pgcc approach of using the *source* file root name can cause
|
||||
# problems in parallel builds. Use a locking strategy to avoid stomping on
|
||||
# the same $tmpdepfile.
|
||||
lockdir=$base.d-lock
|
||||
trap "
|
||||
echo '$0: caught signal, cleaning up...' >&2
|
||||
rmdir '$lockdir'
|
||||
exit 1
|
||||
" 1 2 13 15
|
||||
numtries=100
|
||||
i=$numtries
|
||||
while test $i -gt 0; do
|
||||
# mkdir is a portable test-and-set.
|
||||
if mkdir "$lockdir" 2>/dev/null; then
|
||||
# This process acquired the lock.
|
||||
"$@" -MD
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
# Release the lock.
|
||||
rmdir "$lockdir"
|
||||
break
|
||||
else
|
||||
# If the lock is being held by a different process, wait
|
||||
# until the winning process is done or we timeout.
|
||||
while test -d "$lockdir" && test $i -gt 0; do
|
||||
sleep 1
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
fi
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
trap - 1 2 13 15
|
||||
if test $i -le 0; then
|
||||
echo "$0: failed to acquire lock after $numtries attempts" >&2
|
||||
echo "$0: check lockdir '$lockdir'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
@@ -297,8 +427,8 @@ icc)
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
|
||||
sed -e 's/$/ :/' >> "$depfile"
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
@@ -309,9 +439,8 @@ hp2)
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
@@ -322,8 +451,7 @@ hp2)
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
@@ -333,8 +461,8 @@ hp2)
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add `dependent.h:' lines.
|
||||
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add 'dependent.h:' lines.
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
@@ -342,67 +470,97 @@ hp2)
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
|
||||
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in `foo.d' instead, so we check for that too.
|
||||
# dependencies in 'foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# With Tru64 cc, shared objects can also be used to make a
|
||||
# static library. This mechanism is used in libtool 1.4 series to
|
||||
# handle both shared and static libraries in a single compilation.
|
||||
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
|
||||
#
|
||||
# With libtool 1.5 this exception was removed, and libtool now
|
||||
# generates 2 separate objects for the 2 libraries. These two
|
||||
# compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# Libtool generates 2 separate objects for the 2 libraries. These
|
||||
# two compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
|
||||
tmpdepfile2=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
|
||||
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
tmpdepfile1=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
|
||||
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.o.d
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
tmpdepfile4=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
# Same post-processing that is required for AIX mode.
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
msvc7)
|
||||
if test "$libtool" = yes; then
|
||||
showIncludes=-Wc,-showIncludes
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
showIncludes=-showIncludes
|
||||
fi
|
||||
"$@" $showIncludes > "$tmpdepfile"
|
||||
stat=$?
|
||||
grep -v '^Note: including file: ' "$tmpdepfile"
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The first sed program below extracts the file names and escapes
|
||||
# backslashes for cygpath. The second sed program outputs the file
|
||||
# name when reading, but also accumulates all include files in the
|
||||
# hold buffer in order to output them again at the end. This only
|
||||
# works with sed implementations that can handle large buffers.
|
||||
sed < "$tmpdepfile" -n '
|
||||
/^Note: including file: *\(.*\)/ {
|
||||
s//\1/
|
||||
s/\\/\\\\/g
|
||||
p
|
||||
}' | $cygpath_u | sort -u | sed -n '
|
||||
s/ /\\ /g
|
||||
s/\(.*\)/'"$tab"'\1 \\/p
|
||||
s/.\(.*\) \\/\1:/
|
||||
H
|
||||
$ {
|
||||
s/.*/'"$tab"'/
|
||||
G
|
||||
p
|
||||
}' >> "$depfile"
|
||||
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvc7msys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
@@ -422,7 +580,7 @@ dashmstdout)
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
@@ -442,18 +600,18 @@ dashmstdout)
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for `:'
|
||||
# Require at least two characters before searching for ':'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
|
||||
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this sed invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
@@ -503,12 +661,15 @@ makedepend)
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
sed '1,2d' "$tmpdepfile" | tr ' ' '
|
||||
' | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
# makedepend may prepend the VPATH from the source file name to the object.
|
||||
# No need to regex-escape $object, excess matching of '.' is harmless.
|
||||
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process the last invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed '1,2d' "$tmpdepfile" \
|
||||
| tr ' ' "$nl" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
@@ -525,7 +686,7 @@ cpp)
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
@@ -544,10 +705,10 @@ cpp)
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
"$@" -E \
|
||||
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
| sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
@@ -594,8 +755,8 @@ msvisualcpp)
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
echo " " >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
|
||||
echo "$tab" >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
@@ -622,9 +783,9 @@ exit 0
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
||||
54
djpeg.1
54
djpeg.1
@@ -1,4 +1,4 @@
|
||||
.TH DJPEG 1 "3 October 2009"
|
||||
.TH DJPEG 1 "28 April 2019"
|
||||
.SH NAME
|
||||
djpeg \- decompress a JPEG file to an image file
|
||||
.SH SYNOPSIS
|
||||
@@ -16,7 +16,8 @@ djpeg \- decompress a JPEG file to an image file
|
||||
decompresses the named JPEG file, or the standard input if no file is named,
|
||||
and produces an image file on the standard output. PBMPLUS (PPM/PGM), BMP,
|
||||
GIF, Targa, or RLE (Utah Raster Toolkit) output format can be selected.
|
||||
(RLE is supported only if the URT library is available.)
|
||||
(RLE is supported only if the URT library is available, which it isn't
|
||||
on most non-Unix systems.)
|
||||
.SH OPTIONS
|
||||
All switch names may be abbreviated; for example,
|
||||
.B \-grayscale
|
||||
@@ -55,11 +56,16 @@ default options are chosen for highest quality output.) Currently, this is
|
||||
equivalent to \fB\-dct fast \-nosmooth \-onepass \-dither ordered\fR.
|
||||
.TP
|
||||
.B \-grayscale
|
||||
Force gray-scale output even if JPEG file is color. Useful for viewing on
|
||||
monochrome displays; also,
|
||||
Force grayscale output even if JPEG file is color.
|
||||
Useful for viewing on monochrome displays; also,
|
||||
.B djpeg
|
||||
runs noticeably faster in this mode.
|
||||
.TP
|
||||
.B \-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.
|
||||
.TP
|
||||
.BI \-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
|
||||
@@ -71,31 +77,42 @@ Scaling is handy if the image is larger than your screen; also,
|
||||
runs much faster when scaling down the output.
|
||||
.TP
|
||||
.B \-bmp
|
||||
Select BMP output format (Windows flavor). 8-bit colormapped format is
|
||||
emitted if
|
||||
Select BMP output format (Windows flavor).
|
||||
8-bit colormapped format is emitted if
|
||||
.B \-colors
|
||||
or
|
||||
.B \-grayscale
|
||||
is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color
|
||||
is specified, or if the JPEG file is grayscale; otherwise, 24-bit full-color
|
||||
format is emitted.
|
||||
.TP
|
||||
.B \-gif
|
||||
Select GIF output format. Since GIF does not support more than 256 colors,
|
||||
Select GIF output format (LZW compressed).
|
||||
Since GIF does not support more than 256 colors,
|
||||
.B \-colors 256
|
||||
is assumed (unless you specify a smaller number of colors).
|
||||
is assumed (unless you specify a smaller number of colors). If you specify
|
||||
.BR \-fast ,
|
||||
the default number of colors is 216.
|
||||
.TP
|
||||
.B \-gif0
|
||||
Select GIF output format (uncompressed).
|
||||
Since GIF does not support more than 256 colors,
|
||||
.B \-colors 256
|
||||
is assumed (unless you specify a smaller number of colors). If you specify
|
||||
.BR \-fast ,
|
||||
the default number of colors is 216.
|
||||
.TP
|
||||
.B \-os2
|
||||
Select BMP output format (OS/2 1.x flavor). 8-bit colormapped format is
|
||||
emitted if
|
||||
Select BMP output format (OS/2 1.x flavor).
|
||||
8-bit colormapped format is emitted if
|
||||
.B \-colors
|
||||
or
|
||||
.B \-grayscale
|
||||
is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color
|
||||
is specified, or if the JPEG file is grayscale; otherwise, 24-bit full-color
|
||||
format is emitted.
|
||||
.TP
|
||||
.B \-pnm
|
||||
Select PBMPLUS (PPM/PGM) output format (this is the default format).
|
||||
PGM is emitted if the JPEG file is gray-scale or if
|
||||
PGM is emitted if the JPEG file is grayscale or if
|
||||
.B \-grayscale
|
||||
is specified; otherwise PPM is emitted.
|
||||
.TP
|
||||
@@ -103,8 +120,8 @@ is specified; otherwise PPM is emitted.
|
||||
Select RLE output format. (Requires URT library.)
|
||||
.TP
|
||||
.B \-targa
|
||||
Select Targa output format. Gray-scale format is emitted if the JPEG file is
|
||||
gray-scale or if
|
||||
Select Targa output format. Grayscale format is emitted if the JPEG file is
|
||||
grayscale or if
|
||||
.B \-grayscale
|
||||
is specified; otherwise, colormapped format is emitted if
|
||||
.B \-colors
|
||||
@@ -162,7 +179,7 @@ faster and needs less memory, but it produces a lower-quality image.
|
||||
is ignored unless you also say
|
||||
.B \-colors
|
||||
.IR N .
|
||||
Also, the one-pass method is always used for gray-scale output (the two-pass
|
||||
Also, the one-pass method is always used for grayscale output (the two-pass
|
||||
method is no improvement then).
|
||||
.TP
|
||||
.BI \-maxmemory " N"
|
||||
@@ -245,8 +262,3 @@ Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
|
||||
Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
|
||||
.SH AUTHOR
|
||||
Independent JPEG Group
|
||||
.SH BUGS
|
||||
To avoid the Unisys LZW patent,
|
||||
.B djpeg
|
||||
produces uncompressed GIF files. These are larger than they should be, but
|
||||
are readable by standard GIF decoders.
|
||||
|
||||
34
djpeg.c
34
djpeg.c
@@ -2,7 +2,7 @@
|
||||
* djpeg.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2009 by Guido Vollbeding.
|
||||
* Modified 2009-2019 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.
|
||||
*
|
||||
@@ -59,7 +59,8 @@ static const char * const cdjpeg_message_table[] = {
|
||||
|
||||
typedef enum {
|
||||
FMT_BMP, /* BMP format (Windows flavor) */
|
||||
FMT_GIF, /* GIF format */
|
||||
FMT_GIF, /* GIF format (LZW compressed) */
|
||||
FMT_GIF0, /* GIF format (uncompressed) */
|
||||
FMT_OS2, /* BMP format (OS/2 flavor) */
|
||||
FMT_PPM, /* PPM/PGM (PBMPLUS formats) */
|
||||
FMT_RLE, /* RLE format */
|
||||
@@ -102,6 +103,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
|
||||
@@ -110,8 +112,10 @@ usage (void)
|
||||
(DEFAULT_FMT == FMT_BMP ? " (default)" : ""));
|
||||
#endif
|
||||
#ifdef GIF_SUPPORTED
|
||||
fprintf(stderr, " -gif Select GIF output format%s\n",
|
||||
fprintf(stderr, " -gif Select GIF output format (LZW compressed)%s\n",
|
||||
(DEFAULT_FMT == FMT_GIF ? " (default)" : ""));
|
||||
fprintf(stderr, " -gif0 Select GIF output format (uncompressed)%s\n",
|
||||
(DEFAULT_FMT == FMT_GIF0 ? " (default)" : ""));
|
||||
#endif
|
||||
#ifdef BMP_SUPPORTED
|
||||
fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s\n",
|
||||
@@ -194,7 +198,7 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
|
||||
arg++; /* advance past switch marker character */
|
||||
|
||||
if (keymatch(arg, "bmp", 1)) {
|
||||
/* BMP output format. */
|
||||
/* BMP output format (Windows flavor). */
|
||||
requested_fmt = FMT_BMP;
|
||||
|
||||
} else if (keymatch(arg, "colors", 1) || keymatch(arg, "colours", 1) ||
|
||||
@@ -257,13 +261,21 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
|
||||
cinfo->do_fancy_upsampling = FALSE;
|
||||
|
||||
} else if (keymatch(arg, "gif", 1)) {
|
||||
/* GIF output format. */
|
||||
/* GIF output format (LZW compressed). */
|
||||
requested_fmt = FMT_GIF;
|
||||
|
||||
} else if (keymatch(arg, "gif0", 4)) {
|
||||
/* GIF output format (uncompressed). */
|
||||
requested_fmt = FMT_GIF0;
|
||||
|
||||
} else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) {
|
||||
/* 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 */
|
||||
@@ -298,7 +310,7 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
|
||||
cinfo->mem->max_memory_to_use = lval * 1000L;
|
||||
|
||||
} else if (keymatch(arg, "nosmooth", 3)) {
|
||||
/* Suppress fancy upsampling */
|
||||
/* Suppress fancy upsampling. */
|
||||
cinfo->do_fancy_upsampling = FALSE;
|
||||
|
||||
} else if (keymatch(arg, "onepass", 3)) {
|
||||
@@ -327,7 +339,7 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
|
||||
/* Scale the output image by a fraction M/N. */
|
||||
if (++argn >= argc) /* advance to next argument */
|
||||
usage();
|
||||
if (sscanf(argv[argn], "%d/%d",
|
||||
if (sscanf(argv[argn], "%u/%u",
|
||||
&cinfo->scale_num, &cinfo->scale_denom) < 1)
|
||||
usage();
|
||||
|
||||
@@ -456,7 +468,7 @@ main (int argc, char **argv)
|
||||
* APP12 is used by some digital camera makers for textual info,
|
||||
* so we provide the ability to display it as text.
|
||||
* If you like, additional APPn marker types can be selected for display,
|
||||
* but don't try to override APP0 or APP14 this way (see libjpeg.doc).
|
||||
* but don't try to override APP0 or APP14 this way (see libjpeg.txt).
|
||||
*/
|
||||
jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker);
|
||||
jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker);
|
||||
@@ -549,7 +561,10 @@ main (int argc, char **argv)
|
||||
#endif
|
||||
#ifdef GIF_SUPPORTED
|
||||
case FMT_GIF:
|
||||
dest_mgr = jinit_write_gif(&cinfo);
|
||||
dest_mgr = jinit_write_gif(&cinfo, TRUE);
|
||||
break;
|
||||
case FMT_GIF0:
|
||||
dest_mgr = jinit_write_gif(&cinfo, FALSE);
|
||||
break;
|
||||
#endif
|
||||
#ifdef PPM_SUPPORTED
|
||||
@@ -569,7 +584,6 @@ main (int argc, char **argv)
|
||||
#endif
|
||||
default:
|
||||
ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT);
|
||||
break;
|
||||
}
|
||||
dest_mgr->output_file = output_file;
|
||||
|
||||
|
||||
11
filelist.txt
11
filelist.txt
@@ -1,6 +1,6 @@
|
||||
IJG JPEG LIBRARY: FILE LIST
|
||||
|
||||
Copyright (C) 1994-2009, Thomas G. Lane, Guido Vollbeding.
|
||||
Copyright (C) 1994-2019, 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.
|
||||
|
||||
@@ -151,7 +151,7 @@ transupp.c Support code for jpegtran: lossless image manipulations.
|
||||
Image file reader modules for cjpeg:
|
||||
|
||||
rdbmp.c BMP file input.
|
||||
rdgif.c GIF file input (now just a stub).
|
||||
rdgif.c GIF file input.
|
||||
rdppm.c PPM/PGM file input.
|
||||
rdrle.c Utah RLE file input.
|
||||
rdtarga.c Targa file input.
|
||||
@@ -159,7 +159,7 @@ rdtarga.c Targa file input.
|
||||
Image file writer modules for djpeg:
|
||||
|
||||
wrbmp.c BMP file output.
|
||||
wrgif.c GIF file output (a mere shadow of its former self).
|
||||
wrgif.c GIF file output.
|
||||
wrppm.c PPM/PGM file output.
|
||||
wrrle.c Utah RLE file output.
|
||||
wrtarga.c Targa file output.
|
||||
@@ -197,6 +197,8 @@ config.guess
|
||||
config.sub
|
||||
depcomp
|
||||
missing
|
||||
ar-lib
|
||||
compile
|
||||
install-sh Install shell script for those Unix systems lacking one.
|
||||
Makefile.in Makefile input for configure.
|
||||
Makefile.am Source file for use with Automake to generate Makefile.in.
|
||||
@@ -205,9 +207,8 @@ jconfig.txt Template for making jconfig.h by hand.
|
||||
mak*.* Sample makefiles for particular systems.
|
||||
jconfig.* Sample jconfig.h for particular systems.
|
||||
libjpeg.map Script to generate shared library with versioned symbols.
|
||||
libjpeg.pc.in libjpeg.pc pkg-config file input for configure.
|
||||
aclocal.m4 M4 macro definitions for use with Autoconf.
|
||||
ansi2knr.c De-ANSIfier for pre-ANSI C compilers (courtesy of
|
||||
L. Peter Deutsch and Aladdin Enterprises).
|
||||
|
||||
Test files (see install.txt for test procedure):
|
||||
|
||||
|
||||
176
install-sh
176
install-sh
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
scriptversion=2018-03-11.20; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
@@ -35,25 +35,21 @@ scriptversion=2009-04-28.21; # UTC
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# 'make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
|
||||
tab=' '
|
||||
nl='
|
||||
'
|
||||
IFS=" "" $nl"
|
||||
IFS=" $tab$nl"
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
# Set DOITPROG to "echo" to test this script.
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit=${DOITPROG-}
|
||||
if test -z "$doit"; then
|
||||
doit_exec=exec
|
||||
else
|
||||
doit_exec=$doit
|
||||
fi
|
||||
doit_exec=${doit:-exec}
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
@@ -68,17 +64,6 @@ mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_glob='?'
|
||||
initialize_posix_glob='
|
||||
test "$posix_glob" != "?" || {
|
||||
if (set -f) 2>/dev/null; then
|
||||
posix_glob=
|
||||
else
|
||||
posix_glob=:
|
||||
fi
|
||||
}
|
||||
'
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
@@ -97,7 +82,7 @@ dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
no_target_directory=
|
||||
is_target_a_directory=possibly
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
@@ -143,8 +128,7 @@ while test $# -ne 0; do
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *' '* | *'
|
||||
'* | *'*'* | *'?'* | *'['*)
|
||||
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
@@ -155,10 +139,16 @@ while test $# -ne 0; do
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-t) dst_arg=$2
|
||||
-t)
|
||||
is_target_a_directory=always
|
||||
dst_arg=$2
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-T) no_target_directory=true;;
|
||||
-T) is_target_a_directory=never;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
@@ -173,6 +163,16 @@ while test $# -ne 0; do
|
||||
shift
|
||||
done
|
||||
|
||||
# We allow the use of options -d and -T together, by making -d
|
||||
# take the precedence; this is for compatibility with GNU install.
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
if test -n "$dst_arg"; then
|
||||
echo "$0: target directory not allowed when installing a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
@@ -186,6 +186,10 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -194,13 +198,26 @@ if test $# -eq 0; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call `install-sh -d' without argument.
|
||||
# It's OK to call 'install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
if test $# -gt 1 || test "$is_target_a_directory" = always; then
|
||||
if test ! -d "$dst_arg"; then
|
||||
echo "$0: $dst_arg: Is not a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
do_exit='(exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
@@ -228,9 +245,9 @@ fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names starting with `-'.
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $src in
|
||||
-*) src=./$src;;
|
||||
-* | [=\(\)!]) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
@@ -252,56 +269,33 @@ do
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dst=$dst_arg
|
||||
# Protect names starting with `-'.
|
||||
case $dst in
|
||||
-*) dst=./$dst;;
|
||||
esac
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
# If destination is a directory, append the input filename.
|
||||
if test -d "$dst"; then
|
||||
if test -n "$no_target_directory"; then
|
||||
if test "$is_target_a_directory" = never; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dst=$dstdir/`basename "$src"`
|
||||
dstbase=`basename "$src"`
|
||||
case $dst in
|
||||
*/) dst=$dst$dstbase;;
|
||||
*) dst=$dst/$dstbase;;
|
||||
esac
|
||||
dstdir_status=0
|
||||
else
|
||||
# Prefer dirname, but fall back on a substitute if dirname fails.
|
||||
dstdir=`
|
||||
(dirname "$dst") 2>/dev/null ||
|
||||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$dst" : 'X\(//\)[^/]' \| \
|
||||
X"$dst" : 'X\(//\)$' \| \
|
||||
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
|
||||
echo X"$dst" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)[^/].*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\).*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
s/.*/./; q'
|
||||
`
|
||||
|
||||
dstdir=`dirname "$dst"`
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
case $dstdir in
|
||||
*/) dstdirslash=$dstdir;;
|
||||
*) dstdirslash=$dstdir/;;
|
||||
esac
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
@@ -338,34 +332,43 @@ do
|
||||
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||
;;
|
||||
*)
|
||||
# Note that $RANDOM variable is not portable (e.g. dash); Use it
|
||||
# here however when possible just to lower collision chance.
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||
|
||||
trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||
|
||||
# Because "mkdir -p" follows existing symlinks and we likely work
|
||||
# directly in world-writeable /tmp, make sure that the '$tmpdir'
|
||||
# directory is successfully created first before we actually test
|
||||
# 'mkdir -p' feature.
|
||||
if (umask $mkdir_umask &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
|
||||
$mkdirprog $mkdir_mode "$tmpdir" &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writeable bit of parent directory when it shouldn't.
|
||||
# other-writable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
||||
test_tmpdir="$tmpdir/a"
|
||||
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
|
||||
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/d" "$tmpdir"
|
||||
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
|
||||
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac;;
|
||||
@@ -385,25 +388,23 @@ do
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
-*) prefix='./';;
|
||||
[-=\(\)!]*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
eval "$initialize_posix_glob"
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
$posix_glob set -f
|
||||
set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
$posix_glob set +f
|
||||
set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test -z "$d" && continue
|
||||
test X"$d" = X && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
@@ -443,8 +444,8 @@ do
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
dsttmp=${dstdirslash}_inst.$$_
|
||||
rmtmp=${dstdirslash}_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
@@ -467,13 +468,10 @@ do
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
|
||||
eval "$initialize_posix_glob" &&
|
||||
$posix_glob set -f &&
|
||||
set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
$posix_glob set +f &&
|
||||
|
||||
set +f &&
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
@@ -512,9 +510,9 @@ do
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
||||
200
install.txt
200
install.txt
@@ -1,6 +1,6 @@
|
||||
INSTALLATION INSTRUCTIONS for the Independent JPEG Group's JPEG software
|
||||
|
||||
Copyright (C) 1991-2009, Thomas G. Lane, Guido Vollbeding.
|
||||
Copyright (C) 1991-2019, 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,12 @@ 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*.vc9 jconfig.vc Windows NT/95, MS Visual C++ 2008 (v9)
|
||||
makefile.vc jconfig.vc Windows, MS Visual C++
|
||||
makefile.vs jconfig.vc Windows, MS Visual C++ 6 Developer Studio
|
||||
make*.vc6
|
||||
makefile.vs jconfig.vc Windows, Visual Studio 2019 (v16)
|
||||
make*.v16
|
||||
makefile.b32 jconfig.vc Windows, Borland C++ 32-bit (bcc32)
|
||||
makefile.mms jconfig.vms Digital VMS, with MMS software
|
||||
makefile.vms jconfig.vms Digital VMS, without MMS software
|
||||
|
||||
@@ -321,9 +324,9 @@ several forms:
|
||||
testimg.jpg The output of cjpeg testimg.ppm
|
||||
testprog.jpg Progressive-mode equivalent of testorig.jpg.
|
||||
testimgp.jpg The output of cjpeg -progressive -optimize testimg.ppm
|
||||
(The first- and second-generation .jpg files aren't identical since JPEG is
|
||||
lossy.) If you can generate duplicates of the testimg* files then you
|
||||
probably have working programs.
|
||||
(The first- and second-generation .jpg files aren't identical since the
|
||||
default compression parameters are lossy.) If you can generate duplicates
|
||||
of the testimg* files then you probably have working programs.
|
||||
|
||||
With most of the makefiles, "make test" will perform the necessary
|
||||
comparisons.
|
||||
@@ -418,54 +421,58 @@ support as follows:
|
||||
the directory containing the URT "librle.a" file (typically the
|
||||
"lib" subdirectory of the URT distribution).
|
||||
|
||||
Support for 12-bit-deep pixel data:
|
||||
Support for 9-bit to 12-bit deep pixel data:
|
||||
|
||||
The JPEG standard allows either 8-bit or 12-bit data precision. (For color,
|
||||
this means 8 or 12 bits per channel, of course.) If you need to work with
|
||||
deeper than 8-bit data, you can compile the IJG code for 12-bit operation.
|
||||
The IJG code currently allows 8, 9, 10, 11, or 12 bits sample data precision.
|
||||
(For color, this means 8 to 12 bits per channel, of course.) If you need to
|
||||
work with deeper than 8-bit data, you can compile the IJG code for 9-bit to
|
||||
12-bit operation.
|
||||
To do so:
|
||||
1. In jmorecfg.h, define BITS_IN_JSAMPLE as 12 rather than 8.
|
||||
1. In jmorecfg.h, define BITS_IN_JSAMPLE as 9, 10, 11, or 12 rather than 8.
|
||||
2. In jconfig.h, undefine BMP_SUPPORTED, RLE_SUPPORTED, and TARGA_SUPPORTED,
|
||||
because the code for those formats doesn't handle 12-bit data and won't
|
||||
even compile. (The PPM code does work, as explained below. The GIF
|
||||
code works too; it scales 8-bit GIF data to and from 12-bit depth
|
||||
automatically.)
|
||||
because the code for those formats doesn't handle deeper than 8-bit data
|
||||
and won't even compile. (The PPM code does work, as explained below.
|
||||
The GIF code works too; it scales 8-bit GIF data to and from 12-bit
|
||||
depth automatically.)
|
||||
3. Compile. Don't expect "make test" to pass, since the supplied test
|
||||
files are for 8-bit data.
|
||||
|
||||
Currently, 12-bit support does not work on 16-bit-int machines.
|
||||
Currently, 9-bit to 12-bit support does not work on 16-bit-int machines.
|
||||
|
||||
Note that a 12-bit version will not read 8-bit JPEG files, nor vice versa;
|
||||
so you'll want to keep around a regular 8-bit compilation as well.
|
||||
(Run-time selection of data depth, to allow a single copy that does both,
|
||||
is possible but would probably slow things down considerably; it's very low
|
||||
on our to-do list.)
|
||||
Run-time selection and conversion of data precision are currently not
|
||||
supported and may be added later.
|
||||
Exception: The transcoding part (jpegtran) supports all settings in a
|
||||
single instance, since it operates on the level of DCT coefficients and
|
||||
not sample values.
|
||||
|
||||
The PPM reader (rdppm.c) can read 12-bit data from either text-format or
|
||||
binary-format PPM and PGM files. Binary-format PPM/PGM files which have a
|
||||
maxval greater than 255 are assumed to use 2 bytes per sample, MSB first
|
||||
(big-endian order). As of early 1995, 2-byte binary format is not
|
||||
The PPM reader (rdppm.c) can read deeper than 8-bit data from either
|
||||
text-format or binary-format PPM and PGM files. Binary-format PPM/PGM files
|
||||
which have a maxval greater than 255 are assumed to use 2 bytes per sample,
|
||||
MSB first (big-endian order). As of early 1995, 2-byte binary format is not
|
||||
officially supported by the PBMPLUS library, but it is expected that a
|
||||
future release of PBMPLUS will support it. Note that the PPM reader will
|
||||
read files of any maxval regardless of the BITS_IN_JSAMPLE setting; incoming
|
||||
data is automatically rescaled to either maxval=255 or maxval=4095 as
|
||||
appropriate for the cjpeg bit depth.
|
||||
data is automatically rescaled to maxval=MAXJSAMPLE as appropriate for the
|
||||
cjpeg bit depth.
|
||||
|
||||
The PPM writer (wrppm.c) will normally write 2-byte binary PPM or PGM
|
||||
format, maxval 4095, when compiled with BITS_IN_JSAMPLE=12. Since this
|
||||
format, maxval=MAXJSAMPLE, when compiled with BITS_IN_JSAMPLE>8. Since this
|
||||
format is not yet widely supported, you can disable it by compiling wrppm.c
|
||||
with PPM_NORAWWORD defined; then the data is scaled down to 8 bits to make a
|
||||
standard 1-byte/sample PPM or PGM file. (Yes, this means still another copy
|
||||
of djpeg to keep around. But hopefully you won't need it for very long.
|
||||
Poskanzer's supposed to get that new PBMPLUS release out Real Soon Now.)
|
||||
|
||||
Of course, if you are working with 12-bit data, you probably have it stored
|
||||
in some other, nonstandard format. In that case you'll probably want to
|
||||
write your own I/O modules to read and write your format.
|
||||
Of course, if you are working with 9-bit to 12-bit data, you probably have
|
||||
it stored in some other, nonstandard format. In that case you'll probably
|
||||
want to write your own I/O modules to read and write your format.
|
||||
|
||||
Note that a 12-bit version of cjpeg always runs in "-optimize" mode, in
|
||||
order to generate valid Huffman tables. This is necessary because our
|
||||
default Huffman tables only cover 8-bit data.
|
||||
Note:
|
||||
The standard Huffman tables are only valid for 8-bit data precision. If
|
||||
you selected more than 8-bit data precision, cjpeg uses arithmetic coding
|
||||
by default. The Huffman encoder normally uses entropy optimization to
|
||||
compute usable tables for higher precision. Otherwise, you'll have to
|
||||
supply different default Huffman tables.
|
||||
|
||||
Removing code:
|
||||
|
||||
@@ -848,17 +855,23 @@ with /Oo-.
|
||||
Microsoft Windows (all versions), generic comments:
|
||||
|
||||
Some Windows system include files define typedef boolean as "unsigned char".
|
||||
The IJG code also defines typedef boolean, but we make it "int" by default.
|
||||
The IJG code also defines typedef boolean, but we make it an "enum" by default.
|
||||
This doesn't affect the IJG programs because we don't import those Windows
|
||||
include files. But if you use the JPEG library in your own program, and some
|
||||
of your program's files import one definition of boolean while some import the
|
||||
other, you can get all sorts of mysterious problems. A good preventive step
|
||||
is to make the IJG library use "unsigned char" for boolean. To do that,
|
||||
add something like this to your jconfig.h file:
|
||||
/* 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 */
|
||||
(This is already in jconfig.vc, by the way.)
|
||||
|
||||
@@ -998,8 +1011,8 @@ model. makefile.vc is intended for command-line use. (If you are using
|
||||
the Developer Studio environment, you may prefer the DevStudio project
|
||||
files; see below.)
|
||||
|
||||
v7 adds extern "C" to jpeglib.h. This avoids the need to put extern "C"
|
||||
{ ... } around #include "jpeglib.h" in your C++ application.
|
||||
IJG JPEG 7 adds extern "C" to jpeglib.h. This avoids the need to put
|
||||
extern "C" { ... } around #include "jpeglib.h" in your C++ application.
|
||||
You can also force VC++ to treat the library as C++ code by renaming
|
||||
all the *.c files to *.cpp (and adjusting the makefile to match).
|
||||
In this case you also need to define the symbol DONT_USE_EXTERN_C in
|
||||
@@ -1008,58 +1021,75 @@ the configuration to prevent jpeglib.h from using extern "C".
|
||||
|
||||
Microsoft Windows, Microsoft Visual C++ 6 Developer Studio:
|
||||
|
||||
We include makefiles that should work as project files in DevStudio 6.0 or
|
||||
later. There is a library makefile that builds the IJG library as a static
|
||||
Win32 library, and application makefiles that build the sample applications
|
||||
as Win32 console applications. (Even if you only want the library, we
|
||||
recommend building the applications so that you can run the self-test.)
|
||||
|
||||
To use:
|
||||
1. Copy jconfig.vc to jconfig.h, makejdsw.vc6 to jpeg.dsw,
|
||||
makeadsw.vc6 to apps.dsw, makejmak.vc6 to jpeg.mak,
|
||||
makejdep.vc6 to jpeg.dep, makejdsp.vc6 to jpeg.dsp,
|
||||
makecmak.vc6 to cjpeg.mak, makecdep.vc6 to cjpeg.dep,
|
||||
makecdsp.vc6 to cjpeg.dsp, makedmak.vc6 to djpeg.mak,
|
||||
makeddep.vc6 to djpeg.dep, makeddsp.vc6 to djpeg.dsp,
|
||||
maketmak.vc6 to jpegtran.mak, maketdep.vc6 to jpegtran.dep,
|
||||
maketdsp.vc6 to jpegtran.dsp, makermak.vc6 to rdjpgcom.mak,
|
||||
makerdep.vc6 to rdjpgcom.dep, makerdsp.vc6 to rdjpgcom.dsp,
|
||||
makewmak.vc6 to wrjpgcom.mak, makewdep.vc6 to wrjpgcom.dep, and
|
||||
makewdsp.vc6 to wrjpgcom.dsp. (Note that the renaming is critical!)
|
||||
2. Click on jpeg.dsw and apps.dsw to load the project workspaces.
|
||||
(If you are using DevStudio more recent than 6.0, you'll probably
|
||||
get a message saying that the project files are being updated.)
|
||||
3. Build the library project, then the applications project.
|
||||
4. Move the application .exe files from `app`\Release to an
|
||||
appropriate location on your path.
|
||||
5. To perform the self-test, execute the command line
|
||||
NMAKE /f makefile.vc test
|
||||
|
||||
|
||||
Microsoft Windows, Microsoft Visual C++ 2008 Developer Studio (v9):
|
||||
|
||||
We include makefiles that should work as project files in Visual Studio
|
||||
2008 or later. There is a library makefile that builds the IJG library
|
||||
as a static Win32 library, and application makefiles that build the sample
|
||||
We include makefiles that should work as project files in Developer Studio
|
||||
6.0 or later. There is a library makefile that builds the IJG library as
|
||||
a static Win32 library, and application makefiles that build the sample
|
||||
applications as Win32 console applications. (Even if you only want the
|
||||
library, we recommend building the applications so that you can run the
|
||||
self-test.)
|
||||
|
||||
To use:
|
||||
1. Copy jconfig.vc to jconfig.h, makejsln.vc9 to jpeg.sln,
|
||||
makeasln.vc9 to apps.sln, makejvcp.vc9 to jpeg.vcproj,
|
||||
makecvcp.vc9 to cjpeg.vcproj, makedvcp.vc9 to djpeg.vcproj,
|
||||
maketvcp.vc9 to jpegtran.vcproj, makervcp.vc9 to rdjpgcom.vcproj, and
|
||||
makewvcp.vc9 to wrjpgcom.vcproj. (Note that the renaming is critical!)
|
||||
2. Click on jpeg.sln and apps.sln to load the project solutions.
|
||||
(If you are using Visual Studio more recent than 2008 (v9), you'll
|
||||
probably get a message saying that the project files are being
|
||||
updated.)
|
||||
3. Build the library project, then the applications project.
|
||||
4. Move the application .exe files from `app`\Release to an
|
||||
1. Open the command prompt, change to the source directory and execute
|
||||
the command line
|
||||
NMAKE /f makefile.vs setup-vc6
|
||||
If you get an error message saying that the "NMAKE" command could
|
||||
not be found, execute the command
|
||||
"%ProgramFiles%\Microsoft Visual Studio\VC98\Bin\VCVARS32"
|
||||
to set the environment for using Microsoft Visual C++ tools,
|
||||
and repeat the NMAKE call.
|
||||
This will move jconfig.vc to jconfig.h and makefiles to project files.
|
||||
(Note that the renaming is critical!)
|
||||
Alternatively you can use
|
||||
NMAKE /f makefile.vs setupcopy-vc6
|
||||
This will create renamed copies of the files, which allows to repeat
|
||||
the setup later.
|
||||
2. Open the workspace file jpeg.dsw, build the library project.
|
||||
(If you are using Developer Studio more recent than 6.0, you'll
|
||||
probably get a message saying that the project files are being updated.)
|
||||
3. Open the workspace file apps.dsw, build the application projects.
|
||||
4. To perform the self-test, execute the command line
|
||||
NMAKE /f makefile.vs test-build
|
||||
5. Move the application .exe files from the Release folder to an
|
||||
appropriate location on your path.
|
||||
|
||||
|
||||
Microsoft Windows, Visual Studio 2019 (v16):
|
||||
|
||||
We include makefiles that should work as project files in Visual Studio
|
||||
2019 (v16) or later. There is a library makefile that builds the IJG
|
||||
library as a static Win32/x64 library, and application makefiles that
|
||||
build the sample applications as Win32/x64 console applications. (Even
|
||||
if you only want the library, we recommend building the applications so
|
||||
that you can run the self-test.)
|
||||
|
||||
To use:
|
||||
1. Open the Developer Command Prompt for VS 2019, change to the source
|
||||
directory and execute the command line
|
||||
NMAKE /f makefile.vs setup-v16
|
||||
This will move jconfig.vc to jconfig.h and makefiles to project files.
|
||||
(Note that the renaming is critical!)
|
||||
Alternatively you can use
|
||||
NMAKE /f makefile.vs setupcopy-v16
|
||||
This will create renamed copies of the files, which allows to repeat
|
||||
the setup later.
|
||||
2. Open the solution file jpeg.sln, build the library project.
|
||||
a) If you are using Visual Studio more recent than
|
||||
2019 (v16), you'll probably get a message saying
|
||||
that the project files are being updated.
|
||||
b) If necessary, open the project properties and
|
||||
adapt the Windows Target Platform Version in
|
||||
the Configuration Properties, General section;
|
||||
we support the latest version at the time of release.
|
||||
c) If you want to build x64 code, change the platform setting from
|
||||
Win32 to x64. You can build Win32 and x64 versions side by side.
|
||||
3. Open the solution file apps.sln, build the application projects.
|
||||
4. To perform the self-test, execute the command line
|
||||
NMAKE /f makefile.vs test-32
|
||||
for the Win32 build, or on a 64-bit system
|
||||
NMAKE /f makefile.vs test-64
|
||||
for the x64 build.
|
||||
5. Move the application .exe files from the Release folder to an
|
||||
appropriate location on your path.
|
||||
5. To perform the self-test, execute the command line
|
||||
NMAKE /f makefile.vc test
|
||||
|
||||
|
||||
OS/2, Borland C++:
|
||||
|
||||
10
jaricom.c
10
jaricom.c
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* jaricom.c
|
||||
*
|
||||
* Developed 1997-2009 by Guido Vollbeding.
|
||||
* Developed 1997-2011 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 contains probability estimation tables for common use in
|
||||
* arithmetic entropy encoding and decoding routines.
|
||||
*
|
||||
* This data represents Table D.2 in the JPEG spec (ISO/IEC IS 10918-1
|
||||
* and CCITT Recommendation ITU-T T.81) and Table 24 in the JBIG spec
|
||||
* (ISO/IEC IS 11544 and CCITT Recommendation ITU-T T.82).
|
||||
* This data represents Table D.3 in the JPEG spec (D.2 in the draft),
|
||||
* ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81, and Table 24
|
||||
* in the JBIG spec, ISO/IEC IS 11544 and CCITT Recommendation ITU-T T.82.
|
||||
*/
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
@@ -147,7 +147,7 @@ const INT32 jpeg_aritab[113+1] = {
|
||||
V( 112, 0x59eb, 112, 111, 1 ),
|
||||
/*
|
||||
* This last entry is used for fixed probability estimate of 0.5
|
||||
* as recommended in Section 10.3 Table 5 of ITU-T Rec. T.851.
|
||||
* as suggested in Section 10.3 Table 5 of ITU-T Rec. T.851.
|
||||
*/
|
||||
V( 113, 0x5a1d, 113, 113, 0 )
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* jcapimin.c
|
||||
*
|
||||
* Copyright (C) 1994-1998, Thomas G. Lane.
|
||||
* Modified 2003-2010 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,6 +74,11 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
|
||||
cinfo->ac_huff_tbl_ptrs[i] = NULL;
|
||||
}
|
||||
|
||||
/* Must do it here for emit_dqt in case jpeg_write_tables is used */
|
||||
cinfo->block_size = DCTSIZE;
|
||||
cinfo->natural_order = jpeg_natural_order;
|
||||
cinfo->lim_Se = DCTSIZE2-1;
|
||||
|
||||
cinfo->script_space = NULL;
|
||||
|
||||
cinfo->input_gamma = 1.0; /* in case application forgets */
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* jcapistd.c
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 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.
|
||||
*
|
||||
@@ -145,7 +146,7 @@ jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||
(*cinfo->master->pass_startup) (cinfo);
|
||||
|
||||
/* Verify that at least one iMCU row has been passed. */
|
||||
lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE;
|
||||
lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size;
|
||||
if (num_lines < lines_per_iMCU_row)
|
||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
|
||||
|
||||
97
jcarith.c
97
jcarith.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* jcarith.c
|
||||
*
|
||||
* Developed 1997-2009 by Guido Vollbeding.
|
||||
* Developed 1997-2019 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.
|
||||
*
|
||||
@@ -181,11 +181,11 @@ finish_pass (j_compress_ptr cinfo)
|
||||
if (e->zc) /* output final pending zero bytes */
|
||||
do emit_byte(0x00, cinfo);
|
||||
while (--e->zc);
|
||||
emit_byte((e->c >> 19) & 0xFF, cinfo);
|
||||
emit_byte((int) ((e->c >> 19) & 0xFF), cinfo);
|
||||
if (((e->c >> 19) & 0xFF) == 0xFF)
|
||||
emit_byte(0x00, cinfo);
|
||||
if (e->c & 0x7F800L) {
|
||||
emit_byte((e->c >> 11) & 0xFF, cinfo);
|
||||
emit_byte((int) ((e->c >> 11) & 0xFF), cinfo);
|
||||
if (((e->c >> 11) & 0xFF) == 0xFF)
|
||||
emit_byte(0x00, cinfo);
|
||||
}
|
||||
@@ -223,7 +223,7 @@ arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
|
||||
register INT32 qe, temp;
|
||||
register int sv;
|
||||
|
||||
/* Fetch values from our compact representation of Table D.2:
|
||||
/* Fetch values from our compact representation of Table D.3(D.2):
|
||||
* Qe values and probability estimation state machine
|
||||
*/
|
||||
sv = *st;
|
||||
@@ -280,7 +280,8 @@ arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
|
||||
/* Note: The 3 spacer bits in the C register guarantee
|
||||
* that the new buffer byte can't be 0xFF here
|
||||
* (see page 160 in the P&M JPEG book). */
|
||||
e->buffer = temp & 0xFF; /* new output byte, might overflow later */
|
||||
/* New output byte, might overflow later */
|
||||
e->buffer = (int) (temp & 0xFF);
|
||||
} else if (temp == 0xFF) {
|
||||
++e->sc; /* stack 0xFF byte (which might overflow later) */
|
||||
} else {
|
||||
@@ -302,7 +303,8 @@ arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
|
||||
emit_byte(0x00, cinfo);
|
||||
} while (--e->sc);
|
||||
}
|
||||
e->buffer = temp & 0xFF; /* new output byte (can still overflow) */
|
||||
/* New output byte (can still overflow) */
|
||||
e->buffer = (int) (temp & 0xFF);
|
||||
}
|
||||
e->c &= 0x7FFFFL;
|
||||
e->ct += 8;
|
||||
@@ -362,7 +364,6 @@ METHODDEF(boolean)
|
||||
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
int blkn, ci, tbl;
|
||||
int v, v2, m;
|
||||
@@ -381,14 +382,13 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
/* Encode the MCU data blocks */
|
||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||
block = MCU_data[blkn];
|
||||
ci = cinfo->MCU_membership[blkn];
|
||||
tbl = cinfo->cur_comp_info[ci]->dc_tbl_no;
|
||||
|
||||
/* Compute the DC value after the required point transform by Al.
|
||||
* This is simply an arithmetic right shift.
|
||||
*/
|
||||
m = IRIGHT_SHIFT((int) ((*block)[0]), cinfo->Al);
|
||||
m = IRIGHT_SHIFT((int) (MCU_data[blkn][0][0]), cinfo->Al);
|
||||
|
||||
/* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */
|
||||
|
||||
@@ -453,11 +453,11 @@ METHODDEF(boolean)
|
||||
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
const int * natural_order;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
int tbl, k, ke;
|
||||
int v, v2, m;
|
||||
const int * natural_order;
|
||||
|
||||
/* Emit restart marker if needed */
|
||||
if (cinfo->restart_interval) {
|
||||
@@ -479,7 +479,8 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */
|
||||
|
||||
/* Establish EOB (end-of-block) index */
|
||||
for (ke = cinfo->Se; ke > 0; ke--)
|
||||
ke = cinfo->Se;
|
||||
do {
|
||||
/* We must apply the point transform by Al. For AC coefficients this
|
||||
* is an integer division with rounding towards 0. To do this portably
|
||||
* in C, we shift after obtaining the absolute value.
|
||||
@@ -490,13 +491,14 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
v = -v;
|
||||
if (v >>= cinfo->Al) break;
|
||||
}
|
||||
} while (--ke);
|
||||
|
||||
/* Figure F.5: Encode_AC_Coefficients */
|
||||
for (k = cinfo->Ss; k <= ke; k++) {
|
||||
st = entropy->ac_stats[tbl] + 3 * (k - 1);
|
||||
for (k = cinfo->Ss - 1; k < ke;) {
|
||||
st = entropy->ac_stats[tbl] + 3 * k;
|
||||
arith_encode(cinfo, st, 0); /* EOB decision */
|
||||
for (;;) {
|
||||
if ((v = (*block)[natural_order[k]]) >= 0) {
|
||||
if ((v = (*block)[natural_order[++k]]) >= 0) {
|
||||
if (v >>= cinfo->Al) {
|
||||
arith_encode(cinfo, st + 1, 1);
|
||||
arith_encode(cinfo, entropy->fixed_bin, 0);
|
||||
@@ -510,7 +512,8 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
break;
|
||||
}
|
||||
}
|
||||
arith_encode(cinfo, st + 1, 0); st += 3; k++;
|
||||
arith_encode(cinfo, st + 1, 0);
|
||||
st += 3;
|
||||
}
|
||||
st += 2;
|
||||
/* Figure F.8: Encoding the magnitude category of v */
|
||||
@@ -537,9 +540,9 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
while (m >>= 1)
|
||||
arith_encode(cinfo, st, (m & v) ? 1 : 0);
|
||||
}
|
||||
/* Encode EOB decision only if k <= cinfo->Se */
|
||||
if (k <= cinfo->Se) {
|
||||
st = entropy->ac_stats[tbl] + 3 * (k - 1);
|
||||
/* Encode EOB decision only if k < cinfo->Se */
|
||||
if (k < cinfo->Se) {
|
||||
st = entropy->ac_stats[tbl] + 3 * k;
|
||||
arith_encode(cinfo, st, 1);
|
||||
}
|
||||
|
||||
@@ -549,6 +552,8 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
/*
|
||||
* MCU encoding for DC successive approximation refinement scan.
|
||||
* Note: we assume such scans can be multi-component,
|
||||
* although the spec is not very clear on the point.
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
@@ -590,11 +595,11 @@ METHODDEF(boolean)
|
||||
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
const int * natural_order;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
int tbl, k, ke, kex;
|
||||
int v;
|
||||
const int * natural_order;
|
||||
|
||||
/* Emit restart marker if needed */
|
||||
if (cinfo->restart_interval) {
|
||||
@@ -616,7 +621,8 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Section G.1.3.3: Encoding of AC coefficients */
|
||||
|
||||
/* Establish EOB (end-of-block) index */
|
||||
for (ke = cinfo->Se; ke > 0; ke--)
|
||||
ke = cinfo->Se;
|
||||
do {
|
||||
/* We must apply the point transform by Al. For AC coefficients this
|
||||
* is an integer division with rounding towards 0. To do this portably
|
||||
* in C, we shift after obtaining the absolute value.
|
||||
@@ -627,6 +633,7 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
v = -v;
|
||||
if (v >>= cinfo->Al) break;
|
||||
}
|
||||
} while (--ke);
|
||||
|
||||
/* Establish EOBx (previous stage end-of-block) index */
|
||||
for (kex = ke; kex > 0; kex--)
|
||||
@@ -638,12 +645,12 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Figure G.10: Encode_AC_Coefficients_SA */
|
||||
for (k = cinfo->Ss; k <= ke; k++) {
|
||||
st = entropy->ac_stats[tbl] + 3 * (k - 1);
|
||||
if (k > kex)
|
||||
for (k = cinfo->Ss - 1; k < ke;) {
|
||||
st = entropy->ac_stats[tbl] + 3 * k;
|
||||
if (k >= kex)
|
||||
arith_encode(cinfo, st, 0); /* EOB decision */
|
||||
for (;;) {
|
||||
if ((v = (*block)[natural_order[k]]) >= 0) {
|
||||
if ((v = (*block)[natural_order[++k]]) >= 0) {
|
||||
if (v >>= cinfo->Al) {
|
||||
if (v >> 1) /* previously nonzero coef */
|
||||
arith_encode(cinfo, st + 2, (v & 1));
|
||||
@@ -665,12 +672,13 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
break;
|
||||
}
|
||||
}
|
||||
arith_encode(cinfo, st + 1, 0); st += 3; k++;
|
||||
arith_encode(cinfo, st + 1, 0);
|
||||
st += 3;
|
||||
}
|
||||
}
|
||||
/* Encode EOB decision only if k <= cinfo->Se */
|
||||
if (k <= cinfo->Se) {
|
||||
st = entropy->ac_stats[tbl] + 3 * (k - 1);
|
||||
/* Encode EOB decision only if k < cinfo->Se */
|
||||
if (k < cinfo->Se) {
|
||||
st = entropy->ac_stats[tbl] + 3 * k;
|
||||
arith_encode(cinfo, st, 1);
|
||||
}
|
||||
|
||||
@@ -686,12 +694,13 @@ METHODDEF(boolean)
|
||||
encode_mcu (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
jpeg_component_info * compptr;
|
||||
const int * natural_order;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
int blkn, ci, tbl, k, ke;
|
||||
int tbl, k, ke;
|
||||
int v, v2, m;
|
||||
const int * natural_order;
|
||||
int blkn, ci;
|
||||
jpeg_component_info * compptr;
|
||||
|
||||
/* Emit restart marker if needed */
|
||||
if (cinfo->restart_interval) {
|
||||
@@ -765,18 +774,21 @@ encode_mcu (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
/* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */
|
||||
|
||||
if ((ke = cinfo->lim_Se) == 0) continue;
|
||||
tbl = compptr->ac_tbl_no;
|
||||
|
||||
/* Establish EOB (end-of-block) index */
|
||||
for (ke = cinfo->lim_Se; ke > 0; ke--)
|
||||
do {
|
||||
if ((*block)[natural_order[ke]]) break;
|
||||
} while (--ke);
|
||||
|
||||
/* Figure F.5: Encode_AC_Coefficients */
|
||||
for (k = 1; k <= ke; k++) {
|
||||
st = entropy->ac_stats[tbl] + 3 * (k - 1);
|
||||
for (k = 0; k < ke;) {
|
||||
st = entropy->ac_stats[tbl] + 3 * k;
|
||||
arith_encode(cinfo, st, 0); /* EOB decision */
|
||||
while ((v = (*block)[natural_order[k]]) == 0) {
|
||||
arith_encode(cinfo, st + 1, 0); st += 3; k++;
|
||||
while ((v = (*block)[natural_order[++k]]) == 0) {
|
||||
arith_encode(cinfo, st + 1, 0);
|
||||
st += 3;
|
||||
}
|
||||
arith_encode(cinfo, st + 1, 1);
|
||||
/* Figure F.6: Encoding nonzero value v */
|
||||
@@ -812,9 +824,9 @@ encode_mcu (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
while (m >>= 1)
|
||||
arith_encode(cinfo, st, (m & v) ? 1 : 0);
|
||||
}
|
||||
/* Encode EOB decision only if k <= cinfo->lim_Se */
|
||||
if (k <= cinfo->lim_Se) {
|
||||
st = entropy->ac_stats[tbl] + 3 * (k - 1);
|
||||
/* Encode EOB decision only if k < cinfo->lim_Se */
|
||||
if (k < cinfo->lim_Se) {
|
||||
st = entropy->ac_stats[tbl] + 3 * k;
|
||||
arith_encode(cinfo, st, 1);
|
||||
}
|
||||
}
|
||||
@@ -916,10 +928,9 @@ jinit_arith_encoder (j_compress_ptr cinfo)
|
||||
arith_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (arith_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(arith_entropy_encoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
|
||||
entropy = (arith_entropy_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(arith_entropy_encoder));
|
||||
cinfo->entropy = &entropy->pub;
|
||||
entropy->pub.start_pass = start_pass;
|
||||
entropy->pub.finish_pass = finish_pass;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* jccoefct.c
|
||||
*
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* Modified 2003-2011 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.
|
||||
*
|
||||
@@ -183,7 +184,7 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
ypos, xpos, (JDIMENSION) blockcnt);
|
||||
if (blockcnt < compptr->MCU_width) {
|
||||
/* Create some dummy blocks at the right edge of the image. */
|
||||
jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt],
|
||||
FMEMZERO((void FAR *) coef->MCU_buffer[blkn + blockcnt],
|
||||
(compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK));
|
||||
for (bi = blockcnt; bi < compptr->MCU_width; bi++) {
|
||||
coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0];
|
||||
@@ -191,7 +192,7 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
}
|
||||
} else {
|
||||
/* Create a row of dummy blocks at the bottom of the image. */
|
||||
jzero_far((void FAR *) coef->MCU_buffer[blkn],
|
||||
FMEMZERO((void FAR *) coef->MCU_buffer[blkn],
|
||||
compptr->MCU_width * SIZEOF(JBLOCK));
|
||||
for (bi = 0; bi < compptr->MCU_width; bi++) {
|
||||
coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0];
|
||||
@@ -290,7 +291,7 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
if (ndummy > 0) {
|
||||
/* Create dummy blocks at the right edge of the image. */
|
||||
thisblockrow += blocks_across; /* => first dummy block */
|
||||
jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK));
|
||||
FMEMZERO((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK));
|
||||
lastDC = thisblockrow[-1][0];
|
||||
for (bi = 0; bi < ndummy; bi++) {
|
||||
thisblockrow[bi][0] = lastDC;
|
||||
@@ -309,7 +310,7 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
block_row++) {
|
||||
thisblockrow = buffer[block_row];
|
||||
lastblockrow = buffer[block_row-1];
|
||||
jzero_far((void FAR *) thisblockrow,
|
||||
FMEMZERO((void FAR *) thisblockrow,
|
||||
(size_t) (blocks_across * SIZEOF(JBLOCK)));
|
||||
for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
|
||||
lastDC = lastblockrow[h_samp_factor-1][0];
|
||||
|
||||
274
jccolor.c
274
jccolor.c
@@ -2,6 +2,7 @@
|
||||
* jccolor.c
|
||||
*
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* Modified 2011-2019 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.
|
||||
*
|
||||
@@ -28,13 +29,25 @@ typedef my_color_converter * my_cconvert_ptr;
|
||||
/**************** RGB -> YCbCr conversion: most common case **************/
|
||||
|
||||
/*
|
||||
* YCbCr is defined per CCIR 601-1, except that Cb and Cr are
|
||||
* normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
|
||||
* The conversion equations to be implemented are therefore
|
||||
* Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
|
||||
* Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
|
||||
* Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
|
||||
* (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
|
||||
* YCbCr is defined per Recommendation ITU-R BT.601-7 (03/2011),
|
||||
* previously known as Recommendation CCIR 601-1, except that Cb and Cr
|
||||
* are normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
|
||||
* sRGB (standard RGB color space) is defined per IEC 61966-2-1:1999.
|
||||
* sYCC (standard luma-chroma-chroma color space with extended gamut)
|
||||
* is defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex F.
|
||||
* bg-sRGB and bg-sYCC (big gamut standard color spaces)
|
||||
* are defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex G.
|
||||
* Note that the derived conversion coefficients given in some of these
|
||||
* documents are imprecise. The general conversion equations are
|
||||
* Y = Kr * R + (1 - Kr - Kb) * G + Kb * B
|
||||
* Cb = 0.5 * (B - Y) / (1 - Kb)
|
||||
* Cr = 0.5 * (R - Y) / (1 - Kr)
|
||||
* With Kr = 0.299 and Kb = 0.114 (derived according to SMPTE RP 177-1993
|
||||
* from the 1953 FCC NTSC primaries and CIE Illuminant C),
|
||||
* the conversion equations to be implemented are therefore
|
||||
* Y = 0.299 * R + 0.587 * G + 0.114 * B
|
||||
* Cb = -0.168735892 * R - 0.331264108 * G + 0.5 * B + CENTERJSAMPLE
|
||||
* Cr = 0.5 * R - 0.418687589 * G - 0.081312411 * B + CENTERJSAMPLE
|
||||
* Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2,
|
||||
* rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and
|
||||
* negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0)
|
||||
@@ -48,9 +61,9 @@ typedef my_color_converter * my_cconvert_ptr;
|
||||
* For even more speed, we avoid doing any multiplications in the inner loop
|
||||
* by precalculating the constants times R,G,B for all possible values.
|
||||
* For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
|
||||
* for 12-bit samples it is still acceptable. It's not very reasonable for
|
||||
* 16-bit samples, but if you want lossless storage you shouldn't be changing
|
||||
* colorspace anyway.
|
||||
* for 9-bit to 12-bit samples it is still acceptable. It's not very
|
||||
* reasonable for 16-bit samples, but if you want lossless storage you
|
||||
* shouldn't be changing colorspace anyway.
|
||||
* The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included
|
||||
* in the tables to save adding them separately in the inner loop.
|
||||
*/
|
||||
@@ -92,24 +105,24 @@ rgb_ycc_start (j_compress_ptr cinfo)
|
||||
/* Allocate and fill in the conversion tables. */
|
||||
cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(TABLE_SIZE * SIZEOF(INT32)));
|
||||
TABLE_SIZE * SIZEOF(INT32));
|
||||
|
||||
for (i = 0; i <= MAXJSAMPLE; i++) {
|
||||
rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i;
|
||||
rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i;
|
||||
rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
|
||||
rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i;
|
||||
rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i;
|
||||
rgb_ycc_tab[i+R_Y_OFF] = FIX(0.299) * i;
|
||||
rgb_ycc_tab[i+G_Y_OFF] = FIX(0.587) * i;
|
||||
rgb_ycc_tab[i+B_Y_OFF] = FIX(0.114) * i + ONE_HALF;
|
||||
rgb_ycc_tab[i+R_CB_OFF] = (- FIX(0.168735892)) * i;
|
||||
rgb_ycc_tab[i+G_CB_OFF] = (- FIX(0.331264108)) * i;
|
||||
/* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr.
|
||||
* This ensures that the maximum output will round to MAXJSAMPLE
|
||||
* not MAXJSAMPLE+1, and thus that we don't have to range-limit.
|
||||
*/
|
||||
rgb_ycc_tab[i+B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1;
|
||||
rgb_ycc_tab[i+B_CB_OFF] = FIX(0.5) * i + CBCR_OFFSET + ONE_HALF-1;
|
||||
/* B=>Cb and R=>Cr tables are the same
|
||||
rgb_ycc_tab[i+R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1;
|
||||
rgb_ycc_tab[i+R_CR_OFF] = FIX(0.5) * i + CBCR_OFFSET + ONE_HALF-1;
|
||||
*/
|
||||
rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i;
|
||||
rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i;
|
||||
rgb_ycc_tab[i+G_CR_OFF] = (- FIX(0.418687589)) * i;
|
||||
rgb_ycc_tab[i+B_CR_OFF] = (- FIX(0.081312411)) * i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,12 +131,12 @@ rgb_ycc_start (j_compress_ptr cinfo)
|
||||
* Convert some rows of samples to the JPEG colorspace.
|
||||
*
|
||||
* Note that we change from the application's interleaved-pixel format
|
||||
* to our internal noninterleaved, one-plane-per-component format.
|
||||
* The input buffer is therefore three times as wide as the output buffer.
|
||||
* to our internal noninterleaved, one-plane-per-component format. The
|
||||
* input buffer is therefore three times as wide as the output buffer.
|
||||
*
|
||||
* A starting row offset is provided only for the output buffer. The caller
|
||||
* can easily adjust the passed input_buf value to accommodate any row
|
||||
* offset required on that side.
|
||||
* A starting row offset is provided only for the output buffer. The
|
||||
* caller can easily adjust the passed input_buf value to accommodate
|
||||
* any row offset required on that side.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
@@ -197,8 +210,7 @@ rgb_gray_convert (j_compress_ptr cinfo,
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
inptr = *input_buf++;
|
||||
outptr = output_buf[0][output_row];
|
||||
output_row++;
|
||||
outptr = output_buf[0][output_row++];
|
||||
for (col = 0; col < num_cols; col++) {
|
||||
r = GETJSAMPLE(inptr[RGB_RED]);
|
||||
g = GETJSAMPLE(inptr[RGB_GREEN]);
|
||||
@@ -216,8 +228,8 @@ rgb_gray_convert (j_compress_ptr cinfo,
|
||||
/*
|
||||
* Convert some rows of samples to the JPEG colorspace.
|
||||
* This version handles Adobe-style CMYK->YCCK conversion,
|
||||
* where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same
|
||||
* conversion as above, while passing K (black) unchanged.
|
||||
* where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the
|
||||
* same conversion as above, while passing K (black) unchanged.
|
||||
* We assume rgb_ycc_start has been called.
|
||||
*/
|
||||
|
||||
@@ -270,10 +282,52 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert some rows of samples to the JPEG colorspace.
|
||||
* [R,G,B] to [R-G,G,B-G] conversion with modulo calculation
|
||||
* (forward reversible color transform).
|
||||
* This can be seen as an adaption of the general RGB->YCbCr
|
||||
* conversion equation with Kr = Kb = 0, while replacing the
|
||||
* normalization by modulo calculation.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb1_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
register int r, g, b;
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr0, outptr1, outptr2;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->image_width;
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
inptr = *input_buf++;
|
||||
outptr0 = output_buf[0][output_row];
|
||||
outptr1 = output_buf[1][output_row];
|
||||
outptr2 = output_buf[2][output_row];
|
||||
output_row++;
|
||||
for (col = 0; col < num_cols; col++) {
|
||||
r = GETJSAMPLE(inptr[RGB_RED]);
|
||||
g = GETJSAMPLE(inptr[RGB_GREEN]);
|
||||
b = GETJSAMPLE(inptr[RGB_BLUE]);
|
||||
inptr += RGB_PIXELSIZE;
|
||||
/* Assume that MAXJSAMPLE+1 is a power of 2, so that the MOD
|
||||
* (modulo) operator is equivalent to the bitmask operator AND.
|
||||
*/
|
||||
outptr0[col] = (JSAMPLE) ((r - g + CENTERJSAMPLE) & MAXJSAMPLE);
|
||||
outptr1[col] = (JSAMPLE) g;
|
||||
outptr2[col] = (JSAMPLE) ((b - g + CENTERJSAMPLE) & MAXJSAMPLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert some rows of samples to the JPEG colorspace.
|
||||
* This version handles grayscale output with no conversion.
|
||||
* The source can be either plain grayscale or YCbCr (since Y == gray).
|
||||
* The source can be either plain grayscale or YCC (since Y == gray).
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
@@ -283,17 +337,49 @@ grayscale_convert (j_compress_ptr cinfo,
|
||||
{
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr;
|
||||
register JDIMENSION col;
|
||||
register JDIMENSION count;
|
||||
register int instride = cinfo->input_components;
|
||||
JDIMENSION num_cols = cinfo->image_width;
|
||||
int instride = cinfo->input_components;
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
inptr = *input_buf++;
|
||||
outptr = output_buf[0][output_row];
|
||||
outptr = output_buf[0][output_row++];
|
||||
for (count = num_cols; count > 0; count--) {
|
||||
*outptr++ = *inptr; /* don't need GETJSAMPLE() here */
|
||||
inptr += instride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert some rows of samples to the JPEG colorspace.
|
||||
* No colorspace conversion, but change from interleaved
|
||||
* to separate-planes representation.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr0, outptr1, outptr2;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->image_width;
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
inptr = *input_buf++;
|
||||
outptr0 = output_buf[0][output_row];
|
||||
outptr1 = output_buf[1][output_row];
|
||||
outptr2 = output_buf[2][output_row];
|
||||
output_row++;
|
||||
for (col = 0; col < num_cols; col++) {
|
||||
outptr[col] = inptr[0]; /* don't need GETJSAMPLE() here */
|
||||
inptr += instride;
|
||||
/* We can dispense with GETJSAMPLE() here */
|
||||
outptr0[col] = inptr[RGB_RED];
|
||||
outptr1[col] = inptr[RGB_GREEN];
|
||||
outptr2[col] = inptr[RGB_BLUE];
|
||||
inptr += RGB_PIXELSIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,19 +398,19 @@ null_convert (j_compress_ptr cinfo,
|
||||
{
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr;
|
||||
register JDIMENSION col;
|
||||
register int ci;
|
||||
int nc = cinfo->num_components;
|
||||
register JDIMENSION count;
|
||||
register int num_comps = cinfo->num_components;
|
||||
JDIMENSION num_cols = cinfo->image_width;
|
||||
int ci;
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
/* It seems fastest to make a separate pass for each component. */
|
||||
for (ci = 0; ci < nc; ci++) {
|
||||
inptr = *input_buf;
|
||||
for (ci = 0; ci < num_comps; ci++) {
|
||||
inptr = input_buf[0] + ci;
|
||||
outptr = output_buf[ci][output_row];
|
||||
for (col = 0; col < num_cols; col++) {
|
||||
outptr[col] = inptr[ci]; /* don't need GETJSAMPLE() here */
|
||||
inptr += nc;
|
||||
for (count = num_cols; count > 0; count--) {
|
||||
*outptr++ = *inptr; /* don't need GETJSAMPLE() here */
|
||||
inptr += num_comps;
|
||||
}
|
||||
}
|
||||
input_buf++;
|
||||
@@ -353,10 +439,9 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
{
|
||||
my_cconvert_ptr cconvert;
|
||||
|
||||
cconvert = (my_cconvert_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_color_converter));
|
||||
cinfo->cconvert = (struct jpeg_color_converter *) cconvert;
|
||||
cconvert = (my_cconvert_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_color_converter));
|
||||
cinfo->cconvert = &cconvert->pub;
|
||||
/* set start_pass to null method until we find out differently */
|
||||
cconvert->pub.start_pass = null_method;
|
||||
|
||||
@@ -368,6 +453,7 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
break;
|
||||
|
||||
case JCS_RGB:
|
||||
case JCS_BG_RGB:
|
||||
#if RGB_PIXELSIZE != 3
|
||||
if (cinfo->input_components != RGB_PIXELSIZE)
|
||||
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
||||
@@ -375,6 +461,7 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
#endif /* else share code with YCbCr */
|
||||
|
||||
case JCS_YCbCr:
|
||||
case JCS_BG_YCC:
|
||||
if (cinfo->input_components != 3)
|
||||
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
||||
break;
|
||||
@@ -388,65 +475,121 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
default: /* JCS_UNKNOWN can be anything */
|
||||
if (cinfo->input_components < 1)
|
||||
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Support color transform only for RGB colorspaces */
|
||||
if (cinfo->color_transform &&
|
||||
cinfo->jpeg_color_space != JCS_RGB &&
|
||||
cinfo->jpeg_color_space != JCS_BG_RGB)
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
|
||||
/* Check num_components, set conversion method based on requested space */
|
||||
switch (cinfo->jpeg_color_space) {
|
||||
case JCS_GRAYSCALE:
|
||||
if (cinfo->num_components != 1)
|
||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||
if (cinfo->in_color_space == JCS_GRAYSCALE)
|
||||
switch (cinfo->in_color_space) {
|
||||
case JCS_GRAYSCALE:
|
||||
case JCS_YCbCr:
|
||||
case JCS_BG_YCC:
|
||||
cconvert->pub.color_convert = grayscale_convert;
|
||||
else if (cinfo->in_color_space == JCS_RGB) {
|
||||
break;
|
||||
case JCS_RGB:
|
||||
cconvert->pub.start_pass = rgb_ycc_start;
|
||||
cconvert->pub.color_convert = rgb_gray_convert;
|
||||
} else if (cinfo->in_color_space == JCS_YCbCr)
|
||||
cconvert->pub.color_convert = grayscale_convert;
|
||||
else
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
break;
|
||||
|
||||
case JCS_RGB:
|
||||
case JCS_BG_RGB:
|
||||
if (cinfo->num_components != 3)
|
||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||
if (cinfo->in_color_space == JCS_RGB && RGB_PIXELSIZE == 3)
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
else
|
||||
if (cinfo->in_color_space != cinfo->jpeg_color_space)
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
switch (cinfo->color_transform) {
|
||||
case JCT_NONE:
|
||||
cconvert->pub.color_convert = rgb_convert;
|
||||
break;
|
||||
case JCT_SUBTRACT_GREEN:
|
||||
cconvert->pub.color_convert = rgb_rgb1_convert;
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
break;
|
||||
|
||||
case JCS_YCbCr:
|
||||
if (cinfo->num_components != 3)
|
||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||
if (cinfo->in_color_space == JCS_RGB) {
|
||||
switch (cinfo->in_color_space) {
|
||||
case JCS_RGB:
|
||||
cconvert->pub.start_pass = rgb_ycc_start;
|
||||
cconvert->pub.color_convert = rgb_ycc_convert;
|
||||
} else if (cinfo->in_color_space == JCS_YCbCr)
|
||||
break;
|
||||
case JCS_YCbCr:
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
else
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
break;
|
||||
|
||||
case JCS_BG_YCC:
|
||||
if (cinfo->num_components != 3)
|
||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||
switch (cinfo->in_color_space) {
|
||||
case JCS_RGB:
|
||||
/* For conversion from normal RGB input to BG_YCC representation,
|
||||
* the Cb/Cr values are first computed as usual, and then
|
||||
* quantized further after DCT processing by a factor of
|
||||
* 2 in reference to the nominal quantization factor.
|
||||
*/
|
||||
/* need quantization scale by factor of 2 after DCT */
|
||||
cinfo->comp_info[1].component_needed = TRUE;
|
||||
cinfo->comp_info[2].component_needed = TRUE;
|
||||
/* compute normal YCC first */
|
||||
cconvert->pub.start_pass = rgb_ycc_start;
|
||||
cconvert->pub.color_convert = rgb_ycc_convert;
|
||||
break;
|
||||
case JCS_YCbCr:
|
||||
/* need quantization scale by factor of 2 after DCT */
|
||||
cinfo->comp_info[1].component_needed = TRUE;
|
||||
cinfo->comp_info[2].component_needed = TRUE;
|
||||
/*FALLTHROUGH*/
|
||||
case JCS_BG_YCC:
|
||||
/* Pass through for BG_YCC input */
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
break;
|
||||
|
||||
case JCS_CMYK:
|
||||
if (cinfo->num_components != 4)
|
||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||
if (cinfo->in_color_space == JCS_CMYK)
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
else
|
||||
if (cinfo->in_color_space != JCS_CMYK)
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
break;
|
||||
|
||||
case JCS_YCCK:
|
||||
if (cinfo->num_components != 4)
|
||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||
if (cinfo->in_color_space == JCS_CMYK) {
|
||||
switch (cinfo->in_color_space) {
|
||||
case JCS_CMYK:
|
||||
cconvert->pub.start_pass = rgb_ycc_start;
|
||||
cconvert->pub.color_convert = cmyk_ycck_convert;
|
||||
} else if (cinfo->in_color_space == JCS_YCCK)
|
||||
break;
|
||||
case JCS_YCCK:
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
else
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* allow null conversion of JCS_UNKNOWN */
|
||||
@@ -454,6 +597,5 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
cinfo->num_components != cinfo->input_components)
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
79
jcdctmgr.c
79
jcdctmgr.c
@@ -2,6 +2,7 @@
|
||||
* jcdctmgr.c
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2003-2013 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -25,22 +26,30 @@ typedef struct {
|
||||
/* Pointer to the DCT routine actually in use */
|
||||
forward_DCT_method_ptr do_dct[MAX_COMPONENTS];
|
||||
|
||||
/* The actual post-DCT divisors --- not identical to the quant table
|
||||
* entries, because of scaling (especially for an unnormalized DCT).
|
||||
* Each table is given in normal array order.
|
||||
*/
|
||||
DCTELEM * divisors[NUM_QUANT_TBLS];
|
||||
|
||||
#ifdef DCT_FLOAT_SUPPORTED
|
||||
/* Same as above for the floating-point case. */
|
||||
float_DCT_method_ptr do_float_dct[MAX_COMPONENTS];
|
||||
FAST_FLOAT * float_divisors[NUM_QUANT_TBLS];
|
||||
#endif
|
||||
} my_fdct_controller;
|
||||
|
||||
typedef my_fdct_controller * my_fdct_ptr;
|
||||
|
||||
|
||||
/* The allocated post-DCT divisor tables -- big enough for any
|
||||
* supported variant and not identical to the quant table entries,
|
||||
* because of scaling (especially for an unnormalized DCT) --
|
||||
* are pointed to by dct_table in the per-component comp_info
|
||||
* structures. Each table is given in normal array order.
|
||||
*/
|
||||
|
||||
typedef union {
|
||||
DCTELEM int_array[DCTSIZE2];
|
||||
#ifdef DCT_FLOAT_SUPPORTED
|
||||
FAST_FLOAT float_array[DCTSIZE2];
|
||||
#endif
|
||||
} divisor_table;
|
||||
|
||||
|
||||
/* The current scaled-DCT routines require ISLOW-style divisor tables,
|
||||
* so be sure to compile that code if either ISLOW or SCALING is requested.
|
||||
*/
|
||||
@@ -71,7 +80,7 @@ forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* This routine is heavily used, so it's worth coding it tightly. */
|
||||
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
|
||||
forward_DCT_method_ptr do_dct = fdct->do_dct[compptr->component_index];
|
||||
DCTELEM * divisors = fdct->divisors[compptr->quant_tbl_no];
|
||||
DCTELEM * divisors = (DCTELEM *) compptr->dct_table;
|
||||
DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */
|
||||
JDIMENSION bi;
|
||||
|
||||
@@ -134,7 +143,7 @@ forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* This routine is heavily used, so it's worth coding it tightly. */
|
||||
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
|
||||
float_DCT_method_ptr do_dct = fdct->do_float_dct[compptr->component_index];
|
||||
FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no];
|
||||
FAST_FLOAT * divisors = (FAST_FLOAT *) compptr->dct_table;
|
||||
FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */
|
||||
JDIMENSION bi;
|
||||
|
||||
@@ -352,22 +361,17 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
cinfo->quant_tbl_ptrs[qtblno] == NULL)
|
||||
ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
|
||||
qtbl = cinfo->quant_tbl_ptrs[qtblno];
|
||||
/* Compute divisors for this quant table */
|
||||
/* We may do this more than once for same table, but it's not a big deal */
|
||||
/* Create divisor table from quant table */
|
||||
switch (method) {
|
||||
#ifdef PROVIDE_ISLOW_TABLES
|
||||
case JDCT_ISLOW:
|
||||
/* For LL&M IDCT method, divisors are equal to raw quantization
|
||||
* coefficients multiplied by 8 (to counteract scaling).
|
||||
*/
|
||||
if (fdct->divisors[qtblno] == NULL) {
|
||||
fdct->divisors[qtblno] = (DCTELEM *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
DCTSIZE2 * SIZEOF(DCTELEM));
|
||||
}
|
||||
dtbl = fdct->divisors[qtblno];
|
||||
dtbl = (DCTELEM *) compptr->dct_table;
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3;
|
||||
dtbl[i] =
|
||||
((DCTELEM) qtbl->quantval[i]) << (compptr->component_needed ? 4 : 3);
|
||||
}
|
||||
fdct->pub.forward_DCT[ci] = forward_DCT;
|
||||
break;
|
||||
@@ -395,17 +399,12 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
};
|
||||
SHIFT_TEMPS
|
||||
|
||||
if (fdct->divisors[qtblno] == NULL) {
|
||||
fdct->divisors[qtblno] = (DCTELEM *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
DCTSIZE2 * SIZEOF(DCTELEM));
|
||||
}
|
||||
dtbl = fdct->divisors[qtblno];
|
||||
dtbl = (DCTELEM *) compptr->dct_table;
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
dtbl[i] = (DCTELEM)
|
||||
DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i],
|
||||
(INT32) aanscales[i]),
|
||||
CONST_BITS-3);
|
||||
compptr->component_needed ? CONST_BITS-4 : CONST_BITS-3);
|
||||
}
|
||||
}
|
||||
fdct->pub.forward_DCT[ci] = forward_DCT;
|
||||
@@ -422,25 +421,20 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
* What's actually stored is 1/divisor so that the inner loop can
|
||||
* use a multiplication rather than a division.
|
||||
*/
|
||||
FAST_FLOAT * fdtbl;
|
||||
FAST_FLOAT * fdtbl = (FAST_FLOAT *) compptr->dct_table;
|
||||
int row, col;
|
||||
static const double aanscalefactor[DCTSIZE] = {
|
||||
1.0, 1.387039845, 1.306562965, 1.175875602,
|
||||
1.0, 0.785694958, 0.541196100, 0.275899379
|
||||
};
|
||||
|
||||
if (fdct->float_divisors[qtblno] == NULL) {
|
||||
fdct->float_divisors[qtblno] = (FAST_FLOAT *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
DCTSIZE2 * SIZEOF(FAST_FLOAT));
|
||||
}
|
||||
fdtbl = fdct->float_divisors[qtblno];
|
||||
i = 0;
|
||||
for (row = 0; row < DCTSIZE; row++) {
|
||||
for (col = 0; col < DCTSIZE; col++) {
|
||||
fdtbl[i] = (FAST_FLOAT)
|
||||
(1.0 / (((double) qtbl->quantval[i] *
|
||||
aanscalefactor[row] * aanscalefactor[col] * 8.0)));
|
||||
(1.0 / ((double) qtbl->quantval[i] *
|
||||
aanscalefactor[row] * aanscalefactor[col] *
|
||||
(compptr->component_needed ? 16.0 : 8.0)));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -464,19 +458,20 @@ GLOBAL(void)
|
||||
jinit_forward_dct (j_compress_ptr cinfo)
|
||||
{
|
||||
my_fdct_ptr fdct;
|
||||
int i;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
fdct = (my_fdct_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_fdct_controller));
|
||||
cinfo->fdct = (struct jpeg_forward_dct *) fdct;
|
||||
cinfo->fdct = &fdct->pub;
|
||||
fdct->pub.start_pass = start_pass_fdctmgr;
|
||||
|
||||
/* Mark divisor tables unallocated */
|
||||
for (i = 0; i < NUM_QUANT_TBLS; i++) {
|
||||
fdct->divisors[i] = NULL;
|
||||
#ifdef DCT_FLOAT_SUPPORTED
|
||||
fdct->float_divisors[i] = NULL;
|
||||
#endif
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
/* Allocate a divisor table for each component */
|
||||
compptr->dct_table =
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(divisor_table));
|
||||
}
|
||||
}
|
||||
|
||||
218
jchuff.c
218
jchuff.c
@@ -2,7 +2,7 @@
|
||||
* jchuff.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2006-2009 by Guido Vollbeding.
|
||||
* Modified 2006-2019 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.
|
||||
*
|
||||
@@ -178,13 +178,12 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
htbl =
|
||||
isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
|
||||
if (htbl == NULL)
|
||||
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
|
||||
htbl = jpeg_std_huff_table((j_common_ptr) cinfo, isDC, tblno);
|
||||
|
||||
/* Allocate a workspace if we haven't already done so. */
|
||||
if (*pdtbl == NULL)
|
||||
*pdtbl = (c_derived_tbl *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(c_derived_tbl));
|
||||
*pdtbl = (c_derived_tbl *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(c_derived_tbl));
|
||||
dtbl = *pdtbl;
|
||||
|
||||
/* Figure C.1: make table of Huffman code length for each symbol */
|
||||
@@ -308,20 +307,23 @@ emit_bits_s (working_state * state, unsigned int code, int size)
|
||||
/* Emit some bits; return TRUE if successful, FALSE if must suspend */
|
||||
{
|
||||
/* This routine is heavily used, so it's worth coding tightly. */
|
||||
register INT32 put_buffer = (INT32) code;
|
||||
register int put_bits = state->cur.put_bits;
|
||||
register INT32 put_buffer;
|
||||
register int put_bits;
|
||||
|
||||
/* if size is 0, caller used an invalid Huffman table entry */
|
||||
if (size == 0)
|
||||
ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE);
|
||||
|
||||
put_buffer &= (((INT32) 1)<<size) - 1; /* mask off any extra bits in code */
|
||||
/* mask off any extra bits in code */
|
||||
put_buffer = ((INT32) code) & ((((INT32) 1) << size) - 1);
|
||||
|
||||
put_bits += size; /* new number of bits in buffer */
|
||||
/* new number of bits in buffer */
|
||||
put_bits = size + state->cur.put_bits;
|
||||
|
||||
put_buffer <<= 24 - put_bits; /* align incoming bits */
|
||||
|
||||
put_buffer |= state->cur.put_buffer; /* and merge with old buffer contents */
|
||||
/* and merge with old buffer contents */
|
||||
put_buffer |= state->cur.put_buffer;
|
||||
|
||||
while (put_bits >= 8) {
|
||||
int c = (int) ((put_buffer >> 16) & 0xFF);
|
||||
@@ -347,8 +349,8 @@ emit_bits_e (huff_entropy_ptr entropy, unsigned int code, int size)
|
||||
/* Emit some bits, unless we are in gather mode */
|
||||
{
|
||||
/* This routine is heavily used, so it's worth coding tightly. */
|
||||
register INT32 put_buffer = (INT32) code;
|
||||
register int put_bits = entropy->saved.put_bits;
|
||||
register INT32 put_buffer;
|
||||
register int put_bits;
|
||||
|
||||
/* if size is 0, caller used an invalid Huffman table entry */
|
||||
if (size == 0)
|
||||
@@ -357,9 +359,11 @@ emit_bits_e (huff_entropy_ptr entropy, unsigned int code, int size)
|
||||
if (entropy->gather_statistics)
|
||||
return; /* do nothing if we're only getting stats */
|
||||
|
||||
put_buffer &= (((INT32) 1)<<size) - 1; /* mask off any extra bits in code */
|
||||
/* mask off any extra bits in code */
|
||||
put_buffer = ((INT32) code) & ((((INT32) 1) << size) - 1);
|
||||
|
||||
put_bits += size; /* new number of bits in buffer */
|
||||
/* new number of bits in buffer */
|
||||
put_bits = size + entropy->saved.put_bits;
|
||||
|
||||
put_buffer <<= 24 - put_bits; /* align incoming bits */
|
||||
|
||||
@@ -543,10 +547,7 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
register int temp, temp2;
|
||||
register int nbits;
|
||||
int blkn, ci;
|
||||
int Al = cinfo->Al;
|
||||
JBLOCKROW block;
|
||||
jpeg_component_info * compptr;
|
||||
int blkn, ci, tbl;
|
||||
ISHIFT_TEMPS
|
||||
|
||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||
@@ -559,21 +560,20 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
/* Encode the MCU data blocks */
|
||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||
block = MCU_data[blkn];
|
||||
ci = cinfo->MCU_membership[blkn];
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
tbl = cinfo->cur_comp_info[ci]->dc_tbl_no;
|
||||
|
||||
/* Compute the DC value after the required point transform by Al.
|
||||
* This is simply an arithmetic right shift.
|
||||
*/
|
||||
temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al);
|
||||
temp = IRIGHT_SHIFT((int) (MCU_data[blkn][0][0]), cinfo->Al);
|
||||
|
||||
/* DC differences are figured on the point-transformed values. */
|
||||
temp = temp2 - entropy->saved.last_dc_val[ci];
|
||||
entropy->saved.last_dc_val[ci] = temp2;
|
||||
temp2 = temp - entropy->saved.last_dc_val[ci];
|
||||
entropy->saved.last_dc_val[ci] = temp;
|
||||
|
||||
/* Encode the DC coefficient difference per section G.1.2.1 */
|
||||
temp2 = temp;
|
||||
temp = temp2;
|
||||
if (temp < 0) {
|
||||
temp = -temp; /* temp is abs value of input */
|
||||
/* For a negative input, want temp2 = bitwise complement of abs(input) */
|
||||
@@ -594,7 +594,7 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
||||
|
||||
/* Count/emit the Huffman-coded symbol for the number of bits */
|
||||
emit_dc_symbol(entropy, compptr->dc_tbl_no, nbits);
|
||||
emit_dc_symbol(entropy, tbl, nbits);
|
||||
|
||||
/* Emit that number of bits of the value, if positive, */
|
||||
/* or the complement of its magnitude, if negative. */
|
||||
@@ -628,12 +628,12 @@ METHODDEF(boolean)
|
||||
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
const int * natural_order;
|
||||
JBLOCKROW block;
|
||||
register int temp, temp2;
|
||||
register int nbits;
|
||||
register int r, k;
|
||||
int Se, Al;
|
||||
const int * natural_order;
|
||||
JBLOCKROW block;
|
||||
|
||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
||||
@@ -731,18 +731,15 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
/*
|
||||
* MCU encoding for DC successive approximation refinement scan.
|
||||
* Note: we assume such scans can be multi-component, although the spec
|
||||
* is not very clear on the point.
|
||||
* Note: we assume such scans can be multi-component,
|
||||
* although the spec is not very clear on the point.
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
register int temp;
|
||||
int blkn;
|
||||
int Al = cinfo->Al;
|
||||
JBLOCKROW block;
|
||||
int Al, blkn;
|
||||
|
||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
||||
@@ -752,13 +749,12 @@ encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (entropy->restarts_to_go == 0)
|
||||
emit_restart_e(entropy, entropy->next_restart_num);
|
||||
|
||||
Al = cinfo->Al;
|
||||
|
||||
/* Encode the MCU data blocks */
|
||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||
block = MCU_data[blkn];
|
||||
|
||||
/* We simply emit the Al'th bit of the DC coefficient value. */
|
||||
temp = (*block)[0];
|
||||
emit_bits_e(entropy, (unsigned int) (temp >> Al), 1);
|
||||
emit_bits_e(entropy, (unsigned int) (MCU_data[blkn][0][0] >> Al), 1);
|
||||
}
|
||||
|
||||
cinfo->dest->next_output_byte = entropy->next_output_byte;
|
||||
@@ -786,14 +782,14 @@ METHODDEF(boolean)
|
||||
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
const int * natural_order;
|
||||
JBLOCKROW block;
|
||||
register int temp;
|
||||
register int r, k;
|
||||
int Se, Al;
|
||||
int EOB;
|
||||
char *BR_buffer;
|
||||
unsigned int BR;
|
||||
int Se, Al;
|
||||
const int * natural_order;
|
||||
JBLOCKROW block;
|
||||
int absvalues[DCTSIZE2];
|
||||
|
||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||
@@ -918,7 +914,7 @@ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val,
|
||||
{
|
||||
register int temp, temp2;
|
||||
register int nbits;
|
||||
register int k, r, i;
|
||||
register int r, k;
|
||||
int Se = state->cinfo->lim_Se;
|
||||
const int * natural_order = state->cinfo->natural_order;
|
||||
|
||||
@@ -960,7 +956,7 @@ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val,
|
||||
r = 0; /* r = run length of zeros */
|
||||
|
||||
for (k = 1; k <= Se; k++) {
|
||||
if ((temp = block[natural_order[k]]) == 0) {
|
||||
if ((temp2 = block[natural_order[k]]) == 0) {
|
||||
r++;
|
||||
} else {
|
||||
/* if run length > 15, must emit special run-length-16 codes (0xF0) */
|
||||
@@ -970,7 +966,7 @@ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val,
|
||||
r -= 16;
|
||||
}
|
||||
|
||||
temp2 = temp;
|
||||
temp = temp2;
|
||||
if (temp < 0) {
|
||||
temp = -temp; /* temp is abs value of input */
|
||||
/* This code assumes we are on a two's complement machine */
|
||||
@@ -986,8 +982,8 @@ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val,
|
||||
ERREXIT(state->cinfo, JERR_BAD_DCT_COEF);
|
||||
|
||||
/* Emit Huffman symbol for run length / number of bits */
|
||||
i = (r << 4) + nbits;
|
||||
if (! emit_bits_s(state, actbl->ehufco[i], actbl->ehufsi[i]))
|
||||
temp = (r << 4) + nbits;
|
||||
if (! emit_bits_s(state, actbl->ehufco[temp], actbl->ehufsi[temp]))
|
||||
return FALSE;
|
||||
|
||||
/* Emit that number of bits of the value, if positive, */
|
||||
@@ -1124,7 +1120,7 @@ htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
|
||||
{
|
||||
register int temp;
|
||||
register int nbits;
|
||||
register int k, r;
|
||||
register int r, k;
|
||||
int Se = cinfo->lim_Se;
|
||||
const int * natural_order = cinfo->natural_order;
|
||||
|
||||
@@ -1259,10 +1255,82 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
|
||||
UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */
|
||||
int codesize[257]; /* codesize[k] = code length of symbol k */
|
||||
int others[257]; /* next symbol in current branch of tree */
|
||||
int c1, c2;
|
||||
int p, i, j;
|
||||
int c1, c2, i, j;
|
||||
UINT8 *p;
|
||||
long v;
|
||||
|
||||
freq[256] = 1; /* make sure 256 has a nonzero count */
|
||||
/* Including the pseudo-symbol 256 in the Huffman procedure guarantees
|
||||
* that no real symbol is given code-value of all ones, because 256
|
||||
* will be placed last in the largest codeword category.
|
||||
* In the symbol list build procedure this element serves as sentinel
|
||||
* for the zero run loop.
|
||||
*/
|
||||
|
||||
#ifndef DONT_USE_FANCY_HUFF_OPT
|
||||
|
||||
/* Build list of symbols sorted in order of descending frequency */
|
||||
/* This approach has several benefits (thank to John Korejwa for the idea):
|
||||
* 1.
|
||||
* If a codelength category is split during the length limiting procedure
|
||||
* below, the feature that more frequent symbols are assigned shorter
|
||||
* codewords remains valid for the adjusted code.
|
||||
* 2.
|
||||
* To reduce consecutive ones in a Huffman data stream (thus reducing the
|
||||
* number of stuff bytes in JPEG) it is preferable to follow 0 branches
|
||||
* (and avoid 1 branches) as much as possible. This is easily done by
|
||||
* assigning symbols to leaves of the Huffman tree in order of decreasing
|
||||
* frequency, with no secondary sort based on codelengths.
|
||||
* 3.
|
||||
* The symbol list can be built independently from the assignment of code
|
||||
* lengths by the Huffman procedure below.
|
||||
* Note: The symbol list build procedure must be performed first, because
|
||||
* the Huffman procedure assigning the codelengths clobbers the frequency
|
||||
* counts!
|
||||
*/
|
||||
|
||||
/* Here we use the others array as a linked list of nonzero frequencies
|
||||
* to be sorted. Already sorted elements are removed from the list.
|
||||
*/
|
||||
|
||||
/* Building list */
|
||||
|
||||
/* This item does not correspond to a valid symbol frequency and is used
|
||||
* as starting index.
|
||||
*/
|
||||
j = 256;
|
||||
|
||||
for (i = 0;; i++) {
|
||||
if (freq[i] == 0) /* skip zero frequencies */
|
||||
continue;
|
||||
if (i > 255)
|
||||
break;
|
||||
others[j] = i; /* this symbol value */
|
||||
j = i; /* previous symbol value */
|
||||
}
|
||||
others[j] = -1; /* mark end of list */
|
||||
|
||||
/* Sorting list */
|
||||
|
||||
p = htbl->huffval;
|
||||
while ((c1 = others[256]) >= 0) {
|
||||
v = freq[c1];
|
||||
i = c1; /* first symbol value */
|
||||
j = 256; /* pseudo symbol value for starting index */
|
||||
while ((c2 = others[c1]) >= 0) {
|
||||
if (freq[c2] > v) {
|
||||
v = freq[c2];
|
||||
i = c2; /* this symbol value */
|
||||
j = c1; /* previous symbol value */
|
||||
}
|
||||
c1 = c2;
|
||||
}
|
||||
others[j] = others[i]; /* remove this symbol i from list */
|
||||
*p++ = (UINT8) i;
|
||||
}
|
||||
|
||||
#endif /* DONT_USE_FANCY_HUFF_OPT */
|
||||
|
||||
/* This algorithm is explained in section K.2 of the JPEG standard */
|
||||
|
||||
MEMZERO(bits, SIZEOF(bits));
|
||||
@@ -1270,12 +1338,6 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
|
||||
for (i = 0; i < 257; i++)
|
||||
others[i] = -1; /* init links to empty */
|
||||
|
||||
freq[256] = 1; /* make sure 256 has a nonzero count */
|
||||
/* Including the pseudo-symbol 256 in the Huffman procedure guarantees
|
||||
* that no real symbol is given code-value of all ones, because 256
|
||||
* will be placed last in the largest codeword category.
|
||||
*/
|
||||
|
||||
/* Huffman's basic algorithm to assign optimal code lengths to symbols */
|
||||
|
||||
for (;;) {
|
||||
@@ -1332,7 +1394,7 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
|
||||
/* The JPEG standard seems to think that this can't happen, */
|
||||
/* but I'm paranoid... */
|
||||
if (codesize[i] > MAX_CLEN)
|
||||
ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW);
|
||||
ERREXIT(cinfo, JERR_HUFF_CLEN_OUTOFBOUNDS);
|
||||
|
||||
bits[codesize[i]]++;
|
||||
}
|
||||
@@ -1352,8 +1414,11 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
|
||||
for (i = MAX_CLEN; i > 16; i--) {
|
||||
while (bits[i] > 0) {
|
||||
j = i - 2; /* find length of new prefix to be used */
|
||||
while (bits[j] == 0)
|
||||
while (bits[j] == 0) {
|
||||
if (j == 0)
|
||||
ERREXIT(cinfo, JERR_HUFF_CLEN_OUTOFBOUNDS);
|
||||
j--;
|
||||
}
|
||||
|
||||
bits[i] -= 2; /* remove two symbols */
|
||||
bits[i-1]++; /* one goes in this length */
|
||||
@@ -1370,20 +1435,23 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
|
||||
/* Return final symbol counts (only for lengths 0..16) */
|
||||
MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits));
|
||||
|
||||
#ifdef DONT_USE_FANCY_HUFF_OPT
|
||||
|
||||
/* Return a list of the symbols sorted by code length */
|
||||
/* It's not real clear to me why we don't need to consider the codelength
|
||||
* changes made above, but the JPEG spec seems to think this works.
|
||||
/* Note: Due to the codelength changes made above, it can happen
|
||||
* that more frequent symbols are assigned longer codewords.
|
||||
*/
|
||||
p = 0;
|
||||
p = htbl->huffval;
|
||||
for (i = 1; i <= MAX_CLEN; i++) {
|
||||
for (j = 0; j <= 255; j++) {
|
||||
if (codesize[j] == i) {
|
||||
htbl->huffval[p] = (UINT8) j;
|
||||
p++;
|
||||
*p++ = (UINT8) j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* DONT_USE_FANCY_HUFF_OPT */
|
||||
|
||||
/* Set sent_table FALSE so updated table will be written to JPEG file. */
|
||||
htbl->sent_table = FALSE;
|
||||
}
|
||||
@@ -1403,13 +1471,13 @@ finish_pass_gather (j_compress_ptr cinfo)
|
||||
boolean did_dc[NUM_HUFF_TBLS];
|
||||
boolean did_ac[NUM_HUFF_TBLS];
|
||||
|
||||
/* It's important not to apply jpeg_gen_optimal_table more than once
|
||||
* per table, because it clobbers the input frequency counts!
|
||||
*/
|
||||
if (cinfo->progressive_mode)
|
||||
/* Flush out buffered data (all we care about is counting the EOB symbol) */
|
||||
emit_eobrun(entropy);
|
||||
|
||||
/* It's important not to apply jpeg_gen_optimal_table more than once
|
||||
* per table, because it clobbers the input frequency counts!
|
||||
*/
|
||||
MEMZERO(did_dc, SIZEOF(did_dc));
|
||||
MEMZERO(did_ac, SIZEOF(did_ac));
|
||||
|
||||
@@ -1478,9 +1546,8 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
entropy->pub.encode_mcu = encode_mcu_AC_refine;
|
||||
/* AC refinement needs a correction bit buffer */
|
||||
if (entropy->bit_buffer == NULL)
|
||||
entropy->bit_buffer = (char *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
MAX_CORR_BITS * SIZEOF(char));
|
||||
entropy->bit_buffer = (char *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, MAX_CORR_BITS * SIZEOF(char));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1508,9 +1575,8 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
/* Allocate and zero the statistics tables */
|
||||
/* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
|
||||
if (entropy->dc_count_ptrs[tbl] == NULL)
|
||||
entropy->dc_count_ptrs[tbl] = (long *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
257 * SIZEOF(long));
|
||||
entropy->dc_count_ptrs[tbl] = (long *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, 257 * SIZEOF(long));
|
||||
MEMZERO(entropy->dc_count_ptrs[tbl], 257 * SIZEOF(long));
|
||||
} else {
|
||||
/* Compute derived values for Huffman tables */
|
||||
@@ -1528,9 +1594,8 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
if (tbl < 0 || tbl >= NUM_HUFF_TBLS)
|
||||
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
|
||||
if (entropy->ac_count_ptrs[tbl] == NULL)
|
||||
entropy->ac_count_ptrs[tbl] = (long *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
257 * SIZEOF(long));
|
||||
entropy->ac_count_ptrs[tbl] = (long *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, 257 * SIZEOF(long));
|
||||
MEMZERO(entropy->ac_count_ptrs[tbl], 257 * SIZEOF(long));
|
||||
} else {
|
||||
jpeg_make_c_derived_tbl(cinfo, FALSE, tbl,
|
||||
@@ -1559,10 +1624,9 @@ jinit_huff_encoder (j_compress_ptr cinfo)
|
||||
huff_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (huff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(huff_entropy_encoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
|
||||
entropy = (huff_entropy_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(huff_entropy_encoder));
|
||||
cinfo->entropy = &entropy->pub;
|
||||
entropy->pub.start_pass = start_pass_huff;
|
||||
|
||||
/* Mark tables unallocated */
|
||||
|
||||
184
jcinit.c
184
jcinit.c
@@ -2,6 +2,7 @@
|
||||
* jcinit.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2003-2017 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.
|
||||
*
|
||||
@@ -20,6 +21,168 @@
|
||||
#include "jpeglib.h"
|
||||
|
||||
|
||||
/*
|
||||
* Compute JPEG image dimensions and related values.
|
||||
* NOTE: this is exported for possible use by application.
|
||||
* Hence it mustn't do anything that can't be done twice.
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo)
|
||||
/* Do computations that are needed before master selection phase */
|
||||
{
|
||||
/* Sanity check on input image dimensions to prevent overflow in
|
||||
* following calculations.
|
||||
* We do check jpeg_width and jpeg_height in initial_setup in jcmaster.c,
|
||||
* but image_width and image_height can come from arbitrary data,
|
||||
* and we need some space for multiplication by block_size.
|
||||
*/
|
||||
if (((long) cinfo->image_width >> 24) || ((long) cinfo->image_height >> 24))
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
|
||||
|
||||
#ifdef DCT_SCALING_SUPPORTED
|
||||
|
||||
/* Compute actual JPEG image dimensions and DCT scaling choices. */
|
||||
if (cinfo->scale_num >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/1 scaling */
|
||||
cinfo->jpeg_width = cinfo->image_width * cinfo->block_size;
|
||||
cinfo->jpeg_height = cinfo->image_height * cinfo->block_size;
|
||||
cinfo->min_DCT_h_scaled_size = 1;
|
||||
cinfo->min_DCT_v_scaled_size = 1;
|
||||
} else if (cinfo->scale_num * 2 >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/2 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 2L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 2L);
|
||||
cinfo->min_DCT_h_scaled_size = 2;
|
||||
cinfo->min_DCT_v_scaled_size = 2;
|
||||
} else if (cinfo->scale_num * 3 >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/3 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 3L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 3L);
|
||||
cinfo->min_DCT_h_scaled_size = 3;
|
||||
cinfo->min_DCT_v_scaled_size = 3;
|
||||
} else if (cinfo->scale_num * 4 >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/4 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 4L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 4L);
|
||||
cinfo->min_DCT_h_scaled_size = 4;
|
||||
cinfo->min_DCT_v_scaled_size = 4;
|
||||
} else if (cinfo->scale_num * 5 >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/5 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 5L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 5L);
|
||||
cinfo->min_DCT_h_scaled_size = 5;
|
||||
cinfo->min_DCT_v_scaled_size = 5;
|
||||
} else if (cinfo->scale_num * 6 >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/6 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 6L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 6L);
|
||||
cinfo->min_DCT_h_scaled_size = 6;
|
||||
cinfo->min_DCT_v_scaled_size = 6;
|
||||
} else if (cinfo->scale_num * 7 >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/7 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 7L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 7L);
|
||||
cinfo->min_DCT_h_scaled_size = 7;
|
||||
cinfo->min_DCT_v_scaled_size = 7;
|
||||
} else if (cinfo->scale_num * 8 >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/8 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 8L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 8L);
|
||||
cinfo->min_DCT_h_scaled_size = 8;
|
||||
cinfo->min_DCT_v_scaled_size = 8;
|
||||
} else if (cinfo->scale_num * 9 >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/9 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 9L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 9L);
|
||||
cinfo->min_DCT_h_scaled_size = 9;
|
||||
cinfo->min_DCT_v_scaled_size = 9;
|
||||
} else if (cinfo->scale_num * 10 >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/10 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 10L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 10L);
|
||||
cinfo->min_DCT_h_scaled_size = 10;
|
||||
cinfo->min_DCT_v_scaled_size = 10;
|
||||
} else if (cinfo->scale_num * 11 >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/11 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 11L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 11L);
|
||||
cinfo->min_DCT_h_scaled_size = 11;
|
||||
cinfo->min_DCT_v_scaled_size = 11;
|
||||
} else if (cinfo->scale_num * 12 >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/12 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 12L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 12L);
|
||||
cinfo->min_DCT_h_scaled_size = 12;
|
||||
cinfo->min_DCT_v_scaled_size = 12;
|
||||
} else if (cinfo->scale_num * 13 >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/13 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 13L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 13L);
|
||||
cinfo->min_DCT_h_scaled_size = 13;
|
||||
cinfo->min_DCT_v_scaled_size = 13;
|
||||
} else if (cinfo->scale_num * 14 >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/14 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 14L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 14L);
|
||||
cinfo->min_DCT_h_scaled_size = 14;
|
||||
cinfo->min_DCT_v_scaled_size = 14;
|
||||
} else if (cinfo->scale_num * 15 >= cinfo->scale_denom * cinfo->block_size) {
|
||||
/* Provide block_size/15 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 15L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 15L);
|
||||
cinfo->min_DCT_h_scaled_size = 15;
|
||||
cinfo->min_DCT_v_scaled_size = 15;
|
||||
} else {
|
||||
/* Provide block_size/16 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 16L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 16L);
|
||||
cinfo->min_DCT_h_scaled_size = 16;
|
||||
cinfo->min_DCT_v_scaled_size = 16;
|
||||
}
|
||||
|
||||
#else /* !DCT_SCALING_SUPPORTED */
|
||||
|
||||
/* Hardwire it to "no scaling" */
|
||||
cinfo->jpeg_width = cinfo->image_width;
|
||||
cinfo->jpeg_height = cinfo->image_height;
|
||||
cinfo->min_DCT_h_scaled_size = DCTSIZE;
|
||||
cinfo->min_DCT_v_scaled_size = DCTSIZE;
|
||||
|
||||
#endif /* DCT_SCALING_SUPPORTED */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Master selection of compression modules.
|
||||
* This is done once at the start of processing an image. We determine
|
||||
@@ -29,6 +192,27 @@
|
||||
GLOBAL(void)
|
||||
jinit_compress_master (j_compress_ptr cinfo)
|
||||
{
|
||||
long samplesperrow;
|
||||
JDIMENSION jd_samplesperrow;
|
||||
|
||||
/* For now, precision must match compiled-in value... */
|
||||
if (cinfo->data_precision != BITS_IN_JSAMPLE)
|
||||
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
|
||||
|
||||
/* Sanity check on input image dimensions */
|
||||
if (cinfo->image_height <= 0 || cinfo->image_width <= 0 ||
|
||||
cinfo->input_components <= 0)
|
||||
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
||||
|
||||
/* Width of an input scanline must be representable as JDIMENSION. */
|
||||
samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components;
|
||||
jd_samplesperrow = (JDIMENSION) samplesperrow;
|
||||
if ((long) jd_samplesperrow != samplesperrow)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
|
||||
/* Compute JPEG image dimensions and related values. */
|
||||
jpeg_calc_jpeg_dimensions(cinfo);
|
||||
|
||||
/* Initialize master control (includes parameter checking/processing) */
|
||||
jinit_c_master_control(cinfo, FALSE /* full compression */);
|
||||
|
||||
|
||||
110
jcmainct.c
110
jcmainct.c
@@ -2,6 +2,7 @@
|
||||
* jcmainct.c
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2003-2012 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.
|
||||
*
|
||||
@@ -68,32 +69,32 @@ METHODDEF(void) process_data_buffer_main
|
||||
METHODDEF(void)
|
||||
start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
{
|
||||
my_main_ptr main = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr mainp = (my_main_ptr) cinfo->main;
|
||||
|
||||
/* Do nothing in raw-data mode. */
|
||||
if (cinfo->raw_data_in)
|
||||
return;
|
||||
|
||||
main->cur_iMCU_row = 0; /* initialize counters */
|
||||
main->rowgroup_ctr = 0;
|
||||
main->suspended = FALSE;
|
||||
main->pass_mode = pass_mode; /* save mode for use by process_data */
|
||||
mainp->cur_iMCU_row = 0; /* initialize counters */
|
||||
mainp->rowgroup_ctr = 0;
|
||||
mainp->suspended = FALSE;
|
||||
mainp->pass_mode = pass_mode; /* save mode for use by process_data */
|
||||
|
||||
switch (pass_mode) {
|
||||
case JBUF_PASS_THRU:
|
||||
#ifdef FULL_MAIN_BUFFER_SUPPORTED
|
||||
if (main->whole_image[0] != NULL)
|
||||
if (mainp->whole_image[0] != NULL)
|
||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||
#endif
|
||||
main->pub.process_data = process_data_simple_main;
|
||||
mainp->pub.process_data = process_data_simple_main;
|
||||
break;
|
||||
#ifdef FULL_MAIN_BUFFER_SUPPORTED
|
||||
case JBUF_SAVE_SOURCE:
|
||||
case JBUF_CRANK_DEST:
|
||||
case JBUF_SAVE_AND_PASS:
|
||||
if (main->whole_image[0] == NULL)
|
||||
if (mainp->whole_image[0] == NULL)
|
||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||
main->pub.process_data = process_data_buffer_main;
|
||||
mainp->pub.process_data = process_data_buffer_main;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
@@ -114,46 +115,46 @@ process_data_simple_main (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
||||
JDIMENSION in_rows_avail)
|
||||
{
|
||||
my_main_ptr main = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr mainp = (my_main_ptr) cinfo->main;
|
||||
|
||||
while (main->cur_iMCU_row < cinfo->total_iMCU_rows) {
|
||||
while (mainp->cur_iMCU_row < cinfo->total_iMCU_rows) {
|
||||
/* Read input data if we haven't filled the main buffer yet */
|
||||
if (main->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size)
|
||||
if (mainp->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size)
|
||||
(*cinfo->prep->pre_process_data) (cinfo,
|
||||
input_buf, in_row_ctr, in_rows_avail,
|
||||
main->buffer, &main->rowgroup_ctr,
|
||||
mainp->buffer, &mainp->rowgroup_ctr,
|
||||
(JDIMENSION) cinfo->min_DCT_v_scaled_size);
|
||||
|
||||
/* If we don't have a full iMCU row buffered, return to application for
|
||||
* more data. Note that preprocessor will always pad to fill the iMCU row
|
||||
* at the bottom of the image.
|
||||
*/
|
||||
if (main->rowgroup_ctr != (JDIMENSION) cinfo->min_DCT_v_scaled_size)
|
||||
if (mainp->rowgroup_ctr != (JDIMENSION) cinfo->min_DCT_v_scaled_size)
|
||||
return;
|
||||
|
||||
/* Send the completed row to the compressor */
|
||||
if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) {
|
||||
if (! (*cinfo->coef->compress_data) (cinfo, mainp->buffer)) {
|
||||
/* If compressor did not consume the whole row, then we must need to
|
||||
* suspend processing and return to the application. In this situation
|
||||
* we pretend we didn't yet consume the last input row; otherwise, if
|
||||
* it happened to be the last row of the image, the application would
|
||||
* think we were done.
|
||||
*/
|
||||
if (! main->suspended) {
|
||||
if (! mainp->suspended) {
|
||||
(*in_row_ctr)--;
|
||||
main->suspended = TRUE;
|
||||
mainp->suspended = TRUE;
|
||||
}
|
||||
return;
|
||||
}
|
||||
/* We did finish the row. Undo our little suspension hack if a previous
|
||||
* call suspended; then mark the main buffer empty.
|
||||
*/
|
||||
if (main->suspended) {
|
||||
if (mainp->suspended) {
|
||||
(*in_row_ctr)++;
|
||||
main->suspended = FALSE;
|
||||
mainp->suspended = FALSE;
|
||||
}
|
||||
main->rowgroup_ctr = 0;
|
||||
main->cur_iMCU_row++;
|
||||
mainp->rowgroup_ctr = 0;
|
||||
mainp->cur_iMCU_row++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,25 +171,27 @@ process_data_buffer_main (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
||||
JDIMENSION in_rows_avail)
|
||||
{
|
||||
my_main_ptr main = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr mainp = (my_main_ptr) cinfo->main;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
boolean writing = (main->pass_mode != JBUF_CRANK_DEST);
|
||||
boolean writing = (mainp->pass_mode != JBUF_CRANK_DEST);
|
||||
|
||||
while (main->cur_iMCU_row < cinfo->total_iMCU_rows) {
|
||||
while (mainp->cur_iMCU_row < cinfo->total_iMCU_rows) {
|
||||
/* Realign the virtual buffers if at the start of an iMCU row. */
|
||||
if (main->rowgroup_ctr == 0) {
|
||||
if (mainp->rowgroup_ctr == 0) {
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
main->buffer[ci] = (*cinfo->mem->access_virt_sarray)
|
||||
((j_common_ptr) cinfo, main->whole_image[ci],
|
||||
main->cur_iMCU_row * (compptr->v_samp_factor * DCTSIZE),
|
||||
(JDIMENSION) (compptr->v_samp_factor * DCTSIZE), writing);
|
||||
mainp->buffer[ci] = (*cinfo->mem->access_virt_sarray)
|
||||
((j_common_ptr) cinfo, mainp->whole_image[ci], mainp->cur_iMCU_row *
|
||||
((JDIMENSION) (compptr->v_samp_factor * cinfo->min_DCT_v_scaled_size)),
|
||||
(JDIMENSION) (compptr->v_samp_factor * cinfo->min_DCT_v_scaled_size),
|
||||
writing);
|
||||
}
|
||||
/* In a read pass, pretend we just read some source data. */
|
||||
if (! writing) {
|
||||
*in_row_ctr += cinfo->max_v_samp_factor * DCTSIZE;
|
||||
main->rowgroup_ctr = DCTSIZE;
|
||||
*in_row_ctr += (JDIMENSION)
|
||||
(cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size);
|
||||
mainp->rowgroup_ctr = (JDIMENSION) cinfo->min_DCT_v_scaled_size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,40 +200,40 @@ process_data_buffer_main (j_compress_ptr cinfo,
|
||||
if (writing) {
|
||||
(*cinfo->prep->pre_process_data) (cinfo,
|
||||
input_buf, in_row_ctr, in_rows_avail,
|
||||
main->buffer, &main->rowgroup_ctr,
|
||||
(JDIMENSION) DCTSIZE);
|
||||
mainp->buffer, &mainp->rowgroup_ctr,
|
||||
(JDIMENSION) cinfo->min_DCT_v_scaled_size);
|
||||
/* Return to application if we need more data to fill the iMCU row. */
|
||||
if (main->rowgroup_ctr < DCTSIZE)
|
||||
if (mainp->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Emit data, unless this is a sink-only pass. */
|
||||
if (main->pass_mode != JBUF_SAVE_SOURCE) {
|
||||
if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) {
|
||||
if (mainp->pass_mode != JBUF_SAVE_SOURCE) {
|
||||
if (! (*cinfo->coef->compress_data) (cinfo, mainp->buffer)) {
|
||||
/* If compressor did not consume the whole row, then we must need to
|
||||
* suspend processing and return to the application. In this situation
|
||||
* we pretend we didn't yet consume the last input row; otherwise, if
|
||||
* it happened to be the last row of the image, the application would
|
||||
* think we were done.
|
||||
*/
|
||||
if (! main->suspended) {
|
||||
if (! mainp->suspended) {
|
||||
(*in_row_ctr)--;
|
||||
main->suspended = TRUE;
|
||||
mainp->suspended = TRUE;
|
||||
}
|
||||
return;
|
||||
}
|
||||
/* We did finish the row. Undo our little suspension hack if a previous
|
||||
* call suspended; then mark the main buffer empty.
|
||||
*/
|
||||
if (main->suspended) {
|
||||
if (mainp->suspended) {
|
||||
(*in_row_ctr)++;
|
||||
main->suspended = FALSE;
|
||||
mainp->suspended = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* If get here, we are done with this iMCU row. Mark buffer empty. */
|
||||
main->rowgroup_ctr = 0;
|
||||
main->cur_iMCU_row++;
|
||||
mainp->rowgroup_ctr = 0;
|
||||
mainp->cur_iMCU_row++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,15 +247,15 @@ process_data_buffer_main (j_compress_ptr cinfo,
|
||||
GLOBAL(void)
|
||||
jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
{
|
||||
my_main_ptr main;
|
||||
my_main_ptr mainp;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
main = (my_main_ptr)
|
||||
mainp = (my_main_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_main_controller));
|
||||
cinfo->main = (struct jpeg_c_main_controller *) main;
|
||||
main->pub.start_pass = start_pass_main;
|
||||
cinfo->main = &mainp->pub;
|
||||
mainp->pub.start_pass = start_pass_main;
|
||||
|
||||
/* We don't need to create a buffer in raw-data mode. */
|
||||
if (cinfo->raw_data_in)
|
||||
@@ -267,11 +270,12 @@ jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
/* Note we pad the bottom to a multiple of the iMCU height */
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
main->whole_image[ci] = (*cinfo->mem->request_virt_sarray)
|
||||
mainp->whole_image[ci] = (*cinfo->mem->request_virt_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
|
||||
compptr->width_in_blocks * compptr->DCT_h_scaled_size,
|
||||
(JDIMENSION) jround_up((long) compptr->height_in_blocks,
|
||||
(long) compptr->v_samp_factor) * DCTSIZE,
|
||||
compptr->width_in_blocks * ((JDIMENSION) compptr->DCT_h_scaled_size),
|
||||
((JDIMENSION) jround_up((long) compptr->height_in_blocks,
|
||||
(long) compptr->v_samp_factor)) *
|
||||
((JDIMENSION) cinfo->min_DCT_v_scaled_size),
|
||||
(JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size));
|
||||
}
|
||||
#else
|
||||
@@ -279,14 +283,14 @@ jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
#endif
|
||||
} else {
|
||||
#ifdef FULL_MAIN_BUFFER_SUPPORTED
|
||||
main->whole_image[0] = NULL; /* flag for no virtual arrays */
|
||||
mainp->whole_image[0] = NULL; /* flag for no virtual arrays */
|
||||
#endif
|
||||
/* Allocate a strip buffer for each component */
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
main->buffer[ci] = (*cinfo->mem->alloc_sarray)
|
||||
mainp->buffer[ci] = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
compptr->width_in_blocks * compptr->DCT_h_scaled_size,
|
||||
compptr->width_in_blocks * ((JDIMENSION) compptr->DCT_h_scaled_size),
|
||||
(JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size));
|
||||
}
|
||||
}
|
||||
|
||||
55
jcmarker.c
55
jcmarker.c
@@ -2,7 +2,7 @@
|
||||
* jcmarker.c
|
||||
*
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2003-2009 by Guido Vollbeding.
|
||||
* Modified 2003-2019 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,6 +73,7 @@ typedef enum { /* JPEG marker codes */
|
||||
M_APP15 = 0xef,
|
||||
|
||||
M_JPG0 = 0xf0,
|
||||
M_JPG8 = 0xf8,
|
||||
M_JPG13 = 0xfd,
|
||||
M_COM = 0xfe,
|
||||
|
||||
@@ -249,6 +250,7 @@ emit_dac (j_compress_ptr cinfo)
|
||||
for (i = 0; i < NUM_ARITH_TBLS; i++)
|
||||
length += dc_in_use[i] + ac_in_use[i];
|
||||
|
||||
if (length) {
|
||||
emit_marker(cinfo, M_DAC);
|
||||
|
||||
emit_2bytes(cinfo, length*2 + 2);
|
||||
@@ -263,6 +265,7 @@ emit_dac (j_compress_ptr cinfo)
|
||||
emit_byte(cinfo, cinfo->arith_ac_K[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* C_ARITH_CODING_SUPPORTED */
|
||||
}
|
||||
|
||||
@@ -279,6 +282,37 @@ emit_dri (j_compress_ptr cinfo)
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_lse_ict (j_compress_ptr cinfo)
|
||||
/* Emit an LSE inverse color transform specification marker */
|
||||
{
|
||||
/* Support only 1 transform */
|
||||
if (cinfo->color_transform != JCT_SUBTRACT_GREEN ||
|
||||
cinfo->num_components < 3)
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
|
||||
emit_marker(cinfo, M_JPG8);
|
||||
|
||||
emit_2bytes(cinfo, 24); /* fixed length */
|
||||
|
||||
emit_byte(cinfo, 0x0D); /* ID inverse transform specification */
|
||||
emit_2bytes(cinfo, MAXJSAMPLE); /* MAXTRANS */
|
||||
emit_byte(cinfo, 3); /* Nt=3 */
|
||||
emit_byte(cinfo, cinfo->comp_info[1].component_id);
|
||||
emit_byte(cinfo, cinfo->comp_info[0].component_id);
|
||||
emit_byte(cinfo, cinfo->comp_info[2].component_id);
|
||||
emit_byte(cinfo, 0x80); /* F1: CENTER1=1, NORM1=0 */
|
||||
emit_2bytes(cinfo, 0); /* A(1,1)=0 */
|
||||
emit_2bytes(cinfo, 0); /* A(1,2)=0 */
|
||||
emit_byte(cinfo, 0); /* F2: CENTER2=0, NORM2=0 */
|
||||
emit_2bytes(cinfo, 1); /* A(2,1)=1 */
|
||||
emit_2bytes(cinfo, 0); /* A(2,2)=0 */
|
||||
emit_byte(cinfo, 0); /* F3: CENTER3=0, NORM3=0 */
|
||||
emit_2bytes(cinfo, 1); /* A(3,1)=1 */
|
||||
emit_2bytes(cinfo, 0); /* A(3,2)=0 */
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_sof (j_compress_ptr cinfo, JPEG_MARKER code)
|
||||
/* Emit a SOF marker */
|
||||
@@ -437,7 +471,6 @@ emit_adobe_app14 (j_compress_ptr cinfo)
|
||||
break;
|
||||
default:
|
||||
emit_byte(cinfo, 0); /* Color transform = 0 */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,8 +507,8 @@ write_marker_byte (j_compress_ptr cinfo, int val)
|
||||
* Write datastream header.
|
||||
* This consists of an SOI and optional APPn markers.
|
||||
* We recommend use of the JFIF marker, but not the Adobe marker,
|
||||
* when using YCbCr or grayscale data. The JFIF marker should NOT
|
||||
* be used for any other JPEG colorspace. The Adobe marker is helpful
|
||||
* when using YCbCr or grayscale data. The JFIF marker is also used
|
||||
* for other standard JPEG colorspaces. The Adobe marker is helpful
|
||||
* to distinguish RGB, CMYK, and YCCK colorspaces.
|
||||
* Note that an application can write additional header markers after
|
||||
* jpeg_start_compress returns.
|
||||
@@ -500,7 +533,8 @@ write_file_header (j_compress_ptr cinfo)
|
||||
|
||||
/*
|
||||
* Write frame header.
|
||||
* This consists of DQT and SOFn markers, and a conditional pseudo SOS marker.
|
||||
* This consists of DQT and SOFn markers,
|
||||
* a conditional LSE marker and a conditional pseudo SOS marker.
|
||||
* Note that we do not emit the SOF until we have emitted the DQT(s).
|
||||
* This avoids compatibility problems with incorrect implementations that
|
||||
* try to error-check the quant table numbers as soon as they see the SOF.
|
||||
@@ -558,6 +592,10 @@ write_frame_header (j_compress_ptr cinfo)
|
||||
emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */
|
||||
}
|
||||
|
||||
/* Check to emit LSE inverse color transform specification marker */
|
||||
if (cinfo->color_transform)
|
||||
emit_lse_ict(cinfo);
|
||||
|
||||
/* Check to emit pseudo SOS marker */
|
||||
if (cinfo->progressive_mode && cinfo->block_size != DCTSIZE)
|
||||
emit_pseudo_sos(cinfo);
|
||||
@@ -663,10 +701,9 @@ jinit_marker_writer (j_compress_ptr cinfo)
|
||||
my_marker_ptr marker;
|
||||
|
||||
/* Create the subobject */
|
||||
marker = (my_marker_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_marker_writer));
|
||||
cinfo->marker = (struct jpeg_marker_writer *) marker;
|
||||
marker = (my_marker_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_marker_writer));
|
||||
cinfo->marker = &marker->pub;
|
||||
/* Initialize method pointers */
|
||||
marker->pub.write_file_header = write_file_header;
|
||||
marker->pub.write_frame_header = write_frame_header;
|
||||
|
||||
241
jcmaster.c
241
jcmaster.c
@@ -2,7 +2,7 @@
|
||||
* jcmaster.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2003-2010 by Guido Vollbeding.
|
||||
* Modified 2003-2019 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.
|
||||
*
|
||||
@@ -43,167 +43,18 @@ typedef my_comp_master * my_master_ptr;
|
||||
* Support routines that do various essential calculations.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Compute JPEG image dimensions and related values.
|
||||
* NOTE: this is exported for possible use by application.
|
||||
* Hence it mustn't do anything that can't be done twice.
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo)
|
||||
LOCAL(void)
|
||||
initial_setup (j_compress_ptr cinfo)
|
||||
/* Do computations that are needed before master selection phase */
|
||||
{
|
||||
#ifdef DCT_SCALING_SUPPORTED
|
||||
int ci, ssize;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
/* Compute actual JPEG image dimensions and DCT scaling choices. */
|
||||
if (cinfo->scale_num >= cinfo->scale_denom * 8) {
|
||||
/* Provide 8/1 scaling */
|
||||
cinfo->jpeg_width = cinfo->image_width << 3;
|
||||
cinfo->jpeg_height = cinfo->image_height << 3;
|
||||
cinfo->min_DCT_h_scaled_size = 1;
|
||||
cinfo->min_DCT_v_scaled_size = 1;
|
||||
} else if (cinfo->scale_num >= cinfo->scale_denom * 4) {
|
||||
/* Provide 4/1 scaling */
|
||||
cinfo->jpeg_width = cinfo->image_width << 2;
|
||||
cinfo->jpeg_height = cinfo->image_height << 2;
|
||||
cinfo->min_DCT_h_scaled_size = 2;
|
||||
cinfo->min_DCT_v_scaled_size = 2;
|
||||
} else if (cinfo->scale_num * 3 >= cinfo->scale_denom * 8) {
|
||||
/* Provide 8/3 scaling */
|
||||
cinfo->jpeg_width = (cinfo->image_width << 1) + (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 2, 3L);
|
||||
cinfo->jpeg_height = (cinfo->image_height << 1) + (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 2, 3L);
|
||||
cinfo->min_DCT_h_scaled_size = 3;
|
||||
cinfo->min_DCT_v_scaled_size = 3;
|
||||
} else if (cinfo->scale_num >= cinfo->scale_denom * 2) {
|
||||
/* Provide 2/1 scaling */
|
||||
cinfo->jpeg_width = cinfo->image_width << 1;
|
||||
cinfo->jpeg_height = cinfo->image_height << 1;
|
||||
cinfo->min_DCT_h_scaled_size = 4;
|
||||
cinfo->min_DCT_v_scaled_size = 4;
|
||||
} else if (cinfo->scale_num * 5 >= cinfo->scale_denom * 8) {
|
||||
/* Provide 8/5 scaling */
|
||||
cinfo->jpeg_width = cinfo->image_width + (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 3, 5L);
|
||||
cinfo->jpeg_height = cinfo->image_height + (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 3, 5L);
|
||||
cinfo->min_DCT_h_scaled_size = 5;
|
||||
cinfo->min_DCT_v_scaled_size = 5;
|
||||
} else if (cinfo->scale_num * 3 >= cinfo->scale_denom * 4) {
|
||||
/* Provide 4/3 scaling */
|
||||
cinfo->jpeg_width = cinfo->image_width + (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width, 3L);
|
||||
cinfo->jpeg_height = cinfo->image_height + (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height, 3L);
|
||||
cinfo->min_DCT_h_scaled_size = 6;
|
||||
cinfo->min_DCT_v_scaled_size = 6;
|
||||
} else if (cinfo->scale_num * 7 >= cinfo->scale_denom * 8) {
|
||||
/* Provide 8/7 scaling */
|
||||
cinfo->jpeg_width = cinfo->image_width + (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width, 7L);
|
||||
cinfo->jpeg_height = cinfo->image_height + (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height, 7L);
|
||||
cinfo->min_DCT_h_scaled_size = 7;
|
||||
cinfo->min_DCT_v_scaled_size = 7;
|
||||
} else if (cinfo->scale_num >= cinfo->scale_denom) {
|
||||
/* Provide 1/1 scaling */
|
||||
cinfo->jpeg_width = cinfo->image_width;
|
||||
cinfo->jpeg_height = cinfo->image_height;
|
||||
cinfo->min_DCT_h_scaled_size = 8;
|
||||
cinfo->min_DCT_v_scaled_size = 8;
|
||||
} else if (cinfo->scale_num * 9 >= cinfo->scale_denom * 8) {
|
||||
/* Provide 8/9 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 8, 9L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 8, 9L);
|
||||
cinfo->min_DCT_h_scaled_size = 9;
|
||||
cinfo->min_DCT_v_scaled_size = 9;
|
||||
} else if (cinfo->scale_num * 5 >= cinfo->scale_denom * 4) {
|
||||
/* Provide 4/5 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 4, 5L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 4, 5L);
|
||||
cinfo->min_DCT_h_scaled_size = 10;
|
||||
cinfo->min_DCT_v_scaled_size = 10;
|
||||
} else if (cinfo->scale_num * 11 >= cinfo->scale_denom * 8) {
|
||||
/* Provide 8/11 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 8, 11L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 8, 11L);
|
||||
cinfo->min_DCT_h_scaled_size = 11;
|
||||
cinfo->min_DCT_v_scaled_size = 11;
|
||||
} else if (cinfo->scale_num * 3 >= cinfo->scale_denom * 2) {
|
||||
/* Provide 2/3 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 2, 3L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 2, 3L);
|
||||
cinfo->min_DCT_h_scaled_size = 12;
|
||||
cinfo->min_DCT_v_scaled_size = 12;
|
||||
} else if (cinfo->scale_num * 13 >= cinfo->scale_denom * 8) {
|
||||
/* Provide 8/13 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 8, 13L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 8, 13L);
|
||||
cinfo->min_DCT_h_scaled_size = 13;
|
||||
cinfo->min_DCT_v_scaled_size = 13;
|
||||
} else if (cinfo->scale_num * 7 >= cinfo->scale_denom * 4) {
|
||||
/* Provide 4/7 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 4, 7L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 4, 7L);
|
||||
cinfo->min_DCT_h_scaled_size = 14;
|
||||
cinfo->min_DCT_v_scaled_size = 14;
|
||||
} else if (cinfo->scale_num * 15 >= cinfo->scale_denom * 8) {
|
||||
/* Provide 8/15 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 8, 15L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 8, 15L);
|
||||
cinfo->min_DCT_h_scaled_size = 15;
|
||||
cinfo->min_DCT_v_scaled_size = 15;
|
||||
} else {
|
||||
/* Provide 1/2 scaling */
|
||||
cinfo->jpeg_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width, 2L);
|
||||
cinfo->jpeg_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height, 2L);
|
||||
cinfo->min_DCT_h_scaled_size = 16;
|
||||
cinfo->min_DCT_v_scaled_size = 16;
|
||||
}
|
||||
|
||||
#else /* !DCT_SCALING_SUPPORTED */
|
||||
|
||||
/* Hardwire it to "no scaling" */
|
||||
cinfo->jpeg_width = cinfo->image_width;
|
||||
cinfo->jpeg_height = cinfo->image_height;
|
||||
cinfo->min_DCT_h_scaled_size = DCTSIZE;
|
||||
cinfo->min_DCT_v_scaled_size = DCTSIZE;
|
||||
|
||||
#endif /* DCT_SCALING_SUPPORTED */
|
||||
|
||||
cinfo->block_size = DCTSIZE;
|
||||
cinfo->natural_order = jpeg_natural_order;
|
||||
cinfo->lim_Se = DCTSIZE2-1;
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
jpeg_calc_trans_dimensions (j_compress_ptr cinfo)
|
||||
{
|
||||
if (cinfo->min_DCT_h_scaled_size < 1 || cinfo->min_DCT_h_scaled_size > 16
|
||||
|| cinfo->min_DCT_h_scaled_size != cinfo->min_DCT_v_scaled_size)
|
||||
ERREXIT2(cinfo, JERR_BAD_DCTSIZE,
|
||||
cinfo->min_DCT_h_scaled_size, cinfo->min_DCT_v_scaled_size);
|
||||
|
||||
cinfo->block_size = cinfo->min_DCT_h_scaled_size;
|
||||
/* Sanity check on block_size */
|
||||
if (cinfo->block_size < 1 || cinfo->block_size > 16)
|
||||
ERREXIT2(cinfo, JERR_BAD_DCTSIZE, cinfo->block_size, cinfo->block_size);
|
||||
|
||||
/* Derive natural_order from block_size */
|
||||
switch (cinfo->block_size) {
|
||||
case 2: cinfo->natural_order = jpeg_natural_order2; break;
|
||||
case 3: cinfo->natural_order = jpeg_natural_order3; break;
|
||||
@@ -211,31 +62,16 @@ jpeg_calc_trans_dimensions (j_compress_ptr cinfo)
|
||||
case 5: cinfo->natural_order = jpeg_natural_order5; break;
|
||||
case 6: cinfo->natural_order = jpeg_natural_order6; break;
|
||||
case 7: cinfo->natural_order = jpeg_natural_order7; break;
|
||||
default: cinfo->natural_order = jpeg_natural_order; break;
|
||||
default: cinfo->natural_order = jpeg_natural_order;
|
||||
}
|
||||
|
||||
/* Derive lim_Se from block_size */
|
||||
cinfo->lim_Se = cinfo->block_size < DCTSIZE ?
|
||||
cinfo->block_size * cinfo->block_size - 1 : DCTSIZE2-1;
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||
/* Do computations that are needed before master selection phase */
|
||||
{
|
||||
int ci, ssize;
|
||||
jpeg_component_info *compptr;
|
||||
long samplesperrow;
|
||||
JDIMENSION jd_samplesperrow;
|
||||
|
||||
if (transcode_only)
|
||||
jpeg_calc_trans_dimensions(cinfo);
|
||||
else
|
||||
jpeg_calc_jpeg_dimensions(cinfo);
|
||||
|
||||
/* Sanity check on image dimensions */
|
||||
if (cinfo->jpeg_height <= 0 || cinfo->jpeg_width <= 0 ||
|
||||
cinfo->num_components <= 0 || cinfo->input_components <= 0)
|
||||
cinfo->num_components <= 0)
|
||||
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
||||
|
||||
/* Make sure image isn't bigger than I can handle */
|
||||
@@ -243,14 +79,8 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||
(long) cinfo->jpeg_width > (long) JPEG_MAX_DIMENSION)
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
|
||||
|
||||
/* Width of an input scanline must be representable as JDIMENSION. */
|
||||
samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components;
|
||||
jd_samplesperrow = (JDIMENSION) samplesperrow;
|
||||
if ((long) jd_samplesperrow != samplesperrow)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
|
||||
/* For now, precision must match compiled-in value... */
|
||||
if (cinfo->data_precision != BITS_IN_JSAMPLE)
|
||||
/* Only 8 to 12 bits data precision are supported for DCT based JPEG */
|
||||
if (cinfo->data_precision < 8 || cinfo->data_precision > 12)
|
||||
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
|
||||
|
||||
/* Check that number of components won't exceed internal array sizes */
|
||||
@@ -284,18 +114,22 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||
*/
|
||||
ssize = 1;
|
||||
#ifdef DCT_SCALING_SUPPORTED
|
||||
if (! cinfo->raw_data_in)
|
||||
while (cinfo->min_DCT_h_scaled_size * ssize <=
|
||||
(cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) &&
|
||||
(cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) == 0) {
|
||||
(cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) ==
|
||||
0) {
|
||||
ssize = ssize * 2;
|
||||
}
|
||||
#endif
|
||||
compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize;
|
||||
ssize = 1;
|
||||
#ifdef DCT_SCALING_SUPPORTED
|
||||
if (! cinfo->raw_data_in)
|
||||
while (cinfo->min_DCT_v_scaled_size * ssize <=
|
||||
(cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) &&
|
||||
(cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) == 0) {
|
||||
(cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) ==
|
||||
0) {
|
||||
ssize = ssize * 2;
|
||||
}
|
||||
#endif
|
||||
@@ -323,8 +157,10 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||
jdiv_round_up((long) cinfo->jpeg_height *
|
||||
(long) (compptr->v_samp_factor * compptr->DCT_v_scaled_size),
|
||||
(long) (cinfo->max_v_samp_factor * cinfo->block_size));
|
||||
/* Mark component needed (this flag isn't actually used for compression) */
|
||||
compptr->component_needed = TRUE;
|
||||
/* Don't need quantization scale after DCT,
|
||||
* until color conversion says otherwise.
|
||||
*/
|
||||
compptr->component_needed = FALSE;
|
||||
}
|
||||
|
||||
/* Compute number of fully interleaved MCU rows (number of times that
|
||||
@@ -404,13 +240,9 @@ validate_script (j_compress_ptr cinfo)
|
||||
* out-of-range reconstructed DC values during the first DC scan,
|
||||
* which might cause problems for some decoders.
|
||||
*/
|
||||
#if BITS_IN_JSAMPLE == 8
|
||||
#define MAX_AH_AL 10
|
||||
#else
|
||||
#define MAX_AH_AL 13
|
||||
#endif
|
||||
if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
|
||||
Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL)
|
||||
Ah < 0 || Ah > (cinfo->data_precision > 8 ? 13 : 10) ||
|
||||
Al < 0 || Al > (cinfo->data_precision > 8 ? 13 : 10))
|
||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||
if (Ss == 0) {
|
||||
if (Se != 0) /* DC and AC together not OK */
|
||||
@@ -792,17 +624,16 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
|
||||
{
|
||||
my_master_ptr master;
|
||||
|
||||
master = (my_master_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_comp_master));
|
||||
cinfo->master = (struct jpeg_comp_master *) master;
|
||||
master = (my_master_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_comp_master));
|
||||
cinfo->master = &master->pub;
|
||||
master->pub.prepare_for_pass = prepare_for_pass;
|
||||
master->pub.pass_startup = pass_startup;
|
||||
master->pub.finish_pass = finish_pass_master;
|
||||
master->pub.is_last_pass = FALSE;
|
||||
|
||||
/* Validate parameters, determine derived values */
|
||||
initial_setup(cinfo, transcode_only);
|
||||
initial_setup(cinfo);
|
||||
|
||||
if (cinfo->scan_info != NULL) {
|
||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||
@@ -817,10 +648,14 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
|
||||
cinfo->num_scans = 1;
|
||||
}
|
||||
|
||||
if ((cinfo->progressive_mode || cinfo->block_size < DCTSIZE) &&
|
||||
!cinfo->arith_code) /* TEMPORARY HACK ??? */
|
||||
/* assume default tables no good for progressive or downscale mode */
|
||||
cinfo->optimize_coding = TRUE;
|
||||
if (cinfo->optimize_coding)
|
||||
cinfo->arith_code = FALSE; /* disable arithmetic coding */
|
||||
else if (! cinfo->arith_code &&
|
||||
(cinfo->progressive_mode ||
|
||||
(cinfo->block_size > 1 && cinfo->block_size < DCTSIZE)))
|
||||
/* TEMPORARY HACK ??? */
|
||||
/* assume default tables no good for progressive or reduced AC mode */
|
||||
cinfo->optimize_coding = TRUE; /* force Huffman optimization */
|
||||
|
||||
/* Initialize my private state */
|
||||
if (transcode_only) {
|
||||
|
||||
138
jcomapi.c
138
jcomapi.c
@@ -2,6 +2,7 @@
|
||||
* jcomapi.c
|
||||
*
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* Modified 2019 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.
|
||||
*
|
||||
@@ -104,3 +105,140 @@ jpeg_alloc_huff_table (j_common_ptr cinfo)
|
||||
tbl->sent_table = FALSE; /* make sure this is false in any new table */
|
||||
return tbl;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set up the standard Huffman tables (cf. JPEG standard section K.3).
|
||||
* IMPORTANT: these are only valid for 8-bit data precision!
|
||||
* (Would jutils.c be a more reasonable place to put this?)
|
||||
*/
|
||||
|
||||
GLOBAL(JHUFF_TBL *)
|
||||
jpeg_std_huff_table (j_common_ptr cinfo, boolean isDC, int tblno)
|
||||
{
|
||||
JHUFF_TBL **htblptr, *htbl;
|
||||
const UINT8 *bits, *val;
|
||||
int nsymbols, len;
|
||||
|
||||
static const UINT8 bits_dc_luminance[17] =
|
||||
{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
static const UINT8 val_dc_luminance[] =
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||
|
||||
static const UINT8 bits_dc_chrominance[17] =
|
||||
{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
|
||||
static const UINT8 val_dc_chrominance[] =
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||
|
||||
static const UINT8 bits_ac_luminance[17] =
|
||||
{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
|
||||
static const UINT8 val_ac_luminance[] =
|
||||
{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
|
||||
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
|
||||
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
|
||||
0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
|
||||
0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
|
||||
0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
|
||||
0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||
0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
|
||||
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
|
||||
0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
|
||||
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
|
||||
0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
|
||||
0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
|
||||
0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
||||
0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
|
||||
0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
|
||||
0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
|
||||
0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
|
||||
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
|
||||
0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
|
||||
0xf9, 0xfa };
|
||||
|
||||
static const UINT8 bits_ac_chrominance[17] =
|
||||
{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
|
||||
static const UINT8 val_ac_chrominance[] =
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
|
||||
0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
|
||||
0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
|
||||
0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
|
||||
0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
|
||||
0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
|
||||
0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
|
||||
0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
|
||||
0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
|
||||
0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
|
||||
0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
|
||||
0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
|
||||
0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
|
||||
0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
|
||||
0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
|
||||
0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
|
||||
0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
|
||||
0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
|
||||
0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
|
||||
0xf9, 0xfa };
|
||||
|
||||
if (cinfo->is_decompressor) {
|
||||
if (isDC)
|
||||
htblptr = ((j_decompress_ptr) cinfo)->dc_huff_tbl_ptrs;
|
||||
else
|
||||
htblptr = ((j_decompress_ptr) cinfo)->ac_huff_tbl_ptrs;
|
||||
} else {
|
||||
if (isDC)
|
||||
htblptr = ((j_compress_ptr) cinfo)->dc_huff_tbl_ptrs;
|
||||
else
|
||||
htblptr = ((j_compress_ptr) cinfo)->ac_huff_tbl_ptrs;
|
||||
}
|
||||
|
||||
switch (tblno) {
|
||||
case 0:
|
||||
if (isDC) {
|
||||
bits = bits_dc_luminance;
|
||||
val = val_dc_luminance;
|
||||
} else {
|
||||
bits = bits_ac_luminance;
|
||||
val = val_ac_luminance;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (isDC) {
|
||||
bits = bits_dc_chrominance;
|
||||
val = val_dc_chrominance;
|
||||
} else {
|
||||
bits = bits_ac_chrominance;
|
||||
val = val_ac_chrominance;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
|
||||
return NULL; /* avoid compiler warnings for uninitialized variables */
|
||||
}
|
||||
|
||||
if (htblptr[tblno] == NULL)
|
||||
htblptr[tblno] = jpeg_alloc_huff_table(cinfo);
|
||||
|
||||
htbl = htblptr[tblno];
|
||||
|
||||
/* Copy the number-of-symbols-of-each-code-length counts */
|
||||
MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits));
|
||||
|
||||
/* Validate the counts. We do this here mainly so we can copy the right
|
||||
* number of symbols from the val[] array, without risking marching off
|
||||
* the end of memory. jxhuff.c will do a more thorough test later.
|
||||
*/
|
||||
nsymbols = 0;
|
||||
for (len = 1; len <= 16; len++)
|
||||
nsymbols += bits[len];
|
||||
if (nsymbols > 256)
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
|
||||
if (nsymbols > 0)
|
||||
MEMCOPY(htbl->huffval, val, nsymbols * SIZEOF(UINT8));
|
||||
|
||||
/* Initialize sent_table FALSE so table will be written to JPEG file. */
|
||||
htbl->sent_table = FALSE;
|
||||
|
||||
return htbl;
|
||||
}
|
||||
|
||||
14
jconfig.cfg
14
jconfig.cfg
@@ -17,6 +17,20 @@
|
||||
/* Define this if you get warnings about undefined structures. */
|
||||
#undef INCOMPLETE_TYPES_BROKEN
|
||||
|
||||
/* Define "boolean" as unsigned char, not enum, on Windows systems. */
|
||||
#ifdef _WIN32
|
||||
#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 */
|
||||
#endif
|
||||
|
||||
#ifdef JPEG_INTERNALS
|
||||
|
||||
#undef RIGHT_SHIFT_IS_UNSIGNED
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#define SHORTxLCONST_32 /* enable compiler-specific DCT optimization */
|
||||
/* Note: the above define is known to improve the code with Microsoft C 6.00A.
|
||||
* I do not know whether it is good for later compiler versions.
|
||||
* Please report any info on this point to jpeg-info@uunet.uu.net.
|
||||
* Please report any info on this point to jpeg-info@jpegclub.org.
|
||||
*/
|
||||
|
||||
#endif /* JPEG_INTERNALS */
|
||||
|
||||
16
jconfig.txt
16
jconfig.txt
@@ -2,6 +2,7 @@
|
||||
* 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.
|
||||
*
|
||||
@@ -91,6 +92,21 @@
|
||||
*/
|
||||
#undef INCOMPLETE_TYPES_BROKEN
|
||||
|
||||
/* Define "boolean" as unsigned char, not enum, on Windows systems.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#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 */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* The following options affect code selection within the JPEG library,
|
||||
|
||||
11
jconfig.vc
11
jconfig.vc
@@ -1,4 +1,5 @@
|
||||
/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */
|
||||
/* 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 */
|
||||
|
||||
#define HAVE_PROTOTYPES
|
||||
@@ -15,10 +16,16 @@
|
||||
#undef NEED_SHORT_EXTERNAL_NAMES
|
||||
#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 */
|
||||
|
||||
|
||||
|
||||
224
jcparam.c
224
jcparam.c
@@ -2,7 +2,7 @@
|
||||
* jcparam.c
|
||||
*
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2003-2008 by Guido Vollbeding.
|
||||
* Modified 2003-2019 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.
|
||||
*
|
||||
@@ -150,7 +150,7 @@ jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
|
||||
/* Set or change the 'quality' (quantization) setting, using default tables.
|
||||
* This is the standard quality-adjusting entry point for typical user
|
||||
* interfaces; only those who want detailed control over quantization tables
|
||||
* would use the preceding three routines directly.
|
||||
* would use the preceding routines directly.
|
||||
*/
|
||||
{
|
||||
/* Convert user 0-100 rating to percentage scaling */
|
||||
@@ -162,112 +162,23 @@ jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
|
||||
|
||||
|
||||
/*
|
||||
* Huffman table setup routines
|
||||
* Reset standard Huffman tables
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
add_huff_table (j_compress_ptr cinfo,
|
||||
JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val)
|
||||
/* Define a Huffman table */
|
||||
{
|
||||
int nsymbols, len;
|
||||
|
||||
if (*htblptr == NULL)
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
|
||||
|
||||
/* Copy the number-of-symbols-of-each-code-length counts */
|
||||
MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));
|
||||
|
||||
/* Validate the counts. We do this here mainly so we can copy the right
|
||||
* number of symbols from the val[] array, without risking marching off
|
||||
* the end of memory. jchuff.c will do a more thorough test later.
|
||||
*/
|
||||
nsymbols = 0;
|
||||
for (len = 1; len <= 16; len++)
|
||||
nsymbols += bits[len];
|
||||
if (nsymbols < 1 || nsymbols > 256)
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
|
||||
MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8));
|
||||
|
||||
/* Initialize sent_table FALSE so table will be written to JPEG file. */
|
||||
(*htblptr)->sent_table = FALSE;
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
std_huff_tables (j_compress_ptr cinfo)
|
||||
/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
|
||||
/* IMPORTANT: these are only valid for 8-bit data precision! */
|
||||
{
|
||||
static const UINT8 bits_dc_luminance[17] =
|
||||
{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
static const UINT8 val_dc_luminance[] =
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||
if (cinfo->dc_huff_tbl_ptrs[0] != NULL)
|
||||
(void) jpeg_std_huff_table((j_common_ptr) cinfo, TRUE, 0);
|
||||
|
||||
static const UINT8 bits_dc_chrominance[17] =
|
||||
{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
|
||||
static const UINT8 val_dc_chrominance[] =
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||
if (cinfo->ac_huff_tbl_ptrs[0] != NULL)
|
||||
(void) jpeg_std_huff_table((j_common_ptr) cinfo, FALSE, 0);
|
||||
|
||||
static const UINT8 bits_ac_luminance[17] =
|
||||
{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
|
||||
static const UINT8 val_ac_luminance[] =
|
||||
{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
|
||||
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
|
||||
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
|
||||
0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
|
||||
0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
|
||||
0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
|
||||
0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||
0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
|
||||
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
|
||||
0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
|
||||
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
|
||||
0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
|
||||
0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
|
||||
0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
||||
0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
|
||||
0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
|
||||
0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
|
||||
0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
|
||||
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
|
||||
0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
|
||||
0xf9, 0xfa };
|
||||
if (cinfo->dc_huff_tbl_ptrs[1] != NULL)
|
||||
(void) jpeg_std_huff_table((j_common_ptr) cinfo, TRUE, 1);
|
||||
|
||||
static const UINT8 bits_ac_chrominance[17] =
|
||||
{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
|
||||
static const UINT8 val_ac_chrominance[] =
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
|
||||
0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
|
||||
0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
|
||||
0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
|
||||
0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
|
||||
0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
|
||||
0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
|
||||
0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
|
||||
0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
|
||||
0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
|
||||
0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
|
||||
0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
|
||||
0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
|
||||
0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
|
||||
0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
|
||||
0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
|
||||
0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
|
||||
0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
|
||||
0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
|
||||
0xf9, 0xfa };
|
||||
|
||||
add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0],
|
||||
bits_dc_luminance, val_dc_luminance);
|
||||
add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0],
|
||||
bits_ac_luminance, val_ac_luminance);
|
||||
add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[1],
|
||||
bits_dc_chrominance, val_dc_chrominance);
|
||||
add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[1],
|
||||
bits_ac_chrominance, val_ac_chrominance);
|
||||
if (cinfo->ac_huff_tbl_ptrs[1] != NULL)
|
||||
(void) jpeg_std_huff_table((j_common_ptr) cinfo, FALSE, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -306,7 +217,7 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
||||
cinfo->data_precision = BITS_IN_JSAMPLE;
|
||||
/* Set up two quantization tables using default quality of 75 */
|
||||
jpeg_set_quality(cinfo, 75, TRUE);
|
||||
/* Set up two Huffman tables */
|
||||
/* Reset standard Huffman tables */
|
||||
std_huff_tables(cinfo);
|
||||
|
||||
/* Initialize default arithmetic coding conditioning */
|
||||
@@ -323,18 +234,17 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
||||
/* Expect normal source image, not raw downsampled data */
|
||||
cinfo->raw_data_in = FALSE;
|
||||
|
||||
/* Use Huffman coding, not arithmetic coding, by default */
|
||||
cinfo->arith_code = FALSE;
|
||||
/* The standard Huffman tables are only valid for 8-bit data precision.
|
||||
* If the precision is higher, use arithmetic coding.
|
||||
* (Alternatively, using Huffman coding would be possible with forcing
|
||||
* optimization on so that usable tables will be computed, or by
|
||||
* supplying default tables that are valid for the desired precision.)
|
||||
* Otherwise, use Huffman coding by default.
|
||||
*/
|
||||
cinfo->arith_code = cinfo->data_precision > 8 ? TRUE : FALSE;
|
||||
|
||||
/* By default, don't do extra passes to optimize entropy coding */
|
||||
cinfo->optimize_coding = FALSE;
|
||||
/* The standard Huffman tables are only valid for 8-bit data precision.
|
||||
* If the precision is higher, force optimization on so that usable
|
||||
* tables will be computed. This test can be removed if default tables
|
||||
* are supplied that are valid for the desired precision.
|
||||
*/
|
||||
if (cinfo->data_precision > 8)
|
||||
cinfo->optimize_coding = TRUE;
|
||||
|
||||
/* By default, use the simpler non-cosited sampling alignment */
|
||||
cinfo->CCIR601_sampling = FALSE;
|
||||
@@ -360,6 +270,9 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
||||
* JFIF_minor_version to 2. We could probably get away with just defaulting
|
||||
* to 1.02, but there may still be some decoders in use that will complain
|
||||
* about that; saying 1.01 should minimize compatibility problems.
|
||||
*
|
||||
* For wide gamut colorspaces (BG_RGB and BG_YCC), the major version will be
|
||||
* overridden by jpeg_set_colorspace and set to 2.
|
||||
*/
|
||||
cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */
|
||||
cinfo->JFIF_minor_version = 1;
|
||||
@@ -367,6 +280,9 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
||||
cinfo->X_density = 1; /* Pixel aspect ratio is square by default */
|
||||
cinfo->Y_density = 1;
|
||||
|
||||
/* No color transform */
|
||||
cinfo->color_transform = JCT_NONE;
|
||||
|
||||
/* Choose JPEG colorspace based on input space, set defaults accordingly */
|
||||
|
||||
jpeg_default_colorspace(cinfo);
|
||||
@@ -381,6 +297,9 @@ GLOBAL(void)
|
||||
jpeg_default_colorspace (j_compress_ptr cinfo)
|
||||
{
|
||||
switch (cinfo->in_color_space) {
|
||||
case JCS_UNKNOWN:
|
||||
jpeg_set_colorspace(cinfo, JCS_UNKNOWN);
|
||||
break;
|
||||
case JCS_GRAYSCALE:
|
||||
jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
|
||||
break;
|
||||
@@ -396,8 +315,12 @@ jpeg_default_colorspace (j_compress_ptr cinfo)
|
||||
case JCS_YCCK:
|
||||
jpeg_set_colorspace(cinfo, JCS_YCCK);
|
||||
break;
|
||||
case JCS_UNKNOWN:
|
||||
jpeg_set_colorspace(cinfo, JCS_UNKNOWN);
|
||||
case JCS_BG_RGB:
|
||||
/* No translation for now -- conversion to BG_YCC not yet supportet */
|
||||
jpeg_set_colorspace(cinfo, JCS_BG_RGB);
|
||||
break;
|
||||
case JCS_BG_YCC:
|
||||
jpeg_set_colorspace(cinfo, JCS_BG_YCC);
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
||||
@@ -438,27 +361,40 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
||||
cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */
|
||||
|
||||
switch (colorspace) {
|
||||
case JCS_UNKNOWN:
|
||||
cinfo->num_components = cinfo->input_components;
|
||||
if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS)
|
||||
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
|
||||
MAX_COMPONENTS);
|
||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||
SET_COMP(ci, ci, 1,1, 0, 0,0);
|
||||
}
|
||||
break;
|
||||
case JCS_GRAYSCALE:
|
||||
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
||||
cinfo->num_components = 1;
|
||||
/* JFIF specifies component ID 1 */
|
||||
SET_COMP(0, 1, 1,1, 0, 0,0);
|
||||
SET_COMP(0, 0x01, 1,1, 0, 0,0);
|
||||
break;
|
||||
case JCS_RGB:
|
||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */
|
||||
cinfo->num_components = 3;
|
||||
SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0);
|
||||
SET_COMP(0, 0x52 /* 'R' */, 1,1, 0,
|
||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
||||
SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0);
|
||||
SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0);
|
||||
SET_COMP(2, 0x42 /* 'B' */, 1,1, 0,
|
||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
||||
break;
|
||||
case JCS_YCbCr:
|
||||
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
||||
cinfo->num_components = 3;
|
||||
/* JFIF specifies component IDs 1,2,3 */
|
||||
/* We default to 2x2 subsamples of chrominance */
|
||||
SET_COMP(0, 1, 2,2, 0, 0,0);
|
||||
SET_COMP(1, 2, 1,1, 1, 1,1);
|
||||
SET_COMP(2, 3, 1,1, 1, 1,1);
|
||||
SET_COMP(0, 0x01, 2,2, 0, 0,0);
|
||||
SET_COMP(1, 0x02, 1,1, 1, 1,1);
|
||||
SET_COMP(2, 0x03, 1,1, 1, 1,1);
|
||||
break;
|
||||
case JCS_CMYK:
|
||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */
|
||||
@@ -471,19 +407,33 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
||||
case JCS_YCCK:
|
||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */
|
||||
cinfo->num_components = 4;
|
||||
SET_COMP(0, 1, 2,2, 0, 0,0);
|
||||
SET_COMP(1, 2, 1,1, 1, 1,1);
|
||||
SET_COMP(2, 3, 1,1, 1, 1,1);
|
||||
SET_COMP(3, 4, 2,2, 0, 0,0);
|
||||
SET_COMP(0, 0x01, 2,2, 0, 0,0);
|
||||
SET_COMP(1, 0x02, 1,1, 1, 1,1);
|
||||
SET_COMP(2, 0x03, 1,1, 1, 1,1);
|
||||
SET_COMP(3, 0x04, 2,2, 0, 0,0);
|
||||
break;
|
||||
case JCS_UNKNOWN:
|
||||
cinfo->num_components = cinfo->input_components;
|
||||
if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS)
|
||||
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
|
||||
MAX_COMPONENTS);
|
||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||
SET_COMP(ci, ci, 1,1, 0, 0,0);
|
||||
}
|
||||
case JCS_BG_RGB:
|
||||
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
||||
cinfo->JFIF_major_version = 2; /* Set JFIF major version = 2 */
|
||||
cinfo->num_components = 3;
|
||||
/* Add offset 0x20 to the normal R/G/B component IDs */
|
||||
SET_COMP(0, 0x72 /* 'r' */, 1,1, 0,
|
||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
||||
SET_COMP(1, 0x67 /* 'g' */, 1,1, 0, 0,0);
|
||||
SET_COMP(2, 0x62 /* 'b' */, 1,1, 0,
|
||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
||||
break;
|
||||
case JCS_BG_YCC:
|
||||
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
||||
cinfo->JFIF_major_version = 2; /* Set JFIF major version = 2 */
|
||||
cinfo->num_components = 3;
|
||||
/* Add offset 0x20 to the normal Cb/Cr component IDs */
|
||||
/* We default to 2x2 subsamples of chrominance */
|
||||
SET_COMP(0, 0x01, 2,2, 0, 0,0);
|
||||
SET_COMP(1, 0x22, 1,1, 1, 1,1);
|
||||
SET_COMP(2, 0x23, 1,1, 1, 1,1);
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||
@@ -567,8 +517,10 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||
|
||||
/* Figure space needed for script. Calculation must match code below! */
|
||||
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
|
||||
/* Custom script for YCbCr color images. */
|
||||
if (ncomps == 3 &&
|
||||
(cinfo->jpeg_color_space == JCS_YCbCr ||
|
||||
cinfo->jpeg_color_space == JCS_BG_YCC)) {
|
||||
/* Custom script for YCC color images. */
|
||||
nscans = 10;
|
||||
} else {
|
||||
/* All-purpose script for other color spaces. */
|
||||
@@ -583,7 +535,7 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
||||
* multiple compressions without changing the settings. To avoid a memory
|
||||
* leak if jpeg_simple_progression is called repeatedly for the same JPEG
|
||||
* object, we try to re-use previously allocated space, and we allocate
|
||||
* enough space to handle YCbCr even if initially asked for grayscale.
|
||||
* enough space to handle YCC even if initially asked for grayscale.
|
||||
*/
|
||||
if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) {
|
||||
cinfo->script_space_size = MAX(nscans, 10);
|
||||
@@ -595,8 +547,10 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
||||
cinfo->scan_info = scanptr;
|
||||
cinfo->num_scans = nscans;
|
||||
|
||||
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
|
||||
/* Custom script for YCbCr color images. */
|
||||
if (ncomps == 3 &&
|
||||
(cinfo->jpeg_color_space == JCS_YCbCr ||
|
||||
cinfo->jpeg_color_space == JCS_BG_YCC)) {
|
||||
/* Custom script for YCC color images. */
|
||||
/* Initial DC scan */
|
||||
scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
|
||||
/* Initial AC scan: get some luma data out in a hurry */
|
||||
|
||||
33
jctrans.c
33
jctrans.c
@@ -2,7 +2,7 @@
|
||||
* jctrans.c
|
||||
*
|
||||
* Copyright (C) 1995-1998, Thomas G. Lane.
|
||||
* Modified 2000-2009 by Guido Vollbeding.
|
||||
* Modified 2000-2017 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.
|
||||
*
|
||||
@@ -85,9 +85,15 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
jpeg_set_defaults(dstinfo);
|
||||
/* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB.
|
||||
* Fix it to get the right header markers for the image colorspace.
|
||||
* Note: Entropy table assignment in jpeg_set_colorspace
|
||||
* depends on color_transform.
|
||||
* Adaption is also required for setting the appropriate
|
||||
* entropy coding mode dependent on image data precision.
|
||||
*/
|
||||
dstinfo->color_transform = srcinfo->color_transform;
|
||||
jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space);
|
||||
dstinfo->data_precision = srcinfo->data_precision;
|
||||
dstinfo->arith_code = srcinfo->data_precision > 8 ? TRUE : FALSE;
|
||||
dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling;
|
||||
/* Copy the source's quantization tables. */
|
||||
for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
|
||||
@@ -130,7 +136,7 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno);
|
||||
}
|
||||
}
|
||||
/* Note: we do not copy the source's Huffman table assignments;
|
||||
/* Note: we do not copy the source's entropy table assignments;
|
||||
* instead we rely on jpeg_set_colorspace to have made a suitable choice.
|
||||
*/
|
||||
}
|
||||
@@ -140,10 +146,10 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
* if the application chooses to copy JFIF 1.02 extension markers from
|
||||
* the source file, we need to copy the version to make sure we don't
|
||||
* emit a file that has 1.02 extensions but a claimed version of 1.01.
|
||||
* We will *not*, however, copy version info from mislabeled "2.01" files.
|
||||
*/
|
||||
if (srcinfo->saw_JFIF_marker) {
|
||||
if (srcinfo->JFIF_major_version == 1) {
|
||||
if (srcinfo->JFIF_major_version == 1 ||
|
||||
srcinfo->JFIF_major_version == 2) {
|
||||
dstinfo->JFIF_major_version = srcinfo->JFIF_major_version;
|
||||
dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version;
|
||||
}
|
||||
@@ -154,6 +160,18 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
jpeg_calc_trans_dimensions (j_compress_ptr cinfo)
|
||||
/* Do computations that are needed before master selection phase */
|
||||
{
|
||||
if (cinfo->min_DCT_h_scaled_size != cinfo->min_DCT_v_scaled_size)
|
||||
ERREXIT2(cinfo, JERR_BAD_DCTSIZE,
|
||||
cinfo->min_DCT_h_scaled_size, cinfo->min_DCT_v_scaled_size);
|
||||
|
||||
cinfo->block_size = cinfo->min_DCT_h_scaled_size;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Master selection of compression modules for transcoding.
|
||||
* This substitutes for jcinit.c's initialization of the full compressor.
|
||||
@@ -163,6 +181,9 @@ LOCAL(void)
|
||||
transencode_master_selection (j_compress_ptr cinfo,
|
||||
jvirt_barray_ptr * coef_arrays)
|
||||
{
|
||||
/* Do computations that are needed before master selection phase */
|
||||
jpeg_calc_trans_dimensions(cinfo);
|
||||
|
||||
/* Initialize master control (includes parameter checking/processing) */
|
||||
jinit_c_master_control(cinfo, TRUE /* transcode only */);
|
||||
|
||||
@@ -364,7 +385,7 @@ transencode_coef_controller (j_compress_ptr cinfo,
|
||||
coef = (my_coef_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_coef_controller));
|
||||
cinfo->coef = (struct jpeg_c_coef_controller *) coef;
|
||||
cinfo->coef = &coef->pub;
|
||||
coef->pub.start_pass = start_pass_coef;
|
||||
coef->pub.compress_data = compress_output;
|
||||
|
||||
@@ -375,7 +396,7 @@ transencode_coef_controller (j_compress_ptr cinfo,
|
||||
buffer = (JBLOCKROW)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
|
||||
jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
|
||||
FMEMZERO((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
|
||||
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
|
||||
coef->dummy_buffer[i] = buffer + i;
|
||||
}
|
||||
|
||||
35
jdapimin.c
35
jdapimin.c
@@ -2,7 +2,7 @@
|
||||
* jdapimin.c
|
||||
*
|
||||
* Copyright (C) 1994-1998, Thomas G. Lane.
|
||||
* Modified 2009 by Guido Vollbeding.
|
||||
* 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.
|
||||
*
|
||||
@@ -114,8 +114,9 @@ jpeg_abort_decompress (j_decompress_ptr cinfo)
|
||||
LOCAL(void)
|
||||
default_decompress_parms (j_decompress_ptr cinfo)
|
||||
{
|
||||
int cid0, cid1, cid2;
|
||||
|
||||
/* Guess the input colorspace, and set output colorspace accordingly. */
|
||||
/* (Wish JPEG committee had provided a real way to specify this...) */
|
||||
/* Note application may override our guesses. */
|
||||
switch (cinfo->num_components) {
|
||||
case 1:
|
||||
@@ -124,9 +125,22 @@ default_decompress_parms (j_decompress_ptr cinfo)
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (cinfo->saw_JFIF_marker) {
|
||||
cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */
|
||||
} else if (cinfo->saw_Adobe_marker) {
|
||||
cid0 = cinfo->comp_info[0].component_id;
|
||||
cid1 = cinfo->comp_info[1].component_id;
|
||||
cid2 = cinfo->comp_info[2].component_id;
|
||||
|
||||
/* First try to guess from the component IDs */
|
||||
if (cid0 == 0x01 && cid1 == 0x02 && cid2 == 0x03)
|
||||
cinfo->jpeg_color_space = JCS_YCbCr;
|
||||
else if (cid0 == 0x01 && cid1 == 0x22 && cid2 == 0x23)
|
||||
cinfo->jpeg_color_space = JCS_BG_YCC;
|
||||
else if (cid0 == 0x52 && cid1 == 0x47 && cid2 == 0x42)
|
||||
cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
|
||||
else if (cid0 == 0x72 && cid1 == 0x67 && cid2 == 0x62)
|
||||
cinfo->jpeg_color_space = JCS_BG_RGB; /* ASCII 'r', 'g', 'b' */
|
||||
else if (cinfo->saw_JFIF_marker)
|
||||
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
|
||||
else if (cinfo->saw_Adobe_marker) {
|
||||
switch (cinfo->Adobe_transform) {
|
||||
case 0:
|
||||
cinfo->jpeg_color_space = JCS_RGB;
|
||||
@@ -140,20 +154,9 @@ default_decompress_parms (j_decompress_ptr cinfo)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* Saw no special markers, try to guess from the component IDs */
|
||||
int cid0 = cinfo->comp_info[0].component_id;
|
||||
int cid1 = cinfo->comp_info[1].component_id;
|
||||
int cid2 = cinfo->comp_info[2].component_id;
|
||||
|
||||
if (cid0 == 1 && cid1 == 2 && cid2 == 3)
|
||||
cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
|
||||
else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
|
||||
cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
|
||||
else {
|
||||
TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
|
||||
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
|
||||
}
|
||||
}
|
||||
/* Always guess RGB is proper output colorspace. */
|
||||
cinfo->out_color_space = JCS_RGB;
|
||||
break;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* jdapistd.c
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2002-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.
|
||||
*
|
||||
|
||||
98
jdarith.c
98
jdarith.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* jdarith.c
|
||||
*
|
||||
* Developed 1997-2009 by Guido Vollbeding.
|
||||
* Developed 1997-2019 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
|
||||
@@ -145,7 +145,7 @@ arith_decode (j_decompress_ptr cinfo, unsigned char *st)
|
||||
e->a <<= 1;
|
||||
}
|
||||
|
||||
/* Fetch values from our compact representation of Table D.2:
|
||||
/* Fetch values from our compact representation of Table D.3(D.2):
|
||||
* Qe values and probability estimation state machine
|
||||
*/
|
||||
sv = *st;
|
||||
@@ -280,7 +280,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if ((m = arith_decode(cinfo, st)) != 0) {
|
||||
st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
|
||||
while (arith_decode(cinfo, st)) {
|
||||
if ((m <<= 1) == 0x8000) {
|
||||
if ((m <<= 1) == (int) 0x8000U) {
|
||||
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
|
||||
entropy->ct = -1; /* magnitude overflow */
|
||||
return TRUE;
|
||||
@@ -345,12 +345,15 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Sections F.2.4.2 & F.1.4.4.2: Decoding of AC coefficients */
|
||||
|
||||
/* Figure F.20: Decode_AC_coefficients */
|
||||
for (k = cinfo->Ss; k <= cinfo->Se; k++) {
|
||||
st = entropy->ac_stats[tbl] + 3 * (k - 1);
|
||||
k = cinfo->Ss - 1;
|
||||
do {
|
||||
st = entropy->ac_stats[tbl] + 3 * k;
|
||||
if (arith_decode(cinfo, st)) break; /* EOB flag */
|
||||
while (arith_decode(cinfo, st + 1) == 0) {
|
||||
st += 3; k++;
|
||||
if (k > cinfo->Se) {
|
||||
for (;;) {
|
||||
k++;
|
||||
if (arith_decode(cinfo, st + 1)) break;
|
||||
st += 3;
|
||||
if (k >= cinfo->Se) {
|
||||
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
|
||||
entropy->ct = -1; /* spectral overflow */
|
||||
return TRUE;
|
||||
@@ -367,7 +370,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
st = entropy->ac_stats[tbl] +
|
||||
(k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
|
||||
while (arith_decode(cinfo, st)) {
|
||||
if ((m <<= 1) == 0x8000) {
|
||||
if ((m <<= 1) == (int) 0x8000U) {
|
||||
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
|
||||
entropy->ct = -1; /* magnitude overflow */
|
||||
return TRUE;
|
||||
@@ -384,7 +387,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
v += 1; if (sign) v = -v;
|
||||
/* Scale and output coefficient in natural (dezigzagged) order */
|
||||
(*block)[natural_order[k]] = (JCOEF) (v << cinfo->Al);
|
||||
}
|
||||
} while (k < cinfo->Se);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -392,6 +395,8 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
/*
|
||||
* MCU decoding for DC successive approximation refinement scan.
|
||||
* Note: we assume such scans can be multi-component,
|
||||
* although the spec is not very clear on the point.
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
@@ -399,7 +404,8 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
unsigned char *st;
|
||||
int p1, blkn;
|
||||
JCOEF p1;
|
||||
int blkn;
|
||||
|
||||
/* Process restart marker if needed */
|
||||
if (cinfo->restart_interval) {
|
||||
@@ -435,7 +441,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
JCOEFPTR thiscoef;
|
||||
unsigned char *st;
|
||||
int tbl, k, kex;
|
||||
int p1, m1;
|
||||
JCOEF p1, m1;
|
||||
const int * natural_order;
|
||||
|
||||
/* Process restart marker if needed */
|
||||
@@ -454,18 +460,21 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
|
||||
|
||||
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||
m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */
|
||||
m1 = -p1; /* -1 in the bit position being coded */
|
||||
|
||||
/* Establish EOBx (previous stage end-of-block) index */
|
||||
for (kex = cinfo->Se; kex > 0; kex--)
|
||||
kex = cinfo->Se;
|
||||
do {
|
||||
if ((*block)[natural_order[kex]]) break;
|
||||
} while (--kex);
|
||||
|
||||
for (k = cinfo->Ss; k <= cinfo->Se; k++) {
|
||||
st = entropy->ac_stats[tbl] + 3 * (k - 1);
|
||||
if (k > kex)
|
||||
k = cinfo->Ss - 1;
|
||||
do {
|
||||
st = entropy->ac_stats[tbl] + 3 * k;
|
||||
if (k >= kex)
|
||||
if (arith_decode(cinfo, st)) break; /* EOB flag */
|
||||
for (;;) {
|
||||
thiscoef = *block + natural_order[k];
|
||||
thiscoef = *block + natural_order[++k];
|
||||
if (*thiscoef) { /* previously nonzero coef */
|
||||
if (arith_decode(cinfo, st + 2)) {
|
||||
if (*thiscoef < 0)
|
||||
@@ -482,14 +491,14 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*thiscoef = p1;
|
||||
break;
|
||||
}
|
||||
st += 3; k++;
|
||||
if (k > cinfo->Se) {
|
||||
st += 3;
|
||||
if (k >= cinfo->Se) {
|
||||
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
|
||||
entropy->ct = -1; /* spectral overflow */
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (k < cinfo->Se);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -547,7 +556,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if ((m = arith_decode(cinfo, st)) != 0) {
|
||||
st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
|
||||
while (arith_decode(cinfo, st)) {
|
||||
if ((m <<= 1) == 0x8000) {
|
||||
if ((m <<= 1) == (int) 0x8000U) {
|
||||
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
|
||||
entropy->ct = -1; /* magnitude overflow */
|
||||
return TRUE;
|
||||
@@ -575,15 +584,19 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
/* Sections F.2.4.2 & F.1.4.4.2: Decoding of AC coefficients */
|
||||
|
||||
if (cinfo->lim_Se == 0) continue;
|
||||
tbl = compptr->ac_tbl_no;
|
||||
k = 0;
|
||||
|
||||
/* Figure F.20: Decode_AC_coefficients */
|
||||
for (k = 1; k <= cinfo->lim_Se; k++) {
|
||||
st = entropy->ac_stats[tbl] + 3 * (k - 1);
|
||||
do {
|
||||
st = entropy->ac_stats[tbl] + 3 * k;
|
||||
if (arith_decode(cinfo, st)) break; /* EOB flag */
|
||||
while (arith_decode(cinfo, st + 1) == 0) {
|
||||
st += 3; k++;
|
||||
if (k > cinfo->lim_Se) {
|
||||
for (;;) {
|
||||
k++;
|
||||
if (arith_decode(cinfo, st + 1)) break;
|
||||
st += 3;
|
||||
if (k >= cinfo->lim_Se) {
|
||||
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
|
||||
entropy->ct = -1; /* spectral overflow */
|
||||
return TRUE;
|
||||
@@ -600,7 +613,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
st = entropy->ac_stats[tbl] +
|
||||
(k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
|
||||
while (arith_decode(cinfo, st)) {
|
||||
if ((m <<= 1) == 0x8000) {
|
||||
if ((m <<= 1) == (int) 0x8000U) {
|
||||
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
|
||||
entropy->ct = -1; /* magnitude overflow */
|
||||
return TRUE;
|
||||
@@ -616,7 +629,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (arith_decode(cinfo, st)) v |= m;
|
||||
v += 1; if (sign) v = -v;
|
||||
(*block)[natural_order[k]] = (JCOEF) v;
|
||||
}
|
||||
} while (k < cinfo->lim_Se);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -733,6 +746,17 @@ start_pass (j_decompress_ptr cinfo)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Finish up at the end of an arithmetic-compressed scan.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass (j_decompress_ptr cinfo)
|
||||
{
|
||||
/* no work necessary here */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Module initialization routine for arithmetic entropy decoding.
|
||||
*/
|
||||
@@ -743,11 +767,11 @@ jinit_arith_decoder (j_decompress_ptr cinfo)
|
||||
arith_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (arith_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(arith_entropy_decoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
|
||||
entropy = (arith_entropy_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(arith_entropy_decoder));
|
||||
cinfo->entropy = &entropy->pub;
|
||||
entropy->pub.start_pass = start_pass;
|
||||
entropy->pub.finish_pass = finish_pass;
|
||||
|
||||
/* Mark tables unallocated */
|
||||
for (i = 0; i < NUM_ARITH_TBLS; i++) {
|
||||
@@ -761,9 +785,9 @@ jinit_arith_decoder (j_decompress_ptr cinfo)
|
||||
if (cinfo->progressive_mode) {
|
||||
/* Create progression status table */
|
||||
int *coef_bit_ptr, ci;
|
||||
cinfo->coef_bits = (int (*)[DCTSIZE2])
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components*DCTSIZE2*SIZEOF(int));
|
||||
cinfo->coef_bits = (int (*)[DCTSIZE2]) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * DCTSIZE2 * SIZEOF(int));
|
||||
coef_bit_ptr = & cinfo->coef_bits[0][0];
|
||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||
for (i = 0; i < DCTSIZE2; i++)
|
||||
|
||||
34
jdatadst.c
34
jdatadst.c
@@ -2,7 +2,7 @@
|
||||
* jdatadst.c
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2009 by Guido Vollbeding.
|
||||
* Modified 2009-2019 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.
|
||||
*
|
||||
@@ -46,7 +46,7 @@ typedef struct {
|
||||
struct jpeg_destination_mgr pub; /* public fields */
|
||||
|
||||
unsigned char ** outbuffer; /* target buffer */
|
||||
unsigned long * outsize;
|
||||
size_t * outsize;
|
||||
unsigned char * newbuffer; /* newly allocated buffer */
|
||||
JOCTET * buffer; /* start of buffer */
|
||||
size_t bufsize;
|
||||
@@ -66,9 +66,8 @@ init_destination (j_compress_ptr cinfo)
|
||||
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||
|
||||
/* Allocate the output buffer --- it will be released when done with image */
|
||||
dest->buffer = (JOCTET *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
OUTPUT_BUF_SIZE * SIZEOF(JOCTET));
|
||||
dest->buffer = (JOCTET *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, OUTPUT_BUF_SIZE * SIZEOF(JOCTET));
|
||||
|
||||
dest->pub.next_output_byte = dest->buffer;
|
||||
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
|
||||
@@ -128,10 +127,10 @@ empty_mem_output_buffer (j_compress_ptr cinfo)
|
||||
|
||||
/* Try to allocate new buffer with double size */
|
||||
nextsize = dest->bufsize * 2;
|
||||
nextbuffer = malloc(nextsize);
|
||||
nextbuffer = (JOCTET *) malloc(nextsize);
|
||||
|
||||
if (nextbuffer == NULL)
|
||||
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
|
||||
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 11);
|
||||
|
||||
MEMCOPY(nextbuffer, dest->buffer, dest->bufsize);
|
||||
|
||||
@@ -170,9 +169,9 @@ term_destination (j_compress_ptr cinfo)
|
||||
if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
|
||||
ERREXIT(cinfo, JERR_FILE_WRITE);
|
||||
}
|
||||
fflush(dest->outfile);
|
||||
JFFLUSH(dest->outfile);
|
||||
/* Make sure we wrote the output file OK */
|
||||
if (ferror(dest->outfile))
|
||||
if (JFERROR(dest->outfile))
|
||||
ERREXIT(cinfo, JERR_FILE_WRITE);
|
||||
}
|
||||
|
||||
@@ -204,9 +203,8 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
|
||||
* sizes may be different. Caveat programmer.
|
||||
*/
|
||||
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->dest = (struct jpeg_destination_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(my_destination_mgr));
|
||||
cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_destination_mgr));
|
||||
}
|
||||
|
||||
dest = (my_dest_ptr) cinfo->dest;
|
||||
@@ -226,11 +224,14 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
|
||||
* larger memory, so the buffer is available to the application after
|
||||
* finishing compression, and then the application is responsible for
|
||||
* freeing the requested memory.
|
||||
* Note: An initial buffer supplied by the caller is expected to be
|
||||
* managed by the application. The library does not free such buffer
|
||||
* when allocating a larger buffer.
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_mem_dest (j_compress_ptr cinfo,
|
||||
unsigned char ** outbuffer, unsigned long * outsize)
|
||||
unsigned char ** outbuffer, size_t * outsize)
|
||||
{
|
||||
my_mem_dest_ptr dest;
|
||||
|
||||
@@ -241,9 +242,8 @@ jpeg_mem_dest (j_compress_ptr cinfo,
|
||||
* can be written to the same buffer without re-executing jpeg_mem_dest.
|
||||
*/
|
||||
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->dest = (struct jpeg_destination_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(my_mem_destination_mgr));
|
||||
cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_mem_destination_mgr));
|
||||
}
|
||||
|
||||
dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
@@ -256,7 +256,7 @@ jpeg_mem_dest (j_compress_ptr cinfo,
|
||||
|
||||
if (*outbuffer == NULL || *outsize == 0) {
|
||||
/* Allocate initial buffer */
|
||||
dest->newbuffer = *outbuffer = malloc(OUTPUT_BUF_SIZE);
|
||||
dest->newbuffer = *outbuffer = (unsigned char *) malloc(OUTPUT_BUF_SIZE);
|
||||
if (dest->newbuffer == NULL)
|
||||
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
|
||||
*outsize = OUTPUT_BUF_SIZE;
|
||||
|
||||
42
jdatasrc.c
42
jdatasrc.c
@@ -2,7 +2,7 @@
|
||||
* jdatasrc.c
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2009 by Guido Vollbeding.
|
||||
* Modified 2009-2019 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.
|
||||
*
|
||||
@@ -121,16 +121,17 @@ fill_input_buffer (j_decompress_ptr cinfo)
|
||||
METHODDEF(boolean)
|
||||
fill_mem_input_buffer (j_decompress_ptr cinfo)
|
||||
{
|
||||
static JOCTET mybuffer[4];
|
||||
static const JOCTET mybuffer[4] = {
|
||||
(JOCTET) 0xFF, (JOCTET) JPEG_EOI, 0, 0
|
||||
};
|
||||
|
||||
/* The whole JPEG data is expected to reside in the supplied memory
|
||||
* buffer, so any request for more data beyond the given buffer size
|
||||
* is treated as an error.
|
||||
*/
|
||||
WARNMS(cinfo, JWRN_JPEG_EOF);
|
||||
|
||||
/* Insert a fake EOI marker */
|
||||
mybuffer[0] = (JOCTET) 0xFF;
|
||||
mybuffer[1] = (JOCTET) JPEG_EOI;
|
||||
|
||||
cinfo->src->next_input_byte = mybuffer;
|
||||
cinfo->src->bytes_in_buffer = 2;
|
||||
@@ -155,21 +156,23 @@ METHODDEF(void)
|
||||
skip_input_data (j_decompress_ptr cinfo, long num_bytes)
|
||||
{
|
||||
struct jpeg_source_mgr * src = cinfo->src;
|
||||
size_t nbytes;
|
||||
|
||||
/* Just a dumb implementation for now. Could use fseek() except
|
||||
* it doesn't work on pipes. Not clear that being smart is worth
|
||||
* any trouble anyway --- large skips are infrequent.
|
||||
*/
|
||||
if (num_bytes > 0) {
|
||||
while (num_bytes > (long) src->bytes_in_buffer) {
|
||||
num_bytes -= (long) src->bytes_in_buffer;
|
||||
(void) fill_input_buffer(cinfo);
|
||||
nbytes = (size_t) num_bytes;
|
||||
while (nbytes > src->bytes_in_buffer) {
|
||||
nbytes -= src->bytes_in_buffer;
|
||||
(void) (*src->fill_input_buffer) (cinfo);
|
||||
/* note we assume that fill_input_buffer will never return FALSE,
|
||||
* so suspension need not be handled.
|
||||
*/
|
||||
}
|
||||
src->next_input_byte += (size_t) num_bytes;
|
||||
src->bytes_in_buffer -= (size_t) num_bytes;
|
||||
src->next_input_byte += nbytes;
|
||||
src->bytes_in_buffer -= nbytes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,13 +221,11 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
|
||||
* manager serially with the same JPEG object. Caveat programmer.
|
||||
*/
|
||||
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->src = (struct jpeg_source_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(my_source_mgr));
|
||||
cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_source_mgr));
|
||||
src = (my_src_ptr) cinfo->src;
|
||||
src->buffer = (JOCTET *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
INPUT_BUF_SIZE * SIZEOF(JOCTET));
|
||||
src->buffer = (JOCTET *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_PERMANENT, INPUT_BUF_SIZE * SIZEOF(JOCTET));
|
||||
}
|
||||
|
||||
src = (my_src_ptr) cinfo->src;
|
||||
@@ -246,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, size_t insize)
|
||||
{
|
||||
struct jpeg_source_mgr * src;
|
||||
|
||||
@@ -258,9 +259,8 @@ jpeg_mem_src (j_decompress_ptr cinfo,
|
||||
* the first one.
|
||||
*/
|
||||
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->src = (struct jpeg_source_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(struct jpeg_source_mgr));
|
||||
cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(struct jpeg_source_mgr));
|
||||
}
|
||||
|
||||
src = cinfo->src;
|
||||
@@ -269,6 +269,6 @@ jpeg_mem_src (j_decompress_ptr cinfo,
|
||||
src->skip_input_data = skip_input_data;
|
||||
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->bytes_in_buffer = insize;
|
||||
src->next_input_byte = (const JOCTET *) inbuffer;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* jdcoefct.c
|
||||
*
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* Modified 2002-2011 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.
|
||||
*
|
||||
@@ -162,7 +163,8 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
|
||||
MCU_col_num++) {
|
||||
/* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
|
||||
jzero_far((void FAR *) coef->MCU_buffer[0],
|
||||
if (cinfo->lim_Se) /* can bypass in DC only case */
|
||||
FMEMZERO((void FAR *) coef->MCU_buffer[0],
|
||||
(size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK)));
|
||||
if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
/* Suspension forced; update state counters and exit */
|
||||
@@ -729,6 +731,9 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
|
||||
coef->MCU_buffer[i] = buffer + i;
|
||||
}
|
||||
if (cinfo->lim_Se == 0) /* DC only case: want to bypass later */
|
||||
FMEMZERO((void FAR *) buffer,
|
||||
(size_t) (D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)));
|
||||
coef->pub.consume_data = dummy_consume_data;
|
||||
coef->pub.decompress_data = decompress_onepass;
|
||||
coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
|
||||
|
||||
465
jdcolor.c
465
jdcolor.c
@@ -2,6 +2,7 @@
|
||||
* jdcolor.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2011-2019 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.
|
||||
*
|
||||
@@ -13,32 +14,68 @@
|
||||
#include "jpeglib.h"
|
||||
|
||||
|
||||
#if RANGE_BITS < 2
|
||||
/* Deliberate syntax err */
|
||||
Sorry, this code requires 2 or more range extension bits.
|
||||
#endif
|
||||
|
||||
|
||||
/* Private subobject */
|
||||
|
||||
typedef struct {
|
||||
struct jpeg_color_deconverter pub; /* public fields */
|
||||
|
||||
/* Private state for YCC->RGB conversion */
|
||||
/* Private state for YCbCr->RGB and BG_YCC->RGB conversion */
|
||||
int * Cr_r_tab; /* => table for Cr to R conversion */
|
||||
int * Cb_b_tab; /* => table for Cb to B conversion */
|
||||
INT32 * Cr_g_tab; /* => table for Cr to G conversion */
|
||||
INT32 * Cb_g_tab; /* => table for Cb to G conversion */
|
||||
|
||||
/* Private state for RGB->Y conversion */
|
||||
INT32 * rgb_y_tab; /* => table for RGB to Y conversion */
|
||||
} my_color_deconverter;
|
||||
|
||||
typedef my_color_deconverter * my_cconvert_ptr;
|
||||
|
||||
|
||||
/**************** YCbCr -> RGB conversion: most common case **************/
|
||||
/*************** YCbCr -> RGB conversion: most common case **************/
|
||||
/*************** BG_YCC -> RGB conversion: less common case **************/
|
||||
/*************** RGB -> Y conversion: less common case **************/
|
||||
|
||||
/*
|
||||
* YCbCr is defined per CCIR 601-1, except that Cb and Cr are
|
||||
* normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
|
||||
* The conversion equations to be implemented are therefore
|
||||
* R = Y + 1.40200 * Cr
|
||||
* G = Y - 0.34414 * Cb - 0.71414 * Cr
|
||||
* B = Y + 1.77200 * Cb
|
||||
* YCbCr is defined per Recommendation ITU-R BT.601-7 (03/2011),
|
||||
* previously known as Recommendation CCIR 601-1, except that Cb and Cr
|
||||
* are normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
|
||||
* sRGB (standard RGB color space) is defined per IEC 61966-2-1:1999.
|
||||
* sYCC (standard luma-chroma-chroma color space with extended gamut)
|
||||
* is defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex F.
|
||||
* bg-sRGB and bg-sYCC (big gamut standard color spaces)
|
||||
* are defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex G.
|
||||
* Note that the derived conversion coefficients given in some of these
|
||||
* documents are imprecise. The general conversion equations are
|
||||
*
|
||||
* R = Y + K * (1 - Kr) * Cr
|
||||
* G = Y - K * (Kb * (1 - Kb) * Cb + Kr * (1 - Kr) * Cr) / (1 - Kr - Kb)
|
||||
* B = Y + K * (1 - Kb) * Cb
|
||||
*
|
||||
* Y = Kr * R + (1 - Kr - Kb) * G + Kb * B
|
||||
*
|
||||
* With Kr = 0.299 and Kb = 0.114 (derived according to SMPTE RP 177-1993
|
||||
* from the 1953 FCC NTSC primaries and CIE Illuminant C), K = 2 for sYCC,
|
||||
* the conversion equations to be implemented are therefore
|
||||
*
|
||||
* R = Y + 1.402 * Cr
|
||||
* G = Y - 0.344136286 * Cb - 0.714136286 * Cr
|
||||
* B = Y + 1.772 * Cb
|
||||
*
|
||||
* Y = 0.299 * R + 0.587 * G + 0.114 * B
|
||||
*
|
||||
* where Cb and Cr represent the incoming values less CENTERJSAMPLE.
|
||||
* (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
|
||||
* For bg-sYCC, with K = 4, the equations are
|
||||
*
|
||||
* R = Y + 2.804 * Cr
|
||||
* G = Y - 0.688272572 * Cb - 1.428272572 * Cr
|
||||
* B = Y + 3.544 * Cb
|
||||
*
|
||||
* To avoid floating-point arithmetic, we represent the fractional constants
|
||||
* as integers scaled up by 2^16 (about 4 digits precision); we have to divide
|
||||
@@ -49,9 +86,9 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
||||
* For even more speed, we avoid doing any multiplications in the inner loop
|
||||
* by precalculating the constants times Cb and Cr for all possible values.
|
||||
* For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
|
||||
* for 12-bit samples it is still acceptable. It's not very reasonable for
|
||||
* 16-bit samples, but if you want lossless storage you shouldn't be changing
|
||||
* colorspace anyway.
|
||||
* for 9-bit to 12-bit samples it is still acceptable. It's not very
|
||||
* reasonable for 16-bit samples, but if you want lossless storage you
|
||||
* shouldn't be changing colorspace anyway.
|
||||
* The Cr=>R and Cb=>B values can be rounded to integers in advance; the
|
||||
* values for the G calculation are left scaled up, since we must add them
|
||||
* together before rounding.
|
||||
@@ -61,46 +98,87 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
||||
#define ONE_HALF ((INT32) 1 << (SCALEBITS-1))
|
||||
#define FIX(x) ((INT32) ((x) * (1L<<SCALEBITS) + 0.5))
|
||||
|
||||
/* We allocate one big table for RGB->Y conversion and divide it up into
|
||||
* three parts, instead of doing three alloc_small requests. This lets us
|
||||
* use a single table base address, which can be held in a register in the
|
||||
* inner loops on many machines (more than can hold all three addresses,
|
||||
* anyway).
|
||||
*/
|
||||
|
||||
#define R_Y_OFF 0 /* offset to R => Y section */
|
||||
#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */
|
||||
#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */
|
||||
#define TABLE_SIZE (3*(MAXJSAMPLE+1))
|
||||
|
||||
|
||||
/*
|
||||
* Initialize tables for YCC->RGB colorspace conversion.
|
||||
* Initialize tables for YCbCr->RGB and BG_YCC->RGB colorspace conversion.
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
/* Normal case, sYCC */
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
int i;
|
||||
INT32 x;
|
||||
SHIFT_TEMPS
|
||||
|
||||
cconvert->Cr_r_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * SIZEOF(int));
|
||||
cconvert->Cb_b_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * SIZEOF(int));
|
||||
cconvert->Cr_g_tab = (INT32 *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||
cconvert->Cb_g_tab = (INT32 *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||
cconvert->Cr_r_tab = (int *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
|
||||
cconvert->Cb_b_tab = (int *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
|
||||
cconvert->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||
cconvert->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 1.40200 * x */
|
||||
cconvert->Cr_r_tab[i] = (int)
|
||||
RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);
|
||||
/* Cb=>B value is nearest int to 1.77200 * x */
|
||||
cconvert->Cb_b_tab[i] = (int)
|
||||
RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);
|
||||
/* Cr=>G value is scaled-up -0.71414 * x */
|
||||
cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x;
|
||||
/* Cb=>G value is scaled-up -0.34414 * x */
|
||||
/* Cr=>R value is nearest int to 1.402 * x */
|
||||
cconvert->Cr_r_tab[i] = (int) DESCALE(FIX(1.402) * x, SCALEBITS);
|
||||
/* Cb=>B value is nearest int to 1.772 * x */
|
||||
cconvert->Cb_b_tab[i] = (int) DESCALE(FIX(1.772) * x, SCALEBITS);
|
||||
/* Cr=>G value is scaled-up -0.714136286 * x */
|
||||
cconvert->Cr_g_tab[i] = (- FIX(0.714136286)) * x;
|
||||
/* Cb=>G value is scaled-up -0.344136286 * x */
|
||||
/* We also add in ONE_HALF so that need not do it in inner loop */
|
||||
cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF;
|
||||
cconvert->Cb_g_tab[i] = (- FIX(0.344136286)) * x + ONE_HALF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
build_bg_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
/* Wide gamut case, bg-sYCC */
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
int i;
|
||||
INT32 x;
|
||||
SHIFT_TEMPS
|
||||
|
||||
cconvert->Cr_r_tab = (int *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
|
||||
cconvert->Cb_b_tab = (int *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
|
||||
cconvert->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||
cconvert->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 */
|
||||
cconvert->Cr_r_tab[i] = (int) DESCALE(FIX(2.804) * x, SCALEBITS);
|
||||
/* Cb=>B value is nearest int to 3.544 * x */
|
||||
cconvert->Cb_b_tab[i] = (int) DESCALE(FIX(3.544) * x, SCALEBITS);
|
||||
/* Cr=>G value is scaled-up -1.428272572 * x */
|
||||
cconvert->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 */
|
||||
cconvert->Cb_g_tab[i] = (- FIX(0.688272572)) * x + ONE_HALF;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +189,7 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
* Note that we change from noninterleaved, one-plane-per-component format
|
||||
* to interleaved-pixel format. The output buffer is therefore three times
|
||||
* as wide as the input buffer.
|
||||
*
|
||||
* A starting row offset is provided only for the input buffer. The caller
|
||||
* can easily adjust the passed output_buf value to accommodate any row
|
||||
* offset required on that side.
|
||||
@@ -145,7 +224,9 @@ ycc_rgb_convert (j_decompress_ptr cinfo,
|
||||
y = GETJSAMPLE(inptr0[col]);
|
||||
cb = GETJSAMPLE(inptr1[col]);
|
||||
cr = GETJSAMPLE(inptr2[col]);
|
||||
/* Range-limiting is essential due to noise introduced by DCT losses. */
|
||||
/* Range-limiting is essential due to noise introduced by DCT losses,
|
||||
* for extended gamut (sYCC) and wide gamut (bg-sYCC) encodings.
|
||||
*/
|
||||
outptr[RGB_RED] = range_limit[y + Crrtab[cr]];
|
||||
outptr[RGB_GREEN] = range_limit[y +
|
||||
((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
@@ -157,12 +238,189 @@ ycc_rgb_convert (j_decompress_ptr cinfo,
|
||||
}
|
||||
|
||||
|
||||
/**************** Cases other than YCbCr -> RGB **************/
|
||||
/**************** Cases other than YCC -> RGB ****************/
|
||||
|
||||
|
||||
/*
|
||||
* Initialize for RGB->grayscale colorspace conversion.
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
build_rgb_y_table (j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
INT32 * rgb_y_tab;
|
||||
INT32 i;
|
||||
|
||||
/* Allocate and fill in the conversion tables. */
|
||||
cconvert->rgb_y_tab = rgb_y_tab = (INT32 *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, TABLE_SIZE * SIZEOF(INT32));
|
||||
|
||||
for (i = 0; i <= MAXJSAMPLE; i++) {
|
||||
rgb_y_tab[i+R_Y_OFF] = FIX(0.299) * i;
|
||||
rgb_y_tab[i+G_Y_OFF] = FIX(0.587) * i;
|
||||
rgb_y_tab[i+B_Y_OFF] = FIX(0.114) * i + ONE_HALF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert RGB to grayscale.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_gray_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
register int r, g, b;
|
||||
register INT32 * ctab = cconvert->rgb_y_tab;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
inptr0 = input_buf[0][input_row];
|
||||
inptr1 = input_buf[1][input_row];
|
||||
inptr2 = input_buf[2][input_row];
|
||||
input_row++;
|
||||
outptr = *output_buf++;
|
||||
for (col = 0; col < num_cols; col++) {
|
||||
r = GETJSAMPLE(inptr0[col]);
|
||||
g = GETJSAMPLE(inptr1[col]);
|
||||
b = GETJSAMPLE(inptr2[col]);
|
||||
/* Y */
|
||||
outptr[col] = (JSAMPLE)
|
||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
||||
>> SCALEBITS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert some rows of samples to the output colorspace.
|
||||
* [R-G,G,B-G] to [R,G,B] conversion with modulo calculation
|
||||
* (inverse color transform).
|
||||
* This can be seen as an adaption of the general YCbCr->RGB
|
||||
* conversion equation with Kr = Kb = 0, while replacing the
|
||||
* normalization by modulo calculation.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb1_rgb_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
register int r, g, b;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
inptr0 = input_buf[0][input_row];
|
||||
inptr1 = input_buf[1][input_row];
|
||||
inptr2 = input_buf[2][input_row];
|
||||
input_row++;
|
||||
outptr = *output_buf++;
|
||||
for (col = 0; col < num_cols; col++) {
|
||||
r = GETJSAMPLE(inptr0[col]);
|
||||
g = GETJSAMPLE(inptr1[col]);
|
||||
b = GETJSAMPLE(inptr2[col]);
|
||||
/* Assume that MAXJSAMPLE+1 is a power of 2, so that the MOD
|
||||
* (modulo) operator is equivalent to the bitmask operator AND.
|
||||
*/
|
||||
outptr[RGB_RED] = (JSAMPLE) ((r + g - CENTERJSAMPLE) & MAXJSAMPLE);
|
||||
outptr[RGB_GREEN] = (JSAMPLE) g;
|
||||
outptr[RGB_BLUE] = (JSAMPLE) ((b + g - CENTERJSAMPLE) & MAXJSAMPLE);
|
||||
outptr += RGB_PIXELSIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* [R-G,G,B-G] to grayscale conversion with modulo calculation
|
||||
* (inverse color transform).
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb1_gray_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
register int r, g, b;
|
||||
register INT32 * ctab = cconvert->rgb_y_tab;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
inptr0 = input_buf[0][input_row];
|
||||
inptr1 = input_buf[1][input_row];
|
||||
inptr2 = input_buf[2][input_row];
|
||||
input_row++;
|
||||
outptr = *output_buf++;
|
||||
for (col = 0; col < num_cols; col++) {
|
||||
r = GETJSAMPLE(inptr0[col]);
|
||||
g = GETJSAMPLE(inptr1[col]);
|
||||
b = GETJSAMPLE(inptr2[col]);
|
||||
/* Assume that MAXJSAMPLE+1 is a power of 2, so that the MOD
|
||||
* (modulo) operator is equivalent to the bitmask operator AND.
|
||||
*/
|
||||
r = (r + g - CENTERJSAMPLE) & MAXJSAMPLE;
|
||||
b = (b + g - CENTERJSAMPLE) & MAXJSAMPLE;
|
||||
/* Y */
|
||||
outptr[col] = (JSAMPLE)
|
||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
||||
>> SCALEBITS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert some rows of samples to the output colorspace.
|
||||
* No colorspace change, but conversion from separate-planes
|
||||
* to interleaved representation.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
inptr0 = input_buf[0][input_row];
|
||||
inptr1 = input_buf[1][input_row];
|
||||
inptr2 = input_buf[2][input_row];
|
||||
input_row++;
|
||||
outptr = *output_buf++;
|
||||
for (col = 0; col < num_cols; col++) {
|
||||
/* We can dispense with GETJSAMPLE() here */
|
||||
outptr[RGB_RED] = inptr0[col];
|
||||
outptr[RGB_GREEN] = inptr1[col];
|
||||
outptr[RGB_BLUE] = inptr2[col];
|
||||
outptr += RGB_PIXELSIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Color conversion for no colorspace change: just copy the data,
|
||||
* converting from separate-planes to interleaved representation.
|
||||
* We assume out_color_components == num_components.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
@@ -170,19 +428,21 @@ null_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr;
|
||||
register JDIMENSION count;
|
||||
register int num_components = cinfo->num_components;
|
||||
register int num_comps = cinfo->num_components;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
int ci;
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
for (ci = 0; ci < num_components; ci++) {
|
||||
/* It seems fastest to make a separate pass for each component. */
|
||||
for (ci = 0; ci < num_comps; ci++) {
|
||||
inptr = input_buf[ci][input_row];
|
||||
outptr = output_buf[0] + ci;
|
||||
for (count = num_cols; count > 0; count--) {
|
||||
*outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */
|
||||
outptr += num_components;
|
||||
*outptr = *inptr++; /* don't need GETJSAMPLE() here */
|
||||
outptr += num_comps;
|
||||
}
|
||||
}
|
||||
input_row++;
|
||||
@@ -193,7 +453,7 @@ null_convert (j_decompress_ptr cinfo,
|
||||
|
||||
/*
|
||||
* Color conversion for grayscale: just copy the data.
|
||||
* This also works for YCbCr -> grayscale conversion, in which
|
||||
* This also works for YCC -> grayscale conversion, in which
|
||||
* we just copy the Y (luminance) component and ignore chrominance.
|
||||
*/
|
||||
|
||||
@@ -218,7 +478,8 @@ gray_rgb_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
|
||||
@@ -235,9 +496,10 @@ gray_rgb_convert (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
/*
|
||||
* Adobe-style YCCK->CMYK conversion.
|
||||
* We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same
|
||||
* conversion as above, while passing K (black) unchanged.
|
||||
* Convert some rows of samples to the output colorspace.
|
||||
* This version handles Adobe-style YCCK->CMYK conversion,
|
||||
* where we convert YCbCr to R=1-C, G=1-M, and B=1-Y using the
|
||||
* same conversion as above, while passing K (black) unchanged.
|
||||
* We assume build_ycc_rgb_table has been called.
|
||||
*/
|
||||
|
||||
@@ -271,7 +533,9 @@ ycck_cmyk_convert (j_decompress_ptr cinfo,
|
||||
y = GETJSAMPLE(inptr0[col]);
|
||||
cb = GETJSAMPLE(inptr1[col]);
|
||||
cr = GETJSAMPLE(inptr2[col]);
|
||||
/* Range-limiting is essential due to noise introduced by DCT losses. */
|
||||
/* Range-limiting is essential due to noise introduced by DCT losses,
|
||||
* and for extended gamut encodings (sYCC).
|
||||
*/
|
||||
outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */
|
||||
outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */
|
||||
((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
@@ -306,10 +570,9 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
my_cconvert_ptr cconvert;
|
||||
int ci;
|
||||
|
||||
cconvert = (my_cconvert_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_color_deconverter));
|
||||
cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert;
|
||||
cconvert = (my_cconvert_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_color_deconverter));
|
||||
cinfo->cconvert = &cconvert->pub;
|
||||
cconvert->pub.start_pass = start_pass_dcolor;
|
||||
|
||||
/* Make sure num_components agrees with jpeg_color_space */
|
||||
@@ -321,6 +584,8 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
|
||||
case JCS_RGB:
|
||||
case JCS_YCbCr:
|
||||
case JCS_BG_RGB:
|
||||
case JCS_BG_YCC:
|
||||
if (cinfo->num_components != 3)
|
||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||
break;
|
||||
@@ -334,9 +599,14 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
default: /* JCS_UNKNOWN can be anything */
|
||||
if (cinfo->num_components < 1)
|
||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Support color transform only for RGB colorspaces */
|
||||
if (cinfo->color_transform &&
|
||||
cinfo->jpeg_color_space != JCS_RGB &&
|
||||
cinfo->jpeg_color_space != JCS_BG_RGB)
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
|
||||
/* Set out_color_components and conversion method based on requested space.
|
||||
* Also clear the component_needed flags for any unused components,
|
||||
* so that earlier pipeline stages can avoid useless computation.
|
||||
@@ -345,48 +615,101 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
switch (cinfo->out_color_space) {
|
||||
case JCS_GRAYSCALE:
|
||||
cinfo->out_color_components = 1;
|
||||
if (cinfo->jpeg_color_space == JCS_GRAYSCALE ||
|
||||
cinfo->jpeg_color_space == JCS_YCbCr) {
|
||||
switch (cinfo->jpeg_color_space) {
|
||||
case JCS_GRAYSCALE:
|
||||
case JCS_YCbCr:
|
||||
case JCS_BG_YCC:
|
||||
cconvert->pub.color_convert = grayscale_convert;
|
||||
/* For color->grayscale conversion, only the Y (0) component is needed */
|
||||
for (ci = 1; ci < cinfo->num_components; ci++)
|
||||
cinfo->comp_info[ci].component_needed = FALSE;
|
||||
} else
|
||||
break;
|
||||
case JCS_RGB:
|
||||
switch (cinfo->color_transform) {
|
||||
case JCT_NONE:
|
||||
cconvert->pub.color_convert = rgb_gray_convert;
|
||||
break;
|
||||
case JCT_SUBTRACT_GREEN:
|
||||
cconvert->pub.color_convert = rgb1_gray_convert;
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
build_rgb_y_table(cinfo);
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
break;
|
||||
|
||||
case JCS_RGB:
|
||||
cinfo->out_color_components = RGB_PIXELSIZE;
|
||||
if (cinfo->jpeg_color_space == JCS_YCbCr) {
|
||||
switch (cinfo->jpeg_color_space) {
|
||||
case JCS_GRAYSCALE:
|
||||
cconvert->pub.color_convert = gray_rgb_convert;
|
||||
break;
|
||||
case JCS_YCbCr:
|
||||
cconvert->pub.color_convert = ycc_rgb_convert;
|
||||
build_ycc_rgb_table(cinfo);
|
||||
} else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
|
||||
cconvert->pub.color_convert = gray_rgb_convert;
|
||||
} else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) {
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
} else
|
||||
break;
|
||||
case JCS_BG_YCC:
|
||||
cconvert->pub.color_convert = ycc_rgb_convert;
|
||||
build_bg_ycc_rgb_table(cinfo);
|
||||
break;
|
||||
case JCS_RGB:
|
||||
switch (cinfo->color_transform) {
|
||||
case JCT_NONE:
|
||||
cconvert->pub.color_convert = rgb_convert;
|
||||
break;
|
||||
case JCT_SUBTRACT_GREEN:
|
||||
cconvert->pub.color_convert = rgb1_rgb_convert;
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
break;
|
||||
|
||||
case JCS_BG_RGB:
|
||||
cinfo->out_color_components = RGB_PIXELSIZE;
|
||||
if (cinfo->jpeg_color_space != JCS_BG_RGB)
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
switch (cinfo->color_transform) {
|
||||
case JCT_NONE:
|
||||
cconvert->pub.color_convert = rgb_convert;
|
||||
break;
|
||||
case JCT_SUBTRACT_GREEN:
|
||||
cconvert->pub.color_convert = rgb1_rgb_convert;
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
break;
|
||||
|
||||
case JCS_CMYK:
|
||||
cinfo->out_color_components = 4;
|
||||
if (cinfo->jpeg_color_space == JCS_YCCK) {
|
||||
switch (cinfo->jpeg_color_space) {
|
||||
case JCS_YCCK:
|
||||
cconvert->pub.color_convert = ycck_cmyk_convert;
|
||||
build_ycc_rgb_table(cinfo);
|
||||
} else if (cinfo->jpeg_color_space == JCS_CMYK) {
|
||||
break;
|
||||
case JCS_CMYK:
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
} else
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Permit null conversion to same output space */
|
||||
if (cinfo->out_color_space == cinfo->jpeg_color_space) {
|
||||
default: /* permit null conversion to same output space */
|
||||
if (cinfo->out_color_space != cinfo->jpeg_color_space)
|
||||
/* unsupported non-null conversion */
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
cinfo->out_color_components = cinfo->num_components;
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
} else /* unsupported non-null conversion */
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
break;
|
||||
}
|
||||
|
||||
if (cinfo->quantize_colors)
|
||||
|
||||
36
jdct.h
36
jdct.h
@@ -2,6 +2,7 @@
|
||||
* jdct.h
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2002-2019 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,15 @@ 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
|
||||
* to do the combined operations quickly, assuming that RANGE_CENTER
|
||||
* (defined in jpegint.h) 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 (RANGE_CENTER * 2 - 1)
|
||||
#define RANGE_SUBSET (RANGE_CENTER - CENTERJSAMPLE)
|
||||
|
||||
#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */
|
||||
#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit - RANGE_SUBSET)
|
||||
|
||||
|
||||
/* Short forms of external names for systems with brain-damaged linkers. */
|
||||
@@ -355,13 +358,6 @@ EXTERN(void) jpeg_idct_1x2
|
||||
|
||||
#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5))
|
||||
|
||||
/* Descale and correctly round an INT32 value that's scaled by N bits.
|
||||
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
|
||||
* the fudge factor is correct for either sign of X.
|
||||
*/
|
||||
|
||||
#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
|
||||
|
||||
/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
|
||||
* This macro is used only when the two inputs will actually be no more than
|
||||
* 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a
|
||||
@@ -391,3 +387,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
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* jddctmgr.c
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2002-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.
|
||||
*
|
||||
@@ -324,6 +325,7 @@ start_pass (j_decompress_ptr cinfo)
|
||||
* coefficients scaled by scalefactor[row]*scalefactor[col], where
|
||||
* scalefactor[0] = 1
|
||||
* scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7
|
||||
* We apply a further scale factor of 1/8.
|
||||
*/
|
||||
FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table;
|
||||
int row, col;
|
||||
@@ -337,7 +339,7 @@ start_pass (j_decompress_ptr cinfo)
|
||||
for (col = 0; col < DCTSIZE; col++) {
|
||||
fmtbl[i] = (FLOAT_MULT_TYPE)
|
||||
((double) qtbl->quantval[i] *
|
||||
aanscalefactor[row] * aanscalefactor[col]);
|
||||
aanscalefactor[row] * aanscalefactor[col] * 0.125);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -366,7 +368,7 @@ jinit_inverse_dct (j_decompress_ptr cinfo)
|
||||
idct = (my_idct_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_idct_controller));
|
||||
cinfo->idct = (struct jpeg_inverse_dct *) idct;
|
||||
cinfo->idct = &idct->pub;
|
||||
idct->pub.start_pass = start_pass;
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
|
||||
156
jdhuff.c
156
jdhuff.c
@@ -2,7 +2,7 @@
|
||||
* jdhuff.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2006-2009 by Guido Vollbeding.
|
||||
* Modified 2006-2019 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.
|
||||
*
|
||||
@@ -341,13 +341,12 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
htbl =
|
||||
isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
|
||||
if (htbl == NULL)
|
||||
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
|
||||
htbl = jpeg_std_huff_table((j_common_ptr) cinfo, isDC, tblno);
|
||||
|
||||
/* Allocate a workspace if we haven't already done so. */
|
||||
if (*pdtbl == NULL)
|
||||
*pdtbl = (d_derived_tbl *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(d_derived_tbl));
|
||||
*pdtbl = (d_derived_tbl *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(d_derived_tbl));
|
||||
dtbl = *pdtbl;
|
||||
dtbl->pub = htbl; /* fill in back link */
|
||||
|
||||
@@ -627,6 +626,22 @@ jpeg_huff_decode (bitread_working_state * state,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Finish up at the end of a Huffman-compressed scan.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass_huff (j_decompress_ptr cinfo)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
|
||||
/* Throw away any unused bits remaining in bit buffer; */
|
||||
/* include any full bytes in next_marker's count of discarded bytes */
|
||||
cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
|
||||
entropy->bitstate.bits_left = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check for a restart marker & resynchronize decoder.
|
||||
* Returns FALSE if must suspend.
|
||||
@@ -638,10 +653,7 @@ process_restart (j_decompress_ptr cinfo)
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
int ci;
|
||||
|
||||
/* Throw away any unused bits remaining in bit buffer; */
|
||||
/* include any full bytes in next_marker's count of discarded bytes */
|
||||
cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
|
||||
entropy->bitstate.bits_left = 0;
|
||||
finish_pass_huff(cinfo);
|
||||
|
||||
/* Advance past the RSTn marker */
|
||||
if (! (*cinfo->marker->read_restart_marker) (cinfo))
|
||||
@@ -717,7 +729,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (! entropy->insufficient_data) {
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(state, entropy->saved);
|
||||
|
||||
/* Outer loop handles each block in the MCU */
|
||||
@@ -746,11 +758,12 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(entropy->saved, state);
|
||||
}
|
||||
|
||||
/* Account for restart interval (no-op if not using restarts) */
|
||||
/* Account for restart interval if using restarts */
|
||||
if (cinfo->restart_interval)
|
||||
entropy->restarts_to_go--;
|
||||
|
||||
return TRUE;
|
||||
@@ -786,10 +799,6 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
if (! entropy->insufficient_data) {
|
||||
|
||||
Se = cinfo->Se;
|
||||
Al = cinfo->Al;
|
||||
natural_order = cinfo->natural_order;
|
||||
|
||||
/* Load up working state.
|
||||
* We can avoid loading/saving bitread state if in an EOB run.
|
||||
*/
|
||||
@@ -797,10 +806,13 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
/* There is always only one block per MCU */
|
||||
|
||||
if (EOBRUN > 0) /* if it's a band of zeroes... */
|
||||
if (EOBRUN) /* if it's a band of zeroes... */
|
||||
EOBRUN--; /* ...process it now (we do nothing) */
|
||||
else {
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
Se = cinfo->Se;
|
||||
Al = cinfo->Al;
|
||||
natural_order = cinfo->natural_order;
|
||||
block = MCU_data[0];
|
||||
tbl = entropy->ac_derived_tbl;
|
||||
|
||||
@@ -816,29 +828,29 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Scale and output coefficient in natural (dezigzagged) order */
|
||||
(*block)[natural_order[k]] = (JCOEF) (s << Al);
|
||||
} else {
|
||||
if (r == 15) { /* ZRL */
|
||||
k += 15; /* skip 15 zeroes in band */
|
||||
} else { /* EOBr, run length is 2^r + appended bits */
|
||||
EOBRUN = 1 << r;
|
||||
if (r != 15) { /* EOBr, run length is 2^r + appended bits */
|
||||
if (r) { /* EOBr, r > 0 */
|
||||
EOBRUN = 1 << r;
|
||||
CHECK_BIT_BUFFER(br_state, r, return FALSE);
|
||||
r = GET_BITS(r);
|
||||
EOBRUN += r;
|
||||
}
|
||||
EOBRUN--; /* this band is processed at this moment */
|
||||
}
|
||||
break; /* force end-of-band */
|
||||
}
|
||||
k += 15; /* ZRL: skip 15 zeroes in band */
|
||||
}
|
||||
}
|
||||
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
|
||||
}
|
||||
|
||||
/* Account for restart interval (no-op if not using restarts) */
|
||||
/* Account for restart interval if using restarts */
|
||||
if (cinfo->restart_interval)
|
||||
entropy->restarts_to_go--;
|
||||
|
||||
return TRUE;
|
||||
@@ -847,17 +859,16 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
/*
|
||||
* MCU decoding for DC successive approximation refinement scan.
|
||||
* Note: we assume such scans can be multi-component, although the spec
|
||||
* is not very clear on the point.
|
||||
* Note: we assume such scans can be multi-component,
|
||||
* although the spec is not very clear on the point.
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||
JCOEF p1;
|
||||
int blkn;
|
||||
JBLOCKROW block;
|
||||
BITREAD_STATE_VARS;
|
||||
|
||||
/* Process restart marker if needed; may have to suspend */
|
||||
@@ -872,24 +883,25 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
|
||||
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||
|
||||
/* Outer loop handles each block in the MCU */
|
||||
|
||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||
block = MCU_data[blkn];
|
||||
|
||||
/* Encoded data is simply the next bit of the two's-complement DC value */
|
||||
CHECK_BIT_BUFFER(br_state, 1, return FALSE);
|
||||
if (GET_BITS(1))
|
||||
(*block)[0] |= p1;
|
||||
MCU_data[blkn][0][0] |= p1;
|
||||
/* Note: since we use |=, repeating the assignment later is safe */
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
|
||||
/* Account for restart interval (no-op if not using restarts) */
|
||||
/* Account for restart interval if using restarts */
|
||||
if (cinfo->restart_interval)
|
||||
entropy->restarts_to_go--;
|
||||
|
||||
return TRUE;
|
||||
@@ -906,7 +918,8 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
register int s, k, r;
|
||||
unsigned int EOBRUN;
|
||||
int Se, p1, m1;
|
||||
int Se;
|
||||
JCOEF p1, m1;
|
||||
const int * natural_order;
|
||||
JBLOCKROW block;
|
||||
JCOEFPTR thiscoef;
|
||||
@@ -928,11 +941,11 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
Se = cinfo->Se;
|
||||
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||
m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */
|
||||
m1 = -p1; /* -1 in the bit position being coded */
|
||||
natural_order = cinfo->natural_order;
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
|
||||
|
||||
/* There is always only one block per MCU */
|
||||
@@ -951,7 +964,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
k = cinfo->Ss;
|
||||
|
||||
if (EOBRUN == 0) {
|
||||
for (; k <= Se; k++) {
|
||||
do {
|
||||
HUFF_DECODE(s, br_state, tbl, goto undoit, label3);
|
||||
r = s >> 4;
|
||||
s &= 15;
|
||||
@@ -981,7 +994,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
do {
|
||||
thiscoef = *block + natural_order[k];
|
||||
if (*thiscoef != 0) {
|
||||
if (*thiscoef) {
|
||||
CHECK_BIT_BUFFER(br_state, 1, goto undoit);
|
||||
if (GET_BITS(1)) {
|
||||
if ((*thiscoef & p1) == 0) { /* do nothing if already set it */
|
||||
@@ -1004,18 +1017,19 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Remember its position in case we have to suspend */
|
||||
newnz_pos[num_newnz++] = pos;
|
||||
}
|
||||
}
|
||||
k++;
|
||||
} while (k <= Se);
|
||||
}
|
||||
|
||||
if (EOBRUN > 0) {
|
||||
if (EOBRUN) {
|
||||
/* Scan any remaining coefficient positions after the end-of-band
|
||||
* (the last newly nonzero coefficient, if any). Append a correction
|
||||
* bit to each already-nonzero coefficient. A correction bit is 1
|
||||
* if the absolute value of the coefficient must be increased.
|
||||
*/
|
||||
for (; k <= Se; k++) {
|
||||
do {
|
||||
thiscoef = *block + natural_order[k];
|
||||
if (*thiscoef != 0) {
|
||||
if (*thiscoef) {
|
||||
CHECK_BIT_BUFFER(br_state, 1, goto undoit);
|
||||
if (GET_BITS(1)) {
|
||||
if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */
|
||||
@@ -1026,24 +1040,26 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
k++;
|
||||
} while (k <= Se);
|
||||
/* Count one block completed in EOB run */
|
||||
EOBRUN--;
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
|
||||
}
|
||||
|
||||
/* Account for restart interval (no-op if not using restarts) */
|
||||
/* Account for restart interval if using restarts */
|
||||
if (cinfo->restart_interval)
|
||||
entropy->restarts_to_go--;
|
||||
|
||||
return TRUE;
|
||||
|
||||
undoit:
|
||||
/* Re-zero any output coefficients that we made newly nonzero */
|
||||
while (num_newnz > 0)
|
||||
while (num_newnz)
|
||||
(*block)[newnz_pos[--num_newnz]] = 0;
|
||||
|
||||
return FALSE;
|
||||
@@ -1080,7 +1096,7 @@ decode_mcu_sub (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
Se = cinfo->lim_Se;
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(state, entropy->saved);
|
||||
|
||||
/* Outer loop handles each block in the MCU */
|
||||
@@ -1167,11 +1183,12 @@ decode_mcu_sub (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(entropy->saved, state);
|
||||
}
|
||||
|
||||
/* Account for restart interval (no-op if not using restarts) */
|
||||
/* Account for restart interval if using restarts */
|
||||
if (cinfo->restart_interval)
|
||||
entropy->restarts_to_go--;
|
||||
|
||||
return TRUE;
|
||||
@@ -1204,7 +1221,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (! entropy->insufficient_data) {
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(state, entropy->saved);
|
||||
|
||||
/* Outer loop handles each block in the MCU */
|
||||
@@ -1291,11 +1308,12 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(entropy->saved, state);
|
||||
}
|
||||
|
||||
/* Account for restart interval (no-op if not using restarts) */
|
||||
/* Account for restart interval if using restarts */
|
||||
if (cinfo->restart_interval)
|
||||
entropy->restarts_to_go--;
|
||||
|
||||
return TRUE;
|
||||
@@ -1332,11 +1350,11 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
goto bad;
|
||||
}
|
||||
if (cinfo->Al > 13) { /* need not check for < 0 */
|
||||
/* Arguably the maximum Al value should be less than 13 for 8-bit precision,
|
||||
* but the spec doesn't say so, and we try to be liberal about what we
|
||||
* accept. Note: large Al values could result in out-of-range DC
|
||||
* coefficients during early scans, leading to bizarre displays due to
|
||||
* overflows in the IDCT math. But we won't crash.
|
||||
/* Arguably the maximum Al value should be less than 13 for 8-bit
|
||||
* precision, but the spec doesn't say so, and we try to be liberal
|
||||
* about what we accept. Note: large Al values could result in
|
||||
* out-of-range DC coefficients during early scans, leading to bizarre
|
||||
* displays due to overflows in the IDCT math. But we won't crash.
|
||||
*/
|
||||
bad:
|
||||
ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
|
||||
@@ -1440,7 +1458,8 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
/* Precalculate which table to use for each block */
|
||||
entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no];
|
||||
entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no];
|
||||
entropy->ac_cur_tbls[blkn] = /* AC needs no table when not present */
|
||||
cinfo->lim_Se ? entropy->ac_derived_tbls[compptr->ac_tbl_no] : NULL;
|
||||
/* Decide whether we really care about the coefficient values */
|
||||
if (compptr->component_needed) {
|
||||
ci = compptr->DCT_v_scaled_size;
|
||||
@@ -1483,7 +1502,6 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
if (ci <= 0 || ci > 8) ci = 8;
|
||||
if (i <= 0 || i > 8) i = 8;
|
||||
entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order[ci - 1][i - 1];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
entropy->coef_limit[blkn] = 0;
|
||||
@@ -1511,18 +1529,18 @@ jinit_huff_decoder (j_decompress_ptr cinfo)
|
||||
huff_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (huff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(huff_entropy_decoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
|
||||
entropy = (huff_entropy_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(huff_entropy_decoder));
|
||||
cinfo->entropy = &entropy->pub;
|
||||
entropy->pub.start_pass = start_pass_huff_decoder;
|
||||
entropy->pub.finish_pass = finish_pass_huff;
|
||||
|
||||
if (cinfo->progressive_mode) {
|
||||
/* Create progression status table */
|
||||
int *coef_bit_ptr, ci;
|
||||
cinfo->coef_bits = (int (*)[DCTSIZE2])
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components*DCTSIZE2*SIZEOF(int));
|
||||
cinfo->coef_bits = (int (*)[DCTSIZE2]) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * DCTSIZE2 * SIZEOF(int));
|
||||
coef_bit_ptr = & cinfo->coef_bits[0][0];
|
||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||
for (i = 0; i < DCTSIZE2; i++)
|
||||
@@ -1533,7 +1551,7 @@ jinit_huff_decoder (j_decompress_ptr cinfo)
|
||||
entropy->derived_tbls[i] = NULL;
|
||||
}
|
||||
} else {
|
||||
/* Mark tables unallocated */
|
||||
/* Mark derived tables unallocated */
|
||||
for (i = 0; i < NUM_HUFF_TBLS; i++) {
|
||||
entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;
|
||||
}
|
||||
|
||||
11
jdinput.c
11
jdinput.c
@@ -2,7 +2,7 @@
|
||||
* jdinput.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2002-2009 by Guido Vollbeding.
|
||||
* Modified 2002-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.
|
||||
*
|
||||
@@ -196,7 +196,7 @@ jpeg_core_output_dimensions (j_decompress_ptr cinfo)
|
||||
/* Hardwire it to "no scaling" */
|
||||
cinfo->output_width = cinfo->image_width;
|
||||
cinfo->output_height = cinfo->image_height;
|
||||
/* jdinput.c has already initialized DCT_scaled_size,
|
||||
/* initial_setup has already initialized DCT_scaled_size,
|
||||
* and has computed unscaled downsampled_width and downsampled_height.
|
||||
*/
|
||||
|
||||
@@ -216,8 +216,8 @@ initial_setup (j_decompress_ptr cinfo)
|
||||
(long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
|
||||
|
||||
/* For now, precision must match compiled-in value... */
|
||||
if (cinfo->data_precision != BITS_IN_JSAMPLE)
|
||||
/* Only 8 to 12 bits data precision are supported for DCT based JPEG */
|
||||
if (cinfo->data_precision < 8 || cinfo->data_precision > 12)
|
||||
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
|
||||
|
||||
/* Check that number of components won't exceed internal array sizes */
|
||||
@@ -537,6 +537,7 @@ start_input_pass (j_decompress_ptr cinfo)
|
||||
METHODDEF(void)
|
||||
finish_input_pass (j_decompress_ptr cinfo)
|
||||
{
|
||||
(*cinfo->entropy->finish_pass) (cinfo);
|
||||
cinfo->inputctl->consume_input = consume_markers;
|
||||
}
|
||||
|
||||
@@ -646,7 +647,7 @@ jinit_input_controller (j_decompress_ptr cinfo)
|
||||
inputctl = (my_inputctl_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(my_input_controller));
|
||||
cinfo->inputctl = (struct jpeg_input_controller *) inputctl;
|
||||
cinfo->inputctl = &inputctl->pub;
|
||||
/* Initialize method pointers */
|
||||
inputctl->pub.consume_input = consume_markers;
|
||||
inputctl->pub.reset_input_controller = reset_input_controller;
|
||||
|
||||
151
jdmainct.c
151
jdmainct.c
@@ -2,6 +2,7 @@
|
||||
* jdmainct.c
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2002-2016 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,8 +26,8 @@
|
||||
* trivial. Its responsibility is to provide context rows for upsampling/
|
||||
* rescaling, and doing this in an efficient fashion is a bit tricky.
|
||||
*
|
||||
* Postprocessor input data is counted in "row groups". A row group
|
||||
* is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size)
|
||||
* Postprocessor input data is counted in "row groups". A row group is
|
||||
* defined to be (v_samp_factor * DCT_v_scaled_size / min_DCT_v_scaled_size)
|
||||
* sample rows of each component. (We require DCT_scaled_size values to be
|
||||
* chosen such that these numbers are integers. In practice DCT_scaled_size
|
||||
* values will likely be powers of two, so we actually have the stronger
|
||||
@@ -36,8 +37,8 @@
|
||||
* applying).
|
||||
*
|
||||
* The coefficient controller will deliver data to us one iMCU row at a time;
|
||||
* each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or
|
||||
* exactly min_DCT_scaled_size row groups. (This amount of data corresponds
|
||||
* each iMCU row contains v_samp_factor * DCT_v_scaled_size sample rows, or
|
||||
* exactly min_DCT_v_scaled_size row groups. (This amount of data corresponds
|
||||
* to one row of MCUs when the image is fully interleaved.) Note that the
|
||||
* number of sample rows varies across components, but the number of row
|
||||
* groups does not. Some garbage sample rows may be included in the last iMCU
|
||||
@@ -74,7 +75,7 @@
|
||||
* We could do this most simply by copying data around in our buffer, but
|
||||
* that'd be very slow. We can avoid copying any data by creating a rather
|
||||
* strange pointer structure. Here's how it works. We allocate a workspace
|
||||
* consisting of M+2 row groups (where M = min_DCT_scaled_size is the number
|
||||
* consisting of M+2 row groups (where M = min_DCT_v_scaled_size is the number
|
||||
* of row groups per iMCU row). We create two sets of redundant pointers to
|
||||
* the workspace. Labeling the physical row groups 0 to M+1, the synthesized
|
||||
* pointer lists look like this:
|
||||
@@ -99,11 +100,11 @@
|
||||
* the first or last sample row as necessary (this is cheaper than copying
|
||||
* sample rows around).
|
||||
*
|
||||
* This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1. In that
|
||||
* This scheme breaks down if M < 2, ie, min_DCT_v_scaled_size is 1. In that
|
||||
* situation each iMCU row provides only one row group so the buffering logic
|
||||
* must be different (eg, we must read two iMCU rows before we can emit the
|
||||
* first row group). For now, we simply do not support providing context
|
||||
* rows when min_DCT_scaled_size is 1. That combination seems unlikely to
|
||||
* rows when min_DCT_v_scaled_size is 1. That combination seems unlikely to
|
||||
* be worth providing --- if someone wants a 1/8th-size preview, they probably
|
||||
* want it quick and dirty, so a context-free upsampler is sufficient.
|
||||
*/
|
||||
@@ -117,17 +118,18 @@ typedef struct {
|
||||
/* Pointer to allocated workspace (M or M+2 row groups). */
|
||||
JSAMPARRAY buffer[MAX_COMPONENTS];
|
||||
|
||||
boolean buffer_full; /* Have we gotten an iMCU row from decoder? */
|
||||
JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */
|
||||
JDIMENSION rowgroups_avail; /* row groups available to postprocessor */
|
||||
|
||||
/* Remaining fields are only used in the context case. */
|
||||
|
||||
boolean buffer_full; /* Have we gotten an iMCU row from decoder? */
|
||||
|
||||
/* These are the master pointers to the funny-order pointer lists. */
|
||||
JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */
|
||||
|
||||
int whichptr; /* indicates which pointer set is now in use */
|
||||
int context_state; /* process_data state machine status */
|
||||
JDIMENSION rowgroups_avail; /* row groups available to postprocessor */
|
||||
JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */
|
||||
} my_main_controller;
|
||||
|
||||
@@ -159,7 +161,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
||||
* This is done only once, not once per pass.
|
||||
*/
|
||||
{
|
||||
my_main_ptr main = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr mainp = (my_main_ptr) cinfo->main;
|
||||
int ci, rgroup;
|
||||
int M = cinfo->min_DCT_v_scaled_size;
|
||||
jpeg_component_info *compptr;
|
||||
@@ -168,10 +170,10 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
||||
/* Get top-level space for component array pointers.
|
||||
* We alloc both arrays with one call to save a few cycles.
|
||||
*/
|
||||
main->xbuffer[0] = (JSAMPIMAGE)
|
||||
mainp->xbuffer[0] = (JSAMPIMAGE)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * 2 * SIZEOF(JSAMPARRAY));
|
||||
main->xbuffer[1] = main->xbuffer[0] + cinfo->num_components;
|
||||
mainp->xbuffer[1] = mainp->xbuffer[0] + cinfo->num_components;
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
@@ -184,9 +186,9 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW));
|
||||
xbuf += rgroup; /* want one row group at negative offsets */
|
||||
main->xbuffer[0][ci] = xbuf;
|
||||
mainp->xbuffer[0][ci] = xbuf;
|
||||
xbuf += rgroup * (M + 4);
|
||||
main->xbuffer[1][ci] = xbuf;
|
||||
mainp->xbuffer[1][ci] = xbuf;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,13 +196,13 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
||||
LOCAL(void)
|
||||
make_funny_pointers (j_decompress_ptr cinfo)
|
||||
/* Create the funny pointer lists discussed in the comments above.
|
||||
* The actual workspace is already allocated (in main->buffer),
|
||||
* The actual workspace is already allocated (in mainp->buffer),
|
||||
* and the space for the pointer lists is allocated too.
|
||||
* This routine just fills in the curiously ordered lists.
|
||||
* This will be repeated at the beginning of each pass.
|
||||
*/
|
||||
{
|
||||
my_main_ptr main = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr mainp = (my_main_ptr) cinfo->main;
|
||||
int ci, i, rgroup;
|
||||
int M = cinfo->min_DCT_v_scaled_size;
|
||||
jpeg_component_info *compptr;
|
||||
@@ -210,10 +212,10 @@ make_funny_pointers (j_decompress_ptr cinfo)
|
||||
ci++, compptr++) {
|
||||
rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
|
||||
cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
|
||||
xbuf0 = main->xbuffer[0][ci];
|
||||
xbuf1 = main->xbuffer[1][ci];
|
||||
xbuf0 = mainp->xbuffer[0][ci];
|
||||
xbuf1 = mainp->xbuffer[1][ci];
|
||||
/* First copy the workspace pointers as-is */
|
||||
buf = main->buffer[ci];
|
||||
buf = mainp->buffer[ci];
|
||||
for (i = 0; i < rgroup * (M + 2); i++) {
|
||||
xbuf0[i] = xbuf1[i] = buf[i];
|
||||
}
|
||||
@@ -240,7 +242,7 @@ set_wraparound_pointers (j_decompress_ptr cinfo)
|
||||
* This changes the pointer list state from top-of-image to the normal state.
|
||||
*/
|
||||
{
|
||||
my_main_ptr main = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr mainp = (my_main_ptr) cinfo->main;
|
||||
int ci, i, rgroup;
|
||||
int M = cinfo->min_DCT_v_scaled_size;
|
||||
jpeg_component_info *compptr;
|
||||
@@ -250,8 +252,8 @@ set_wraparound_pointers (j_decompress_ptr cinfo)
|
||||
ci++, compptr++) {
|
||||
rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
|
||||
cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
|
||||
xbuf0 = main->xbuffer[0][ci];
|
||||
xbuf1 = main->xbuffer[1][ci];
|
||||
xbuf0 = mainp->xbuffer[0][ci];
|
||||
xbuf1 = mainp->xbuffer[1][ci];
|
||||
for (i = 0; i < rgroup; i++) {
|
||||
xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i];
|
||||
xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i];
|
||||
@@ -269,7 +271,7 @@ set_bottom_pointers (j_decompress_ptr cinfo)
|
||||
* Also sets rowgroups_avail to indicate number of nondummy row groups in row.
|
||||
*/
|
||||
{
|
||||
my_main_ptr main = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr mainp = (my_main_ptr) cinfo->main;
|
||||
int ci, i, rgroup, iMCUheight, rows_left;
|
||||
jpeg_component_info *compptr;
|
||||
JSAMPARRAY xbuf;
|
||||
@@ -286,12 +288,12 @@ set_bottom_pointers (j_decompress_ptr cinfo)
|
||||
* so we need only do it once.
|
||||
*/
|
||||
if (ci == 0) {
|
||||
main->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1);
|
||||
mainp->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1);
|
||||
}
|
||||
/* Duplicate the last real sample row rgroup*2 times; this pads out the
|
||||
* last partial rowgroup and ensures at least one full rowgroup of context.
|
||||
*/
|
||||
xbuf = main->xbuffer[main->whichptr][ci];
|
||||
xbuf = mainp->xbuffer[mainp->whichptr][ci];
|
||||
for (i = 0; i < rgroup * 2; i++) {
|
||||
xbuf[rows_left + i] = xbuf[rows_left-1];
|
||||
}
|
||||
@@ -306,27 +308,27 @@ set_bottom_pointers (j_decompress_ptr cinfo)
|
||||
METHODDEF(void)
|
||||
start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
{
|
||||
my_main_ptr main = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr mainp = (my_main_ptr) cinfo->main;
|
||||
|
||||
switch (pass_mode) {
|
||||
case JBUF_PASS_THRU:
|
||||
if (cinfo->upsample->need_context_rows) {
|
||||
main->pub.process_data = process_data_context_main;
|
||||
mainp->pub.process_data = process_data_context_main;
|
||||
make_funny_pointers(cinfo); /* Create the xbuffer[] lists */
|
||||
main->whichptr = 0; /* Read first iMCU row into xbuffer[0] */
|
||||
main->context_state = CTX_PREPARE_FOR_IMCU;
|
||||
main->iMCU_row_ctr = 0;
|
||||
mainp->whichptr = 0; /* Read first iMCU row into xbuffer[0] */
|
||||
mainp->context_state = CTX_PREPARE_FOR_IMCU;
|
||||
mainp->iMCU_row_ctr = 0;
|
||||
mainp->buffer_full = FALSE; /* Mark buffer empty */
|
||||
} else {
|
||||
/* Simple case with no context needed */
|
||||
main->pub.process_data = process_data_simple_main;
|
||||
mainp->pub.process_data = process_data_simple_main;
|
||||
mainp->rowgroup_ctr = mainp->rowgroups_avail; /* Mark buffer empty */
|
||||
}
|
||||
main->buffer_full = FALSE; /* Mark buffer empty */
|
||||
main->rowgroup_ctr = 0;
|
||||
break;
|
||||
#ifdef QUANT_2PASS_SUPPORTED
|
||||
case JBUF_CRANK_DEST:
|
||||
/* For last pass of 2-pass quantization, just crank the postprocessor */
|
||||
main->pub.process_data = process_data_crank_post;
|
||||
mainp->pub.process_data = process_data_crank_post;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
@@ -346,33 +348,24 @@ process_data_simple_main (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
{
|
||||
my_main_ptr main = (my_main_ptr) cinfo->main;
|
||||
JDIMENSION rowgroups_avail;
|
||||
my_main_ptr mainp = (my_main_ptr) cinfo->main;
|
||||
|
||||
/* Read input data if we haven't filled the main buffer yet */
|
||||
if (! main->buffer_full) {
|
||||
if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer))
|
||||
if (mainp->rowgroup_ctr >= mainp->rowgroups_avail) {
|
||||
if (! (*cinfo->coef->decompress_data) (cinfo, mainp->buffer))
|
||||
return; /* suspension forced, can do nothing more */
|
||||
main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
|
||||
mainp->rowgroup_ctr = 0; /* OK, we have an iMCU row to work with */
|
||||
}
|
||||
|
||||
/* There are always min_DCT_scaled_size row groups in an iMCU row. */
|
||||
rowgroups_avail = (JDIMENSION) cinfo->min_DCT_v_scaled_size;
|
||||
/* Note: at the bottom of the image, we may pass extra garbage row groups
|
||||
* to the postprocessor. The postprocessor has to check for bottom
|
||||
* of image anyway (at row resolution), so no point in us doing it too.
|
||||
*/
|
||||
|
||||
/* Feed the postprocessor */
|
||||
(*cinfo->post->post_process_data) (cinfo, main->buffer,
|
||||
&main->rowgroup_ctr, rowgroups_avail,
|
||||
(*cinfo->post->post_process_data) (cinfo, mainp->buffer,
|
||||
&mainp->rowgroup_ctr, mainp->rowgroups_avail,
|
||||
output_buf, out_row_ctr, out_rows_avail);
|
||||
|
||||
/* Has postprocessor consumed all the data yet? If so, mark buffer empty */
|
||||
if (main->rowgroup_ctr >= rowgroups_avail) {
|
||||
main->buffer_full = FALSE;
|
||||
main->rowgroup_ctr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -386,15 +379,15 @@ process_data_context_main (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
{
|
||||
my_main_ptr main = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr mainp = (my_main_ptr) cinfo->main;
|
||||
|
||||
/* Read input data if we haven't filled the main buffer yet */
|
||||
if (! main->buffer_full) {
|
||||
if (! mainp->buffer_full) {
|
||||
if (! (*cinfo->coef->decompress_data) (cinfo,
|
||||
main->xbuffer[main->whichptr]))
|
||||
mainp->xbuffer[mainp->whichptr]))
|
||||
return; /* suspension forced, can do nothing more */
|
||||
main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
|
||||
main->iMCU_row_ctr++; /* count rows received */
|
||||
mainp->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
|
||||
mainp->iMCU_row_ctr++; /* count rows received */
|
||||
}
|
||||
|
||||
/* Postprocessor typically will not swallow all the input data it is handed
|
||||
@@ -402,47 +395,47 @@ process_data_context_main (j_decompress_ptr cinfo,
|
||||
* to exit and restart. This switch lets us keep track of how far we got.
|
||||
* Note that each case falls through to the next on successful completion.
|
||||
*/
|
||||
switch (main->context_state) {
|
||||
switch (mainp->context_state) {
|
||||
case CTX_POSTPONED_ROW:
|
||||
/* Call postprocessor using previously set pointers for postponed row */
|
||||
(*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr],
|
||||
&main->rowgroup_ctr, main->rowgroups_avail,
|
||||
(*cinfo->post->post_process_data) (cinfo, mainp->xbuffer[mainp->whichptr],
|
||||
&mainp->rowgroup_ctr, mainp->rowgroups_avail,
|
||||
output_buf, out_row_ctr, out_rows_avail);
|
||||
if (main->rowgroup_ctr < main->rowgroups_avail)
|
||||
if (mainp->rowgroup_ctr < mainp->rowgroups_avail)
|
||||
return; /* Need to suspend */
|
||||
main->context_state = CTX_PREPARE_FOR_IMCU;
|
||||
mainp->context_state = CTX_PREPARE_FOR_IMCU;
|
||||
if (*out_row_ctr >= out_rows_avail)
|
||||
return; /* Postprocessor exactly filled output buf */
|
||||
/*FALLTHROUGH*/
|
||||
case CTX_PREPARE_FOR_IMCU:
|
||||
/* Prepare to process first M-1 row groups of this iMCU row */
|
||||
main->rowgroup_ctr = 0;
|
||||
main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size - 1);
|
||||
mainp->rowgroup_ctr = 0;
|
||||
mainp->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size - 1);
|
||||
/* Check for bottom of image: if so, tweak pointers to "duplicate"
|
||||
* the last sample row, and adjust rowgroups_avail to ignore padding rows.
|
||||
*/
|
||||
if (main->iMCU_row_ctr == cinfo->total_iMCU_rows)
|
||||
if (mainp->iMCU_row_ctr == cinfo->total_iMCU_rows)
|
||||
set_bottom_pointers(cinfo);
|
||||
main->context_state = CTX_PROCESS_IMCU;
|
||||
mainp->context_state = CTX_PROCESS_IMCU;
|
||||
/*FALLTHROUGH*/
|
||||
case CTX_PROCESS_IMCU:
|
||||
/* Call postprocessor using previously set pointers */
|
||||
(*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr],
|
||||
&main->rowgroup_ctr, main->rowgroups_avail,
|
||||
(*cinfo->post->post_process_data) (cinfo, mainp->xbuffer[mainp->whichptr],
|
||||
&mainp->rowgroup_ctr, mainp->rowgroups_avail,
|
||||
output_buf, out_row_ctr, out_rows_avail);
|
||||
if (main->rowgroup_ctr < main->rowgroups_avail)
|
||||
if (mainp->rowgroup_ctr < mainp->rowgroups_avail)
|
||||
return; /* Need to suspend */
|
||||
/* After the first iMCU, change wraparound pointers to normal state */
|
||||
if (main->iMCU_row_ctr == 1)
|
||||
if (mainp->iMCU_row_ctr == 1)
|
||||
set_wraparound_pointers(cinfo);
|
||||
/* Prepare to load new iMCU row using other xbuffer list */
|
||||
main->whichptr ^= 1; /* 0=>1 or 1=>0 */
|
||||
main->buffer_full = FALSE;
|
||||
mainp->whichptr ^= 1; /* 0=>1 or 1=>0 */
|
||||
mainp->buffer_full = FALSE;
|
||||
/* Still need to process last row group of this iMCU row, */
|
||||
/* which is saved at index M+1 of the other xbuffer */
|
||||
main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 1);
|
||||
main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 2);
|
||||
main->context_state = CTX_POSTPONED_ROW;
|
||||
mainp->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 1);
|
||||
mainp->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 2);
|
||||
mainp->context_state = CTX_POSTPONED_ROW;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,15 +468,15 @@ process_data_crank_post (j_decompress_ptr cinfo,
|
||||
GLOBAL(void)
|
||||
jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
{
|
||||
my_main_ptr main;
|
||||
my_main_ptr mainp;
|
||||
int ci, rgroup, ngroups;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
main = (my_main_ptr)
|
||||
mainp = (my_main_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_main_controller));
|
||||
cinfo->main = (struct jpeg_d_main_controller *) main;
|
||||
main->pub.start_pass = start_pass_main;
|
||||
cinfo->main = &mainp->pub;
|
||||
mainp->pub.start_pass = start_pass_main;
|
||||
|
||||
if (need_full_buffer) /* shouldn't happen */
|
||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||
@@ -497,16 +490,18 @@ jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */
|
||||
ngroups = cinfo->min_DCT_v_scaled_size + 2;
|
||||
} else {
|
||||
/* There are always min_DCT_v_scaled_size row groups in an iMCU row. */
|
||||
ngroups = cinfo->min_DCT_v_scaled_size;
|
||||
mainp->rowgroups_avail = (JDIMENSION) ngroups;
|
||||
}
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
|
||||
cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
|
||||
main->buffer[ci] = (*cinfo->mem->alloc_sarray)
|
||||
mainp->buffer[ci] = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
compptr->width_in_blocks * compptr->DCT_h_scaled_size,
|
||||
compptr->width_in_blocks * ((JDIMENSION) compptr->DCT_h_scaled_size),
|
||||
(JDIMENSION) (rgroup * ngroups));
|
||||
}
|
||||
}
|
||||
|
||||
151
jdmarker.c
151
jdmarker.c
@@ -2,7 +2,7 @@
|
||||
* jdmarker.c
|
||||
*
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2009 by Guido Vollbeding.
|
||||
* Modified 2009-2019 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.
|
||||
*
|
||||
@@ -77,6 +77,7 @@ typedef enum { /* JPEG marker codes */
|
||||
M_APP15 = 0xef,
|
||||
|
||||
M_JPG0 = 0xf0,
|
||||
M_JPG8 = 0xf8,
|
||||
M_JPG13 = 0xfd,
|
||||
M_COM = 0xfe,
|
||||
|
||||
@@ -217,6 +218,7 @@ get_soi (j_decompress_ptr cinfo)
|
||||
/* Set initial assumptions for colorspace etc */
|
||||
|
||||
cinfo->jpeg_color_space = JCS_UNKNOWN;
|
||||
cinfo->color_transform = JCT_NONE;
|
||||
cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */
|
||||
|
||||
cinfo->saw_JFIF_marker = FALSE;
|
||||
@@ -240,7 +242,7 @@ get_sof (j_decompress_ptr cinfo, boolean is_baseline, boolean is_prog,
|
||||
/* Process a SOFn marker */
|
||||
{
|
||||
INT32 length;
|
||||
int c, ci;
|
||||
int c, ci, i;
|
||||
jpeg_component_info * compptr;
|
||||
INPUT_VARS(cinfo);
|
||||
|
||||
@@ -267,8 +269,8 @@ get_sof (j_decompress_ptr cinfo, boolean is_baseline, boolean is_prog,
|
||||
/* We don't support files in which the image height is initially specified */
|
||||
/* as 0 and is later redefined by DNL. As long as we have to check that, */
|
||||
/* might as well have a general sanity check. */
|
||||
if (cinfo->image_height <= 0 || cinfo->image_width <= 0
|
||||
|| cinfo->num_components <= 0)
|
||||
if (cinfo->image_height <= 0 || cinfo->image_width <= 0 ||
|
||||
cinfo->num_components <= 0)
|
||||
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
||||
|
||||
if (length != (cinfo->num_components * 3))
|
||||
@@ -279,10 +281,26 @@ get_sof (j_decompress_ptr cinfo, boolean is_baseline, boolean is_prog,
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * SIZEOF(jpeg_component_info));
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||
INPUT_BYTE(cinfo, c, return FALSE);
|
||||
/* Check to see whether component id has already been seen */
|
||||
/* (in violation of the spec, but unfortunately seen in some */
|
||||
/* files). If so, create "fake" component id equal to the */
|
||||
/* max id seen so far + 1. */
|
||||
for (i = 0, compptr = cinfo->comp_info; i < ci; i++, compptr++) {
|
||||
if (c == compptr->component_id) {
|
||||
compptr = cinfo->comp_info;
|
||||
c = compptr->component_id;
|
||||
compptr++;
|
||||
for (i = 1; i < ci; i++, compptr++) {
|
||||
if (compptr->component_id > c) c = compptr->component_id;
|
||||
}
|
||||
c++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
compptr->component_id = c;
|
||||
compptr->component_index = ci;
|
||||
INPUT_BYTE(cinfo, compptr->component_id, return FALSE);
|
||||
INPUT_BYTE(cinfo, c, return FALSE);
|
||||
compptr->h_samp_factor = (c >> 4) & 15;
|
||||
compptr->v_samp_factor = (c ) & 15;
|
||||
@@ -305,12 +323,12 @@ get_sos (j_decompress_ptr cinfo)
|
||||
/* Process a SOS marker */
|
||||
{
|
||||
INT32 length;
|
||||
int i, ci, n, c, cc;
|
||||
int c, ci, i, n;
|
||||
jpeg_component_info * compptr;
|
||||
INPUT_VARS(cinfo);
|
||||
|
||||
if (! cinfo->marker->saw_SOF)
|
||||
ERREXIT(cinfo, JERR_SOS_NO_SOF);
|
||||
ERREXITS(cinfo, JERR_SOF_BEFORE, "SOS");
|
||||
|
||||
INPUT_2BYTES(cinfo, length, return FALSE);
|
||||
|
||||
@@ -328,24 +346,41 @@ get_sos (j_decompress_ptr cinfo)
|
||||
/* Collect the component-spec parameters */
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
INPUT_BYTE(cinfo, cc, return FALSE);
|
||||
INPUT_BYTE(cinfo, c, return FALSE);
|
||||
|
||||
/* Detect the case where component id's are not unique, and, if so, */
|
||||
/* create a fake component id using the same logic as in get_sof. */
|
||||
/* Note: This also ensures that all of the SOF components are */
|
||||
/* referenced in the single scan case, which prevents access to */
|
||||
/* uninitialized memory in later decoding stages. */
|
||||
for (ci = 0; ci < i; ci++) {
|
||||
if (c == cinfo->cur_comp_info[ci]->component_id) {
|
||||
c = cinfo->cur_comp_info[0]->component_id;
|
||||
for (ci = 1; ci < i; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
if (compptr->component_id > c) c = compptr->component_id;
|
||||
}
|
||||
c++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
if (cc == compptr->component_id)
|
||||
if (c == compptr->component_id)
|
||||
goto id_found;
|
||||
}
|
||||
|
||||
ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
|
||||
ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, c);
|
||||
|
||||
id_found:
|
||||
|
||||
cinfo->cur_comp_info[i] = compptr;
|
||||
INPUT_BYTE(cinfo, c, return FALSE);
|
||||
compptr->dc_tbl_no = (c >> 4) & 15;
|
||||
compptr->ac_tbl_no = (c ) & 15;
|
||||
|
||||
TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,
|
||||
TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, compptr->component_id,
|
||||
compptr->dc_tbl_no, compptr->ac_tbl_no);
|
||||
}
|
||||
|
||||
@@ -480,7 +515,8 @@ get_dht (j_decompress_ptr cinfo)
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
|
||||
|
||||
MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));
|
||||
MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval));
|
||||
if (count > 0)
|
||||
MEMCOPY((*htblptr)->huffval, huffval, count * SIZEOF(UINT8));
|
||||
}
|
||||
|
||||
if (length != 0)
|
||||
@@ -540,14 +576,14 @@ get_dqt (j_decompress_ptr cinfo)
|
||||
count = DCTSIZE2;
|
||||
}
|
||||
|
||||
switch (count) {
|
||||
switch ((int) count) {
|
||||
case (2*2): natural_order = jpeg_natural_order2; break;
|
||||
case (3*3): natural_order = jpeg_natural_order3; break;
|
||||
case (4*4): natural_order = jpeg_natural_order4; break;
|
||||
case (5*5): natural_order = jpeg_natural_order5; break;
|
||||
case (6*6): natural_order = jpeg_natural_order6; break;
|
||||
case (7*7): natural_order = jpeg_natural_order7; break;
|
||||
default: natural_order = jpeg_natural_order; break;
|
||||
default: natural_order = jpeg_natural_order;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -605,6 +641,68 @@ get_dri (j_decompress_ptr cinfo)
|
||||
}
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
get_lse (j_decompress_ptr cinfo)
|
||||
/* Process an LSE marker */
|
||||
{
|
||||
INT32 length;
|
||||
unsigned int tmp;
|
||||
int cid;
|
||||
INPUT_VARS(cinfo);
|
||||
|
||||
if (! cinfo->marker->saw_SOF)
|
||||
ERREXITS(cinfo, JERR_SOF_BEFORE, "LSE");
|
||||
|
||||
if (cinfo->num_components < 3) goto bad;
|
||||
|
||||
INPUT_2BYTES(cinfo, length, return FALSE);
|
||||
|
||||
if (length != 24)
|
||||
ERREXIT(cinfo, JERR_BAD_LENGTH);
|
||||
|
||||
INPUT_BYTE(cinfo, tmp, return FALSE);
|
||||
if (tmp != 0x0D) /* ID inverse transform specification */
|
||||
ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
|
||||
INPUT_2BYTES(cinfo, tmp, return FALSE);
|
||||
if (tmp != MAXJSAMPLE) goto bad; /* MAXTRANS */
|
||||
INPUT_BYTE(cinfo, tmp, return FALSE);
|
||||
if (tmp != 3) goto bad; /* Nt=3 */
|
||||
INPUT_BYTE(cinfo, cid, return FALSE);
|
||||
if (cid != cinfo->comp_info[1].component_id) goto bad;
|
||||
INPUT_BYTE(cinfo, cid, return FALSE);
|
||||
if (cid != cinfo->comp_info[0].component_id) goto bad;
|
||||
INPUT_BYTE(cinfo, cid, return FALSE);
|
||||
if (cid != cinfo->comp_info[2].component_id) goto bad;
|
||||
INPUT_BYTE(cinfo, tmp, return FALSE);
|
||||
if (tmp != 0x80) goto bad; /* F1: CENTER1=1, NORM1=0 */
|
||||
INPUT_2BYTES(cinfo, tmp, return FALSE);
|
||||
if (tmp != 0) goto bad; /* A(1,1)=0 */
|
||||
INPUT_2BYTES(cinfo, tmp, return FALSE);
|
||||
if (tmp != 0) goto bad; /* A(1,2)=0 */
|
||||
INPUT_BYTE(cinfo, tmp, return FALSE);
|
||||
if (tmp != 0) goto bad; /* F2: CENTER2=0, NORM2=0 */
|
||||
INPUT_2BYTES(cinfo, tmp, return FALSE);
|
||||
if (tmp != 1) goto bad; /* A(2,1)=1 */
|
||||
INPUT_2BYTES(cinfo, tmp, return FALSE);
|
||||
if (tmp != 0) goto bad; /* A(2,2)=0 */
|
||||
INPUT_BYTE(cinfo, tmp, return FALSE);
|
||||
if (tmp != 0) goto bad; /* F3: CENTER3=0, NORM3=0 */
|
||||
INPUT_2BYTES(cinfo, tmp, return FALSE);
|
||||
if (tmp != 1) goto bad; /* A(3,1)=1 */
|
||||
INPUT_2BYTES(cinfo, tmp, return FALSE);
|
||||
if (tmp != 0) { /* A(3,2)=0 */
|
||||
bad:
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
|
||||
/* OK, valid transform that we can handle. */
|
||||
cinfo->color_transform = JCT_SUBTRACT_GREEN;
|
||||
|
||||
INPUT_SYNC(cinfo);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Routines for processing APPn and COM markers.
|
||||
* These are either saved in memory or discarded, per application request.
|
||||
@@ -641,12 +739,13 @@ examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data,
|
||||
cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]);
|
||||
cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]);
|
||||
/* Check version.
|
||||
* Major version must be 1, anything else signals an incompatible change.
|
||||
* Major version must be 1 or 2, anything else signals an incompatible
|
||||
* change.
|
||||
* (We used to treat this as an error, but now it's a nonfatal warning,
|
||||
* because some bozo at Hijaak couldn't read the spec.)
|
||||
* Minor version should be 0..2, but process anyway if newer.
|
||||
*/
|
||||
if (cinfo->JFIF_major_version != 1)
|
||||
if (cinfo->JFIF_major_version != 1 && cinfo->JFIF_major_version != 2)
|
||||
WARNMS2(cinfo, JWRN_JFIF_MAJOR,
|
||||
cinfo->JFIF_major_version, cinfo->JFIF_minor_version);
|
||||
/* Generate trace messages */
|
||||
@@ -684,7 +783,6 @@ examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data,
|
||||
default:
|
||||
TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION,
|
||||
GETJOCTET(data[5]), (int) totallen);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* Start of APP0 does not match "JFIF" or "JFXX", or too short */
|
||||
@@ -758,7 +856,6 @@ get_interesting_appn (j_decompress_ptr cinfo)
|
||||
default:
|
||||
/* can't get here unless jpeg_save_markers chooses wrong processor */
|
||||
ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
|
||||
break;
|
||||
}
|
||||
|
||||
/* skip any remaining data -- could be lots */
|
||||
@@ -864,7 +961,6 @@ save_marker (j_decompress_ptr cinfo)
|
||||
default:
|
||||
TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker,
|
||||
(int) (data_length + length));
|
||||
break;
|
||||
}
|
||||
|
||||
/* skip any remaining data -- could be lots */
|
||||
@@ -1085,6 +1181,11 @@ read_markers (j_decompress_ptr cinfo)
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_JPG8:
|
||||
if (! get_lse(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_APP0:
|
||||
case M_APP1:
|
||||
case M_APP2:
|
||||
@@ -1135,7 +1236,6 @@ read_markers (j_decompress_ptr cinfo)
|
||||
* ought to change!
|
||||
*/
|
||||
ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
|
||||
break;
|
||||
}
|
||||
/* Successfully processed marker, so reset state variable */
|
||||
cinfo->unread_marker = 0;
|
||||
@@ -1311,10 +1411,9 @@ jinit_marker_reader (j_decompress_ptr cinfo)
|
||||
int i;
|
||||
|
||||
/* Create subobject in permanent pool */
|
||||
marker = (my_marker_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(my_marker_reader));
|
||||
cinfo->marker = (struct jpeg_marker_reader *) marker;
|
||||
marker = (my_marker_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_marker_reader));
|
||||
cinfo->marker = &marker->pub;
|
||||
/* Initialize public method pointers */
|
||||
marker->pub.reset_marker_reader = reset_marker_reader;
|
||||
marker->pub.read_markers = read_markers;
|
||||
|
||||
102
jdmaster.c
102
jdmaster.c
@@ -2,7 +2,7 @@
|
||||
* jdmaster.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2002-2009 by Guido Vollbeding.
|
||||
* Modified 2002-2019 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,13 +45,26 @@ 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->out_color_components != RGB_PIXELSIZE ||
|
||||
cinfo->color_transform)
|
||||
return FALSE;
|
||||
/* and it only handles 2h1v or 2h2v sampling ratios */
|
||||
if (cinfo->comp_info[0].h_samp_factor != 2 ||
|
||||
@@ -91,7 +104,7 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
*/
|
||||
{
|
||||
#ifdef IDCT_SCALING_SUPPORTED
|
||||
int ci;
|
||||
int ci, ssize;
|
||||
jpeg_component_info *compptr;
|
||||
#endif
|
||||
|
||||
@@ -111,17 +124,21 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
*/
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
int ssize = 1;
|
||||
ssize = 1;
|
||||
if (! cinfo->raw_data_out)
|
||||
while (cinfo->min_DCT_h_scaled_size * ssize <=
|
||||
(cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
|
||||
(cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) == 0) {
|
||||
(cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) ==
|
||||
0) {
|
||||
ssize = ssize * 2;
|
||||
}
|
||||
compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize;
|
||||
ssize = 1;
|
||||
if (! cinfo->raw_data_out)
|
||||
while (cinfo->min_DCT_v_scaled_size * ssize <=
|
||||
(cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
|
||||
(cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) == 0) {
|
||||
(cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) ==
|
||||
0) {
|
||||
ssize = ssize * 2;
|
||||
}
|
||||
compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size * ssize;
|
||||
@@ -131,13 +148,10 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size * 2;
|
||||
else if (compptr->DCT_v_scaled_size > compptr->DCT_h_scaled_size * 2)
|
||||
compptr->DCT_v_scaled_size = compptr->DCT_h_scaled_size * 2;
|
||||
}
|
||||
|
||||
/* Recompute downsampled dimensions of components;
|
||||
* application needs to know these if using raw downsampled data.
|
||||
*/
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
/* Size in samples, after IDCT scaling */
|
||||
compptr->downsampled_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width *
|
||||
@@ -158,11 +172,13 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
cinfo->out_color_components = 1;
|
||||
break;
|
||||
case JCS_RGB:
|
||||
case JCS_BG_RGB:
|
||||
#if RGB_PIXELSIZE != 3
|
||||
cinfo->out_color_components = RGB_PIXELSIZE;
|
||||
break;
|
||||
#endif /* else share code with YCbCr */
|
||||
case JCS_YCbCr:
|
||||
case JCS_BG_YCC:
|
||||
cinfo->out_color_components = 3;
|
||||
break;
|
||||
case JCS_CMYK:
|
||||
@@ -171,7 +187,6 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
break;
|
||||
default: /* else must be same colorspace as in file */
|
||||
cinfo->out_color_components = cinfo->num_components;
|
||||
break;
|
||||
}
|
||||
cinfo->output_components = (cinfo->quantize_colors ? 1 :
|
||||
cinfo->out_color_components);
|
||||
@@ -198,30 +213,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.
|
||||
@@ -234,25 +239,18 @@ prepare_range_limit_table (j_decompress_ptr cinfo)
|
||||
JSAMPLE * table;
|
||||
int i;
|
||||
|
||||
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 */
|
||||
table = (JSAMPLE *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
|
||||
JPOOL_IMAGE, (RANGE_CENTER * 2 + MAXJSAMPLE + 1) * SIZEOF(JSAMPLE));
|
||||
/* First segment of range limit table: limit[x] = 0 for x < 0 */
|
||||
MEMZERO(table, RANGE_CENTER * SIZEOF(JSAMPLE));
|
||||
table += RANGE_CENTER; /* 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 <= MAXJSAMPLE + RANGE_CENTER; 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));
|
||||
}
|
||||
|
||||
|
||||
@@ -275,10 +273,19 @@ master_selection (j_decompress_ptr cinfo)
|
||||
long samplesperrow;
|
||||
JDIMENSION jd_samplesperrow;
|
||||
|
||||
/* For now, precision must match compiled-in value... */
|
||||
if (cinfo->data_precision != BITS_IN_JSAMPLE)
|
||||
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
|
||||
|
||||
/* Initialize dimensions and other stuff */
|
||||
jpeg_calc_output_dimensions(cinfo);
|
||||
prepare_range_limit_table(cinfo);
|
||||
|
||||
/* Sanity check on image dimensions */
|
||||
if (cinfo->output_height <= 0 || cinfo->output_width <= 0 ||
|
||||
cinfo->out_color_components <= 0)
|
||||
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
||||
|
||||
/* Width of an output scanline must be representable as JDIMENSION. */
|
||||
samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;
|
||||
jd_samplesperrow = (JDIMENSION) samplesperrow;
|
||||
@@ -520,10 +527,9 @@ jinit_master_decompress (j_decompress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master;
|
||||
|
||||
master = (my_master_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_decomp_master));
|
||||
cinfo->master = (struct jpeg_decomp_master *) master;
|
||||
master = (my_master_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_decomp_master));
|
||||
cinfo->master = &master->pub;
|
||||
master->pub.prepare_for_output_pass = prepare_for_output_pass;
|
||||
master->pub.finish_output_pass = finish_output_pass;
|
||||
|
||||
|
||||
100
jdmerge.c
100
jdmerge.c
@@ -2,6 +2,7 @@
|
||||
* jdmerge.c
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2013-2019 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.
|
||||
*
|
||||
@@ -23,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.
|
||||
@@ -39,6 +40,12 @@
|
||||
#ifdef UPSAMPLE_MERGING_SUPPORTED
|
||||
|
||||
|
||||
#if RANGE_BITS < 2
|
||||
/* Deliberate syntax err */
|
||||
Sorry, this code requires 2 or more range extension bits.
|
||||
#endif
|
||||
|
||||
|
||||
/* Private subobject */
|
||||
|
||||
typedef struct {
|
||||
@@ -75,45 +82,74 @@ 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;
|
||||
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));
|
||||
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 1.40200 * x */
|
||||
upsample->Cr_r_tab[i] = (int)
|
||||
RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);
|
||||
/* Cb=>B value is nearest int to 1.77200 * x */
|
||||
upsample->Cb_b_tab[i] = (int)
|
||||
RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);
|
||||
/* Cr=>G value is scaled-up -0.71414 * x */
|
||||
upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x;
|
||||
/* Cb=>G value is scaled-up -0.34414 * x */
|
||||
/* Cr=>R value is nearest int to 1.402 * x */
|
||||
upsample->Cr_r_tab[i] = (int) DESCALE(FIX(1.402) * x, SCALEBITS);
|
||||
/* Cb=>B value is nearest int to 1.772 * x */
|
||||
upsample->Cb_b_tab[i] = (int) DESCALE(FIX(1.772) * x, SCALEBITS);
|
||||
/* Cr=>G value is scaled-up -0.714136286 * x */
|
||||
upsample->Cr_g_tab[i] = (- FIX(0.714136286)) * x;
|
||||
/* Cb=>G value is scaled-up -0.344136286 * x */
|
||||
/* We also add in ONE_HALF so that need not do it in inner loop */
|
||||
upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF;
|
||||
upsample->Cb_g_tab[i] = (- FIX(0.344136286)) * x + ONE_HALF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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) DESCALE(FIX(2.804) * x, SCALEBITS);
|
||||
/* Cb=>B value is nearest int to 3.544 * x */
|
||||
upsample->Cb_b_tab[i] = (int) DESCALE(FIX(3.544) * x, 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,10 +407,9 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample;
|
||||
|
||||
upsample = (my_upsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_upsampler));
|
||||
cinfo->upsample = (struct jpeg_upsampler *) upsample;
|
||||
upsample = (my_upsample_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_upsampler));
|
||||
cinfo->upsample = &upsample->pub;
|
||||
upsample->pub.start_pass = start_pass_merged_upsample;
|
||||
upsample->pub.need_context_rows = FALSE;
|
||||
|
||||
@@ -384,9 +419,9 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
|
||||
upsample->pub.upsample = merged_2v_upsample;
|
||||
upsample->upmethod = h2v2_merged_upsample;
|
||||
/* Allocate a spare row buffer */
|
||||
upsample->spare_row = (JSAMPROW)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(size_t) (upsample->out_row_width * SIZEOF(JSAMPLE)));
|
||||
upsample->spare_row = (JSAMPROW) (*cinfo->mem->alloc_large)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(size_t) upsample->out_row_width * SIZEOF(JSAMPLE));
|
||||
} else {
|
||||
upsample->pub.upsample = merged_1v_upsample;
|
||||
upsample->upmethod = h2v1_merged_upsample;
|
||||
@@ -394,6 +429,9 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
|
||||
upsample->spare_row = NULL;
|
||||
}
|
||||
|
||||
if (cinfo->jpeg_color_space == JCS_BG_YCC)
|
||||
build_bg_ycc_rgb_table(cinfo);
|
||||
else
|
||||
build_ycc_rgb_table(cinfo);
|
||||
}
|
||||
|
||||
|
||||
19
jdsample.c
19
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
jerror.c
11
jerror.c
@@ -2,6 +2,7 @@
|
||||
* jerror.c
|
||||
*
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* 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.
|
||||
*
|
||||
@@ -18,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
|
||||
@@ -66,7 +67,7 @@ const char * const jpeg_std_message_table[] = {
|
||||
* or jpeg_destroy) at some point.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
METHODDEF(noreturn_t)
|
||||
error_exit (j_common_ptr cinfo)
|
||||
{
|
||||
/* Always display the message */
|
||||
|
||||
6
jerror.h
6
jerror.h
@@ -2,7 +2,7 @@
|
||||
* jerror.h
|
||||
*
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* Modified 1997-2009 by Guido Vollbeding.
|
||||
* Modified 1997-2018 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.
|
||||
*
|
||||
@@ -84,7 +84,7 @@ JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan")
|
||||
JMESSAGE(JERR_FILE_READ, "Input file read error")
|
||||
JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?")
|
||||
JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet")
|
||||
JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow")
|
||||
JMESSAGE(JERR_HUFF_CLEN_OUTOFBOUNDS, "Huffman code size table out of bounds")
|
||||
JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry")
|
||||
JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels")
|
||||
JMESSAGE(JERR_INPUT_EMPTY, "Empty input file")
|
||||
@@ -106,11 +106,11 @@ JMESSAGE(JERR_QUANT_COMPONENTS,
|
||||
"Cannot quantize more than %d color components")
|
||||
JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors")
|
||||
JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors")
|
||||
JMESSAGE(JERR_SOF_BEFORE, "Invalid JPEG file structure: %s before SOF")
|
||||
JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers")
|
||||
JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker")
|
||||
JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x")
|
||||
JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers")
|
||||
JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF")
|
||||
JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s")
|
||||
JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file")
|
||||
JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file")
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* jfdctflt.c
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2003-2009 by Guido Vollbeding.
|
||||
* Modified 2003-2017 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.
|
||||
*
|
||||
@@ -48,12 +48,14 @@
|
||||
*/
|
||||
|
||||
#if DCTSIZE != 8
|
||||
Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
|
||||
Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* jfdctfst.c
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2003-2009 by Guido Vollbeding.
|
||||
* Modified 2003-2017 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.
|
||||
*
|
||||
@@ -44,7 +44,7 @@
|
||||
*/
|
||||
|
||||
#if DCTSIZE != 8
|
||||
Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
|
||||
Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
795
jfdctint.c
795
jfdctint.c
File diff suppressed because it is too large
Load Diff
64
jidctflt.c
64
jidctflt.c
@@ -2,6 +2,7 @@
|
||||
* jidctflt.c
|
||||
*
|
||||
* Copyright (C) 1994-1998, Thomas G. Lane.
|
||||
* Modified 2010-2017 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.
|
||||
*
|
||||
@@ -49,7 +50,7 @@
|
||||
*/
|
||||
|
||||
#if DCTSIZE != 8
|
||||
Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
|
||||
Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */
|
||||
#endif
|
||||
|
||||
|
||||
@@ -62,6 +63,8 @@
|
||||
|
||||
/*
|
||||
* Perform dequantization and inverse DCT on one block of coefficients.
|
||||
*
|
||||
* cK represents cos(K*pi/16).
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
@@ -79,7 +82,6 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
|
||||
int ctr;
|
||||
FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */
|
||||
SHIFT_TEMPS
|
||||
|
||||
/* Pass 1: process columns from input, store into work array. */
|
||||
|
||||
@@ -152,12 +154,12 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */
|
||||
|
||||
z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */
|
||||
tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */
|
||||
tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */
|
||||
tmp10 = z5 - z12 * ((FAST_FLOAT) 1.082392200); /* 2*(c2-c6) */
|
||||
tmp12 = z5 - z10 * ((FAST_FLOAT) 2.613125930); /* 2*(c2+c6) */
|
||||
|
||||
tmp6 = tmp12 - tmp7; /* phase 2 */
|
||||
tmp5 = tmp11 - tmp6;
|
||||
tmp4 = tmp10 + tmp5;
|
||||
tmp4 = tmp10 - tmp5;
|
||||
|
||||
wsptr[DCTSIZE*0] = tmp0 + tmp7;
|
||||
wsptr[DCTSIZE*7] = tmp0 - tmp7;
|
||||
@@ -165,8 +167,8 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
wsptr[DCTSIZE*6] = tmp1 - tmp6;
|
||||
wsptr[DCTSIZE*2] = tmp2 + tmp5;
|
||||
wsptr[DCTSIZE*5] = tmp2 - tmp5;
|
||||
wsptr[DCTSIZE*4] = tmp3 + tmp4;
|
||||
wsptr[DCTSIZE*3] = tmp3 - tmp4;
|
||||
wsptr[DCTSIZE*3] = tmp3 + tmp4;
|
||||
wsptr[DCTSIZE*4] = tmp3 - tmp4;
|
||||
|
||||
inptr++; /* advance pointers to next column */
|
||||
quantptr++;
|
||||
@@ -174,7 +176,6 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
|
||||
wsptr = workspace;
|
||||
for (ctr = 0; ctr < DCTSIZE; ctr++) {
|
||||
@@ -187,11 +188,14 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp10 = wsptr[0] + wsptr[4];
|
||||
tmp11 = wsptr[0] - wsptr[4];
|
||||
/* 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;
|
||||
@@ -205,35 +209,27 @@ 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 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */
|
||||
tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */
|
||||
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;
|
||||
tmp4 = tmp10 - tmp5;
|
||||
|
||||
/* Final output stage: scale down by a factor of 8 and range-limit */
|
||||
/* Final output stage: float->int conversion and range-limit */
|
||||
|
||||
outptr[0] = range_limit[(int) DESCALE((INT32) (tmp0 + tmp7), 3)
|
||||
& RANGE_MASK];
|
||||
outptr[7] = range_limit[(int) DESCALE((INT32) (tmp0 - tmp7), 3)
|
||||
& RANGE_MASK];
|
||||
outptr[1] = range_limit[(int) DESCALE((INT32) (tmp1 + tmp6), 3)
|
||||
& RANGE_MASK];
|
||||
outptr[6] = range_limit[(int) DESCALE((INT32) (tmp1 - tmp6), 3)
|
||||
& RANGE_MASK];
|
||||
outptr[2] = range_limit[(int) DESCALE((INT32) (tmp2 + tmp5), 3)
|
||||
& RANGE_MASK];
|
||||
outptr[5] = range_limit[(int) DESCALE((INT32) (tmp2 - tmp5), 3)
|
||||
& RANGE_MASK];
|
||||
outptr[4] = range_limit[(int) DESCALE((INT32) (tmp3 + tmp4), 3)
|
||||
& RANGE_MASK];
|
||||
outptr[3] = range_limit[(int) DESCALE((INT32) (tmp3 - tmp4), 3)
|
||||
& 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 */
|
||||
}
|
||||
|
||||
91
jidctfst.c
91
jidctfst.c
@@ -2,6 +2,7 @@
|
||||
* jidctfst.c
|
||||
*
|
||||
* Copyright (C) 1994-1998, Thomas G. Lane.
|
||||
* Modified 2015-2017 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,7 +46,7 @@
|
||||
*/
|
||||
|
||||
#if DCTSIZE != 8
|
||||
Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
|
||||
Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
553
jidctint.c
553
jidctint.c
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@
|
||||
* jinclude.h
|
||||
*
|
||||
* Copyright (C) 1991-1994, Thomas G. Lane.
|
||||
* Modified 2017 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.
|
||||
*
|
||||
@@ -83,9 +84,14 @@
|
||||
* The modules that use fread() and fwrite() always invoke them through
|
||||
* these macros. On some systems you may need to twiddle the argument casts.
|
||||
* CAUTION: argument order is different from underlying functions!
|
||||
*
|
||||
* Furthermore, macros are provided for fflush() and ferror() in order
|
||||
* to facilitate adaption by applications using an own FILE class.
|
||||
*/
|
||||
|
||||
#define JFREAD(file,buf,sizeofbuf) \
|
||||
((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
||||
#define JFWRITE(file,buf,sizeofbuf) \
|
||||
((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
||||
#define JFFLUSH(file) fflush(file)
|
||||
#define JFERROR(file) ferror(file)
|
||||
|
||||
65
jmemmgr.c
65
jmemmgr.c
@@ -2,6 +2,7 @@
|
||||
* jmemmgr.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2011-2019 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.
|
||||
*
|
||||
@@ -129,7 +130,7 @@ typedef struct {
|
||||
jvirt_barray_ptr virt_barray_list;
|
||||
|
||||
/* This counts total space obtained from jpeg_get_small/large */
|
||||
long total_space_allocated;
|
||||
size_t total_space_allocated;
|
||||
|
||||
/* alloc_sarray and alloc_barray set this value for use by virtual
|
||||
* array routines.
|
||||
@@ -194,7 +195,7 @@ print_mem_stats (j_common_ptr cinfo, int pool_id)
|
||||
* This is helpful because message parm array can't handle longs.
|
||||
*/
|
||||
fprintf(stderr, "Freeing pool %d, total space = %ld\n",
|
||||
pool_id, mem->total_space_allocated);
|
||||
pool_id, (long) mem->total_space_allocated);
|
||||
|
||||
for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL;
|
||||
lhdr_ptr = lhdr_ptr->hdr.next) {
|
||||
@@ -213,7 +214,7 @@ print_mem_stats (j_common_ptr cinfo, int pool_id)
|
||||
#endif /* MEM_STATS */
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
LOCAL(noreturn_t)
|
||||
out_of_memory (j_common_ptr cinfo, int which)
|
||||
/* Report an out-of-memory error and stop execution */
|
||||
/* If we compiled MEM_STATS support, report alloc requests before dying */
|
||||
@@ -259,11 +260,11 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
small_pool_ptr hdr_ptr, prev_hdr_ptr;
|
||||
char * data_ptr;
|
||||
size_t odd_bytes, min_request, slop;
|
||||
char * data_ptr;
|
||||
|
||||
/* Check for unsatisfiable request (do now to ensure no overflow below) */
|
||||
if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr)))
|
||||
if (sizeofobject > (size_t) MAX_ALLOC_CHUNK - SIZEOF(small_pool_hdr))
|
||||
out_of_memory(cinfo, 1); /* request exceeds malloc's ability */
|
||||
|
||||
/* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */
|
||||
@@ -292,8 +293,8 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
else
|
||||
slop = extra_pool_slop[pool_id];
|
||||
/* Don't ask for more than MAX_ALLOC_CHUNK */
|
||||
if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request))
|
||||
slop = (size_t) (MAX_ALLOC_CHUNK-min_request);
|
||||
if (slop > (size_t) MAX_ALLOC_CHUNK - min_request)
|
||||
slop = (size_t) MAX_ALLOC_CHUNK - min_request;
|
||||
/* Try to get space, if fail reduce slop and try again */
|
||||
for (;;) {
|
||||
hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop);
|
||||
@@ -347,7 +348,7 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
size_t odd_bytes;
|
||||
|
||||
/* Check for unsatisfiable request (do now to ensure no overflow below) */
|
||||
if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)))
|
||||
if (sizeofobject > (size_t) MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr))
|
||||
out_of_memory(cinfo, 3); /* request exceeds malloc's ability */
|
||||
|
||||
/* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */
|
||||
@@ -403,7 +404,7 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
long ltemp;
|
||||
|
||||
/* Calculate max # of rows allowed in one allocation chunk */
|
||||
ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) /
|
||||
ltemp = (MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr)) /
|
||||
((long) samplesperrow * SIZEOF(JSAMPLE));
|
||||
if (ltemp <= 0)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
@@ -415,15 +416,14 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
|
||||
/* Get space for row pointers (small object) */
|
||||
result = (JSAMPARRAY) alloc_small(cinfo, pool_id,
|
||||
(size_t) (numrows * SIZEOF(JSAMPROW)));
|
||||
(size_t) numrows * SIZEOF(JSAMPROW));
|
||||
|
||||
/* Get the rows themselves (large objects) */
|
||||
currow = 0;
|
||||
while (currow < numrows) {
|
||||
rowsperchunk = MIN(rowsperchunk, numrows - currow);
|
||||
workspace = (JSAMPROW) alloc_large(cinfo, pool_id,
|
||||
(size_t) ((size_t) rowsperchunk * (size_t) samplesperrow
|
||||
* SIZEOF(JSAMPLE)));
|
||||
(size_t) rowsperchunk * (size_t) samplesperrow * SIZEOF(JSAMPLE));
|
||||
for (i = rowsperchunk; i > 0; i--) {
|
||||
result[currow++] = workspace;
|
||||
workspace += samplesperrow;
|
||||
@@ -451,7 +451,7 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
|
||||
long ltemp;
|
||||
|
||||
/* Calculate max # of rows allowed in one allocation chunk */
|
||||
ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) /
|
||||
ltemp = (MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr)) /
|
||||
((long) blocksperrow * SIZEOF(JBLOCK));
|
||||
if (ltemp <= 0)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
@@ -463,15 +463,14 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
|
||||
|
||||
/* Get space for row pointers (small object) */
|
||||
result = (JBLOCKARRAY) alloc_small(cinfo, pool_id,
|
||||
(size_t) (numrows * SIZEOF(JBLOCKROW)));
|
||||
(size_t) numrows * SIZEOF(JBLOCKROW));
|
||||
|
||||
/* Get the rows themselves (large objects) */
|
||||
currow = 0;
|
||||
while (currow < numrows) {
|
||||
rowsperchunk = MIN(rowsperchunk, numrows - currow);
|
||||
workspace = (JBLOCKROW) alloc_large(cinfo, pool_id,
|
||||
(size_t) ((size_t) rowsperchunk * (size_t) blocksperrow
|
||||
* SIZEOF(JBLOCK)));
|
||||
(size_t) rowsperchunk * (size_t) blocksperrow * SIZEOF(JBLOCK));
|
||||
for (i = rowsperchunk; i > 0; i--) {
|
||||
result[currow++] = workspace;
|
||||
workspace += blocksperrow;
|
||||
@@ -584,8 +583,8 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
/* Allocate the in-memory buffers for any unrealized virtual arrays */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
long space_per_minheight, maximum_space, avail_mem;
|
||||
long minheights, max_minheights;
|
||||
long bytesperrow, space_per_minheight, maximum_space;
|
||||
long avail_mem, minheights, max_minheights;
|
||||
jvirt_sarray_ptr sptr;
|
||||
jvirt_barray_ptr bptr;
|
||||
|
||||
@@ -597,18 +596,16 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
maximum_space = 0;
|
||||
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
||||
if (sptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
space_per_minheight += (long) sptr->maxaccess *
|
||||
(long) sptr->samplesperrow * SIZEOF(JSAMPLE);
|
||||
maximum_space += (long) sptr->rows_in_array *
|
||||
(long) sptr->samplesperrow * SIZEOF(JSAMPLE);
|
||||
bytesperrow = (long) sptr->samplesperrow * SIZEOF(JSAMPLE);
|
||||
space_per_minheight += (long) sptr->maxaccess * bytesperrow;
|
||||
maximum_space += (long) sptr->rows_in_array * bytesperrow;
|
||||
}
|
||||
}
|
||||
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
||||
if (bptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
space_per_minheight += (long) bptr->maxaccess *
|
||||
(long) bptr->blocksperrow * SIZEOF(JBLOCK);
|
||||
maximum_space += (long) bptr->rows_in_array *
|
||||
(long) bptr->blocksperrow * SIZEOF(JBLOCK);
|
||||
bytesperrow = (long) bptr->blocksperrow * SIZEOF(JBLOCK);
|
||||
space_per_minheight += (long) bptr->maxaccess * bytesperrow;
|
||||
maximum_space += (long) bptr->rows_in_array * bytesperrow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -617,7 +614,7 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
|
||||
/* Determine amount of memory to actually use; this is system-dependent. */
|
||||
avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space,
|
||||
mem->total_space_allocated);
|
||||
(long) mem->total_space_allocated);
|
||||
|
||||
/* If the maximum space needed is available, make all the buffers full
|
||||
* height; otherwise parcel it out with the same number of minheights
|
||||
@@ -693,7 +690,7 @@ do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
|
||||
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
|
||||
|
||||
bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE);
|
||||
file_offset = ptr->cur_start_row * bytesperrow;
|
||||
file_offset = (long) ptr->cur_start_row * bytesperrow;
|
||||
/* Loop to read or write each allocation chunk in mem_buffer */
|
||||
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
/* One chunk, but check for short chunk at end of buffer */
|
||||
@@ -726,7 +723,7 @@ do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
|
||||
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
|
||||
|
||||
bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK);
|
||||
file_offset = ptr->cur_start_row * bytesperrow;
|
||||
file_offset = (long) ptr->cur_start_row * bytesperrow;
|
||||
/* Loop to read or write each allocation chunk in mem_buffer */
|
||||
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
/* One chunk, but check for short chunk at end of buffer */
|
||||
@@ -770,7 +767,7 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
|
||||
/* Make the desired part of the virtual array accessible */
|
||||
if (start_row < ptr->cur_start_row ||
|
||||
end_row > ptr->cur_start_row+ptr->rows_in_mem) {
|
||||
end_row > ptr->cur_start_row + ptr->rows_in_mem) {
|
||||
if (! ptr->b_s_open)
|
||||
ERREXIT(cinfo, JERR_VIRTUAL_BUG);
|
||||
/* Flush old buffer contents if necessary */
|
||||
@@ -821,7 +818,7 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
|
||||
end_row -= ptr->cur_start_row;
|
||||
while (undef_row < end_row) {
|
||||
jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow);
|
||||
FMEMZERO((void FAR *) ptr->mem_buffer[undef_row], bytesperrow);
|
||||
undef_row++;
|
||||
}
|
||||
} else {
|
||||
@@ -855,7 +852,7 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
|
||||
/* Make the desired part of the virtual array accessible */
|
||||
if (start_row < ptr->cur_start_row ||
|
||||
end_row > ptr->cur_start_row+ptr->rows_in_mem) {
|
||||
end_row > ptr->cur_start_row + ptr->rows_in_mem) {
|
||||
if (! ptr->b_s_open)
|
||||
ERREXIT(cinfo, JERR_VIRTUAL_BUG);
|
||||
/* Flush old buffer contents if necessary */
|
||||
@@ -906,7 +903,7 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
|
||||
end_row -= ptr->cur_start_row;
|
||||
while (undef_row < end_row) {
|
||||
jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow);
|
||||
FMEMZERO((void FAR *) ptr->mem_buffer[undef_row], bytesperrow);
|
||||
undef_row++;
|
||||
}
|
||||
} else {
|
||||
@@ -1092,7 +1089,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
||||
mem->total_space_allocated = SIZEOF(my_memory_mgr);
|
||||
|
||||
/* Declare ourselves open for business */
|
||||
cinfo->mem = & mem->pub;
|
||||
cinfo->mem = &mem->pub;
|
||||
|
||||
/* Check for an environment variable JPEGMEM; if found, override the
|
||||
* default max_memory setting from jpeg_mem_init. Note that the
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* jmemnobs.c
|
||||
*
|
||||
* Copyright (C) 1992-1996, Thomas G. Lane.
|
||||
* Modified 2019 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.
|
||||
*
|
||||
@@ -12,7 +13,7 @@
|
||||
* This is very portable in the sense that it'll compile on almost anything,
|
||||
* but you'd better have lots of main memory (or virtual memory) if you want
|
||||
* to process big images.
|
||||
* Note that the max_memory_to_use option is ignored by this implementation.
|
||||
* Note that the max_memory_to_use option is respected by this implementation.
|
||||
*/
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
@@ -66,13 +67,16 @@ jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
|
||||
|
||||
/*
|
||||
* This routine computes the total memory space available for allocation.
|
||||
* Here we always say, "we got all you want bud!"
|
||||
*/
|
||||
|
||||
GLOBAL(long)
|
||||
jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
|
||||
long max_bytes_needed, long already_allocated)
|
||||
{
|
||||
if (cinfo->mem->max_memory_to_use)
|
||||
return cinfo->mem->max_memory_to_use - already_allocated;
|
||||
|
||||
/* Here we say, "we got all you want bud!" */
|
||||
return max_bytes_needed;
|
||||
}
|
||||
|
||||
|
||||
105
jmorecfg.h
105
jmorecfg.h
@@ -2,7 +2,7 @@
|
||||
* jmorecfg.h
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 1997-2009 by Guido Vollbeding.
|
||||
* Modified 1997-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.
|
||||
*
|
||||
@@ -15,13 +15,22 @@
|
||||
/*
|
||||
* Define BITS_IN_JSAMPLE as either
|
||||
* 8 for 8-bit sample values (the usual setting)
|
||||
* 9 for 9-bit sample values
|
||||
* 10 for 10-bit sample values
|
||||
* 11 for 11-bit sample values
|
||||
* 12 for 12-bit sample values
|
||||
* Only 8 and 12 are legal data precisions for lossy JPEG according to the
|
||||
* JPEG standard, and the IJG code does not support anything else!
|
||||
* We do not support run-time selection of data precision, sorry.
|
||||
* Only 8, 9, 10, 11, and 12 bits sample data precision are supported for
|
||||
* full-feature DCT processing. Further depths up to 16-bit may be added
|
||||
* later for the lossless modes of operation.
|
||||
* Run-time selection and conversion of data precision will be added later
|
||||
* and are currently not supported, sorry.
|
||||
* Exception: The transcoding part (jpegtran) supports all settings in a
|
||||
* single instance, since it operates on the level of DCT coefficients and
|
||||
* not sample values. The DCT coefficients are of the same type (16 bits)
|
||||
* in all cases (see below).
|
||||
*/
|
||||
|
||||
#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
|
||||
#define BITS_IN_JSAMPLE 8 /* use 8, 9, 10, 11, or 12 */
|
||||
|
||||
|
||||
/*
|
||||
@@ -77,6 +86,48 @@ typedef char JSAMPLE;
|
||||
#endif /* BITS_IN_JSAMPLE == 8 */
|
||||
|
||||
|
||||
#if BITS_IN_JSAMPLE == 9
|
||||
/* JSAMPLE should be the smallest type that will hold the values 0..511.
|
||||
* On nearly all machines "short" will do nicely.
|
||||
*/
|
||||
|
||||
typedef short JSAMPLE;
|
||||
#define GETJSAMPLE(value) ((int) (value))
|
||||
|
||||
#define MAXJSAMPLE 511
|
||||
#define CENTERJSAMPLE 256
|
||||
|
||||
#endif /* BITS_IN_JSAMPLE == 9 */
|
||||
|
||||
|
||||
#if BITS_IN_JSAMPLE == 10
|
||||
/* JSAMPLE should be the smallest type that will hold the values 0..1023.
|
||||
* On nearly all machines "short" will do nicely.
|
||||
*/
|
||||
|
||||
typedef short JSAMPLE;
|
||||
#define GETJSAMPLE(value) ((int) (value))
|
||||
|
||||
#define MAXJSAMPLE 1023
|
||||
#define CENTERJSAMPLE 512
|
||||
|
||||
#endif /* BITS_IN_JSAMPLE == 10 */
|
||||
|
||||
|
||||
#if BITS_IN_JSAMPLE == 11
|
||||
/* JSAMPLE should be the smallest type that will hold the values 0..2047.
|
||||
* On nearly all machines "short" will do nicely.
|
||||
*/
|
||||
|
||||
typedef short JSAMPLE;
|
||||
#define GETJSAMPLE(value) ((int) (value))
|
||||
|
||||
#define MAXJSAMPLE 2047
|
||||
#define CENTERJSAMPLE 1024
|
||||
|
||||
#endif /* BITS_IN_JSAMPLE == 11 */
|
||||
|
||||
|
||||
#if BITS_IN_JSAMPLE == 12
|
||||
/* JSAMPLE should be the smallest type that will hold the values 0..4095.
|
||||
* On nearly all machines "short" will do nicely.
|
||||
@@ -210,6 +261,26 @@ typedef unsigned int JDIMENSION;
|
||||
#endif
|
||||
|
||||
|
||||
/* The noreturn type identifier is used to declare functions
|
||||
* which cannot return.
|
||||
* Compilers can thus create more optimized code and perform
|
||||
* better checks for warnings and errors.
|
||||
* Static analyzer tools can make improved inferences about
|
||||
* execution paths and are prevented from giving false alerts.
|
||||
*
|
||||
* Unfortunately, the proposed specifications of corresponding
|
||||
* extensions in the Dec 2011 ISO C standard revision (C11),
|
||||
* GCC, MSVC, etc. are not viable.
|
||||
* Thus we introduce a user defined type to declare noreturn
|
||||
* functions at least for clarity. A proper compiler would
|
||||
* have a suitable noreturn type to match in place of void.
|
||||
*/
|
||||
|
||||
#ifndef HAVE_NORETURN_T
|
||||
typedef void noreturn_t;
|
||||
#endif
|
||||
|
||||
|
||||
/* Here is the pseudo-keyword for declaring pointers that must be "far"
|
||||
* on 80x86 machines. Most of the specialized coding for 80x86 is handled
|
||||
* by just saying "FAR *" where such a pointer is needed. In a few places
|
||||
@@ -233,14 +304,19 @@ typedef unsigned int JDIMENSION;
|
||||
*/
|
||||
|
||||
#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;
|
||||
#endif
|
||||
#ifndef FALSE /* in case these macros already exist */
|
||||
#define FALSE 0 /* values of boolean */
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#else
|
||||
typedef enum { FALSE = 0, TRUE = 1 } boolean;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ -278,11 +354,12 @@ typedef int boolean;
|
||||
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
|
||||
#define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW)*/
|
||||
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
|
||||
/* Note: if you selected 12-bit data precision, it is dangerous to turn off
|
||||
* ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
|
||||
* precision, so jchuff.c normally uses entropy optimization to compute
|
||||
* usable tables for higher precision. If you don't want to do optimization,
|
||||
* you'll have to supply different default Huffman tables.
|
||||
/* Note: if you selected more than 8-bit data precision, it is dangerous to
|
||||
* turn off ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only
|
||||
* good for 8-bit precision, so arithmetic coding is recommended for higher
|
||||
* precision. The Huffman encoder normally uses entropy optimization to
|
||||
* compute usable tables for higher precision. Otherwise, you'll have to
|
||||
* supply different default Huffman tables.
|
||||
* The exact same statements apply for progressive JPEG: the default tables
|
||||
* don't work for progressive mode. (This may get fixed, however.)
|
||||
*/
|
||||
@@ -293,7 +370,7 @@ typedef int boolean;
|
||||
#define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
|
||||
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
|
||||
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
|
||||
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
|
||||
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? (Requires DCT_ISLOW)*/
|
||||
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
|
||||
#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
|
||||
#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
|
||||
@@ -312,9 +389,7 @@ typedef int boolean;
|
||||
* the offsets will also change the order in which colormap data is organized.
|
||||
* RESTRICTIONS:
|
||||
* 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
|
||||
* 2. These macros only affect RGB<=>YCbCr color conversion, so they are not
|
||||
* useful if you are using JPEG color spaces other than YCbCr or grayscale.
|
||||
* 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
|
||||
* 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
|
||||
* is not 3 (they don't understand about dummy color components!). So you
|
||||
* can't use color quantization if you change that value.
|
||||
*/
|
||||
|
||||
61
jpegint.h
61
jpegint.h
@@ -2,7 +2,7 @@
|
||||
* jpegint.h
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 1997-2009 by Guido Vollbeding.
|
||||
* Modified 1997-2019 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.
|
||||
*
|
||||
@@ -211,8 +211,8 @@ struct jpeg_marker_reader {
|
||||
/* Entropy decoding */
|
||||
struct jpeg_entropy_decoder {
|
||||
JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
|
||||
JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data));
|
||||
JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, JBLOCKROW *MCU_data));
|
||||
JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
|
||||
};
|
||||
|
||||
/* Inverse DCT (also performs dequantization) */
|
||||
@@ -260,6 +260,19 @@ struct jpeg_color_quantizer {
|
||||
};
|
||||
|
||||
|
||||
/* Definition of range extension bits for decompression processes.
|
||||
* See the comments with prepare_range_limit_table (in jdmaster.c)
|
||||
* for more info.
|
||||
* The recommended default value for normal applications is 2.
|
||||
* Applications with special requirements may use a different value.
|
||||
* For example, Ghostscript wants to use 3 for proper handling of
|
||||
* wacky images with oversize coefficient values.
|
||||
*/
|
||||
|
||||
#define RANGE_BITS 2
|
||||
#define RANGE_CENTER (CENTERJSAMPLE << RANGE_BITS)
|
||||
|
||||
|
||||
/* Miscellaneous useful macros */
|
||||
|
||||
#undef MAX
|
||||
@@ -289,6 +302,13 @@ struct jpeg_color_quantizer {
|
||||
#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
|
||||
#endif
|
||||
|
||||
/* Descale and correctly round an INT32 value that's scaled by N bits.
|
||||
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
|
||||
* the fudge factor is correct for either sign of X.
|
||||
*/
|
||||
|
||||
#define DESCALE(x,n) RIGHT_SHIFT((x) + ((INT32) 1 << ((n)-1)), n)
|
||||
|
||||
|
||||
/* Short forms of external names for systems with brain-damaged linkers. */
|
||||
|
||||
@@ -321,21 +341,41 @@ struct jpeg_color_quantizer {
|
||||
#define jinit_memory_mgr jIMemMgr
|
||||
#define jdiv_round_up jDivRound
|
||||
#define jround_up jRound
|
||||
#define jzero_far jZeroFar
|
||||
#define jcopy_sample_rows jCopySamples
|
||||
#define jcopy_block_row jCopyBlocks
|
||||
#define jzero_far jZeroFar
|
||||
#define jpeg_zigzag_order jZIGTable
|
||||
#define jpeg_natural_order jZAGTable
|
||||
#define jpeg_natural_order7 jZAGTable7
|
||||
#define jpeg_natural_order6 jZAGTable6
|
||||
#define jpeg_natural_order5 jZAGTable5
|
||||
#define jpeg_natural_order4 jZAGTable4
|
||||
#define jpeg_natural_order3 jZAGTable3
|
||||
#define jpeg_natural_order2 jZAGTable2
|
||||
#define jpeg_natural_order7 jZAG7Table
|
||||
#define jpeg_natural_order6 jZAG6Table
|
||||
#define jpeg_natural_order5 jZAG5Table
|
||||
#define jpeg_natural_order4 jZAG4Table
|
||||
#define jpeg_natural_order3 jZAG3Table
|
||||
#define jpeg_natural_order2 jZAG2Table
|
||||
#define jpeg_aritab jAriTab
|
||||
#endif /* NEED_SHORT_EXTERNAL_NAMES */
|
||||
|
||||
|
||||
/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays
|
||||
* and coefficient-block arrays. This won't work on 80x86 because the arrays
|
||||
* are FAR and we're assuming a small-pointer memory model. However, some
|
||||
* DOS compilers provide far-pointer versions of memcpy() and memset() even
|
||||
* in the small-model libraries. These will be used if USE_FMEM is defined.
|
||||
* Otherwise, the routines in jutils.c do it the hard way.
|
||||
*/
|
||||
|
||||
#ifndef NEED_FAR_POINTERS /* normal case, same as regular macro */
|
||||
#define FMEMZERO(target,size) MEMZERO(target,size)
|
||||
#else /* 80x86 case */
|
||||
#ifdef USE_FMEM
|
||||
#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size))
|
||||
#else
|
||||
EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero));
|
||||
#define FMEMZERO(target,size) jzero_far(target, size)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Compression module initialization routines */
|
||||
EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo,
|
||||
@@ -381,7 +421,6 @@ EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,
|
||||
int num_rows, JDIMENSION num_cols));
|
||||
EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
JDIMENSION num_blocks));
|
||||
EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero));
|
||||
/* Constant tables in jutils.c */
|
||||
#if 0 /* This table is not actually needed in v6a */
|
||||
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
|
||||
|
||||
69
jpeglib.h
69
jpeglib.h
@@ -2,7 +2,7 @@
|
||||
* jpeglib.h
|
||||
*
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2002-2009 by Guido Vollbeding.
|
||||
* Modified 2002-2019 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.
|
||||
*
|
||||
@@ -33,19 +33,21 @@ extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Version ID for the JPEG library.
|
||||
* Might be useful for tests like "#if JPEG_LIB_VERSION >= 80".
|
||||
/* Version IDs for the JPEG library.
|
||||
* Might be useful for tests like "#if JPEG_LIB_VERSION >= 90".
|
||||
*/
|
||||
|
||||
#define JPEG_LIB_VERSION 80 /* Version 8.0 */
|
||||
#define JPEG_LIB_VERSION 90 /* Compatibility version 9.0 */
|
||||
#define JPEG_LIB_VERSION_MAJOR 9
|
||||
#define JPEG_LIB_VERSION_MINOR 4
|
||||
|
||||
|
||||
/* Various constants determining the sizes of things.
|
||||
* All of these are specified by the JPEG standard, so don't change them
|
||||
* if you want to be compatible.
|
||||
* All of these are specified by the JPEG standard,
|
||||
* so don't change them if you want to be compatible.
|
||||
*/
|
||||
|
||||
#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */
|
||||
#define DCTSIZE 8 /* The basic DCT block is 8x8 coefficients */
|
||||
#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
|
||||
#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */
|
||||
#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */
|
||||
@@ -155,16 +157,21 @@ typedef struct {
|
||||
/* The downsampled dimensions are the component's actual, unpadded number
|
||||
* of samples at the main buffer (preprocessing/compression interface);
|
||||
* DCT scaling is included, so
|
||||
* downsampled_width = ceil(image_width * Hi/Hmax * DCT_h_scaled_size/DCTSIZE)
|
||||
* downsampled_width =
|
||||
* ceil(image_width * Hi/Hmax * DCT_h_scaled_size/block_size)
|
||||
* and similarly for height.
|
||||
*/
|
||||
JDIMENSION downsampled_width; /* actual width in samples */
|
||||
JDIMENSION downsampled_height; /* actual height in samples */
|
||||
/* This flag is used only for decompression. In cases where some of the
|
||||
* components will be ignored (eg grayscale output from YCbCr image),
|
||||
* we can skip most computations for the unused components.
|
||||
/* For decompression, in cases where some of the components will be
|
||||
* ignored (eg grayscale output from YCbCr image), we can skip most
|
||||
* computations for the unused components.
|
||||
* For compression, some of the components will need further quantization
|
||||
* scale by factor of 2 after DCT (eg BG_YCC output from normal RGB input).
|
||||
* The field is first set TRUE for decompression, FALSE for compression
|
||||
* in initial_setup, and then adapted in color conversion setup.
|
||||
*/
|
||||
boolean component_needed; /* do we need the value of this component? */
|
||||
boolean component_needed;
|
||||
|
||||
/* These values are computed before starting a scan of the component. */
|
||||
/* The decompressor output side may not use these variables. */
|
||||
@@ -213,12 +220,21 @@ struct jpeg_marker_struct {
|
||||
typedef enum {
|
||||
JCS_UNKNOWN, /* error/unspecified */
|
||||
JCS_GRAYSCALE, /* monochrome */
|
||||
JCS_RGB, /* red/green/blue */
|
||||
JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */
|
||||
JCS_RGB, /* red/green/blue, standard RGB (sRGB) */
|
||||
JCS_YCbCr, /* Y/Cb/Cr (also known as YUV), standard YCC */
|
||||
JCS_CMYK, /* C/M/Y/K */
|
||||
JCS_YCCK /* Y/Cb/Cr/K */
|
||||
JCS_YCCK, /* Y/Cb/Cr/K */
|
||||
JCS_BG_RGB, /* big gamut red/green/blue, bg-sRGB */
|
||||
JCS_BG_YCC /* big gamut Y/Cb/Cr, bg-sYCC */
|
||||
} J_COLOR_SPACE;
|
||||
|
||||
/* Supported color transforms. */
|
||||
|
||||
typedef enum {
|
||||
JCT_NONE = 0,
|
||||
JCT_SUBTRACT_GREEN = 1
|
||||
} J_COLOR_TRANSFORM;
|
||||
|
||||
/* DCT/IDCT algorithm options. */
|
||||
|
||||
typedef enum {
|
||||
@@ -368,6 +384,9 @@ struct jpeg_compress_struct {
|
||||
UINT16 Y_density; /* Vertical pixel density */
|
||||
boolean write_Adobe_marker; /* should an Adobe marker be written? */
|
||||
|
||||
J_COLOR_TRANSFORM color_transform;
|
||||
/* Color transform identifier, writes LSE marker if nonzero */
|
||||
|
||||
/* State variable: index of next scanline to be written to
|
||||
* jpeg_write_scanlines(). Application may use this to control its
|
||||
* processing loop, e.g., "while (next_scanline < image_height)".
|
||||
@@ -392,8 +411,8 @@ struct jpeg_compress_struct {
|
||||
JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */
|
||||
/* The coefficient controller receives data in units of MCU rows as defined
|
||||
* for fully interleaved scans (whether the JPEG file is interleaved or not).
|
||||
* There are v_samp_factor * DCTSIZE sample rows of each component in an
|
||||
* "iMCU" (interleaved MCU) row.
|
||||
* There are v_samp_factor * DCT_v_scaled_size sample rows of each component
|
||||
* in an "iMCU" (interleaved MCU) row.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -587,6 +606,9 @@ struct jpeg_decompress_struct {
|
||||
boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */
|
||||
UINT8 Adobe_transform; /* Color transform code from Adobe marker */
|
||||
|
||||
J_COLOR_TRANSFORM color_transform;
|
||||
/* Color transform identifier derived from LSE marker, otherwise zero */
|
||||
|
||||
boolean CCIR601_sampling; /* TRUE=first samples are cosited */
|
||||
|
||||
/* Aside from the specific data retained from APPn markers known to the
|
||||
@@ -614,7 +636,7 @@ struct jpeg_decompress_struct {
|
||||
* in fully interleaved JPEG scans, but are used whether the scan is
|
||||
* interleaved or not. We define an iMCU row as v_samp_factor DCT block
|
||||
* rows of each component. Therefore, the IDCT output contains
|
||||
* v_samp_factor*DCT_v_scaled_size sample rows of a component per iMCU row.
|
||||
* v_samp_factor * DCT_v_scaled_size sample rows of a component per iMCU row.
|
||||
*/
|
||||
|
||||
JSAMPLE * sample_range_limit; /* table for fast range-limiting */
|
||||
@@ -679,7 +701,7 @@ struct jpeg_decompress_struct {
|
||||
|
||||
struct jpeg_error_mgr {
|
||||
/* Error exit handler: does not return to caller */
|
||||
JMETHOD(void, error_exit, (j_common_ptr cinfo));
|
||||
JMETHOD(noreturn_t, error_exit, (j_common_ptr cinfo));
|
||||
/* Conditionally emit a trace or warning message */
|
||||
JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level));
|
||||
/* Routine that actually outputs a trace or error message */
|
||||
@@ -887,6 +909,7 @@ typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
|
||||
#define jpeg_suppress_tables jSuppressTables
|
||||
#define jpeg_alloc_quant_table jAlcQTable
|
||||
#define jpeg_alloc_huff_table jAlcHTable
|
||||
#define jpeg_std_huff_table jStdHTable
|
||||
#define jpeg_start_compress jStrtCompress
|
||||
#define jpeg_write_scanlines jWrtScanlines
|
||||
#define jpeg_finish_compress jFinCompress
|
||||
@@ -955,10 +978,10 @@ EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile));
|
||||
/* Data source and destination managers: memory buffers. */
|
||||
EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
|
||||
unsigned char ** outbuffer,
|
||||
unsigned long * outsize));
|
||||
size_t * outsize));
|
||||
EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo,
|
||||
unsigned char * inbuffer,
|
||||
unsigned long insize));
|
||||
const unsigned char * inbuffer,
|
||||
size_t insize));
|
||||
|
||||
/* Default parameter setup for compression */
|
||||
EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo));
|
||||
@@ -983,6 +1006,8 @@ EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo,
|
||||
boolean suppress));
|
||||
EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo));
|
||||
EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo));
|
||||
EXTERN(JHUFF_TBL *) jpeg_std_huff_table JPP((j_common_ptr cinfo,
|
||||
boolean isDC, int tblno));
|
||||
|
||||
/* Main entry points for compression */
|
||||
EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo,
|
||||
|
||||
63
jpegtran.1
63
jpegtran.1
@@ -1,4 +1,4 @@
|
||||
.TH JPEGTRAN 1 "28 December 2009"
|
||||
.TH JPEGTRAN 1 "28 August 2019"
|
||||
.SH NAME
|
||||
jpegtran \- lossless transformation of JPEG files
|
||||
.SH SYNOPSIS
|
||||
@@ -19,6 +19,10 @@ 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.
|
||||
.PP
|
||||
For EXIF files and JPEG files containing Exif data, you may prefer to use
|
||||
.B exiftran
|
||||
instead.
|
||||
.PP
|
||||
.B jpegtran
|
||||
works by rearranging the compressed data (DCT coefficients), without
|
||||
ever fully decoding the image. Therefore, its transformations are lossless:
|
||||
@@ -28,7 +32,11 @@ followed by
|
||||
.B cjpeg
|
||||
to accomplish the same conversion. But by the same token,
|
||||
.B jpegtran
|
||||
cannot perform lossy operations such as changing the image quality.
|
||||
cannot perform lossy operations such as changing the image quality. However,
|
||||
while the image data is losslessly transformed, metadata can be removed. See
|
||||
the
|
||||
.B \-copy
|
||||
option for specifics.
|
||||
.PP
|
||||
.B jpegtran
|
||||
reads the named JPEG/JFIF file, or the standard input if no file is
|
||||
@@ -156,15 +164,49 @@ image region but losslessly preserves what is inside. Like the rotate and
|
||||
flip transforms, lossless crop is restricted by the current JPEG format: the
|
||||
upper left corner of the selected region must fall on an iMCU boundary. If
|
||||
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.)
|
||||
|
||||
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 by
|
||||
attaching an 'f' character ("force") to the width or height number.
|
||||
.PP
|
||||
The image can be losslessly cropped by giving the switch:
|
||||
.TP
|
||||
.B \-crop WxH+X+Y
|
||||
Crop to a rectangular subarea of width W, height H starting at point X,Y.
|
||||
.PP
|
||||
Crop extension: The width or height parameters can be made larger than the
|
||||
source image. In this case the extra area is filled in with zero (neutral
|
||||
gray). A larger width parameter has two more options: Attaching an 'f'
|
||||
character ("flatten") to the width number will fill in the extra area with
|
||||
the DC of the adjacent block, instead of gray out. Attaching an 'r'
|
||||
character ("reflect") to the width number will fill in the extra area with
|
||||
repeated reflections of the source region, instead of gray out.
|
||||
.PP
|
||||
A complementary lossless-wipe option is provided to discard (gray out) data
|
||||
inside a given image region while losslessly preserving what is outside:
|
||||
.TP
|
||||
.B \-wipe WxH+X+Y
|
||||
Wipe (gray out) a rectangular subarea of width W, height H starting at point
|
||||
X,Y.
|
||||
.PP
|
||||
Attaching an 'f' character ("flatten") to the width number will fill the
|
||||
region with the average of adjacent blocks, instead of gray out. In case
|
||||
the wipe region and outside area form two horizontally adjacent rectangles,
|
||||
attaching an 'r' character ("reflect") to the width number will fill the
|
||||
region with repeated reflections of the outside area, instead of gray out.
|
||||
.PP
|
||||
Another option is lossless-drop, which replaces data at a given image
|
||||
position by another image:
|
||||
.TP
|
||||
.B \-drop +X+Y filename
|
||||
Drop another image
|
||||
.PP
|
||||
Both source images must have the same subsampling values. It is best if
|
||||
they also have the same quantization, otherwise quantization adaption occurs.
|
||||
The trim option can be used with the drop option to requantize the drop file
|
||||
to the source file.
|
||||
.PP
|
||||
Other not-strictly-lossless transformation switches are:
|
||||
.TP
|
||||
.B \-grayscale
|
||||
@@ -198,16 +240,17 @@ such as comment blocks:
|
||||
.TP
|
||||
.B \-copy none
|
||||
Copy no extra markers from source file. This setting suppresses all
|
||||
comments and other excess baggage present in the source file.
|
||||
comments and other metadata in the source file.
|
||||
.TP
|
||||
.B \-copy comments
|
||||
Copy only comment markers. This setting copies comments from the source file,
|
||||
but discards any other inessential (for image display) data.
|
||||
but discards any other metadata.
|
||||
.TP
|
||||
.B \-copy all
|
||||
Copy all extra markers. This setting preserves miscellaneous markers
|
||||
Copy all extra markers. This setting preserves metadata
|
||||
found in the source file, such as JFIF thumbnails, Exif data, and Photoshop
|
||||
settings. In some files these extra markers can be sizable.
|
||||
settings. In some files these extra markers can be sizable. Note that this
|
||||
option will copy thumbnails as-is; they will not be transformed.
|
||||
.IP
|
||||
The default behavior is
|
||||
.BR "\-copy comments" .
|
||||
|
||||
120
jpegtran.c
120
jpegtran.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* jpegtran.c
|
||||
*
|
||||
* Copyright (C) 1995-2009, Thomas G. Lane, Guido Vollbeding.
|
||||
* Copyright (C) 1995-2019, 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.
|
||||
*
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
static const char * progname; /* program name for error messages */
|
||||
static char * outfilename; /* for -outfile switch */
|
||||
static char * dropfilename; /* for -drop switch */
|
||||
static char * scaleoption; /* -scale switch */
|
||||
static JCOPY_OPTION copyoption; /* -copy switch */
|
||||
static jpeg_transform_info transformoption; /* image transformation options */
|
||||
@@ -63,27 +64,32 @@ usage (void)
|
||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||
fprintf(stderr, " -progressive Create progressive JPEG file\n");
|
||||
#endif
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
fprintf(stderr, "Switches for modifying the image:\n");
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
fprintf(stderr, " -crop WxH+X+Y Crop to a rectangular subarea\n");
|
||||
fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n");
|
||||
fprintf(stderr, " -drop +X+Y filename Drop another image\n");
|
||||
fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n");
|
||||
fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n");
|
||||
fprintf(stderr, " -perfect Fail if there is non-transformable edge blocks\n");
|
||||
fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n");
|
||||
#endif
|
||||
fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n");
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
fprintf(stderr, " -transpose Transpose image\n");
|
||||
fprintf(stderr, " -transverse Transverse transpose image\n");
|
||||
fprintf(stderr, " -trim Drop non-transformable edge blocks\n");
|
||||
#endif /* TRANSFORMS_SUPPORTED */
|
||||
fprintf(stderr, " with -drop: Requantize drop file to source file\n");
|
||||
fprintf(stderr, " -wipe WxH+X+Y Wipe (gray out) a rectangular subarea\n");
|
||||
#endif
|
||||
fprintf(stderr, "Switches for advanced users:\n");
|
||||
#ifdef C_ARITH_CODING_SUPPORTED
|
||||
fprintf(stderr, " -arithmetic Use arithmetic coding\n");
|
||||
#endif
|
||||
fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n");
|
||||
fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n");
|
||||
fprintf(stderr, " -outfile name Specify name for output file\n");
|
||||
fprintf(stderr, " -verbose or -debug Emit debug output\n");
|
||||
fprintf(stderr, "Switches for wizards:\n");
|
||||
#ifdef C_ARITH_CODING_SUPPORTED
|
||||
fprintf(stderr, " -arithmetic Use arithmetic coding\n");
|
||||
#endif
|
||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||
fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n");
|
||||
#endif
|
||||
@@ -185,7 +191,8 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
if (++argn >= argc) /* advance to next argument */
|
||||
usage();
|
||||
if (! jtransform_parse_crop_spec(&transformoption, argv[argn])) {
|
||||
if (transformoption.crop /* reject multiple crop/drop/wipe requests */ ||
|
||||
! jtransform_parse_crop_spec(&transformoption, argv[argn])) {
|
||||
fprintf(stderr, "%s: bogus -crop argument '%s'\n",
|
||||
progname, argv[argn]);
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -194,6 +201,26 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
select_transform(JXFORM_NONE); /* force an error */
|
||||
#endif
|
||||
|
||||
} else if (keymatch(arg, "drop", 2)) {
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
if (++argn >= argc) /* advance to next argument */
|
||||
usage();
|
||||
if (transformoption.crop /* reject multiple crop/drop/wipe requests */ ||
|
||||
! jtransform_parse_crop_spec(&transformoption, argv[argn]) ||
|
||||
transformoption.crop_width_set != JCROP_UNSET ||
|
||||
transformoption.crop_height_set != JCROP_UNSET) {
|
||||
fprintf(stderr, "%s: bogus -drop argument '%s'\n",
|
||||
progname, argv[argn]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (++argn >= argc) /* advance to next argument */
|
||||
usage();
|
||||
dropfilename = argv[argn];
|
||||
select_transform(JXFORM_DROP);
|
||||
#else
|
||||
select_transform(JXFORM_NONE); /* force an error */
|
||||
#endif
|
||||
|
||||
} else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
|
||||
/* Enable debug printouts. */
|
||||
/* On first -d, print version identification */
|
||||
@@ -334,6 +361,21 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
/* Trim off any partial edge MCUs that the transform can't handle. */
|
||||
transformoption.trim = TRUE;
|
||||
|
||||
} else if (keymatch(arg, "wipe", 1)) {
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
if (++argn >= argc) /* advance to next argument */
|
||||
usage();
|
||||
if (transformoption.crop /* reject multiple crop/drop/wipe requests */ ||
|
||||
! jtransform_parse_crop_spec(&transformoption, argv[argn])) {
|
||||
fprintf(stderr, "%s: bogus -wipe argument '%s'\n",
|
||||
progname, argv[argn]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
select_transform(JXFORM_WIPE);
|
||||
#else
|
||||
select_transform(JXFORM_NONE); /* force an error */
|
||||
#endif
|
||||
|
||||
} else {
|
||||
usage(); /* bogus switch */
|
||||
}
|
||||
@@ -367,8 +409,14 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
struct jpeg_decompress_struct srcinfo;
|
||||
struct jpeg_error_mgr jsrcerr;
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
struct jpeg_decompress_struct dropinfo;
|
||||
struct jpeg_error_mgr jdroperr;
|
||||
FILE * drop_file;
|
||||
#endif
|
||||
struct jpeg_compress_struct dstinfo;
|
||||
struct jpeg_error_mgr jsrcerr, jdsterr;
|
||||
struct jpeg_error_mgr jdsterr;
|
||||
#ifdef PROGRESS_REPORT
|
||||
struct cdjpeg_progress_mgr progress;
|
||||
#endif
|
||||
@@ -408,7 +456,7 @@ main (int argc, char **argv)
|
||||
* values read here are mostly ignored; we will rescan the switches after
|
||||
* opening the input file. Also note that most of the switches affect the
|
||||
* destination JPEG object, so we parse into that and then copy over what
|
||||
* needs to affects the source too.
|
||||
* needs to affect the source too.
|
||||
*/
|
||||
|
||||
file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE);
|
||||
@@ -450,6 +498,21 @@ main (int argc, char **argv)
|
||||
fp = read_stdin();
|
||||
}
|
||||
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
/* Open the drop file. */
|
||||
if (dropfilename != NULL) {
|
||||
if ((drop_file = fopen(dropfilename, READ_BINARY)) == NULL) {
|
||||
fprintf(stderr, "%s: can't open %s for reading\n", progname, dropfilename);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
dropinfo.err = jpeg_std_error(&jdroperr);
|
||||
jpeg_create_decompress(&dropinfo);
|
||||
jpeg_stdio_src(&dropinfo, drop_file);
|
||||
} else {
|
||||
drop_file = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PROGRESS_REPORT
|
||||
start_progress_monitor((j_common_ptr) &dstinfo, &progress);
|
||||
#endif
|
||||
@@ -465,10 +528,21 @@ main (int argc, char **argv)
|
||||
|
||||
/* Adjust default decompression parameters */
|
||||
if (scaleoption != NULL)
|
||||
if (sscanf(scaleoption, "%d/%d",
|
||||
if (sscanf(scaleoption, "%u/%u",
|
||||
&srcinfo.scale_num, &srcinfo.scale_denom) < 1)
|
||||
usage();
|
||||
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
if (dropfilename != NULL) {
|
||||
(void) jpeg_read_header(&dropinfo, TRUE);
|
||||
transformoption.crop_width = dropinfo.image_width;
|
||||
transformoption.crop_width_set = JCROP_POS;
|
||||
transformoption.crop_height = dropinfo.image_height;
|
||||
transformoption.crop_height_set = JCROP_POS;
|
||||
transformoption.drop_ptr = &dropinfo;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Any space needed by a transform option must be requested before
|
||||
* jpeg_read_coefficients so that memory allocation will be done right.
|
||||
*/
|
||||
@@ -484,6 +558,12 @@ main (int argc, char **argv)
|
||||
/* Read source file as DCT coefficients */
|
||||
src_coef_arrays = jpeg_read_coefficients(&srcinfo);
|
||||
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
if (dropfilename != NULL) {
|
||||
transformoption.drop_coef_arrays = jpeg_read_coefficients(&dropinfo);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize destination compression parameters from source values */
|
||||
jpeg_copy_critical_parameters(&srcinfo, &dstinfo);
|
||||
|
||||
@@ -541,18 +621,34 @@ main (int argc, char **argv)
|
||||
/* Finish compression and release memory */
|
||||
jpeg_finish_compress(&dstinfo);
|
||||
jpeg_destroy_compress(&dstinfo);
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
if (dropfilename != NULL) {
|
||||
(void) jpeg_finish_decompress(&dropinfo);
|
||||
jpeg_destroy_decompress(&dropinfo);
|
||||
}
|
||||
#endif
|
||||
(void) jpeg_finish_decompress(&srcinfo);
|
||||
jpeg_destroy_decompress(&srcinfo);
|
||||
|
||||
/* Close output file, if we opened it */
|
||||
if (fp != stdout)
|
||||
fclose(fp);
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
if (drop_file != NULL)
|
||||
fclose(drop_file);
|
||||
#endif
|
||||
|
||||
#ifdef PROGRESS_REPORT
|
||||
end_progress_monitor((j_common_ptr) &dstinfo);
|
||||
#endif
|
||||
|
||||
/* All done. */
|
||||
exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS);
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
if (dropfilename != NULL)
|
||||
exit(jsrcerr.num_warnings + jdroperr.num_warnings +
|
||||
jdsterr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS);
|
||||
#endif
|
||||
exit(jsrcerr.num_warnings + jdsterr.num_warnings ?
|
||||
EXIT_WARNING : EXIT_SUCCESS);
|
||||
return 0; /* suppress no-return-value warnings */
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* jquant1.c
|
||||
*
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* Modified 2011 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.
|
||||
*
|
||||
@@ -530,7 +531,7 @@ quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
|
||||
for (row = 0; row < num_rows; row++) {
|
||||
/* Initialize output values to 0 so can process components separately */
|
||||
jzero_far((void FAR *) output_buf[row],
|
||||
FMEMZERO((void FAR *) output_buf[row],
|
||||
(size_t) (width * SIZEOF(JSAMPLE)));
|
||||
row_index = cquantize->row_index;
|
||||
for (ci = 0; ci < nc; ci++) {
|
||||
@@ -635,7 +636,7 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
|
||||
for (row = 0; row < num_rows; row++) {
|
||||
/* Initialize output values to 0 so can process components separately */
|
||||
jzero_far((void FAR *) output_buf[row],
|
||||
FMEMZERO((void FAR *) output_buf[row],
|
||||
(size_t) (width * SIZEOF(JSAMPLE)));
|
||||
for (ci = 0; ci < nc; ci++) {
|
||||
input_ptr = input_buf[row] + ci;
|
||||
@@ -781,7 +782,7 @@ start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
/* Initialize the propagated errors to zero. */
|
||||
arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR));
|
||||
for (i = 0; i < cinfo->out_color_components; i++)
|
||||
jzero_far((void FAR *) cquantize->fserrors[i], arraysize);
|
||||
FMEMZERO((void FAR *) cquantize->fserrors[i], arraysize);
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* jquant2.c
|
||||
*
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* Modified 2011 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.
|
||||
*
|
||||
@@ -1203,7 +1204,7 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize);
|
||||
/* Initialize the propagated errors to zero. */
|
||||
jzero_far((void FAR *) cquantize->fserrors, arraysize);
|
||||
FMEMZERO((void FAR *) cquantize->fserrors, arraysize);
|
||||
/* Make the error-limit table if we didn't already. */
|
||||
if (cquantize->error_limiter == NULL)
|
||||
init_error_limit(cinfo);
|
||||
@@ -1214,7 +1215,7 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
/* Zero the histogram or inverse color map, if necessary */
|
||||
if (cquantize->needs_zeroed) {
|
||||
for (i = 0; i < HIST_C0_ELEMS; i++) {
|
||||
jzero_far((void FAR *) histogram[i],
|
||||
FMEMZERO((void FAR *) histogram[i],
|
||||
HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell));
|
||||
}
|
||||
cquantize->needs_zeroed = FALSE;
|
||||
|
||||
44
jutils.c
44
jutils.c
@@ -2,7 +2,7 @@
|
||||
* jutils.c
|
||||
*
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* Modified 2009 by Guido Vollbeding.
|
||||
* Modified 2009-2019 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.
|
||||
*
|
||||
@@ -148,13 +148,27 @@ jround_up (long a, long b)
|
||||
* is not all that great, because these routines aren't very heavily used.)
|
||||
*/
|
||||
|
||||
#ifndef NEED_FAR_POINTERS /* normal case, same as regular macros */
|
||||
#ifndef NEED_FAR_POINTERS /* normal case, same as regular macro */
|
||||
#define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size)
|
||||
#define FMEMZERO(target,size) MEMZERO(target,size)
|
||||
#else /* 80x86 case, define if we can */
|
||||
#ifdef USE_FMEM
|
||||
#define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size))
|
||||
#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size))
|
||||
#else
|
||||
/* This function is for use by the FMEMZERO macro defined in jpegint.h.
|
||||
* Do not call this function directly, use the FMEMZERO macro instead.
|
||||
*/
|
||||
GLOBAL(void)
|
||||
jzero_far (void FAR * target, size_t bytestozero)
|
||||
/* Zero out a chunk of FAR memory. */
|
||||
/* This might be sample-array data, block-array data, or alloc_large data. */
|
||||
{
|
||||
register char FAR * ptr = (char FAR *) target;
|
||||
register size_t count;
|
||||
|
||||
for (count = bytestozero; count > 0; count--) {
|
||||
*ptr++ = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -171,7 +185,7 @@ jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
#ifdef FMEMCOPY
|
||||
register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE));
|
||||
register size_t count = (size_t) num_cols * SIZEOF(JSAMPLE);
|
||||
#else
|
||||
register JDIMENSION count;
|
||||
#endif
|
||||
@@ -199,7 +213,7 @@ jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
/* Copy a row of coefficient blocks from one place to another. */
|
||||
{
|
||||
#ifdef FMEMCOPY
|
||||
FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF)));
|
||||
FMEMCOPY(output_row, input_row, (size_t) num_blocks * (DCTSIZE2 * SIZEOF(JCOEF)));
|
||||
#else
|
||||
register JCOEFPTR inptr, outptr;
|
||||
register long count;
|
||||
@@ -211,21 +225,3 @@ jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
jzero_far (void FAR * target, size_t bytestozero)
|
||||
/* Zero out a chunk of FAR memory. */
|
||||
/* This might be sample-array data, block-array data, or alloc_large data. */
|
||||
{
|
||||
#ifdef FMEMZERO
|
||||
FMEMZERO(target, bytestozero);
|
||||
#else
|
||||
register char FAR * ptr = (char FAR *) target;
|
||||
register size_t count;
|
||||
|
||||
for (count = bytestozero; count > 0; count--) {
|
||||
*ptr++ = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* jversion.h
|
||||
*
|
||||
* Copyright (C) 1991-2010, Thomas G. Lane, Guido Vollbeding.
|
||||
* Copyright (C) 1991-2020, 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 "8 10-Jan-2010"
|
||||
#define JVERSION "9d 12-Jan-2020"
|
||||
|
||||
#define JCOPYRIGHT "Copyright (C) 2010, Thomas G. Lane, Guido Vollbeding"
|
||||
#define JCOPYRIGHT "Copyright (C) 2020, Thomas G. Lane, Guido Vollbeding"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
LIBJPEG_8.0 {
|
||||
LIBJPEG_9.0 {
|
||||
global:
|
||||
*;
|
||||
};
|
||||
|
||||
10
libjpeg.pc.in
Normal file
10
libjpeg.pc.in
Normal file
@@ -0,0 +1,10 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: libjpeg
|
||||
Description: Reads and writes JPEG files
|
||||
Version: @JPEG_LIB_VERSION_MAJOR@.@JPEG_LIB_VERSION_MINOR@.0
|
||||
Libs: -L${libdir} -ljpeg
|
||||
Cflags: -I${includedir}
|
||||
188
libjpeg.txt
188
libjpeg.txt
@@ -1,6 +1,6 @@
|
||||
USING THE IJG JPEG LIBRARY
|
||||
|
||||
Copyright (C) 1994-2009, Thomas G. Lane, Guido Vollbeding.
|
||||
Copyright (C) 1994-2019, 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.
|
||||
|
||||
@@ -95,8 +95,8 @@ use.) Unsupported ISO options include:
|
||||
* Lossless JPEG
|
||||
* DNL marker
|
||||
* Nonintegral subsampling ratios
|
||||
We support both 8- and 12-bit data precision, but this is a compile-time
|
||||
choice rather than a run-time choice; hence it is difficult to use both
|
||||
We support 8-bit to 12-bit data precision, but this is a compile-time choice
|
||||
rather than a run-time choice; hence it is difficult to use different
|
||||
precisions in a single application.
|
||||
|
||||
By itself, the library handles only interchange JPEG datastreams --- in
|
||||
@@ -225,7 +225,7 @@ For best results, source data values should have the precision specified by
|
||||
BITS_IN_JSAMPLE (normally 8 bits). For instance, if you choose to compress
|
||||
data that's only 6 bits/channel, you should left-justify each value in a
|
||||
byte before passing it to the compressor. If you need to compress data
|
||||
that has more than 8 bits/channel, compile with BITS_IN_JSAMPLE = 12.
|
||||
that has more than 8 bits/channel, compile with BITS_IN_JSAMPLE = 9 to 12.
|
||||
(See "Library compile-time options", later.)
|
||||
|
||||
|
||||
@@ -876,6 +876,22 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
||||
|
||||
Compression parameters (cinfo fields) include:
|
||||
|
||||
boolean arith_code
|
||||
If TRUE, use arithmetic coding.
|
||||
If FALSE, use Huffman coding.
|
||||
|
||||
int block_size
|
||||
Set DCT block size. All N from 1 to 16 are possible.
|
||||
Default is 8 (baseline format).
|
||||
Larger values produce higher compression,
|
||||
smaller values produce higher quality.
|
||||
An exact DCT stage is possible with 1 or 2.
|
||||
With the default quality of 75 and default Luminance qtable
|
||||
the DCT+Quantization stage is lossless for value 1.
|
||||
Note that values other than 8 require a SmartScale capable decoder,
|
||||
introduced with IJG JPEG 8. Setting the block_size parameter for
|
||||
compression works with version 8c and later.
|
||||
|
||||
J_DCT_METHOD dct_method
|
||||
Selects the algorithm used for the DCT step. Choices are:
|
||||
JDCT_ISLOW: slow but accurate integer algorithm
|
||||
@@ -895,14 +911,25 @@ J_DCT_METHOD dct_method
|
||||
unsigned int scale_num, scale_denom
|
||||
Scale the image by the fraction scale_num/scale_denom. Default is
|
||||
1/1, or no scaling. Currently, the supported scaling ratios are
|
||||
8/N with all N from 1 to 16. (The library design allows for arbitrary
|
||||
scaling ratios but this is not likely to be implemented any time soon.)
|
||||
M/N with all N from 1 to 16, where M is the destination DCT size,
|
||||
which is 8 by default (see block_size parameter above).
|
||||
(The library design allows for arbitrary scaling ratios but this
|
||||
is not likely to be implemented any time soon.)
|
||||
|
||||
J_COLOR_SPACE jpeg_color_space
|
||||
int num_components
|
||||
The JPEG color space and corresponding number of components; see
|
||||
"Special color spaces", below, for more info. We recommend using
|
||||
jpeg_set_color_space() if you want to change these.
|
||||
jpeg_set_colorspace() if you want to change these.
|
||||
|
||||
J_COLOR_TRANSFORM color_transform
|
||||
Internal color transform identifier, writes LSE marker if nonzero
|
||||
(requires decoder with inverse color transform support, introduced
|
||||
with IJG JPEG 9).
|
||||
Two values are currently possible: JCT_NONE and JCT_SUBTRACT_GREEN.
|
||||
Set this value for lossless RGB application *before* calling
|
||||
jpeg_set_colorspace(), because entropy table assignment in
|
||||
jpeg_set_colorspace() depends on color_transform.
|
||||
|
||||
boolean optimize_coding
|
||||
TRUE causes the compressor to compute optimal Huffman coding tables
|
||||
@@ -1246,9 +1273,10 @@ Special color spaces
|
||||
The JPEG standard itself is "color blind" and doesn't specify any particular
|
||||
color space. It is customary to convert color data to a luminance/chrominance
|
||||
color space before compressing, since this permits greater compression. The
|
||||
existing de-facto JPEG file format standards specify YCbCr or grayscale data
|
||||
(JFIF), or grayscale, RGB, YCbCr, CMYK, or YCCK (Adobe). For special
|
||||
applications such as multispectral images, other color spaces can be used,
|
||||
existing JPEG file interchange format standards specify YCbCr or GRAYSCALE
|
||||
data (JFIF version 1), GRAYSCALE, RGB, YCbCr, CMYK, or YCCK (Adobe), or BG_RGB
|
||||
or BG_YCC (big gamut color spaces, JFIF version 2). For special applications
|
||||
such as multispectral images, other color spaces can be used,
|
||||
but it must be understood that such files will be unportable.
|
||||
|
||||
The JPEG library can handle the most common colorspace conversions (namely
|
||||
@@ -1265,22 +1293,25 @@ jpeg_set_colorspace(). Of course you must select a supported transformation.
|
||||
jccolor.c currently supports the following transformations:
|
||||
RGB => YCbCr
|
||||
RGB => GRAYSCALE
|
||||
RGB => BG_YCC
|
||||
YCbCr => GRAYSCALE
|
||||
YCbCr => BG_YCC
|
||||
CMYK => YCCK
|
||||
plus the null transforms: GRAYSCALE => GRAYSCALE, RGB => RGB,
|
||||
YCbCr => YCbCr, CMYK => CMYK, YCCK => YCCK, and UNKNOWN => UNKNOWN.
|
||||
BG_RGB => BG_RGB, YCbCr => YCbCr, BG_YCC => BG_YCC, CMYK => CMYK,
|
||||
YCCK => YCCK, and UNKNOWN => UNKNOWN.
|
||||
|
||||
The de-facto file format standards (JFIF and Adobe) specify APPn markers that
|
||||
indicate the color space of the JPEG file. It is important to ensure that
|
||||
these are written correctly, or omitted if the JPEG file's color space is not
|
||||
one of the ones supported by the de-facto standards. jpeg_set_colorspace()
|
||||
will set the compression parameters to include or omit the APPn markers
|
||||
properly, so long as it is told the truth about the JPEG color space.
|
||||
For example, if you are writing some random 3-component color space without
|
||||
conversion, don't try to fake out the library by setting in_color_space and
|
||||
jpeg_color_space to JCS_YCbCr; use JCS_UNKNOWN. You may want to write an
|
||||
APPn marker of your own devising to identify the colorspace --- see "Special
|
||||
markers", below.
|
||||
The file interchange format standards (JFIF and Adobe) specify APPn markers
|
||||
that indicate the color space of the JPEG file. It is important to ensure
|
||||
that these are written correctly, or omitted if the JPEG file's color space
|
||||
is not one of the ones supported by the interchange standards.
|
||||
jpeg_set_colorspace() will set the compression parameters to include or omit
|
||||
the APPn markers properly, so long as it is told the truth about the JPEG
|
||||
color space. For example, if you are writing some random 3-component color
|
||||
space without conversion, don't try to fake out the library by setting
|
||||
in_color_space and jpeg_color_space to JCS_YCbCr; use JCS_UNKNOWN.
|
||||
You may want to write an APPn marker of your own devising to identify
|
||||
the colorspace --- see "Special markers", below.
|
||||
|
||||
When told that the color space is UNKNOWN, the library will default to using
|
||||
luminance-quality compression parameters for all color components. You may
|
||||
@@ -1296,8 +1327,11 @@ jpeg_read_header's guess by setting jpeg_color_space. jpeg_read_header also
|
||||
selects a default output color space based on (its guess of) jpeg_color_space;
|
||||
set out_color_space to override this. Again, you must select a supported
|
||||
transformation. jdcolor.c currently supports
|
||||
YCbCr => GRAYSCALE
|
||||
YCbCr => RGB
|
||||
YCbCr => GRAYSCALE
|
||||
BG_YCC => RGB
|
||||
BG_YCC => GRAYSCALE
|
||||
RGB => GRAYSCALE
|
||||
GRAYSCALE => RGB
|
||||
YCCK => CMYK
|
||||
as well as the null transforms. (Since GRAYSCALE=>RGB is provided, an
|
||||
@@ -2557,10 +2591,10 @@ different sizes. If the image dimensions are not a multiple of the MCU size,
|
||||
you must also pad the data correctly (usually, this is done by replicating
|
||||
the last column and/or row). The data must be padded to a multiple of a DCT
|
||||
block in each component: that is, each downsampled row must contain a
|
||||
multiple of 8 valid samples, and there must be a multiple of 8 sample rows
|
||||
for each component. (For applications such as conversion of digital TV
|
||||
images, the standard image size is usually a multiple of the DCT block size,
|
||||
so that no padding need actually be done.)
|
||||
multiple of DCT_h_scaled_size valid samples, and there must be a multiple of
|
||||
DCT_v_scaled_size sample rows for each component. (For applications such as
|
||||
conversion of digital TV images, the standard image size is usually a
|
||||
multiple of the DCT block size, so that no padding need actually be done.)
|
||||
|
||||
The procedure for compression of raw data is basically the same as normal
|
||||
compression, except that you call jpeg_write_raw_data() in place of
|
||||
@@ -2568,8 +2602,6 @@ jpeg_write_scanlines(). Before calling jpeg_start_compress(), you must do
|
||||
the following:
|
||||
* Set cinfo->raw_data_in to TRUE. (It is set FALSE by jpeg_set_defaults().)
|
||||
This notifies the library that you will be supplying raw data.
|
||||
Furthermore, set cinfo->do_fancy_downsampling to FALSE if you want to use
|
||||
real downsampled data. (It is set TRUE by jpeg_set_defaults().)
|
||||
* Ensure jpeg_color_space is correct --- an explicit jpeg_set_colorspace()
|
||||
call is a good idea. Note that since color conversion is bypassed,
|
||||
in_color_space is ignored, except that jpeg_set_defaults() uses it to
|
||||
@@ -2586,23 +2618,25 @@ The scanlines count passed to and returned from jpeg_write_raw_data is
|
||||
measured in terms of the component with the largest v_samp_factor.
|
||||
|
||||
jpeg_write_raw_data() processes one MCU row per call, which is to say
|
||||
v_samp_factor*DCTSIZE sample rows of each component. The passed num_lines
|
||||
value must be at least max_v_samp_factor*DCTSIZE, and the return value will
|
||||
be exactly that amount (or possibly some multiple of that amount, in future
|
||||
library versions). This is true even on the last call at the bottom of the
|
||||
image; don't forget to pad your data as necessary.
|
||||
v_samp_factor*min_DCT_v_scaled_size sample rows of each component. The passed
|
||||
num_lines value must be at least max_v_samp_factor*min_DCT_v_scaled_size, and
|
||||
the return value will be exactly that amount (or possibly some multiple of
|
||||
that amount, in future library versions). This is true even on the last call
|
||||
at the bottom of the image; don't forget to pad your data as necessary.
|
||||
|
||||
The required dimensions of the supplied data can be computed for each
|
||||
component as
|
||||
cinfo->comp_info[i].width_in_blocks*DCTSIZE samples per row
|
||||
cinfo->comp_info[i].height_in_blocks*DCTSIZE rows in image
|
||||
cinfo->comp_info[i].width_in_blocks *
|
||||
cinfo->comp_info[i].DCT_h_scaled_size samples per row
|
||||
cinfo->comp_info[i].height_in_blocks *
|
||||
cinfo->comp_info[i].DCT_v_scaled_size rows in image
|
||||
after jpeg_start_compress() has initialized those fields. If the valid data
|
||||
is smaller than this, it must be padded appropriately. For some sampling
|
||||
factors and image sizes, additional dummy DCT blocks are inserted to make
|
||||
the image a multiple of the MCU dimensions. The library creates such dummy
|
||||
blocks itself; it does not read them from your supplied data. Therefore you
|
||||
need never pad by more than DCTSIZE samples. An example may help here.
|
||||
Assume 2h2v downsampling of YCbCr data, that is
|
||||
need never pad by more than DCT_scaled_size samples.
|
||||
An example may help here. Assume 2h2v downsampling of YCbCr data, that is
|
||||
cinfo->comp_info[0].h_samp_factor = 2 for Y
|
||||
cinfo->comp_info[0].v_samp_factor = 2
|
||||
cinfo->comp_info[1].h_samp_factor = 1 for Cb
|
||||
@@ -2628,27 +2662,26 @@ destination module suspends, jpeg_write_raw_data() will return 0.
|
||||
In this case the same data rows must be passed again on the next call.
|
||||
|
||||
|
||||
Decompression with raw data output implies bypassing all postprocessing.
|
||||
You must deal with the color space and sampling factors present in the
|
||||
incoming file. If your application only handles, say, 2h1v YCbCr data,
|
||||
you must check for and fail on other color spaces or other sampling factors.
|
||||
Decompression with raw data output implies bypassing all postprocessing:
|
||||
you cannot ask for color quantization, for instance. More seriously, you
|
||||
must deal with the color space and sampling factors present in the incoming
|
||||
file. If your application only handles, say, 2h1v YCbCr data, you must
|
||||
check for and fail on other color spaces or other sampling factors.
|
||||
The library will not convert to a different color space for you.
|
||||
|
||||
To obtain raw data output, set cinfo->raw_data_out = TRUE before
|
||||
jpeg_start_decompress() (it is set FALSE by jpeg_read_header()). Be sure to
|
||||
verify that the color space and sampling factors are ones you can handle.
|
||||
Furthermore, set cinfo->do_fancy_upsampling = FALSE if you want to get real
|
||||
downsampled data (it is set TRUE by jpeg_read_header()).
|
||||
Then call jpeg_read_raw_data() in place of jpeg_read_scanlines(). The
|
||||
decompression process is otherwise the same as usual.
|
||||
|
||||
jpeg_read_raw_data() returns one MCU row per call, and thus you must pass a
|
||||
buffer of at least max_v_samp_factor*DCTSIZE scanlines (scanline counting is
|
||||
the same as for raw-data compression). The buffer you pass must be large
|
||||
enough to hold the actual data plus padding to DCT-block boundaries. As with
|
||||
compression, any entirely dummy DCT blocks are not processed so you need not
|
||||
allocate space for them, but the total scanline count includes them. The
|
||||
above example of computing buffer dimensions for raw-data compression is
|
||||
buffer of at least max_v_samp_factor*min_DCT_v_scaled_size scanlines (scanline
|
||||
counting is the same as for raw-data compression). The buffer you pass must
|
||||
be large enough to hold the actual data plus padding to DCT-block boundaries.
|
||||
As with compression, any entirely dummy DCT blocks are not processed so you
|
||||
need not allocate space for them, but the total scanline count includes them.
|
||||
The above example of computing buffer dimensions for raw-data compression is
|
||||
equally valid for decompression.
|
||||
|
||||
Input suspension is supported with raw-data decompression: if the data source
|
||||
@@ -2900,10 +2933,10 @@ This does not count any memory allocated by the application, such as a
|
||||
buffer to hold the final output image.
|
||||
|
||||
The above figures are valid for 8-bit JPEG data precision and a machine with
|
||||
32-bit ints. For 12-bit JPEG data, double the size of the strip buffers and
|
||||
quantization pixel buffer. The "fixed-size" data will be somewhat smaller
|
||||
with 16-bit ints, larger with 64-bit ints. Also, CMYK or other unusual
|
||||
color spaces will require different amounts of space.
|
||||
32-bit ints. For 9-bit to 12-bit JPEG data, double the size of the strip
|
||||
buffers and quantization pixel buffer. The "fixed-size" data will be
|
||||
somewhat smaller with 16-bit ints, larger with 64-bit ints. Also, CMYK
|
||||
or other unusual color spaces will require different amounts of space.
|
||||
|
||||
The full-image coefficient and pixel buffers, if needed at all, do not
|
||||
have to be fully RAM resident; you can have the library use temporary
|
||||
@@ -2925,27 +2958,34 @@ Library compile-time options
|
||||
|
||||
A number of compile-time options are available by modifying jmorecfg.h.
|
||||
|
||||
The JPEG standard provides for both the baseline 8-bit DCT process and
|
||||
a 12-bit DCT process. The IJG code supports 12-bit lossy JPEG if you define
|
||||
BITS_IN_JSAMPLE as 12 rather than 8. Note that this causes JSAMPLE to be
|
||||
larger than a char, so it affects the surrounding application's image data.
|
||||
The sample applications cjpeg and djpeg can support 12-bit mode only for PPM
|
||||
and GIF file formats; you must disable the other file formats to compile a
|
||||
12-bit cjpeg or djpeg. (install.txt has more information about that.)
|
||||
At present, a 12-bit library can handle *only* 12-bit images, not both
|
||||
precisions. (If you need to include both 8- and 12-bit libraries in a single
|
||||
application, you could probably do it by defining NEED_SHORT_EXTERNAL_NAMES
|
||||
for just one of the copies. You'd have to access the 8-bit and 12-bit copies
|
||||
from separate application source files. This is untested ... if you try it,
|
||||
we'd like to hear whether it works!)
|
||||
The IJG code currently supports 8-bit to 12-bit sample data precision by
|
||||
defining BITS_IN_JSAMPLE as 8, 9, 10, 11, or 12.
|
||||
Note that a value larger than 8 causes JSAMPLE to be larger than a char,
|
||||
so it affects the surrounding application's image data.
|
||||
The sample applications cjpeg and djpeg can support deeper than 8-bit data
|
||||
only for PPM and GIF file formats; you must disable the other file formats
|
||||
to compile a 9-bit to 12-bit cjpeg or djpeg. (install.txt has more
|
||||
information about that.)
|
||||
Run-time selection and conversion of data precision are currently not
|
||||
supported and may be added later.
|
||||
Exception: The transcoding part (jpegtran) supports all settings in a
|
||||
single instance, since it operates on the level of DCT coefficients and
|
||||
not sample values.
|
||||
(If you need to include an 8-bit library and a 9-bit to 12-bit library for
|
||||
compression or decompression in a single application, you could probably do
|
||||
it by defining NEED_SHORT_EXTERNAL_NAMES for just one of the copies. You'd
|
||||
have to access the 8-bit and the 9-bit to 12-bit copies from separate
|
||||
application source files. This is untested ... if you try it, we'd like to
|
||||
hear whether it works!)
|
||||
|
||||
Note that a 12-bit library always compresses in Huffman optimization mode,
|
||||
in order to generate valid Huffman tables. This is necessary because our
|
||||
default Huffman tables only cover 8-bit data. If you need to output 12-bit
|
||||
files in one pass, you'll have to supply suitable default Huffman tables.
|
||||
You may also want to supply your own DCT quantization tables; the existing
|
||||
quality-scaling code has been developed for 8-bit use, and probably doesn't
|
||||
generate especially good tables for 12-bit.
|
||||
Note that the standard Huffman tables are only valid for 8-bit data precision.
|
||||
If you selected more than 8-bit data precision, cjpeg uses arithmetic coding
|
||||
by default. The Huffman encoder normally uses entropy optimization to
|
||||
compute usable tables for higher precision. Otherwise, you'll have to
|
||||
supply different default Huffman tables. You may also want to supply your
|
||||
own DCT quantization tables; the existing quality-scaling code has been
|
||||
developed for 8-bit use, and probably doesn't generate especially good tables
|
||||
for 9-bit to 12-bit.
|
||||
|
||||
The maximum number of components (color channels) in the image is determined
|
||||
by MAX_COMPONENTS. The JPEG standard allows up to 255 components, but we
|
||||
|
||||
33
makeasln.v10
Normal file
33
makeasln.v10
Normal file
@@ -0,0 +1,33 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD>
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual C++ Express 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cjpeg", "cjpeg.vcxproj", "{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "djpeg", "djpeg.vcxproj", "{11043137-B453-4DFA-9010-4D2B9DC1545C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jpegtran", "jpegtran.vcxproj", "{025BAC50-51B5-4FFE-BC47-3F920BB4047E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rdjpgcom", "rdjpgcom.vcxproj", "{C81513DB-78DC-46BC-BC98-82E745203976}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wrjpgcom", "wrjpgcom.vcxproj", "{B57065D4-DDDA-4668-BAF5-2D49270C973C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|Win32.Build.0 = Release|Win32
|
||||
{11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|Win32.Build.0 = Release|Win32
|
||||
{025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|Win32.Build.0 = Release|Win32
|
||||
{C81513DB-78DC-46BC-BC98-82E745203976}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{C81513DB-78DC-46BC-BC98-82E745203976}.Release|Win32.Build.0 = Release|Win32
|
||||
{B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
33
makeasln.v15
Normal file
33
makeasln.v15
Normal file
@@ -0,0 +1,33 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD>
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual C++ Express 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cjpeg", "cjpeg.vcxproj", "{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "djpeg", "djpeg.vcxproj", "{11043137-B453-4DFA-9010-4D2B9DC1545C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jpegtran", "jpegtran.vcxproj", "{025BAC50-51B5-4FFE-BC47-3F920BB4047E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rdjpgcom", "rdjpgcom.vcxproj", "{C81513DB-78DC-46BC-BC98-82E745203976}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wrjpgcom", "wrjpgcom.vcxproj", "{B57065D4-DDDA-4668-BAF5-2D49270C973C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|Win32.Build.0 = Release|Win32
|
||||
{11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|Win32.Build.0 = Release|Win32
|
||||
{025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|Win32.Build.0 = Release|Win32
|
||||
{C81513DB-78DC-46BC-BC98-82E745203976}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{C81513DB-78DC-46BC-BC98-82E745203976}.Release|Win32.Build.0 = Release|Win32
|
||||
{B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
49
makeasln.v16
Normal file
49
makeasln.v16
Normal file
@@ -0,0 +1,49 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD>
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.329
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cjpeg", "cjpeg.vcxproj", "{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "djpeg", "djpeg.vcxproj", "{11043137-B453-4DFA-9010-4D2B9DC1545C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jpegtran", "jpegtran.vcxproj", "{025BAC50-51B5-4FFE-BC47-3F920BB4047E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rdjpgcom", "rdjpgcom.vcxproj", "{C81513DB-78DC-46BC-BC98-82E745203976}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wrjpgcom", "wrjpgcom.vcxproj", "{B57065D4-DDDA-4668-BAF5-2D49270C973C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|Win32.Build.0 = Release|Win32
|
||||
{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|x64.ActiveCfg = Release|x64
|
||||
{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}.Release|x64.Build.0 = Release|x64
|
||||
{11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|Win32.Build.0 = Release|Win32
|
||||
{11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|x64.ActiveCfg = Release|x64
|
||||
{11043137-B453-4DFA-9010-4D2B9DC1545C}.Release|x64.Build.0 = Release|x64
|
||||
{025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|Win32.Build.0 = Release|Win32
|
||||
{025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|x64.ActiveCfg = Release|x64
|
||||
{025BAC50-51B5-4FFE-BC47-3F920BB4047E}.Release|x64.Build.0 = Release|x64
|
||||
{C81513DB-78DC-46BC-BC98-82E745203976}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{C81513DB-78DC-46BC-BC98-82E745203976}.Release|Win32.Build.0 = Release|Win32
|
||||
{C81513DB-78DC-46BC-BC98-82E745203976}.Release|x64.ActiveCfg = Release|x64
|
||||
{C81513DB-78DC-46BC-BC98-82E745203976}.Release|x64.Build.0 = Release|x64
|
||||
{B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|Win32.Build.0 = Release|Win32
|
||||
{B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|x64.ActiveCfg = Release|x64
|
||||
{B57065D4-DDDA-4668-BAF5-2D49270C973C}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {2F6B4B1E-5D02-475F-B2FE-EA2D9E697E54}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
33
makeasln.vc9
33
makeasln.vc9
@@ -1,33 +0,0 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD>
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual C++ Express 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cjpeg", "cjpeg.vcproj", "{B4F61778-C45D-45C6-9E87-06F03F50519F}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "djpeg", "djpeg.vcproj", "{9B7E57AE-31CD-405E-8070-26A8303B9DC9}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jpegtran", "jpegtran.vcproj", "{813C33AF-9031-49D2-BA19-93D600CDD404}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rdjpgcom", "rdjpgcom.vcproj", "{EB107F86-A8CC-4507-8115-88D31DDE4CDF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wrjpgcom", "wrjpgcom.vcproj", "{178670D7-FA7F-44A8-96C7-11B1CA14269C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B4F61778-C45D-45C6-9E87-06F03F50519F}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B4F61778-C45D-45C6-9E87-06F03F50519F}.Release|Win32.Build.0 = Release|Win32
|
||||
{9B7E57AE-31CD-405E-8070-26A8303B9DC9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{9B7E57AE-31CD-405E-8070-26A8303B9DC9}.Release|Win32.Build.0 = Release|Win32
|
||||
{813C33AF-9031-49D2-BA19-93D600CDD404}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{813C33AF-9031-49D2-BA19-93D600CDD404}.Release|Win32.Build.0 = Release|Win32
|
||||
{EB107F86-A8CC-4507-8115-88D31DDE4CDF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{EB107F86-A8CC-4507-8115-88D31DDE4CDF}.Release|Win32.Build.0 = Release|Win32
|
||||
{178670D7-FA7F-44A8-96C7-11B1CA14269C}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{178670D7-FA7F-44A8-96C7-11B1CA14269C}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -33,8 +33,8 @@ RSC=rc.exe
|
||||
# PROP BASE Target_Dir ".\cjpeg"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\cjpeg\Release"
|
||||
# PROP Intermediate_Dir ".\cjpeg\Release"
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release\cjpeg"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ".\cjpeg"
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
|
||||
|
||||
69
makecfil.v10
Normal file
69
makecfil.v10
Normal file
@@ -0,0 +1,69 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="cderror.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="cdjpeg.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jconfig.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jerror.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jinclude.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jmorecfg.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jpeglib.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jversion.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="cdjpeg.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cjpeg.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdbmp.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdgif.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdppm.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdrle.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdswitch.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdtarga.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
69
makecfil.v15
Normal file
69
makecfil.v15
Normal file
@@ -0,0 +1,69 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="cderror.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="cdjpeg.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jconfig.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jerror.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jinclude.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jmorecfg.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jpeglib.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jversion.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="cdjpeg.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cjpeg.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdbmp.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdgif.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdppm.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdrle.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdswitch.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdtarga.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
69
makecfil.v16
Normal file
69
makecfil.v16
Normal file
@@ -0,0 +1,69 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="cderror.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="cdjpeg.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jconfig.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jerror.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jinclude.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jmorecfg.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jpeglib.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jversion.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="cdjpeg.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cjpeg.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdbmp.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdgif.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdppm.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdrle.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdswitch.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdtarga.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
186
makecvcp.vc9
186
makecvcp.vc9
@@ -1,186 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="cjpeg"
|
||||
ProjectGUID="{B4F61778-C45D-45C6-9E87-06F03F50519F}"
|
||||
RootNamespace="cjpeg"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(ProjectName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
EnableIntrinsicFunctions="false"
|
||||
EnableFiberSafeOptimizations="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"
|
||||
DisableSpecificWarnings="4996"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Release\jpeg.lib"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Quelldateien"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\cdjpeg.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cjpeg.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\rdbmp.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\rdgif.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\rdppm.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\rdrle.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\rdswitch.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\rdtarga.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Headerdateien"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\cderror.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cdjpeg.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\jconfig.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\jerror.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\jinclude.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\jmorecfg.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\jpeglib.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\jversion.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Ressourcendateien"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
76
makecvcx.v10
Normal file
76
makecvcx.v10
Normal file
@@ -0,0 +1,76 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>cjpeg</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(ProjectName)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>Release\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="cderror.h" />
|
||||
<ClInclude Include="cdjpeg.h" />
|
||||
<ClInclude Include="jconfig.h" />
|
||||
<ClInclude Include="jerror.h" />
|
||||
<ClInclude Include="jinclude.h" />
|
||||
<ClInclude Include="jmorecfg.h" />
|
||||
<ClInclude Include="jpeglib.h" />
|
||||
<ClInclude Include="jversion.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="cdjpeg.c" />
|
||||
<ClCompile Include="cjpeg.c" />
|
||||
<ClCompile Include="rdbmp.c" />
|
||||
<ClCompile Include="rdgif.c" />
|
||||
<ClCompile Include="rdppm.c" />
|
||||
<ClCompile Include="rdrle.c" />
|
||||
<ClCompile Include="rdswitch.c" />
|
||||
<ClCompile Include="rdtarga.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
78
makecvcx.v15
Normal file
78
makecvcx.v15
Normal file
@@ -0,0 +1,78 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>cjpeg</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(ProjectName)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>Release\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="cderror.h" />
|
||||
<ClInclude Include="cdjpeg.h" />
|
||||
<ClInclude Include="jconfig.h" />
|
||||
<ClInclude Include="jerror.h" />
|
||||
<ClInclude Include="jinclude.h" />
|
||||
<ClInclude Include="jmorecfg.h" />
|
||||
<ClInclude Include="jpeglib.h" />
|
||||
<ClInclude Include="jversion.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="cdjpeg.c" />
|
||||
<ClCompile Include="cjpeg.c" />
|
||||
<ClCompile Include="rdbmp.c" />
|
||||
<ClCompile Include="rdgif.c" />
|
||||
<ClCompile Include="rdppm.c" />
|
||||
<ClCompile Include="rdrle.c" />
|
||||
<ClCompile Include="rdswitch.c" />
|
||||
<ClCompile Include="rdtarga.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
117
makecvcx.v16
Normal file
117
makecvcx.v16
Normal file
@@ -0,0 +1,117 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{2E7FAAD9-2F58-4BDE-81F2-1D6D3FB8BF57}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>cjpeg</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(Configuration)\$(Platform)\</OutDir>
|
||||
<IntDir>$(Configuration)\$(Platform)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(Configuration)\$(Platform)\</OutDir>
|
||||
<IntDir>$(Configuration)\$(Platform)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>$(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>$(Configuration)\$(Platform)\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="cderror.h" />
|
||||
<ClInclude Include="cdjpeg.h" />
|
||||
<ClInclude Include="jconfig.h" />
|
||||
<ClInclude Include="jerror.h" />
|
||||
<ClInclude Include="jinclude.h" />
|
||||
<ClInclude Include="jmorecfg.h" />
|
||||
<ClInclude Include="jpeglib.h" />
|
||||
<ClInclude Include="jversion.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="cdjpeg.c" />
|
||||
<ClCompile Include="cjpeg.c" />
|
||||
<ClCompile Include="rdbmp.c" />
|
||||
<ClCompile Include="rdgif.c" />
|
||||
<ClCompile Include="rdppm.c" />
|
||||
<ClCompile Include="rdrle.c" />
|
||||
<ClCompile Include="rdswitch.c" />
|
||||
<ClCompile Include="rdtarga.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -33,8 +33,8 @@ RSC=rc.exe
|
||||
# PROP BASE Target_Dir ".\djpeg"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\djpeg\Release"
|
||||
# PROP Intermediate_Dir ".\djpeg\Release"
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release\djpeg"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ".\djpeg"
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
|
||||
|
||||
69
makedfil.v10
Normal file
69
makedfil.v10
Normal file
@@ -0,0 +1,69 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="cderror.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="cdjpeg.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jconfig.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jerror.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jinclude.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jmorecfg.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jpeglib.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jversion.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="cdjpeg.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="djpeg.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdcolmap.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrbmp.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrgif.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrppm.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrrle.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrtarga.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
69
makedfil.v15
Normal file
69
makedfil.v15
Normal file
@@ -0,0 +1,69 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="cderror.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="cdjpeg.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jconfig.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jerror.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jinclude.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jmorecfg.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jpeglib.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jversion.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="cdjpeg.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="djpeg.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdcolmap.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrbmp.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrgif.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrppm.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrrle.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrtarga.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
69
makedfil.v16
Normal file
69
makedfil.v16
Normal file
@@ -0,0 +1,69 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="cderror.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="cdjpeg.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jconfig.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jerror.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jinclude.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jmorecfg.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jpeglib.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jversion.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="cdjpeg.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="djpeg.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rdcolmap.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrbmp.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrgif.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrppm.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrrle.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wrtarga.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
186
makedvcp.vc9
186
makedvcp.vc9
@@ -1,186 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="djpeg"
|
||||
ProjectGUID="{9B7E57AE-31CD-405E-8070-26A8303B9DC9}"
|
||||
RootNamespace="djpeg"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(ProjectName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
EnableIntrinsicFunctions="false"
|
||||
EnableFiberSafeOptimizations="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"
|
||||
DisableSpecificWarnings="4996"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Release\jpeg.lib"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Quelldateien"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\cdjpeg.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\djpeg.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\rdcolmap.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\wrbmp.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\wrgif.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\wrppm.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\wrrle.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\wrtarga.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Headerdateien"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\cderror.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cdjpeg.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\jconfig.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\jerror.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\jinclude.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\jmorecfg.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\jpeglib.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\jversion.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Ressourcendateien"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
76
makedvcx.v10
Normal file
76
makedvcx.v10
Normal file
@@ -0,0 +1,76 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{11043137-B453-4DFA-9010-4D2B9DC1545C}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>djpeg</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(ProjectName)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>Release\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="cderror.h" />
|
||||
<ClInclude Include="cdjpeg.h" />
|
||||
<ClInclude Include="jconfig.h" />
|
||||
<ClInclude Include="jerror.h" />
|
||||
<ClInclude Include="jinclude.h" />
|
||||
<ClInclude Include="jmorecfg.h" />
|
||||
<ClInclude Include="jpeglib.h" />
|
||||
<ClInclude Include="jversion.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="cdjpeg.c" />
|
||||
<ClCompile Include="djpeg.c" />
|
||||
<ClCompile Include="rdcolmap.c" />
|
||||
<ClCompile Include="wrbmp.c" />
|
||||
<ClCompile Include="wrgif.c" />
|
||||
<ClCompile Include="wrppm.c" />
|
||||
<ClCompile Include="wrrle.c" />
|
||||
<ClCompile Include="wrtarga.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user