]> granicus.if.org Git - libjpeg-turbo/log
libjpeg-turbo
6 years agoFix JPEG spec references per ISO/ITU-T suggestions
DRC [Tue, 24 Jul 2018 23:36:51 +0000 (18:36 -0500)]
Fix JPEG spec references per ISO/ITU-T suggestions

- When referring to specific clauses, annexes, tables, and figures, a
  "timed reference" (a reference that includes the year) must be used in
  order to avoid confusion.
- "CCITT" = "ITU-T"
- Replace ambiguous "JPEG spec" with the specific document number.

6 years agoFix int overflow when decompr. corrupt prog. JPEG
Even Rouault [Fri, 20 Jul 2018 16:04:15 +0000 (18:04 +0200)]
Fix int overflow when decompr. corrupt prog. JPEG

No discernible performance regression

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9447
Credit to OSS Fuzz
Closes #259

6 years agocjpeg: Fix OOB read caused by malformed 8-bit BMP
DRC [Fri, 20 Jul 2018 22:21:36 +0000 (17:21 -0500)]
cjpeg: Fix OOB read caused by malformed 8-bit BMP

... in which one or more of the color indices is out of range for the
number of palette entries.

Fix partly borrowed from jpeg-9c.  This commit also adopts Guido's
JERR_PPM_OUTOFRANGE enum value in lieu of our project-specific
JERR_PPM_TOOLARGE enum value.

Fixes #258

6 years agoBuild: Preserve CMake exe suffix from cmd line
DRC [Fri, 20 Jul 2018 16:30:04 +0000 (11:30 -0500)]
Build: Preserve CMake exe suffix from cmd line

Normally the value of CMAKE_EXECUTABLE_SUFFIX is clobbered by project().

This allows for specifying an executable suffix of .html with Emscripten
builds, which causes Emscripten to build standalone HTML versions of the
libjpeg-turbo test programs.

6 years agoHonor CMake exe suffix when inst. static builds
DRC [Thu, 19 Jul 2018 22:01:42 +0000 (17:01 -0500)]
Honor CMake exe suffix when inst. static builds

This specifically allows an Emscripten (WASM) static build (for which
CMAKE_EXECUTABLE_SUFFIX=.js) to be properly installed.

6 years agoREADME.ijg: Clarification regarding JPEG 2000/XR
DRC [Tue, 10 Jul 2018 20:06:46 +0000 (15:06 -0500)]
README.ijg: Clarification regarding JPEG 2000/XR

The sentence:
"Indeed, one of the original reasons for developing this free software
was to help force convergence on common, interoperable format standards
for JPEG files."
might be seen to imply that JPEG 2000 and JPEG XR are not interoperable
with themselves, although it is certainly the case that those formats
are not interoperable with each other, nor with
ITU T.81 | ISO/IEC 10918.  They are also certainly not as common as
ITU T.81 | ISO/IEC 10918, and (as an example) popular web browsers will
not display JPEG 2000 files.

The sentence in question was originally referring to proprietary,
non-standard formats and was meant to provide historical context.
libjpeg was originally released prior to the adoption of JFIF as an
official standard, so it encouraged adoption of JFIF as a de facto
standard by providing, under a business-friendly free software license,
a library for reading and writing images in that format.

6 years agoBUILDING.md: Correct iOS/Android examples
DRC [Mon, 2 Jul 2018 16:42:06 +0000 (11:42 -0500)]
BUILDING.md: Correct iOS/Android examples

toolchain.cmake should be created in the build directory, so the scripts
need to cd to that directory before generating that file.

Closes #254

6 years agoBuild: Detect whether compiler supports DSPr2
DRC [Fri, 29 Jun 2018 17:45:57 +0000 (12:45 -0500)]
Build: Detect whether compiler supports DSPr2

This is basically the same test that was performed in acinclude.m4 in
the old autotools-based build system.  It was not ported to the
CMake-based build system because I previously had no way of testing
a non-DSPr2 build environment.

Fixes #248

6 years agoFix jpeg_skip_scanlines() segfault w/merged upsamp
Darrell Walisser [Sat, 16 Jun 2018 22:31:35 +0000 (18:31 -0400)]
Fix jpeg_skip_scanlines() segfault w/merged upsamp

Fixes NULL pointer reference when decompressing 4:2:2 or 4:2:0 JPEG
images with cinfo.do_fancy_upsampling = FALSE.

Closes #244

6 years agoFix infinite loop in partial image decompression
DRC [Sun, 24 Jun 2018 22:31:15 +0000 (17:31 -0500)]
Fix infinite loop in partial image decompression

... caused by using certain specific combinations of
jpeg_skip_scanlines() and jpeg_read_scanlines() calls with progressive,
vertically-subsampled JPEG images.

Fixes #237

6 years agotjLoadImage(): Fix FPE triggered by malformed BMP
DRC [Wed, 13 Jun 2018 01:27:00 +0000 (20:27 -0500)]
tjLoadImage(): Fix FPE triggered by malformed BMP

In rdbmp.c, it is necessary to guard against 32-bit overflow/wraparound
when allocating the row buffer, because since BMP files have 32-bit
width and height fields, the value of biWidth can be up to 4294967295.
Specifically, if biWidth is 1073741824 and cinfo->input_components = 4,
then the samplesperrow argument in alloc_sarray() would wrap around to
0, and a division by zero error would occur at line 458 in jmemmgr.c.

If biWidth is set to a higher value, then samplesperrow would wrap
around to a small number, which would likely cause a buffer overflow
(this has not been tested or verified.)

6 years agoTurboJPEG: Handle JERR_BMP*,JERR_PPM* error codes
DRC [Tue, 12 Jun 2018 23:49:37 +0000 (18:49 -0500)]
TurboJPEG: Handle JERR_BMP*,JERR_PPM* error codes

... in tjLoadImage()/tjSaveImage().  These error codes require an add-on
message table, and if it isn't initialized, then format_message()
produces "Bogus message code XXXX" instead.

6 years agoFix CVE-2018-11813
DRC [Tue, 12 Jun 2018 21:08:26 +0000 (16:08 -0500)]
Fix CVE-2018-11813

Refer to change log for details.

Fixes #242

6 years agoTravis: Use SKS keyserver pool
DRC [Tue, 22 May 2018 03:52:39 +0000 (22:52 -0500)]
Travis: Use SKS keyserver pool

pgp.mit.edu seems to be frequently down, which was causing the PR builds
to fail.

6 years agoAdditional code formatting tweaks
DRC [Mon, 21 May 2018 17:07:40 +0000 (12:07 -0500)]
Additional code formatting tweaks

... detected with an improved version of our checkstyle script

6 years agoJava: Further style refinements
DRC [Wed, 16 May 2018 15:49:09 +0000 (10:49 -0500)]
Java: Further style refinements

(detected by enabling additional checkstyle modules)

This commit also removes unnecessary uses of the "private" modifier in
the Java tests/examples.  The default access modifier disallows access
outside of the package, and none of these classes is in a package.  The
only reason we use "private" with member variables in these classes is
to make checkstyle happy, because we want it to enforce that behavior in
the TurboJPEG API code.

6 years agoJava: Reformat code per checkstyle recommendations
DRC [Tue, 15 May 2018 19:51:49 +0000 (14:51 -0500)]
Java: Reformat code per checkstyle recommendations

... and modify tjbench.c to match the variable name changes made to
TJBench.java

("checkstyle" = http://checkstyle.sourceforge.net, not our regex-based
checkstyle script)

6 years agoTurboJPEG: Handle CMYK JPEGs w/ subsampled M, Y
DRC [Thu, 26 Apr 2018 23:01:52 +0000 (18:01 -0500)]
TurboJPEG: Handle CMYK JPEGs w/ subsampled M, Y

Arguably it doesn't make much sense for non-chroma components to be
subsampled (which is why this type of image was overlooked in
cd7c3e6672cce3779450c6dd10d0d70b0c2278b2-- I didn't realize it was a
thing), but certain Adobe applications apparently generate these images.

Fixes #236

6 years agoBump revision to 1.5.91 for post-beta fixes
DRC [Thu, 26 Apr 2018 22:33:52 +0000 (17:33 -0500)]
Bump revision to 1.5.91 for post-beta fixes

6 years agoAdditional code formatting tweaks
DRC [Thu, 12 Apr 2018 22:02:10 +0000 (17:02 -0500)]
Additional code formatting tweaks

... detected with an improved version of our checkstyle script

6 years ago"Further" = "Furthermore"
DRC [Wed, 11 Apr 2018 15:47:16 +0000 (10:47 -0500)]
"Further" = "Furthermore"

Grammar Police.  Has Ray Stevens taught me nothing?

6 years agox86[-64] SIMD: Don't auto-generate jsimdcfg.inc
DRC [Tue, 10 Apr 2018 20:50:22 +0000 (15:50 -0500)]
x86[-64] SIMD: Don't auto-generate jsimdcfg.inc

The old Un*x (autotools-based) build system always auto-generated this
file, but that behavior was more or less a relic of the days before the
libjpeg-turbo colorspace extensions were implemented.  The thinking was
that, if a particular developer wanted to change RGB_RED, RGB_GREEN,
RGB_BLUE, or RGB_PIXELSIZE in order to compress from/decompress to
different RGB pixel layouts, then the SIMD extensions should
automatically respond to those changes whenever they were made to
jmorecfg.h.  The modern reality is that changing RGB_* is no longer
necessary because of the libjpeg-turbo colorspace extensions, and
changing any of the other constants in jsimdcfg.inc can't be done
without making deeper modifications to the SIMD extensions.  In general,
we treat RGB_* as a de facto, immutable part of the legacy libpjeg API.
Realistically, since the values of those constants have been the same in
every Un*x distribution released in the past 20-30 years, any software
that uses a system-supplied build of libjpeg must assume that those
constants will have default values.

Furthermore, even if it made sense to auto-generate jsimdcfg.inc, it was
never possible to do so on Windows, so it was always going to be
necessary to manually generate the Windows version of the file whenever
any of the constants changed.  This commit introduces a new custom CMake
target called "jsimdcfg" that can be used, on Un*x platforms, to
generate jsimdcfg.inc on demand, although this should only be necessary
when introducing new x86 SIMD instructions or making other deep
modifications, such as SIMD acceleration for 12-bit JPEGs.

For those who may be wondering why we don't do the same thing for
win/jconfig.h.in, it's because performing all of the necessary CMake
checks to populate that file is very slow on Windows.

6 years agojsimd_can_encode_mcu_AC_*(): Remove useless checks
mayeut [Mon, 9 Apr 2018 22:02:57 +0000 (00:02 +0200)]
jsimd_can_encode_mcu_AC_*(): Remove useless checks

These were necessary for the first iteration of the feature (see #46),
which provided a different C front end for the SIMD version of the
function.  The final version of the feature uses a common C front end
for both SIMD and non-SIMD implementations, so these checks are no
longer necessary.

Closes #231

6 years agoAdditional code formatting tweaks
DRC [Sun, 8 Apr 2018 17:49:05 +0000 (12:49 -0500)]
Additional code formatting tweaks

... detected with an improved version of our checkstyle script

6 years agoREADMEs: Mention that prog JPEG is now accelerated
DRC [Fri, 6 Apr 2018 23:31:17 +0000 (18:31 -0500)]
READMEs: Mention that prog JPEG is now accelerated

6 years agoREADME.ijg: Wordsmith per ISO/ITU-T suggestions
DRC [Fri, 6 Apr 2018 22:07:56 +0000 (17:07 -0500)]
README.ijg: Wordsmith per ISO/ITU-T suggestions

This commit merges the following paragraph from the latest libjpeg
release:
https://github.com/libjpeg-turbo/ijg/blob/jpeg-9c/README#L222-L229
which takes into account the fact that JFIF is now an official ISO/ITU-T
standard.  I also included the ISO/IEC document number for the JFIF spec
(jpeg-9c included only the ITU-T rec number.)

This commit also heavily wordsmiths the "FILE FORMAT WARS" section.
In jpeg-7 and later, this section has become somewhat impolitic,
referring to JPEG 2000 and JPEG XR as "faulty technologies" and
"momentary mistakes."  The original intent of this section, which was
introduced in jpeg-5 and refined in jpeg-6
(https://github.com/libjpeg-turbo/ijg/blob/jpeg-5/README#L317-L338,
https://github.com/libjpeg-turbo/ijg/blob/jpeg-6b/README#L335-L367)
was to highlight the problem of JPEG file format divergence that existed
in the 1990s prior to the adoption of JFIF as an official ISO/ITU-T
standard.  That problem is fortunately no longer a problem, thanks in
part to the existence of libjpeg.  I have attempted to preserve Tom's
intent of using this section to describe which file formats the code is
compatible with and why it isn't compatible with some file formats
bearing the name "JPEG."  Such modifications always put our project in a
very awkward position, because we are not the IJG and do not claim to
be, but it is still necessary for us to modify the IJG README file from
time to time to eliminate obsolete information while attempting to
remain as neutral as possible.

6 years agoFix compiler warning w/ 32-bit MSVC builds
DRC [Sun, 1 Apr 2018 02:48:20 +0000 (21:48 -0500)]
Fix compiler warning w/ 32-bit MSVC builds

6 years agoFix build errors when C flags include -Werror
DRC [Sat, 31 Mar 2018 21:19:01 +0000 (16:19 -0500)]
Fix build errors when C flags include -Werror

Instructing the compiler to treat warnings as errors caused some of the
compiler tests to fail, because the test code was not 100% clean.

Note that we now use check_symbol_exists() to check for memset() and
memcpy(), since the test code for check_function_exists() produces a
compiler warning due to not including <string.h>.

6 years agoCMakeLists.txt: Move intrin.h header check
DRC [Sat, 31 Mar 2018 20:34:23 +0000 (15:34 -0500)]
CMakeLists.txt: Move intrin.h header check

It is more readable for this to be next to the __builtin_ctzl() check,
since both are used by the accelerated progressive Huffman code.

6 years agoEliminate compiler warnings w/ Solaris Studio
DRC [Sat, 31 Mar 2018 18:51:31 +0000 (13:51 -0500)]
Eliminate compiler warnings w/ Solaris Studio

6 years agoPowerPC: Fix comp. warning when built w/ -maltivec
DRC [Sat, 31 Mar 2018 18:25:44 +0000 (13:25 -0500)]
PowerPC: Fix comp. warning when built w/ -maltivec

6 years agoLICENSE.md: Explain why three licenses were used
DRC [Sat, 31 Mar 2018 17:39:04 +0000 (12:39 -0500)]
LICENSE.md: Explain why three licenses were used

6 years agojversion.h: Bump copyright year to 2018
DRC [Sat, 31 Mar 2018 16:33:22 +0000 (11:33 -0500)]
jversion.h: Bump copyright year to 2018

6 years agoBuild: Use Colin Plumb's public domain MD5 code
DRC [Sat, 31 Mar 2018 15:36:06 +0000 (10:36 -0500)]
Build: Use Colin Plumb's public domain MD5 code

... instead of the RSA code, the license for which contains an
advertising clause.  It is strongly believed that the RSA advertising
clause is innocuous, because:

- A clarification from RSA
  (http://www.ietf.org/ietf-ftp/IPR/RSA-MD-all), published in 2000,
  stated:

  "Implementations of these message-digest algorithms, including
  implementations derived from the reference C code in RFC-1319,
  RFC-1320, and RFC-1321, may be made, used, and sold without license
  from RSA for any purpose."

  Referring to the opinion from Fedora's legal team
  (https://fedoraproject.org/wiki/Licensing:FAQ?rd=Licensing/FAQ#What_about_the_RSA_license_on_their_MD5_implementation.3F_Isn.27t_that_GPL-incompatible.3F),
  this means that md5.c and md5.h, which were derived from the original
  RFC 1321 reference code (http://www.faqs.org/rfcs/rfc1321.html), can
  be used without the RSA license.

- In the context of libjpeg-turbo, RSA's MD5 code was used only in the
  build/test system.  It was not part of the libjpeg-turbo binary
  distribution, and thus the only "material mentioning or referencing"
  the MD5 code was the libjpeg-turbo source code, which-- by virtue of
  including RSA's original copyright headers-- properly attributed the
  code as required under the RSA license.

However, in light of the open source community's tendency to have
knee-jerk reactions to stuff like this, it would've been necessary to
include the above explanation in our source tree in order to head off
potential FUD, and a simple fix is always better than a complex
explanation.

This commit also assigns the 3-clause BSD license to my modifications of
the MD5 code.  This license is the same one used by md5cmp and other
parts of the build system.

6 years agoTravis: Deploy only when using official repo
Matthieu Darbois [Thu, 29 Mar 2018 22:33:00 +0000 (00:33 +0200)]
Travis: Deploy only when using official repo

This prevents build failures on forks that contain a master or dev
branch.

6 years agoBuild: Fix rpath in iOS shared libraries 1.5.90
DRC [Sat, 24 Mar 2018 04:17:08 +0000 (23:17 -0500)]
Build: Fix rpath in iOS shared libraries

When attempting to configure an iOS/ARM build with Xcode 7.2 and CMake
2.8.12, I got the following errors:

CMake Error at CMakeLists.txt:560 (add_library):
  Attempting to use MACOSX_RPATH without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG
  being set.  This could be because you are using a Mac OS X version less
  than 10.5 or because CMake's platform configuration is corrupt.
(x 3)

CMake Error at sharedlib/CMakeLists.txt:38 (add_library):
  Attempting to use MACOSX_RPATH without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG
  being set.  This could be because you are using a Mac OS X version less
  than 10.5 or because CMake's platform configuration is corrupt.
(x 3)

Upgrading to CMake 3.x (tried 3.0 and 3.1) got rid of the errors, but
the resulting shared libs still did not use @rpath as expected.  Note
also that CMake 3.x (at least the two versions I tested) does not
automatically set the MACOSX_RPATH property as claimed.  I could find
nothing in the release notes for later CMake releases to indicate that
either problem has been fixed.  What I did find was this little nugget
of code in the Darwin platform module:

https://github.com/Kitware/CMake/blob/f6b93fbf3ae00a9157af2f6497bed074d585cea9/Modules/Platform/Darwin.cmake#L33-L36

This sets CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG="-Wl,-rpath," only if you
are running OS X 10.5 or later.  It makes no such check for iOS, perhaps
because shared libraries aren't much of a thing with iOS apps.  In any
event, this commit simply sets CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG if it
isn't set already, and that fixes all of the aforementioned problems.

6 years agoTravis: Don't build tags
DRC [Fri, 23 Mar 2018 21:11:06 +0000 (16:11 -0500)]
Travis: Don't build tags

6 years agoFix continuous integration of pull requests
DRC [Fri, 23 Mar 2018 18:57:59 +0000 (13:57 -0500)]
Fix continuous integration of pull requests

- Travis doesn't set the $encrypted_* variables for PRs, so disable GPG
signing when building a PR (artifacts aren't deployed for PRs anyhow,
and even if they were, I wouldn't want them to be signed, as they may
contain unvetted code.)
- Take advantage of the new -d option in buildljt, which allows for
building from an existing Git clone directory.  This eliminates the need
to rename and restore .git/shallow, allows the official build scripts to
work properly when building PRs, and prevents 'git clone' being invoked
twice in CI builds.

Refer to #217

6 years agoInclude .pc and man files in MinGW install[er]s
DRC [Fri, 23 Mar 2018 16:14:50 +0000 (11:14 -0500)]
Include .pc and man files in MinGW install[er]s

These files are potentially useful to MinGW users, since MSYS2 MinGW
environments have a man command by default and provide an easy way to
install pkg-config.

Closes #223

6 years agorelease/installer.nsi.in: Remove extraneous quotes
DRC [Fri, 23 Mar 2018 16:04:45 +0000 (11:04 -0500)]
release/installer.nsi.in: Remove extraneous quotes

These don't seem to affect anything, because $INSTDIR is already quoted
per 25758055ac74db8edb0486c256fe11539086498f.

6 years agojcphuff.c: Fix compiler warning
DRC [Fri, 23 Mar 2018 15:41:07 +0000 (10:41 -0500)]
jcphuff.c: Fix compiler warning

Misleading indentation, introduced by
5b177b3cab5cfb661256c1e74df160158ec6c34e

6 years agoREADME.md: clarify where API docs can be found
DRC [Fri, 23 Mar 2018 05:00:58 +0000 (00:00 -0500)]
README.md: clarify where API docs can be found

6 years agoChangeLog.md: bump revision to prepare for beta
DRC [Thu, 22 Mar 2018 22:15:53 +0000 (17:15 -0500)]
ChangeLog.md: bump revision to prepare for beta

6 years agojcphuff.c: Fix compiler warning with Visual C++
DRC [Thu, 22 Mar 2018 22:14:15 +0000 (17:14 -0500)]
jcphuff.c: Fix compiler warning with Visual C++

GCC doesn't seem to care if we pass no arguments to the ENCODE_COEFS*
macros, but MSVC does.  Insert a no-op to make it happy.

6 years agoBump revision to 1.5.90 to prepare for beta
DRC [Thu, 22 Mar 2018 21:08:25 +0000 (16:08 -0500)]
Bump revision to 1.5.90 to prepare for beta

6 years agoLabel this release 2.0 instead of 1.6
DRC [Thu, 22 Mar 2018 21:04:29 +0000 (16:04 -0500)]
Label this release 2.0 instead of 1.6

This also pulls the formatting changes from
19c791cdac6df84418c66eb9d67cfa9703bc2461 into the TurboJPEG C API docs.

6 years agoChangeLog.md: clarification regarding AVX2
DRC [Thu, 22 Mar 2018 20:56:09 +0000 (15:56 -0500)]
ChangeLog.md: clarification regarding AVX2

6 years agoC/SSE2 optimization of encode_mcu_AC_first()
mayeut [Thu, 22 Mar 2018 16:36:43 +0000 (11:36 -0500)]
C/SSE2 optimization of encode_mcu_AC_first()

This commit adds C and SSE2 optimizations for the encode_mcu_AC_first()
function used in progressive Huffman encoding.

The image used for testing can be retrieved from this page:
https://blog.cloudflare.com/doubling-the-speed-of-jpegtran

All timings done on `Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz`
clang version is `Apple LLVM version 9.0.0 (clang-900.0.39.2)`
gcc-5 version is `gcc-5 (Homebrew GCC 5.5.0) 5.5.0`
gcc-7 version is `gcc-7 (Homebrew GCC 7.2.0) 7.2.0`

Here are the results in comparison to libjpeg-turbo@293263c using
`time ./jpegtran -outfile /dev/null -progressive -optimise -copy none print_poster_0025.jpg`

C
clang x86_64: +19%
gcc-5 x86_64: +80%
gcc-7 x86_64: +57%
clang i386: +5%
gcc-5 i386: +59%
gcc-7 i386: +51%

SSE2
clang x86_64: +79%
gcc-5 x86_64: +158%
gcc-7 x86_64: +122%
clang i386: +71%
gcc-5 i386: +134%
gcc-7 i386: +135%

Discussion in libjpeg-turbo/libjpeg-turbo#46

6 years agoC/SSE2 optimization of encode_mcu_AC_refine()
mayeut [Fri, 2 Mar 2018 21:33:19 +0000 (22:33 +0100)]
C/SSE2 optimization of encode_mcu_AC_refine()

This commit adds C and SSE2 optimizations for the encode_mcu_AC_refine()
function used in progressive Huffman encoding.

The image used for testing can be retrieved from this page:
https://blog.cloudflare.com/doubling-the-speed-of-jpegtran

All timings done on `Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz`
clang version is `Apple LLVM version 9.0.0 (clang-900.0.39.2)`
gcc-5 version is `gcc-5 (Homebrew GCC 5.5.0) 5.5.0`
gcc-7 version is `gcc-7 (Homebrew GCC 7.2.0) 7.2.0`

Here are the results in comparison to libjpeg-turbo@3c54642 using
`time ./jpegtran -outfile /dev/null -progressive -optimise -copy none print_poster_0025.jpg`

C
clang x86_64: +7%
gcc-5 x86_64: +30%
gcc-7 x86_64: +33%
clang i386: +0%
gcc-5 i386: +24%
gcc-7 i386: +23%

SSE2
clang x86_64: +42%
gcc-5 x86_64: +53%
gcc-7 x86_64: +64%
clang i386: +35%
gcc-5 i386: +46%
gcc-7 i386: +49%

Discussion in libjpeg-turbo/libjpeg-turbo#46

6 years agosimd/i386/jchuff-sse2.asm: Minor formatting tweak
DRC [Wed, 21 Mar 2018 18:03:30 +0000 (13:03 -0500)]
simd/i386/jchuff-sse2.asm: Minor formatting tweak

7 years agoFormat preprocessor macros more consistently
DRC [Sat, 17 Mar 2018 20:14:35 +0000 (15:14 -0500)]
Format preprocessor macros more consistently

Within the libjpeg API code, it seems to be more the convention than not
to separate the macro name and value by two or more spaces, which
improves general readability.  Making this consistent across all of
libjpeg-turbo is less about my individual preferences and more about
making it easy to automatically detect variations from our chosen
formatting convention.  I intend to release the script I'm using to
validate this stuff, once it matures and stabilizes a bit.

7 years agoAdditional code formatting tweaks
DRC [Fri, 16 Mar 2018 23:20:05 +0000 (18:20 -0500)]
Additional code formatting tweaks

Missed by previous analysis

7 years agoMerge branch 'master' into dev
DRC [Sat, 17 Mar 2018 05:27:49 +0000 (00:27 -0500)]
Merge branch 'master' into dev

7 years agoMake all get/putenv() calls compile-time optional
DRC [Sat, 17 Mar 2018 05:06:10 +0000 (00:06 -0500)]
Make all get/putenv() calls compile-time optional

* Modify the SIMD dispatchers so they guard their usage of getenv() with
  the existing NO_GETENV preprocessor definition.
* Introduce a new NO_PUTENV preprocessor definition to guard the
  usage of putenv() in the TurboJPEG API library.

This at least puts Windows Store compatibility within the realm of
possibility, although further steps are required.

7 years agoWin installer: allow install directories w/ spaces
DRC [Sat, 17 Mar 2018 01:34:18 +0000 (20:34 -0500)]
Win installer: allow install directories w/ spaces

7 years agoFix build with older MinGW releases
Cameron Cawley [Tue, 6 Mar 2018 22:10:14 +0000 (22:10 +0000)]
Fix build with older MinGW releases

Some MinGW implementations need stdint.h in order to define SIZE_MAX.

Regression caused by a09ba29a55b9a43d346421210d94370065eeaf53 and
not fully fixed by a0047bdea4d11dfeefb9ea797865b1a2ea0a665e.

Closes #220

7 years agoturbojpeg.c: Fix Windows build
DRC [Fri, 16 Mar 2018 19:09:53 +0000 (14:09 -0500)]
turbojpeg.c: Fix Windows build

Broken by previous commit.  Although turbojpeg.c no longer needs
tjutil.h on Un*x, it still needs to include that file on Windows in
order to use snprintf() and strcasecmp() (which, on Windows, are macros
that wrap _snprintf_s() and stricmp().)

7 years agoMerge branch 'master' into dev
DRC [Fri, 16 Mar 2018 07:16:41 +0000 (02:16 -0500)]
Merge branch 'master' into dev

7 years agoImprove code formatting consistency
DRC [Thu, 8 Mar 2018 16:55:20 +0000 (10:55 -0600)]
Improve code formatting consistency

With rare exceptions ...
- Always separate line continuation characters by one space from
  preceding code.
- Always use two-space indentation.  Never use tabs.
- Always use K&R-style conditional blocks.
- Always surround operators with spaces, except in raw assembly code.
- Always put a space after, but not before, a comma.
- Never put a space between type casts and variables/function calls.
- Never put a space between the function name and the argument list in
  function declarations and prototypes.
- Always surround braces ('{' and '}') with spaces.
- Always surround statements (if, for, else, catch, while, do, switch)
  with spaces.
- Always attach pointer symbols ('*' and '**') to the variable or
  function name.
- Always precede pointer symbols ('*' and '**') by a space in type
  casts.
- Use the MIN() macro from jpegint.h within the libjpeg and TurboJPEG
  API libraries (using min() from tjutil.h is still necessary for
  TJBench.)
- Where it makes sense (particularly in the TurboJPEG code), put a blank
  line after variable declaration blocks.
- Always separate statements in one-liners by two spaces.

The purpose of this was to ease maintenance on my part and also to make
it easier for contributors to figure out how to format patch
submissions.  This was admittedly confusing (even to me sometimes) when
we had 3 or 4 different style conventions in the same source tree.  The
new convention is more consistent with the formatting of other OSS code
bases.

This commit corrects deviations from the chosen formatting style in the
libjpeg API code and reformats the TurboJPEG API code such that it
conforms to the same standard.

NOTES:
- Although it is no longer necessary for the function name in function
  declarations to begin in Column 1 (this was historically necessary
  because of the ansi2knr utility, which allowed libjpeg to be built
  with non-ANSI compilers), we retain that formatting for the libjpeg
  code because it improves readability when using libjpeg's function
  attribute macros (GLOBAL(), etc.)
- This reformatting project was accomplished with the help of AStyle and
  Uncrustify, although neither was completely up to the task, and thus
  a great deal of manual tweaking was required.  Note to developers of
  code formatting utilities:  the libjpeg-turbo code base is an
  excellent test bed, because AFAICT, it breaks every single one of the
  utilities that are currently available.
- The legacy (MMX, SSE, 3DNow!) assembly code for i386 has been
  formatted to match the SSE2 code (refer to
  ff5685d5344273df321eb63a005eaae19d2496e3.)  I hadn't intended to
  bother with this, but the Loongson MMI implementation demonstrated
  that there is still academic value to the MMX implementation, as an
  algorithmic model for other 64-bit vector implementations.  Thus, it
  is desirable to improve its readability in the same manner as that of
  the SSE2 implementation.

7 years agousage.txt: Remove Alt-Space non-ASCII character
DRC [Fri, 16 Mar 2018 07:13:03 +0000 (02:13 -0500)]
usage.txt: Remove Alt-Space non-ASCII character

7 years agoFix build when RGB_{RED,GREEN,BLUE}!={0,1,2}
DRC [Tue, 13 Mar 2018 15:54:57 +0000 (10:54 -0500)]
Fix build when RGB_{RED,GREEN,BLUE}!={0,1,2}

Broken by aa7459050d7a50e1d8a99488902d41fbc118a50f

7 years agoTravis: OS X official builds now use YASM
DRC [Mon, 5 Mar 2018 18:50:19 +0000 (12:50 -0600)]
Travis: OS X official builds now use YASM

Because 367a838626576b4ff2a47cbd5a494199b800dc48

7 years agoLoongson MMI SIMD extensions
DRC [Thu, 1 Mar 2018 16:38:17 +0000 (10:38 -0600)]
Loongson MMI SIMD extensions

Based on:
https://github.com/zhuchen1911/libjpeg-turbo/commit/42aff4497bdaca3258279cafc74511e3c25454b8

Closes #158

7 years agoSIMD: Formatting tweaks + remove unnecessary code
DRC [Wed, 28 Feb 2018 22:24:03 +0000 (16:24 -0600)]
SIMD: Formatting tweaks + remove unnecessary code

+ "JSIMD_ARM_NEON" = "JSIMD_NEON"
+ "JSIMD_MIPS_DSPR2" = "JSIMD_DSPR2"
+ "*_mips_dspr2" = "*_dspr2"

It's obvious that "NEON" refers to Arm and "DSPr2" refers to MIPS, and
this naming convention is consistent with the other SIMD extensions.

7 years agoFix iOS/ARM[-64] build w/ newer versions of CMake
DRC [Tue, 27 Feb 2018 17:36:43 +0000 (11:36 -0600)]
Fix iOS/ARM[-64] build w/ newer versions of CMake

Newer versions of CMake (known to be the case with 3.7.x and 3.10.x)
fail to add a space between CMAKE_C_FLAGS and CMAKE_ASM_FLAGS, which
causes the build to fail when using the official build procedure.

Closes #216

7 years agoMake SIMD syms private for x86[-64]/Mach-O builds
DRC [Tue, 27 Feb 2018 01:41:59 +0000 (19:41 -0600)]
Make SIMD syms private for x86[-64]/Mach-O builds

... if building with YASM.  NASM doesn't currently support the necessary
directives.

Closes #212

7 years agoMerge branch 'master' into dev
DRC [Tue, 27 Feb 2018 00:43:40 +0000 (18:43 -0600)]
Merge branch 'master' into dev

Closes #214

7 years agoFix Win64 ABI conformance when using xmm8-xmm11
mayeut [Sat, 24 Feb 2018 13:50:56 +0000 (14:50 +0100)]
Fix Win64 ABI conformance when using xmm8-xmm11

Referring to https://docs.microsoft.com/en-US/cpp/build/stack-usage:

"All memory beyond the current address of RSP is considered volatile:
The OS, or a debugger, may overwrite this memory during a user debug
session, or an interrupt handler.  Thus, RSP must always be set before
attempting to read or write values to a stack frame."

Basically, if-- under extremely rare circumstances-- a context swap were
to occur between saving the values of xmm8-xmm11 and setting the new
value of rsp, the O/S might not preserve that area of the stack.  In
general, libjpeg-turbo should not be using xmm8-xmm11 before or after
the call to jsimd_huff_encode_one_block_sse2(), so this is probably a
non-issue, but it's still a good idea to fix it.

Based on
https://github.com/mayeut/libjpeg-turbo/commit/ff7d2030dd26c7b8c37ff540c594490198843f15

7 years agoFix BUILDING.md buglet ("--mfloat-abi=softfp")
Matthieu Darbois [Sat, 24 Feb 2018 17:00:51 +0000 (18:00 +0100)]
Fix BUILDING.md buglet ("--mfloat-abi=softfp")

(Introduced with the build system overhaul)

Closes #215

7 years agoFix Win64 ABI conformance issue in AVX2 ISLOW IDCT
mayeut [Sat, 24 Feb 2018 11:07:34 +0000 (12:07 +0100)]
Fix Win64 ABI conformance issue in AVX2 ISLOW IDCT

xmm8-xmm11 must be saved and restored, since the function uses
ymm8-ymm11.

Closes #211

7 years agoFix build with YASM
mayeut [Sat, 24 Feb 2018 13:20:59 +0000 (14:20 +0100)]
Fix build with YASM

vinserti128 requires all operands to be specified

7 years agoMake SIMD symbols private for MIPS ELF builds
mayeut [Fri, 23 Feb 2018 23:02:27 +0000 (00:02 +0100)]
Make SIMD symbols private for MIPS ELF builds

Closes #210

7 years agoMake SIMD symbols private for iOS ARM/ARM64 builds
mayeut [Fri, 23 Feb 2018 22:31:02 +0000 (23:31 +0100)]
Make SIMD symbols private for iOS ARM/ARM64 builds

7 years agoMake SIMD symbols private for x86[-64] ELF builds
mayeut [Fri, 23 Feb 2018 20:56:32 +0000 (21:56 +0100)]
Make SIMD symbols private for x86[-64] ELF builds

7 years ago32-bit AVX2 implementation of slow int inverse DCT
DRC [Fri, 23 Feb 2018 19:58:24 +0000 (13:58 -0600)]
32-bit AVX2 implementation of slow int inverse DCT

7 years ago32-bit AVX2 buglet: IS_ALIGNED_SSE=IS_ALIGNED_AVX
DRC [Fri, 23 Feb 2018 18:24:10 +0000 (12:24 -0600)]
32-bit AVX2 buglet: IS_ALIGNED_SSE=IS_ALIGNED_AVX

7 years ago64-bit AVX2 implementation of slow int inverse DCT
DRC [Fri, 23 Feb 2018 17:50:11 +0000 (11:50 -0600)]
64-bit AVX2 implementation of slow int inverse DCT

7 years ago32-bit AVX2 implementation of int sample conv.
DRC [Sun, 18 Feb 2018 04:15:58 +0000 (22:15 -0600)]
32-bit AVX2 implementation of int sample conv.

7 years ago32-bit AVX2 implementation of slow int forward DCT
DRC [Sun, 18 Feb 2018 02:31:30 +0000 (20:31 -0600)]
32-bit AVX2 implementation of slow int forward DCT

7 years ago64-bit AVX2 implementation of int sample conv.
DRC [Sun, 18 Feb 2018 01:39:53 +0000 (19:39 -0600)]
64-bit AVX2 implementation of int sample conv.

7 years ago64-bit AVX2 implementation of slow int forward DCT
DRC [Sat, 17 Feb 2018 23:32:25 +0000 (17:32 -0600)]
64-bit AVX2 implementation of slow int forward DCT

7 years agoAVX2: Introduce YMMBLOCK macro for readability
DRC [Sat, 17 Feb 2018 23:29:38 +0000 (17:29 -0600)]
AVX2: Introduce YMMBLOCK macro for readability

7 years agoProg Huff enc: bit count/branchless abs val opts
DRC [Wed, 14 Feb 2018 23:22:00 +0000 (17:22 -0600)]
Prog Huff enc: bit count/branchless abs val opts

Ported from baseline Huffman encoder.  This improves overall compression
performance by ~3-9% in my testing.

7 years agoMerge branch 'master' into dev
DRC [Wed, 14 Feb 2018 20:50:04 +0000 (14:50 -0600)]
Merge branch 'master' into dev

7 years agoREADME.md: Fix permissions
Ben Boeckel [Wed, 14 Feb 2018 20:41:36 +0000 (15:41 -0500)]
README.md: Fix permissions

7 years agoMerge branch 'master' into dev
DRC [Tue, 13 Feb 2018 22:34:21 +0000 (16:34 -0600)]
Merge branch 'master' into dev

7 years agoFix dithering bug in merged 4:2:0/RGB565 algorithm
DRC [Tue, 13 Feb 2018 22:14:03 +0000 (16:14 -0600)]
Fix dithering bug in merged 4:2:0/RGB565 algorithm

d0 should always be used for the first row, and d1 should always be used
for the second row.

Addresses concerns raised in #95, #81.

7 years agoMerge branch 'master' into dev
DRC [Fri, 5 Jan 2018 18:05:43 +0000 (12:05 -0600)]
Merge branch 'master' into dev

7 years agoTravis/OS X: Use 'brew bundle' + Brewfile
Stephen [Wed, 3 Jan 2018 15:56:12 +0000 (07:56 -0800)]
Travis/OS X: Use 'brew bundle' + Brewfile

This ensures that the build script will not fail if the Homebrew
dependencies are already installed.

7 years agoMerge branch 'master' into dev
DRC [Sat, 16 Dec 2017 15:34:28 +0000 (09:34 -0600)]
Merge branch 'master' into dev

7 years agojdarith.c: Fix two signed integer overflows
DRC [Sat, 16 Dec 2017 02:37:02 +0000 (20:37 -0600)]
jdarith.c: Fix two signed integer overflows

I guess I have to fix these, or Google Autofuzz is going to keep bugging
me about them.

Fixes #171
Fixes #197
Fixes #198

7 years agoBump version to 1.5.4 to prepare for new commits
DRC [Sat, 16 Dec 2017 02:05:58 +0000 (20:05 -0600)]
Bump version to 1.5.4 to prepare for new commits

7 years agoBUILDING.md: Adjust Android recipes for NDK r16+
DRC [Fri, 15 Dec 2017 22:45:25 +0000 (16:45 -0600)]
BUILDING.md: Adjust Android recipes for NDK r16+

NDK r16b moved some things around, so modify the Android build recipes
to take that into account while preserving compatibility with previous
NDK releases.

NOTE: the GCC 4.9 NDK toolchain is deprecated, so we will need to
develop new Android build recipes for libjpeg-turbo 1.6 that use the
Clang toolchain.

Closes #196

7 years agoFix whitespace errors 1.5.3
DRC [Fri, 8 Dec 2017 01:29:42 +0000 (19:29 -0600)]
Fix whitespace errors

7 years agoMerge branch 'master' into dev
DRC [Wed, 6 Dec 2017 18:20:24 +0000 (12:20 -0600)]
Merge branch 'master' into dev

+ acknowledge 1.5.3 release

7 years agojpeg_crop_scanlines: Handle gray images w/ samp!=1
DRC [Wed, 6 Dec 2017 17:59:04 +0000 (11:59 -0600)]
jpeg_crop_scanlines: Handle gray images w/ samp!=1

Since the sampling factor has no meaning for single-component images,
the decompressor ignores it, and jpeg_crop_scanlines() should as well.

Fixes #195

7 years agoFix lib state when skipping to end of 1-scan image
DRC [Tue, 5 Dec 2017 21:27:34 +0000 (15:27 -0600)]
Fix lib state when skipping to end of 1-scan image

If jpeg_skip_scanlines() is used to skip to the end of a single-scan
image, then we need to change the library state such that subsequent
calls to jpeg_consume_input() will return JPEG_REACHED_EOI rather than
JPEG_SUSPENDED.  (NOTE: not necessary for multi-scan images, since the
scans are processed prior to any call to jpeg_skip_scanlines().)

Unless I miss my guess, using jpeg_skip_scanlines() in this manner
will prevent any markers at the end of the JPEG image from being
read, but I don't think there is any way around that without actually
reading the data, which would defeat the purpose of
jpeg_skip_scanlines().

Fixes #194

7 years agoMerge branch 'master' into dev
DRC [Wed, 29 Nov 2017 20:36:39 +0000 (14:36 -0600)]
Merge branch 'master' into dev

7 years agoTravis: Work around xcode7.3 image bug
DRC [Wed, 29 Nov 2017 20:23:31 +0000 (14:23 -0600)]
Travis: Work around xcode7.3 image bug

Refer to travis-ci/travis-ci#8552.  This was supposed to be fixed on
November 15, then on November 28.  Travis blew through both deadlines,
so I have no confidence that the issue will be fixed as promised in a
timely manner.  Adding 'brew update' to .travis.yml slows the OS X
build, but there is no choice at the moment.

7 years agotjLoadImage(): Fix OOB array access w/TJPF_UNKNOWN
DRC [Sun, 19 Nov 2017 15:18:36 +0000 (09:18 -0600)]
tjLoadImage(): Fix OOB array access w/TJPF_UNKNOWN

Because the previous commit added a test for TJPF_UNKNOWN to tjunittest,
the ASAN CI build detected this issue.