]> granicus.if.org Git - libjpeg-turbo/log
libjpeg-turbo
7 years agotjLoadImage(): Don't convert RGB to grayscale
DRC [Sat, 18 Nov 2017 17:33:05 +0000 (11:33 -0600)]
tjLoadImage(): Don't convert RGB to grayscale

Loading RGB image files into a grayscale buffer isn't a particularly
useful feature, given that libjpeg-turbo can perform this conversion
much more optimally (with SIMD acceleration on some platforms) during
the compression process.  Also, the RGB2GRAY() macro was not producing
deterministic cross-platform results because of variations in the
round-off behavior of various floating point implementations, so
`tjunittest -bmp` was failing in i386 builds.

7 years agoAdd TurboJPEG C example and clean up Java example
DRC [Fri, 17 Nov 2017 00:46:01 +0000 (18:46 -0600)]
Add TurboJPEG C example and clean up Java example

Also rename example.c --> example.txt and add a disclaimer to that file
so people will stop trying to compile it.

7 years agoTurboJPEG: Add alpha offset array/method
DRC [Fri, 17 Nov 2017 02:43:12 +0000 (20:43 -0600)]
TurboJPEG: Add alpha offset array/method

Also, set the red/green/blue offsets for TJPF_GRAY to -1 rather than 0.
It was undefined behavior for an application to use those arrays/methods
with TJPF_GRAY anyhow, and this makes it easier for applications to
programmatically detect whether a given pixel format has red, green, and
blue components.

7 years agoTurboJPEG C API: Add BMP/PPM load/save functions
DRC [Fri, 17 Nov 2017 00:09:07 +0000 (18:09 -0600)]
TurboJPEG C API: Add BMP/PPM load/save functions

The main justification for this is to provide new libjpeg-turbo users
with a quick & easy way of developing a complete JPEG
compression/decompression program without requiring them to build
libjpeg-turbo from source (which was necessary in order to use the
project-private bmp API) or to use external libraries.  These new
functions build upon significant enhancements to rdbmp.c, wrbmp.c,
rdppm.c, and wrppm.c which allow those engines to convert directly
between the native pixel format of the file and a pixel format
("colorspace" in libjpeg parlance) specified by the calling program.
rdbmp.c and wrbmp.c have also been modified such that the calling
program can choose to read or write image rows in the native (bottom-up)
order of the file format, thus eliminating the need to use an inversion
array.  tjLoadImage() and tjSaveImage() leverage these new underlying
features in order to significantly improve upon the performance of the
old bmp API.

Because these new functions cannot work without the libjpeg-turbo
colorspace extensions, the libjpeg-compatible code in turbojpeg.c has
been removed.  That code was only there to serve as an example of how
to use the TurboJPEG API on top of libjpeg, but more specific, buildable
examples now exist in the https://github.com/libjpeg-turbo/ijg
repository.

7 years agotjbenchtest: Test new TurboJPEG progressive flag
DRC [Thu, 16 Nov 2017 02:50:53 +0000 (20:50 -0600)]
tjbenchtest: Test new TurboJPEG progressive flag

7 years agoBuild: Fix 'tjtest' target on Windows
DRC [Wed, 15 Nov 2017 15:19:27 +0000 (09:19 -0600)]
Build: Fix 'tjtest' target on Windows

tjbenchtest and its Java derivatives are useful for rooting out hidden
problems with the more esoteric TJBench and TurboJPEG features.  For
instance, on Windows, running tjbenchtest uncovered
5fce2e942136cb70e5a30ff15a2d58b07947aa84.

This commit also causes tjbenchtest and tjbenchtest.java to append -yuv
and -alloc to their log file names, depending on the arguments passed,
and it causes the build system to clean up those log files when the
'testclean' target is built.

7 years agoMerge branch 'master' into dev
DRC [Sat, 18 Nov 2017 01:00:53 +0000 (19:00 -0600)]
Merge branch 'master' into dev

7 years agoTJExample: Fix array index OOB w/ 4:1:1 JPEG input
DRC [Sat, 18 Nov 2017 00:45:08 +0000 (18:45 -0600)]
TJExample: Fix array index OOB w/ 4:1:1 JPEG input

7 years agoCode formatting tweaks
DRC [Sat, 18 Nov 2017 00:15:42 +0000 (18:15 -0600)]
Code formatting tweaks

7 years agoUniquify tjbenchtest log file names based on args
DRC [Thu, 16 Nov 2017 01:39:45 +0000 (19:39 -0600)]
Uniquify tjbenchtest log file names based on args

+ clean up log files when 'make testclean' is invoked
+ fix 'tjbenchtest -yuv -alloc'
+ fix tjexampletest so that it creates images under /tmp
+ clean up tjexampletest

7 years agoTJExample.java: Don't ignore mistyped args
DRC [Thu, 16 Nov 2017 01:33:06 +0000 (19:33 -0600)]
TJExample.java: Don't ignore mistyped args

7 years agoDoc tweak: TJFLAG_ACCURATEDCT is the first flag
DRC [Tue, 14 Nov 2017 22:12:13 +0000 (16:12 -0600)]
Doc tweak: TJFLAG_ACCURATEDCT is the first flag

7 years agotjbench.exe: Fix decompression access violation
DRC [Tue, 14 Nov 2017 21:30:06 +0000 (15:30 -0600)]
tjbench.exe: Fix decompression access violation

The program crashed when a JPEG image was passed on the command line,
because we were mixing our metaphors vis-a-vis malloc()/free() and
tjAlloc()/tjFree() (malloc()/free() uses the tjbench.exe heap,
whereas tjAlloc()/tjFree() uses the turbojpeg.dll heap.)

7 years agoChangeLog.md: buglet
DRC [Tue, 14 Nov 2017 03:46:07 +0000 (21:46 -0600)]
ChangeLog.md: buglet

7 years agoBuild: Fix `make dist`
DRC [Tue, 14 Nov 2017 03:24:05 +0000 (21:24 -0600)]
Build: Fix `make dist`

Broken by previous commit

7 years agoFurther partial image decompression fixes
DRC [Tue, 14 Nov 2017 03:01:53 +0000 (21:01 -0600)]
Further partial image decompression fixes

- Referring to 073b0e88a192adebbb479ee2456beb089d8b5de7 and #185, the
  reason why BMP and RLE didn't (and won't) work with partial image
  decompression is that the output engines for both formats maintain a
  whole-image buffer, which is used to reverse the order of scanlines.
  However, it was straightforward to add -crop support for GIF and
  Targa, which is useful for testing partial image decompression along
  with color quantization.
- Such testing reproduced a bug reported by Mozilla (refer to PR #182)
  whereby jpeg_skip_scanlines() would segfault if color quantization was
  enabled.  To fix this issue, read_and_discard_scanlines() now sets up
  a dummy quantize function in the same manner that it sets up a dummy
  color conversion function.

Closes #182

7 years agoTJBench/TJUnitTest: Don't ignore mistyped args
DRC [Mon, 13 Nov 2017 22:00:35 +0000 (16:00 -0600)]
TJBench/TJUnitTest: Don't ignore mistyped args

7 years agoTurboJPEG C: Code formatting tweaks
DRC [Mon, 13 Nov 2017 14:15:50 +0000 (08:15 -0600)]
TurboJPEG C: Code formatting tweaks

7 years agodjpeg -crop: Exit gracefully with non-PPM formats
DRC [Thu, 9 Nov 2017 03:01:57 +0000 (21:01 -0600)]
djpeg -crop: Exit gracefully with non-PPM formats

... and document that only PPM/PGM output images are supported with the
-crop option for the moment.

I investigated the possibility of supporting -crop with -bmp, but even
after resetting the buffer dimensions, I still kept getting virtual
array access errors.  It seems that doing this the "right way" would
require creating a re-initialization function for each image format's
destination manager.  I'm disinclined to do that right now, given that
this feature was Google's baby (developed as a prerequisite for
including libjpeg-turbo in Android), and the -crop option in djpeg is
intended only as an example of how to use the partial image
decompression API.  Real-world applications would need to handle this
in their own destination managers.

It would probably be possible to make this work with Targa by employing
a similar hack to the one we used with PPM, but Targa isn't popular
enough to bother.

Fixes #185

7 years agoTurboJPEG C: Compiler warnings
DRC [Wed, 20 Sep 2017 19:55:54 +0000 (19:55 +0000)]
TurboJPEG C: Compiler warnings

Introduced in b9ab64d8dbee2db829e59357d335c151680f44f0.

7 years agoSRPM build: Define _libdir based on build arch
DRC [Wed, 20 Sep 2017 18:11:03 +0000 (18:11 +0000)]
SRPM build: Define _libdir based on build arch

Setting _libdir to CMAKE_INSTALL_FULL_LIBDIR only works when doing an
in-tree RPM build.  SRPMs are architecture-agnostic, so the spec needs
to compute_libdir at the time the SRPM is rebuilt, not at the time it
is generated.

This is a regression introduced when implementing the new CMake-based
cross-platform build system.

7 years agoMerge branch 'master' into dev
DRC [Wed, 20 Sep 2017 17:13:46 +0000 (17:13 +0000)]
Merge branch 'master' into dev

7 years agoPrevent "unmappable character" error in Java build
DRC [Wed, 20 Sep 2017 16:52:48 +0000 (16:52 +0000)]
Prevent "unmappable character" error in Java build

This was causing the build to fail when rebuilding libjpeg-turbo from
a source RPM.

7 years agoFix PowerPC 32-bit RPM build
DRC [Tue, 19 Sep 2017 20:01:34 +0000 (20:01 +0000)]
Fix PowerPC 32-bit RPM build

7 years agoFix 32-bit RPM build w/ newer RHEL/Fedora releases
DRC [Tue, 19 Sep 2017 18:03:49 +0000 (13:03 -0500)]
Fix 32-bit RPM build w/ newer RHEL/Fedora releases

The version of RPM on RHEL 5 and older platforms defines _libdir
as %{_exec_prefix}/%{_lib}, so defining _lib in the spec file redefined
_libdir.  However, newer versions of RPM (probably >= 4.6, since that
was the version that introduced the ISA macros) define _libdir as either
%{_prefix}/lib or %{_prefix}/lib64.  Thus, we need to explicitly
override _libdir in our spec file.

7 years agoPackaging: Use parallel make when rebuilding SRPM
DRC [Mon, 11 Sep 2017 15:06:22 +0000 (10:06 -0500)]
Packaging: Use parallel make when rebuilding SRPM

7 years agoTravis: Limit parallel make jobs to # of CPU cores
DRC [Mon, 11 Sep 2017 14:48:33 +0000 (09:48 -0500)]
Travis: Limit parallel make jobs to # of CPU cores

This tends to be faster than 'make -j', since it is making more wise
use of the available resources.

7 years agowrjpgcom: Fix comment typo
nyg [Tue, 5 Sep 2017 16:23:04 +0000 (18:23 +0200)]
wrjpgcom: Fix comment typo

Comment was copied/pasted from skip_variable() without making the
necessary modifications.

7 years agoMerge branch 'master' into dev
DRC [Sat, 2 Sep 2017 04:20:03 +0000 (04:20 +0000)]
Merge branch 'master' into dev

7 years agoTJUnitTest: Usage formatting tweaks
DRC [Sat, 2 Sep 2017 04:08:06 +0000 (04:08 +0000)]
TJUnitTest: Usage formatting tweaks

7 years agoJava: Fix TJUnitTest on big endian platforms
DRC [Sat, 2 Sep 2017 03:40:46 +0000 (03:40 +0000)]
Java: Fix TJUnitTest on big endian platforms

It is necessary for the C code to be aware of the machine's endianness,
which is why the TurboJPEG Java wrapper sets a different pixel format
for integer BufferedImages depending on ByteOrder.nativeOrder().
However, it isn't necessary to handle endianness in pure Java code such
as TJUnitTest (d'oh!)  This was a product of porting the C version of
TJUnitTest too literally, and of insufficient testing (historically,
the big endian systems I had available for testing didn't have Java.)

7 years agoBuild: Change ppc64le DEB arch to ppc64el
DRC [Fri, 1 Sep 2017 21:57:48 +0000 (21:57 +0000)]
Build: Change ppc64le DEB arch to ppc64el

This is the convention among Debian-based distros.

7 years agoMerge branch 'master' into dev
DRC [Fri, 1 Sep 2017 14:02:55 +0000 (09:02 -0500)]
Merge branch 'master' into dev

7 years agoBuild: Fix AltiVec detection on OS X Leopard
DRC [Fri, 1 Sep 2017 14:01:00 +0000 (09:01 -0500)]
Build: Fix AltiVec detection on OS X Leopard

The ability to directly access elements of an AltiVec vector is
apparently a more recent thing.

7 years agoBuild: Use -maltivec when testing AltiVec support
DRC [Fri, 1 Sep 2017 13:52:21 +0000 (13:52 +0000)]
Build: Use -maltivec when testing AltiVec support

Doesn't seem to be necessary with recent Linux/GCC configurations, but
it is definitely necessary with OS X.

7 years agoMerge branch 'master' into dev
DRC [Fri, 1 Sep 2017 01:57:19 +0000 (20:57 -0500)]
Merge branch 'master' into dev

7 years agoFix build on PowerPC SPE systems
DRC [Fri, 1 Sep 2017 01:10:08 +0000 (01:10 +0000)]
Fix build on PowerPC SPE systems

SPE systems don't support AltiVec instructions.

Fixes #172

7 years agoJava: Fix NullPointerException in YUVImage
DRC [Mon, 14 Aug 2017 15:54:27 +0000 (10:54 -0500)]
Java: Fix NullPointerException in YUVImage

planes == null is a valid argument to setBuf() if alloc == true, so we
need to make sure that planes is non-null before validating its length.
We also need to allocate one dimension of the planes array if it's null.

Fixes #168

7 years agoBump version to 1.5.3 to prepare for new commits
DRC [Mon, 14 Aug 2017 16:18:35 +0000 (11:18 -0500)]
Bump version to 1.5.3 to prepare for new commits

7 years agox86: Fix "short jump is out of range" w/ NASM<2.04 1.5.2
DRC [Fri, 7 Jul 2017 20:15:19 +0000 (15:15 -0500)]
x86: Fix "short jump is out of range" w/ NASM<2.04

7 years agoTJBench: Recover from non-fatal errors if possible
DRC [Thu, 29 Jun 2017 21:49:09 +0000 (16:49 -0500)]
TJBench: Recover from non-fatal errors if possible

Previously, -stoponwarning only had an effect on the underlying
TurboJPEG C functions, but TJBench still aborted if a non-fatal error
occurred.  This commit modifies the C version of TJBench such that it
always recovers from a non-fatal error unless -stoponwarning is
specified.  Furthermore, the benchmark stores the details of the last
non-fatal error and does not print any subsequent non-fatal error
messages unless they differ from the last one.

Due to limitations in the Java API (specifically, the fact that it
cannot communicate errors, fatal or otherwise, to the calling program
without throwing a TJException), it was only possible to make
decompression operations fully recoverable within TJBench.  With other
operations, -stoponwarning still has an effect on the underlying C
library but has no effect at the Java level.

The Java API documentation has been amended to reflect that only certain
methods are truly recoverable, regardless of the state of
TJ.FLAG_STOPONWARNING.

7 years agoTurboJPEG: Don't make STOPONWARNING persistent
DRC [Thu, 29 Jun 2017 17:08:02 +0000 (12:08 -0500)]
TurboJPEG: Don't make STOPONWARNING persistent

Due to an oversight in d4092f6b4dd94c64864662987b070d517c399490,
the state of TJFLAG_STOPONWARNING persisted beyond the function it
was passed to.

7 years agoTurboJPEG: Add "copy none", progressive xform opts
DRC [Wed, 28 Jun 2017 16:43:08 +0000 (11:43 -0500)]
TurboJPEG: Add "copy none", progressive xform opts

Allow progressive entropy coding to be enabled on a
transform-by-transform basis, and implement a new transform option for
disabling the copying of markers.

Closes #153

7 years agoMerge branch 'master' into dev
DRC [Wed, 28 Jun 2017 20:30:41 +0000 (15:30 -0500)]
Merge branch 'master' into dev

7 years agoTurboJPEG: Document xform issue w/ big marker data
DRC [Wed, 28 Jun 2017 19:47:45 +0000 (14:47 -0500)]
TurboJPEG: Document xform issue w/ big marker data

If the source image for a transform operation has a lot of EXIF or ICC
data embedded in it, then it may cause the output image size to exceed
the worst-case size returned by tjBufSize() (because tjTransform()
transfers all markers to the output image.)  This is only a problem if
TJFLAG_NOREALLOC is passed to the function.  Since the TurboJPEG C API
doesn't require the destination image size to be set in this case, it
makes the documented assumption that the calling program has allocated
the destination buffer to exactly the size returned by tjBufSize().
Changing this assumption would change the API behavior and necessitate
a new function name (tjTransform2().)  At the moment, it's easier to
just document this as a known issue, since it's easy to work around in
the C API.

The Java API is unfortunately a different story, since it must always
use TJFLAG_NOREALLOC (because, when using the TurboJPEG Java API, all
buffers are allocated on the Java heap, and thus they can't be
reallocated by the C code.)  There is no easy way to work around this
without changing the C API as discussed above, because if the source
image contains large amounts of marker data, it's virtually impossible
to determine how big the output image will be.

7 years agoJava TJBench: Fix parsing of -warmup argument
DRC [Wed, 28 Jun 2017 19:40:35 +0000 (14:40 -0500)]
Java TJBench: Fix parsing of -warmup argument

Due to an oversight, this wasn't included in
1db1ce45da2e78d87ff05119b674c71d630926aa.

7 years agoBuild: Disable warmup in TJBench regression tests
DRC [Wed, 28 Jun 2017 00:45:35 +0000 (19:45 -0500)]
Build: Disable warmup in TJBench regression tests

Fixes slow-down in 'make test' caused by previous commit.

7 years agoTJBench: Improve consistency of results
DRC [Tue, 27 Jun 2017 19:22:39 +0000 (14:22 -0500)]
TJBench: Improve consistency of results

Given that libjpeg-turbo can often process hundreds of megapixels/second
on modern hardware, the default of one warmup iteration was essentially
meaningless.  Furthermore, the -warmup option was a bit clunky, since
it required some foreknowledge of how fast the benchmarks were going to
execute.

This commit introduces a 1-second warmup interval for each benchmark by
default, and the -warmup option has been retasked to control the length
of that interval.

7 years agoTurboJPEG: Opt. enable progressive entropy coding
DRC [Tue, 27 Jun 2017 18:24:08 +0000 (13:24 -0500)]
TurboJPEG: Opt. enable progressive entropy coding

Fulfills part of the feature request in #153.  Also paves the way for
SIMD-accelerated progressive Huffman coding (refer to #46.)

7 years agoMerge branch 'master' into dev
DRC [Tue, 27 Jun 2017 16:51:34 +0000 (11:51 -0500)]
Merge branch 'master' into dev

7 years agoTurboJPEG: C API documentation buglet
DRC [Tue, 27 Jun 2017 16:36:25 +0000 (11:36 -0500)]
TurboJPEG: C API documentation buglet

TJFLAG_NOREALLOC, tjAlloc(), and tjFree() apply to all TurboJPEG
compression functions, not just tjCompress2().

7 years agoTurboJPEG: Improve error handling
DRC [Tue, 27 Jun 2017 15:54:21 +0000 (10:54 -0500)]
TurboJPEG: Improve error handling

- Provide a new C API function and TJException method that allows
  calling programs to query the severity of a compression/decompression/
  transform error.
- Provide a new flag that instructs the library to immediately stop
  compressing/decompressing/transforming if a warning is encountered.

Fixes #151

7 years agoBuild: Custom target for generating JNI headers
DRC [Tue, 27 Jun 2017 00:19:44 +0000 (19:19 -0500)]
Build: Custom target for generating JNI headers

7 years agoBuild: Add custom target for generating Java docs
DRC [Fri, 12 May 2017 02:29:07 +0000 (21:29 -0500)]
Build: Add custom target for generating Java docs

7 years agoBuild: Fix buglet in java/CMakeLists.txt (MSYS)
DRC [Fri, 12 May 2017 02:23:45 +0000 (21:23 -0500)]
Build: Fix buglet in java/CMakeLists.txt (MSYS)

CMAKE_HOST_SYSTEM_NAME should be restored with the value of
CMAKE_HOST_SYSTEM_NAME_BAK.

7 years agoTurboJPEG: Thread-safe error message retrieval
DRC [Fri, 12 May 2017 02:02:29 +0000 (21:02 -0500)]
TurboJPEG: Thread-safe error message retrieval

Introduce a new C API function (tjGetErrorStr2()) that can be used to
retrieve compression/decompression/transform error messages in a
thread-safe (i.e. instance-specific) manner.  Retrieving error messages
from global functions is still thread-unsafe.

Addresses a concern expressed in #151.

7 years agoMerge branch 'master' into dev
DRC [Tue, 27 Jun 2017 02:58:32 +0000 (21:58 -0500)]
Merge branch 'master' into dev

7 years agoTJBench: Code formatting tweaks
DRC [Thu, 11 May 2017 23:33:47 +0000 (18:33 -0500)]
TJBench: Code formatting tweaks

Spaces-->tab + remove stray control character that was introduced in
95e4cb206085c3a715f0f017c174fdf367a2c1ff

7 years agoTJBench: Fix errors when decomp. files w/ ICC data
DRC [Tue, 27 Jun 2017 01:48:02 +0000 (20:48 -0500)]
TJBench: Fix errors when decomp. files w/ ICC data

Embedded ICC profiles can cause the size of a JPEG file to exceed the
size returned by tjBufSize() (which is really meant to be used for
compression anyhow, not for decompression), and this was causing a
segfault (C) or an ArrayIndexOutOfBoundsException (Java) when
decompressing such files with TJBench.  This commit modifies the
benchmark such that, when tiled decompression is disabled, it re-uses
the source buffer as the primary JPEG buffer.

7 years agoBUILDING.md: Include Android/x86 build recipes
DRC [Mon, 26 Jun 2017 20:15:08 +0000 (15:15 -0500)]
BUILDING.md: Include Android/x86 build recipes

Addresses a concern raised in #155.

7 years agoTravis: Fix OS X build
DRC [Mon, 8 May 2017 13:15:11 +0000 (08:15 -0500)]
Travis: Fix OS X build

The Travis xcode7.3 image now apparently includes GnuPG 1.4.x by
default, so use it instead of installing GnuPG 2.  Using GnuPG 2.1.x,
the default version in Homebrew as of this writing, is problematic for
this reason:
https://wiki.archlinux.org/index.php/GnuPG#Unattended_passphrase

7 years agoRestore compatibility with older autoconf releases
DRC [Sat, 6 May 2017 01:45:40 +0000 (20:45 -0500)]
Restore compatibility with older autoconf releases

(broken by f06cc1200fd5f61b63479d7099ccf4a7457a89bd)

Fixes #149

7 years agoAttribute ARM runtime detection code to Nokia
DRC [Mon, 24 Apr 2017 19:42:58 +0000 (14:42 -0500)]
Attribute ARM runtime detection code to Nokia

This code was submitted in the initial ARM NEON patches
(https://sourceforge.net/p/libjpeg-turbo/patches/7/) by Siarhei while he
was still a Nokia employee.

7 years agoHonor max_memory_to_use/JPEGMEM/-maxmemory
DRC [Sat, 18 Mar 2017 21:15:14 +0000 (16:15 -0500)]
Honor max_memory_to_use/JPEGMEM/-maxmemory

This re-introduces a feature of the obsolete system-specific libjpeg
memory managers-- namely the ability to limit the amount of main memory
used by the library during decompression or multi-pass compression.
This is mainly beneficial for two reasons:

- Works around a 2 GB limit in libFuzzer
- Allows security-sensitive applications to set a memory limit for the
  JPEG decoder so as to work around the progressive JPEG exploit
  (LJT-01-004) described here:
  http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf

This commit also removes obsolete documentation regarding the MS-DOS
memory manager (which itself was removed long ago) and changes the
documentation of the -maxmemory switch and JPEGMEM environment variable
to reflect the fact that backing stores are never used in libjpeg-turbo.

Inspired by:
https://github.com/caolanm/libjpeg-turbo/commit/066fee2e7d6834f24838bc1896aa38ca77209e3c

Closes #143

8 years agoAppVeyor: Fix CI build
DRC [Sat, 18 Mar 2017 18:24:50 +0000 (13:24 -0500)]
AppVeyor: Fix CI build

Something changed in the CI build environment, and our previous trick of
setting the Git URL to file://c:/projects/libjpeg-turbo no longer works.
Using cygpath to translate the Windows path to a MinGW-friendly format
is a better solution anyhow.

8 years agoTurboJPEG: Fix potential memory leaks
DRC [Sat, 18 Mar 2017 17:56:36 +0000 (12:56 -0500)]
TurboJPEG: Fix potential memory leaks

Referring to https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=746,
it seems that the values of local buffer pointers in TurboJPEG API
functions aren't always preserved if longjmp() returns control to a
point prior to the allocation of the local buffers.  This is known to
be an issue with GCC 4.x and clang with -O1 and higher optimization
levels but not with GCC 5.x and later.  It is unknown why GCC 5.x and
6.x do not suffer from the issue, but possibly the local buffer pointers
are not allocated on the stack when using those more recent compilers.

In any case, this commit modifies the TurboJPEG API library code such
that the jump buffer is always updated after any local buffer pointers
are allocated but before any subsequent libjpeg API functions are
called.

8 years agolibjpeg API: Support reading/writing ICC profiles
DRC [Thu, 19 Jan 2017 21:18:57 +0000 (15:18 -0600)]
libjpeg API: Support reading/writing ICC profiles

This commit does the following:

-- Merges the two glueware functions (read_icc_profile() and
write_icc_profile()) from iccjpeg.c, which is contained in downstream
projects such as LCMS, Ghostscript, Mozilla, etc.  These functions were
originally intended for inclusion in libjpeg, but Tom Lane left the IJG
before that could be accomplished.  Since then, programs and libraries
that needed to embed/extract ICC profiles in JPEG files had to include
their own local copy of iccjpeg.c, which is suboptimal.

   -- The new functions were prefixed with jpeg_ and split into separate
   files for the compressor and decompressor, per the existing libjpeg
   coding standards.

   -- jpeg_write_icc_profile() was made slightly more fault-tolerant.
   It will now trigger a libjpeg error if it is called before
   jpeg_start_compress() or if it is passed NULL arguments.

   -- jpeg_read_icc_profile() was made slightly more fault-tolerant.
   It will now trigger a libjpeg error if it is called before
   jpeg_read_header() or if it is passed NULL arguments.  It will also
   now trigger libjpeg warnings if the ICC profile data is corrupt.

   -- The code comments have been wordsmithed.

   -- Note that the one-line setup_read_icc_profile() function was not
   included.  Instead, libjpeg.txt now documents the need to call
   jpeg_save_markers(cinfo, JPEG_APP0 + 2, 0xFFFF) prior to calling
   jpeg_read_header(), if jpeg_read_icc_profile() is to be used.

-- Adds documentation for the new functions to libjpeg.txt.

-- Adds an -icc switch to cjpeg and jpegtran that allows those programs
to embed an ICC profile in the JPEG files they generate.

-- Adds an -icc switch to djpeg that allows that program to extract an
ICC profile from a JPEG file while decompressing.

-- Adds appropriate unit tests for all of the above.

-- Bumps the SO_AGE of the libjpeg API library to indicate the presence
of new API functions.

Note that the licensing information was obtained from:
https://github.com/mm2/Little-CMS/issues/37#issuecomment-66450180

8 years agoRemove vestigial license text regarding autoconf
DRC [Mon, 16 Jan 2017 21:55:02 +0000 (15:55 -0600)]
Remove vestigial license text regarding autoconf

8 years agoMerge branch 'master' into dev
DRC [Fri, 20 Jan 2017 01:05:21 +0000 (19:05 -0600)]
Merge branch 'master' into dev

8 years agoAlways tweak EXIF w/h tags w/ lossless transforms
DRC [Fri, 20 Jan 2017 00:51:41 +0000 (18:51 -0600)]
Always tweak EXIF w/h tags w/ lossless transforms

... even if using libjpeg v6b emulation.  Previously
adjust_exif_parameters() was only called with libjpeg v7/v8 emulation,
but due to a bug (which this commit also fixes), it only worked properly
with libjpeg v8 emulation.

8 years agoFix error w/ lossless crop & libjpeg v7 emulation
DRC [Thu, 19 Jan 2017 23:50:59 +0000 (17:50 -0600)]
Fix error w/ lossless crop & libjpeg v7 emulation

The JPEG_LIB_VERSION #ifdef in jtransform_adjust_parameters() was
incorrect, which caused a "Bogus virtual array access" error when
attempting to use the lossless crop feature.

Introduced in c04bd3cc97f44fd9030de1e141754c8775d4e5a5.

This also adds libjpeg v7 API/ABI emulation to the Travis CI tests.

8 years agoInclude jpeg_skip/crop_scanlines() in jpeg7.dll
DRC [Thu, 19 Jan 2017 22:44:10 +0000 (16:44 -0600)]
Include jpeg_skip/crop_scanlines() in jpeg7.dll

... when the in-memory source/destination managers are included.
Oversight in 306e1d2d778cf5a4d2a22ac847a31722b9fc2845 and
3ab68cf563f6edc2608c085f5c8b2d5d5c61157e.

8 years agolibjpeg.txt: Include partial decomp. in TOC
DRC [Thu, 19 Jan 2017 21:36:58 +0000 (15:36 -0600)]
libjpeg.txt: Include partial decomp. in TOC

(oversight)

8 years agoSlightly de-confusify cjpeg, jpegtran usage info
DRC [Thu, 19 Jan 2017 21:33:48 +0000 (15:33 -0600)]
Slightly de-confusify cjpeg, jpegtran usage info

+ bump copyright year

8 years agoBUILDING.md: Documentation buglet
DRC [Mon, 12 Dec 2016 04:38:30 +0000 (22:38 -0600)]
BUILDING.md: Documentation buglet

`make cygwinpkg` was listed under "Mac".

8 years agoMerge branch 'master' into dev
DRC [Sat, 10 Dec 2016 15:35:30 +0000 (09:35 -0600)]
Merge branch 'master' into dev

8 years agoLICENSE.md: Include text of BSD/zlib licenses
DRC [Sat, 10 Dec 2016 15:32:23 +0000 (09:32 -0600)]
LICENSE.md: Include text of BSD/zlib licenses

LICENSE.md is included in the binary distributions as well, so it
doesn't make much sense to refer to license headers in source files that
aren't necessarily going to be there.

8 years agoPackaging system: "PACKAGE_NAME" = "PKGNAME"
DRC [Sat, 10 Dec 2016 15:10:57 +0000 (09:10 -0600)]
Packaging system: "PACKAGE_NAME" = "PKGNAME"

Using PACKAGE_NAME as a variable name made more sense with autotools,
but now it's more of an inconvenience variable than a convenience
variable.

8 years agoBuild: Don't require sudo for `make tarball`
DRC [Sat, 10 Dec 2016 15:00:39 +0000 (09:00 -0600)]
Build: Don't require sudo for `make tarball`

The whole point of `make tarball` is to make it easy for users to create
a binary distribution of libjpeg-turbo on platforms that aren't
supported by our official build system, so requiring root permissions
somewhat defeated that purpose.  Intead, the script now attempts to
detect whether the system has GNU tar or a recent version of BSD tar
that supports setting the ownership of the files in the tarball.

8 years agoMac pkg: Use PKGNAME for documentation directory
DRC [Fri, 9 Dec 2016 23:12:12 +0000 (17:12 -0600)]
Mac pkg: Use PKGNAME for documentation directory

Although there is little chance that we will ever have a package
conflict on OS X, the convention from our Linux packages is to use the
package name, not the project name, for the name of the documentation
directory.

8 years agoBuild: More GNUInstallDirs improvements
DRC [Fri, 9 Dec 2016 16:21:29 +0000 (10:21 -0600)]
Build: More GNUInstallDirs improvements

These improvements enable build systems to use GNUInstallDirs to define
custom directory variables.

- The set_dir() macro was renamed to GNUInstallDirs_set_install_dir(),
  in keeping with the module's established macro naming convention.

- Rather than detecting whether the prefix has changed, the new
  GNUInstallDirs_set_install_dir() macro instead examines whether the
  default for the variable in question has changed.  This allows for
  more flexibility, since build systems may decide to change the
  defaults based on factors other than the prefix.  It also enables the
  macro to work properly outside of the module.

- The module now performs directory variable substitution within the
  body of GNUInstallDirs_get_absolute_install_dir().

- The JAVADIR variable is no longer included in GNUInstallDirs.  That
  directory is not part of the GNU spec, and it turns out that various
  operating systems use different conventions for the location of Java
  classes.  Instead, the variable is now implemented in our build
  system as a demonstration of the aforementioned GNUInstallDirs
  enhancements.

8 years agoBuild: Various improvements to install/pkg system
DRC [Thu, 8 Dec 2016 20:43:59 +0000 (14:43 -0600)]
Build: Various improvements to install/pkg system

- GNUInstallDirs: any directory variable can now reference any other
  directory variable by including its name in angle brackets (<>).

- Changed the documentation of the directory variables in BUILDING.md
  accordingly.  This commit also includes some formatting tweaks to
  that section (using boldface for directory names, as is our
  convention.)

- Changed the package scripts such that they use
  CMAKE_INSTALL_DATAROOTDIR rather than CMAKE_INSTALL_DATADIR.

- We no longer override the install dir. defaults on Windows unless
  performing an official build.  It may be useful, for instance, to
  use the GNU defaults when installing into an MSYS environment.

8 years agoBuild: Minor tweaks to GNUInstallDirs defaults
DRC [Thu, 8 Dec 2016 01:14:20 +0000 (19:14 -0600)]
Build: Minor tweaks to GNUInstallDirs defaults

It isn't actually necessary to specify `CMAKE_INSTALL_DEFAULT_MANDIR`
for our official build.  Because `CMAKE_INSTALL_DEFAULT_DATAROOTDIR` is
blank for the official build, the default of "<DATAROOTDIR>/man" will
resolve to "man".

For the same reason, this commit changes the specification of
`CMAKE_INSTALL_DEFAULT_DOCDIR` and `CMAKE_INSTALL_DEFAULT_JAVADIR` in
the official build to be dependent on the data root directory (mainly to
make it obvious what we're doing.)

This commit also tweaks the example CMake command line in the directory
variable documentation so that it shows the correct location of the
CMake argument.

8 years agoBuild: Fix Debug/RelWithDebInfo build with YASM
DRC [Thu, 8 Dec 2016 00:11:38 +0000 (18:11 -0600)]
Build: Fix Debug/RelWithDebInfo build with YASM

YASM requires a debug format to be specified with -g.  Currently the
only combination that I can make work at all is DWARF-2/ELF (YASM
doesn't support Mach-O debugging at all, and its support for CV8/MSVC
and MinGW/DWARF-2 appears to be broken), so debugging is only enabled
automatically for ELF at the moment.  For other formats, we don't
specify -g at all, which is how the old build system behaved.

Fixes #125, Closes #126

8 years agoBuild: Set install dirs in a more GNU-friendly way
DRC [Wed, 7 Dec 2016 16:54:54 +0000 (10:54 -0600)]
Build: Set install dirs in a more GNU-friendly way

This builds upon the existing GNUInstallDirs module in CMake but adds
the following features to that module:

- The ability to override the defaults for each install directory
  through a new set of variables (`CMAKE_INSTALL_DEFAULT_*DIR`).

  Before operating system vendors began shipping libjpeg-turbo, it was
  meant to be a run-time drop-in replacement for the system's
  distribution of libjpeg, so it has traditionally installed itself
  under /opt/libjpeg-turbo on Un*x systems by default.  On Windows, it
  has traditionally installed itself under %SystemDrive%\libjpeg-turbo*,
  which is not uncommon behavior for open source libraries (open source
  SDKs tend to install outside of the Program Files directory so as to
  avoid spaces in the directory name.)  At least in the case of Un*x,
  the install directory behavior is based somewhat on the Solaris
  standard, which requires all non-O/S packages to install their files
  under /opt/{package_name}.  I adopted that standard for VirtualGL and
  TurboVNC while working at Sun, because it allowed those packages to be
  located under the same directory on all platforms.  I adopted it for
  libjpeg-turbo because it ensured that our files would never conflict
  with the system's version of libjpeg.  Even though many Un*x
  distributions ship libjpeg-turbo these days, not all of them ship the
  TurboJPEG API library or the Java classes or even the latest version
  of the libjpeg API library, so there are still many cases in which it
  is desirable to install a separate version of libjpeg-turbo than the
  one installed by the system.  Furthermore, installing the files under
  /opt mimics the directory structure of our official binary packages,
  and it makes it very easy to uninstall libjpeg-turbo.

  For these reasons, our build system needs to be able to use
  non-GNU-compliant defaults for each install directory if
  `CMAKE_INSTALL_PREFIX` is set to the default value.

- For each directory variable, the module now detects changes to
  `CMAKE_INSTALL_PREFIX` and changes the directory variable accordingly,
  if the variable has not been changed by the user.

  This makes it easy to switch between our "official" directory
  structure and the GNU-compliant directory structure "on the fly"
  simply by changing `CMAKE_INSTALL_PREFIX`.  Also, this new mechanism
  eliminated the need for the crufty mechanism that previously did the
  same thing just for the library directory variable.

  How it should work:
  - If a dir variable is unset, then the module will set an internal
    property indicating that the dir variable was initialized to its
    default value.
  - If the dir variable ever diverges from its default value, then the
    internal property is cleared, and it cannot be set again without
    unsetting the dir variable.
  - If the install prefix changes, and if the internal property
    indicates that the dir variable is still set to its default value,
    and if the dir variable's value is not being manually changed at the
    same time that the install prefix is being changed, then the dir
    variable's value is automatically changed to the new default value
    for that variable (as determined by the new install prefix.)

- The directory variables are now always cached, regardless of whether
  they were set on the command line or not.  This ensures that they can
  easily be examined and modified after being set, regardless of how they
  were set.

  This was made possible by the introduction of the aforementioned
  `CMAKE_INSTALL_DEFAULT_*DIR` variables.

- Improved directory variable documentation (based on descriptions at
  https://www.gnu.org/prep/standards/html_node/Directory-Variables.html)

- The module now allows "<DATAROOTDIR>" to be used as a placeholder in
  relative directory variables.

  It is replaced "on the fly" with the actual path of
  `CMAKE_INSTALL_DATAROOTDIR`.

This should more closely mimic the behavior of the old autotools build
system while retaining our customizations to it, and it should retain
the behavior of the old CMake build system.

Closes #124

8 years agoBuild: Fix Win "installer" target Java dependency
DRC [Wed, 7 Dec 2016 20:09:41 +0000 (14:09 -0600)]
Build: Fix Win "installer" target Java dependency

The correct target name is now "turbojpeg-java".

8 years agoBuild: Formatting tweak
DRC [Wed, 7 Dec 2016 16:40:28 +0000 (10:40 -0600)]
Build: Formatting tweak

(It is our convention to use lowercase for CMake macro/function names)

8 years agoBuild: Clean up inline keyword detection
DRC [Mon, 5 Dec 2016 22:52:54 +0000 (16:52 -0600)]
Build: Clean up inline keyword detection

Strict C89-conformant compilers don't support the "inline" keyword, but
most of them support "__inline__", and that keyword can be used with the
always_inline atribute as well.  This commit also removes duplicate code
by using a foreach() loop to test the various keywords.

8 years agoFix build when CFLAGS contains -std=c89 (or -ansi)
DRC [Mon, 5 Dec 2016 20:02:59 +0000 (14:02 -0600)]
Fix build when CFLAGS contains -std=c89 (or -ansi)

This is a subtle point, but AC_C_INLINE defines "inline" to be either
"inline", "__inline__", or "__inline".  The subsequent test for
"inline __attribute__((always_inline))" uses this definition.  The
attribute is irrespective of the inline keyword, so whereas
"__inline__ __attribute__((always_inline))" works under C89,
"inline __attribute__((always_inline))" doesn't, and defining INLINE to
the latter causes the build to fail.  The easiest way around this is
simply to define "inline" ahead of "INLINE" in jconfigint.h,
which causes the inline keyword detected by AC_C_INLINE to modify the
INLINE macro if necessary.

8 years agoReorg AltiVec detection code
DRC [Mon, 5 Dec 2016 18:39:49 +0000 (12:39 -0600)]
Reorg AltiVec detection code

+ advertise that full AltiVec SIMD acceleration is now available on
OpenBSD.

The relevant compilers probably all support C99 or GNU's variation of
C90 that allows variables to be declared anywhere, but our policy is to
conform to the C90 standard, if for no other reason than that it
improves code readability.

8 years agoDetect AltiVec support on OpenBSD
Donovan Watteau [Sat, 3 Dec 2016 14:46:49 +0000 (15:46 +0100)]
Detect AltiVec support on OpenBSD

8 years agoPackaging: Use correct name for SRPM spec file
DRC [Sat, 3 Dec 2016 21:51:58 +0000 (15:51 -0600)]
Packaging: Use correct name for SRPM spec file

Per convention, the file should be named {package name}.spec.

8 years agoFix sign mismatch comparison warnings
Colin Cross [Fri, 2 Dec 2016 00:56:18 +0000 (16:56 -0800)]
Fix sign mismatch comparison warnings

Fixes:
rdppm.c:257:14: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]
    if (temp > maxval)
        ~~~~ ^ ~~~~~~
rdppm.c:284:14: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]
    if (temp > maxval)
        ~~~~ ^ ~~~~~~
rdppm.c:289:14: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]
    if (temp > maxval)
        ~~~~ ^ ~~~~~~
rdppm.c:294:14: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]
    if (temp > maxval)

8 years agoBuild: Fix issues when building as a Git submodule
DRC [Sat, 3 Dec 2016 20:21:11 +0000 (14:21 -0600)]
Build: Fix issues when building as a Git submodule

- Replace CMAKE_SOURCE_DIR with CMAKE_CURRENT_SOURCE_DIR
- Replace CMAKE_BINARY_DIR with CMAKE_CURRENT_BINARY_DIR
- Don't use "libjpeg-turbo" in any of the package system filenames
  (because CMAKE_PROJECT_NAME will not be the same if building LJT as
  a submodule.)

Closes #122

8 years agoBuild: Fix buglet in output of `make tjtest`
DRC [Sat, 3 Dec 2016 19:38:21 +0000 (13:38 -0600)]
Build: Fix buglet in output of `make tjtest`

8 years agoBuild: Fix regression in AltiVec SIMD detection
DRC [Sat, 3 Dec 2016 21:17:09 +0000 (21:17 +0000)]
Build: Fix regression in AltiVec SIMD detection

Only the SIMD source files should be built with -maltivec.  Otherwise
the detection code will not be compiled in.

8 years agoFix md5cmp on AmigaOS 4 (PowerPC big-endian)
DRC [Fri, 2 Dec 2016 00:23:32 +0000 (18:23 -0600)]
Fix md5cmp on AmigaOS 4 (PowerPC big-endian)

+ Document AmigaOS support in the change log.

Based on:
https://github.com/chris-y/libjpeg-turbo/commit/b4f3b757970cd9dd448af9d2713b6bcdd9929147

Closes #119

8 years agoTravis: Use xcode7.3 image
DRC [Thu, 1 Dec 2016 07:58:34 +0000 (01:58 -0600)]
Travis: Use xcode7.3 image

The xcode7.2 image is verfallen, verlumpt, verblunget, verkackt

This also ensures that the build scripts are checked out from a
branch matching the libjpeg-turbo repository branch (not strictly
necessary when building from master, but it keeps the code in sync with
dev.)

8 years agoBuild: Use wrapper script for gas-preprocessor.pl
DRC [Sat, 26 Nov 2016 00:50:11 +0000 (18:50 -0600)]
Build: Use wrapper script for gas-preprocessor.pl

The previous hack (adding ${CMAKE_ASM_COMPILER} to CMAKE_ASM_FLAGS)
didn't work in all cases, because more recent versions of CMake place
the includes ahead of the flags (which meant that the real assembler
wasn't the first argument to gas-preprocessor.pl.)

8 years agoTravis: Fix OS X build
DRC [Thu, 24 Nov 2016 00:44:33 +0000 (18:44 -0600)]
Travis: Fix OS X build

+ migrate to new xcode7.3 image, since xcode7.2 is going away soon.