Files
mozjpeg/java
Kornel Lesiński 662bf6ba7b Merge libjpeg-turbo r1390
* commit '73edb3d734a628fd88994bc974dc6737a58bd956': (45 commits)
  Rename the ARM64 assembly file to match the C file
  Fix several mathematical issues discovered in the ARM64 NEON code while running the extended regression tests introduced in r1267.  Specific comments can be found in the original patches: https://sourceforge.net/p/libjpeg-turbo/patches/64/
  Reformat code per Siarhei's original patch (to clearly indicate that the offset instructions are completely independent) and add Siarhei as an individual author (he no longer works for Nokia.)
  Clarify forward compatibility of iOS/ARM builds
  ARM64 NEON SIMD support for YCC-to-RGB565 conversion
  ARM NEON SIMD support for YCC-to-RGB565 conversion, and optimizations to the existing YCC-to-RGB conversion code:
  Ensure that tjFree() is used for any JPEG buffers that might have been dynamically allocated by the compress/transform functions.  To keep things simple, we use tjAlloc() for the statically-allocated buffer as well, so that tjFree() can always be used to free the buffer, regardless of whether it was allocated by tjbench or by the TurboJPEG library.  This fixes crashes that occurred on Windows when running tjunittest or tjbench with the -alloc flag.
  Revert r1335 and r1336.  It was a valiant effort, but on Windows, xmm8-xmm15 are non-volatile, and the overhead of pushing them onto the stack at the beginning of each function and popping them at the end was causing worse performance (in the neighborhood of 3-5%) than just using the work areas and limiting the register usage to xmm0-xmm7.  Best to leave the SSE2 code alone.  We can optimize the register usage for AVX2, once that port takes place.
  Windows doesn't have setenv().  Go, go Gadget Macros.
  1.4 beta1
  Fix 'make dist'
  Don't use sudo when building a Debian package unless the user is non-root
  Add a set of undocumented environment variables and Java system properties that allow compression features of libjpeg that are not normally exposed in the TurboJPEG API to be enabled.  These features are not normally exposed because, for the most part, they aren't "turbo" features, but it is still useful to be able to benchmark them without modifying the code.
  .func/.endfunc are only necessary when generating STABS debug info, which basically went out of style with parachute pants and Rick Astley.  At any rate, none of the platforms for which we're building the ARM code use it (DWARF is the common format these days), and the .func/.endfunc directives cause the clang integrated assembler to fail (http://llvm.org/bugs/show_bug.cgi?id=20424).
  Extend tjbenchtest so that it tests the dynamic JPEG buffer allocation feature in TurboJPEG.  Disable the tiling feature in TJBench whenever dynamic buffer allocation is enabled (because the tiling feature requires a separate buffer for each tile, using it successfully with dynamic buffer allocation would require a separate TurboJPEG compressor instance for each tile, and it's not worth going to that trouble right now.)
  Run the TurboJPEG conformance tests out of a directory in /tmp (for improved performance, if the source directory is on a remote file share.)  Fix an issue in TJBench.java that prevented it from working properly if the source image resided in a directory with a dot in the name.
  Oops
  Subtle point, but dest->outbuffer is a pointer to the address of the JPEG buffer, which is stored in the calling program.  Thus, *(dest->outbuffer) will always equal *outbuffer.  We need to compare *outbuffer with dest->buffer instead to determine if the pointer is being reused.
  If the output buffer in the TurboJPEG destination manager was allocated by the destination manager and is being reused from a previous compression operation, then we need to get the buffer size from the previous operation, since the calling program doesn't know the actual buffer size.
  Actually, we need to increase the size of BUFSIZE, not just the size of _buffer.  The previous patch might have cause problems if, for instance, state->free_in_buffer was 127 but 129 bytes were compressed.  In that case, only 127 of the 129 bytes would have been written to the file.  Also document the fix.
  ...

Conflicts:
	CMakeLists.txt
	Makefile.am
	configure.ac
	jcdctmgr.c
	release/deb-control.tmpl
	sharedlib/CMakeLists.txt
	simd/CMakeLists.txt
	turbojpeg.c
2014-09-07 18:21:19 +01:00
..
2014-09-07 16:50:54 +01:00

TurboJPEG Java Wrapper
======================

The TurboJPEG shared library can optionally be built with a Java Native
Interface wrapper, which allows the library to be loaded and used directly from
Java applications.  The Java front end for this is defined in several classes
located under org/libjpegturbo/turbojpeg.  The source code for these Java
classes is licensed under a BSD-style license, so the files can be incorporated
directly into both open source and proprietary projects without restriction.  A
Java archive (JAR) file containing these classes is also shipped with the
"official" distribution packages of libjpeg-turbo.

TJExample.java, which should also be located in the same directory as this
README file, demonstrates how to use the TurboJPEG Java API to compress and
decompress JPEG images in memory.


Performance Pitfalls
--------------------

The TurboJPEG Java API defines several convenience methods that can allocate
image buffers or instantiate classes to hold the result of compress,
decompress, or transform operations.  However, if you use these methods, then
be mindful of the amount of new data you are creating on the heap.  It may be
necessary to manually invoke the garbage collector to prevent heap exhaustion
or to prevent performance degradation.  Background garbage collection can kill
performance, particularly in a multi-threaded environment (Java pauses all
threads when the GC runs.)

The TurboJPEG Java API always gives you the option of pre-allocating your own
source and destination buffers, which allows you to re-use those buffers for
compressing/decompressing multiple images.  If the image sequence you are
compressing or decompressing consists of images of the same size, then
pre-allocating the buffers is recommended.


Installation Directory
----------------------

The TurboJPEG Java Wrapper will look for the TurboJPEG JNI library
(libturbojpeg.so, libturbojpeg.jnilib, or turbojpeg.dll) in the system library
paths or in any paths specified in LD_LIBRARY_PATH (Un*x), DYLD_LIBRARY_PATH
(Mac), or PATH (Windows.)  Failing this, on Un*x and Mac systems, the wrapper
will look for the JNI library under the library directory configured when
libjpeg-turbo was built.  If that library directory is
/opt/libjpeg-turbo/lib32, then /opt/libjpeg-turbo/lib64 is also searched, and
vice versa.

If you installed the JNI library into another directory, then you will need
to pass an argument of -Djava.library.path={path_to_JNI_library} to java, or
manipulate LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, or PATH to include the directory
containing the JNI library.